diff --git a/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/ShareDialog.java b/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/ShareDialog.java index 9265481..6805212 100644 --- a/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/ShareDialog.java +++ b/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/ShareDialog.java @@ -15,6 +15,7 @@ import com.vaadin.flow.i18n.LocaleChangeObserver; @CssImport("./styles/view/share-dialog.css") public class ShareDialog extends Dialog implements LocaleChangeObserver { + private static final String SHARE_DIALOG_ID = "shareDialog"; private static final String LAYOUT_ID = "share-dialog-layout"; private static final String FIELD_CLASS = "share-dialog-field"; @@ -36,6 +37,7 @@ public class ShareDialog extends Dialog implements LocaleChangeObserver { VerticalLayout layout = new VerticalLayout(); layout.setId(LAYOUT_ID); add(layout); + setId(SHARE_DIALOG_ID); heading = new H3(); urlField = new TextField(); diff --git a/src/test/java/edu/kit/typicalc/view/ScreenshotIT.java b/src/test/java/edu/kit/typicalc/view/ScreenshotIT.java index caa5610..2c31a17 100644 --- a/src/test/java/edu/kit/typicalc/view/ScreenshotIT.java +++ b/src/test/java/edu/kit/typicalc/view/ScreenshotIT.java @@ -4,18 +4,14 @@ 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.commands.TestBenchCommandExecutor; - -import edu.kit.typicalc.view.pageobjects.ControlPanelElement; -import edu.kit.typicalc.view.pageobjects.ExampleDialogElement; -import edu.kit.typicalc.view.pageobjects.InputBarElement; -import edu.kit.typicalc.view.pageobjects.TypeAssumptionFieldElement; -import edu.kit.typicalc.view.pageobjects.TypeAssumptionsAreaElement; +import edu.kit.typicalc.view.pageobjects.*; import org.junit.Assert; import org.junit.Test; import java.io.IOException; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; /** * This example contains usage examples of screenshot comparison feature. @@ -24,6 +20,7 @@ import static org.junit.Assert.*; public class ScreenshotIT extends AbstractIT { private static final String IDENTITY_TERM = "λx.x"; + private static final String LET_TERM = "let f = λx. g y y in f 3"; /** * We'll want to perform some additional setup functions, so we override the @@ -76,6 +73,42 @@ public class ScreenshotIT extends AbstractIT { testBench().compareScreen("identityView")); } + @Test + public void createPermalink() throws IOException { + InputBarElement inputBar = $(InputBarElement.class).first(); + inputBar.setCurrentValue(LET_TERM); + + assertEquals(LET_TERM, inputBar.getCurrentValue()); + + inputBar.typeInfer(); + TestBenchCommandExecutor executor = getCommandExecutor(); + executor.waitForVaadin(); + + assertTrue("Screenshot comparison for 'letView' failed, see " + + Parameters.getScreenshotErrorDirectory() + + " for error images", + testBench().compareScreen("letView")); + + ControlPanelElement control = $(ControlPanelElement.class).waitForFirst(); + control.openShareDialog(); + executor.waitForVaadin(); + + assertTrue("Screenshot comparison for 'letShareDialog' failed, see " + + Parameters.getScreenshotErrorDirectory() + + " for error images", + testBench().compareScreen("letShareDialog")); + + ShareDialogElement shareDialogElement = $(ShareDialogElement.class).waitForFirst(); + String permalink = shareDialogElement.getPermalink(); + getDriver().get(permalink); + + assertTrue("Screenshot comparison for 'letView' from permalink failed, see " + + Parameters.getScreenshotErrorDirectory() + + " for error images", + testBench().compareScreen("letView")); + // TODO: jeden Schritt durchgehen? + } + @Test public void chooseExample() throws IOException { InputBarElement inputBar = $(InputBarElement.class).first(); diff --git a/src/test/java/edu/kit/typicalc/view/pageobjects/ShareDialogElement.java b/src/test/java/edu/kit/typicalc/view/pageobjects/ShareDialogElement.java new file mode 100644 index 0000000..eb370d3 --- /dev/null +++ b/src/test/java/edu/kit/typicalc/view/pageobjects/ShareDialogElement.java @@ -0,0 +1,22 @@ +package edu.kit.typicalc.view.pageobjects; + +import com.vaadin.flow.component.dialog.testbench.DialogElement; +import com.vaadin.flow.component.orderedlayout.testbench.VerticalLayoutElement; +import com.vaadin.flow.component.textfield.testbench.TextFieldElement; +import com.vaadin.testbench.annotations.Attribute; + +/** + * Vaadin TestBench element for {@link edu.kit.typicalc.view.content.typeinferencecontent.ShareDialog}. + */ +@Attribute(name = "id", value = "shareDialog") +public class ShareDialogElement extends DialogElement { + + /** + * Get the permalink in the share dialog. + * + * @return the permalink + */ + public String getPermalink() { + return $(VerticalLayoutElement.class).first().$(TextFieldElement.class).first().getValue(); + } +} diff --git a/src/test/resources/screenshots/letShareDialog_linux_firefox_86.png b/src/test/resources/screenshots/letShareDialog_linux_firefox_86.png new file mode 100644 index 0000000..cec48bb Binary files /dev/null and b/src/test/resources/screenshots/letShareDialog_linux_firefox_86.png differ diff --git a/src/test/resources/screenshots/letView_linux_firefox_86.png b/src/test/resources/screenshots/letView_linux_firefox_86.png new file mode 100644 index 0000000..e1477ff Binary files /dev/null and b/src/test/resources/screenshots/letView_linux_firefox_86.png differ