mirror of
https://gitlab.kit.edu/uskyk/typicalc.git
synced 2024-11-08 18:30:42 +00:00
Integration test: latex export + type assumptions
This commit is contained in:
parent
24454a26ee
commit
b058ee037c
@ -1,10 +1,15 @@
|
|||||||
package edu.kit.typicalc.view;
|
package edu.kit.typicalc.view;
|
||||||
|
|
||||||
|
import com.vaadin.flow.component.button.testbench.ButtonElement;
|
||||||
|
import com.vaadin.flow.component.orderedlayout.testbench.HorizontalLayoutElement;
|
||||||
import com.vaadin.testbench.Parameters;
|
import com.vaadin.testbench.Parameters;
|
||||||
import com.vaadin.testbench.commands.TestBenchCommandExecutor;
|
import com.vaadin.testbench.commands.TestBenchCommandExecutor;
|
||||||
|
|
||||||
import edu.kit.typicalc.view.pageobjects.ControlPanelElement;
|
import edu.kit.typicalc.view.pageobjects.ControlPanelElement;
|
||||||
import edu.kit.typicalc.view.pageobjects.ExampleDialogElement;
|
import edu.kit.typicalc.view.pageobjects.ExampleDialogElement;
|
||||||
import edu.kit.typicalc.view.pageobjects.InputBarElement;
|
import edu.kit.typicalc.view.pageobjects.InputBarElement;
|
||||||
|
import edu.kit.typicalc.view.pageobjects.TypeAssumptionFieldElement;
|
||||||
|
import edu.kit.typicalc.view.pageobjects.TypeAssumptionsAreaElement;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
@ -106,4 +111,50 @@ public class ScreenshotIT extends AbstractIT {
|
|||||||
assertTrue("Screenshot comparison for 'chooseExample' (stage 3) failed",
|
assertTrue("Screenshot comparison for 'chooseExample' (stage 3) failed",
|
||||||
testBench().compareScreen("chooseExample3"));
|
testBench().compareScreen("chooseExample3"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void exportLatexWithAssumptions() throws IOException {
|
||||||
|
TestBenchCommandExecutor executor = getCommandExecutor();
|
||||||
|
|
||||||
|
InputBarElement inputBar = $(InputBarElement.class).first();
|
||||||
|
String term = "λx. f x";
|
||||||
|
inputBar.setCurrentValue(term);
|
||||||
|
|
||||||
|
// check if the correct term is entered
|
||||||
|
Assert.assertEquals(term, inputBar.getCurrentValue());
|
||||||
|
|
||||||
|
inputBar.openTypeAssumptionsArea();
|
||||||
|
TypeAssumptionsAreaElement assumptionsArea = $(TypeAssumptionsAreaElement.class).waitForFirst();
|
||||||
|
assumptionsArea.addTypeAssumption();
|
||||||
|
executor.waitForVaadin();
|
||||||
|
TypeAssumptionFieldElement assumptionField = assumptionsArea.getLastTypeAssumption();
|
||||||
|
|
||||||
|
String variable = "f";
|
||||||
|
String type = "int -> y";
|
||||||
|
assumptionField.setVariable(variable);
|
||||||
|
assumptionField.setType(type);
|
||||||
|
assumptionsArea.$(HorizontalLayoutElement.class).first().$(ButtonElement.class).last().focus();
|
||||||
|
|
||||||
|
executor.waitForVaadin();
|
||||||
|
// check if type assumption is added correctly
|
||||||
|
assertTrue("Screenshot comparison for 'exportLatexWithAssumptions' (stage 1) failed",
|
||||||
|
testBench().compareScreen("exportLatexWithAssumptions1"));
|
||||||
|
assumptionsArea.closeDialog();
|
||||||
|
|
||||||
|
inputBar.typeInfer();
|
||||||
|
executor.waitForVaadin();
|
||||||
|
ControlPanelElement controlPanel = $(ControlPanelElement.class).waitForFirst();
|
||||||
|
controlPanel.lastStep();
|
||||||
|
executor.waitForVaadin();
|
||||||
|
|
||||||
|
// check if the algorithm is processed correctly
|
||||||
|
assertTrue("Screenshot comparison for 'exportLatexWithAssumptions' (stage 2) failed",
|
||||||
|
testBench().compareScreen("exportLatexWithAssumptions2"));
|
||||||
|
|
||||||
|
controlPanel.openShareDialog();
|
||||||
|
executor.waitForVaadin();
|
||||||
|
// check if the share dialog content is correct
|
||||||
|
assertTrue("Screenshot comparison for 'exportLatexWithAssumptions' (stage 3) failed",
|
||||||
|
testBench().compareScreen("exportLatexWithAssumptions3"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,12 @@ import com.vaadin.testbench.annotations.Attribute;
|
|||||||
|
|
||||||
@Attribute(name = "id", value = "control-panel")
|
@Attribute(name = "id", value = "control-panel")
|
||||||
public class ControlPanelElement extends HorizontalLayoutElement {
|
public class ControlPanelElement extends HorizontalLayoutElement {
|
||||||
|
|
||||||
public void lastStep() {
|
public void lastStep() {
|
||||||
$(ButtonElement.class).get(4).click();
|
$(ButtonElement.class).get(4).click();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void openShareDialog() {
|
||||||
|
$(ButtonElement.class).first().click();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,4 +42,12 @@ public class InputBarElement extends HorizontalLayoutElement {
|
|||||||
public void openExampleDialog() {
|
public void openExampleDialog() {
|
||||||
$(ButtonElement.class).id("exampleButton").click();
|
$(ButtonElement.class).id("exampleButton").click();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opens the type assumptions area.
|
||||||
|
*/
|
||||||
|
public void openTypeAssumptionsArea() {
|
||||||
|
$(ButtonElement.class).first().click();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
package edu.kit.typicalc.view.pageobjects;
|
||||||
|
|
||||||
|
import com.vaadin.flow.component.orderedlayout.testbench.HorizontalLayoutElement;
|
||||||
|
import com.vaadin.flow.component.textfield.testbench.TextFieldElement;
|
||||||
|
import com.vaadin.testbench.annotations.Attribute;
|
||||||
|
|
||||||
|
@Attribute(name = "id", value = "typeAssumptionField")
|
||||||
|
public class TypeAssumptionFieldElement extends HorizontalLayoutElement {
|
||||||
|
|
||||||
|
public void setVariable(String variable) {
|
||||||
|
$(TextFieldElement.class).first().setValue(variable);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(String type) {
|
||||||
|
$(TextFieldElement.class).last().setValue(type);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
package edu.kit.typicalc.view.pageobjects;
|
||||||
|
|
||||||
|
import com.vaadin.flow.component.button.testbench.ButtonElement;
|
||||||
|
import com.vaadin.flow.component.orderedlayout.testbench.HorizontalLayoutElement;
|
||||||
|
import com.vaadin.flow.component.orderedlayout.testbench.VerticalLayoutElement;
|
||||||
|
import com.vaadin.testbench.annotations.Attribute;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Vaadin TestBench element for {@link edu.kit.typicalc.view.main.TypeAssumptionsArea}.
|
||||||
|
*/
|
||||||
|
@Attribute(name = "id", value = "assLayout")
|
||||||
|
public class TypeAssumptionsAreaElement extends VerticalLayoutElement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a new TypeAssumption.
|
||||||
|
*/
|
||||||
|
public void addTypeAssumption() {
|
||||||
|
$(HorizontalLayoutElement.class).id("assButtons").$(ButtonElement.class).first().click();
|
||||||
|
}
|
||||||
|
|
||||||
|
public TypeAssumptionFieldElement getLastTypeAssumption() {
|
||||||
|
return $(VerticalLayoutElement.class).id("assContainer")
|
||||||
|
.$(TypeAssumptionFieldElement.class).last();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void closeDialog() {
|
||||||
|
$(HorizontalLayoutElement.class).first().$(ButtonElement.class).last().click();
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 52 KiB |
Binary file not shown.
After Width: | Height: | Size: 57 KiB |
Binary file not shown.
After Width: | Height: | Size: 57 KiB |
Binary file not shown.
After Width: | Height: | Size: 82 KiB |
Binary file not shown.
After Width: | Height: | Size: 38 KiB |
Binary file not shown.
After Width: | Height: | Size: 89 KiB |
Loading…
Reference in New Issue
Block a user