diff --git a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/component/DocumentTableComponentPage.java b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/component/DocumentTableComponentPage.java index 62557408920..b277b919174 100644 --- a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/component/DocumentTableComponentPage.java +++ b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/component/DocumentTableComponentPage.java @@ -30,4 +30,20 @@ public void waitForDocumentTableComponentPageLoaded() { public int countDocuments() { return getDocuments().size(); } + + public void clickPreviewButton() { + $("[id$=':document-preview']").click(); + } + + public void waitForPreviewDialog() { + $("[id$=':preview-document-dialog']").shouldBe(Condition.appear, DEFAULT_TIMEOUT); + } + + public boolean isPreviewContentDisplayed() { + return $("object[type='application/pdf']").shouldBe(Condition.appear, DEFAULT_TIMEOUT).isDisplayed(); + } + + public void closePreviewDialog() { + $("[id$=':preview-document-dialog'] .ui-dialog-titlebar-close").click(); + } } diff --git a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/DocumentTableComponentTest.java b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/DocumentTableComponentTest.java index 02835279319..fb64c2de8ba 100644 --- a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/DocumentTableComponentTest.java +++ b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/DocumentTableComponentTest.java @@ -27,4 +27,16 @@ public void testUploadDocument() { assertEquals(1, documentTableComponentPage.countDocuments()); } + @Test + public void testPreviewDocument() { + DocumentTableComponentPage documentTableComponentPage = new DocumentTableComponentPage(); + documentTableComponentPage.uploadSampleDocument(FileHelper.getAbsolutePathToTestFile("sample-file.txt")); + refreshPage(); + documentTableComponentPage.waitForDocumentTableComponentPageLoaded(); + assertEquals(1, documentTableComponentPage.countDocuments()); + documentTableComponentPage.clickPreviewButton(); + documentTableComponentPage.waitForPreviewDialog(); + assertTrue(documentTableComponentPage.isPreviewContentDisplayed()); + documentTableComponentPage.closePreviewDialog(); + } }