From 473ebb2834cf6634cb9e5389a8a540b61a4a7d9b Mon Sep 17 00:00:00 2001 From: Arved Solth Date: Wed, 8 Feb 2023 19:25:44 +0100 Subject: [PATCH] Fix Selenium test --- .../src/test/java/org/kitodo/selenium/MetadataST.java | 8 ++++++++ .../testframework/pages/MetadataEditorPage.java | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/Kitodo/src/test/java/org/kitodo/selenium/MetadataST.java b/Kitodo/src/test/java/org/kitodo/selenium/MetadataST.java index 58691d2382a..f13f9accdc2 100644 --- a/Kitodo/src/test/java/org/kitodo/selenium/MetadataST.java +++ b/Kitodo/src/test/java/org/kitodo/selenium/MetadataST.java @@ -69,6 +69,7 @@ public void hideStructureDataTest() throws Exception { Pages.getLoginPage().goTo().performLogin(metadataUser); Pages.getProcessesPage().goTo().editSecondProcessMetadata(); Assert.assertFalse(Pages.getMetadataEditorPage().isStructureTreeFormVisible()); + Pages.getMetadataEditorPage().closeEditor(); } /** @@ -94,6 +95,7 @@ public void changeProcessLinkOrderTest() throws Exception { Pages.getMetadataEditorPage().getNameOfFirstLinkedChildProcess().endsWith(SECOND_CHILD_PROCESS_TITLE)); Assert.assertTrue("Wrong resulting order of linked child processes", Pages.getMetadataEditorPage().getNameOfSecondLinkedChildProcess().endsWith(FIRST_CHILD_PROCESS_TITLE)); + Pages.getMetadataEditorPage().closeEditor(); cleanup(); } @@ -102,9 +104,12 @@ public void changeProcessLinkOrderTest() throws Exception { */ @Test public void totalNumberOfScansTest() throws Exception { + User metadataUser = ServiceManager.getUserService().getByLogin("kowal"); + Pages.getLoginPage().goTo().performLogin(metadataUser); Pages.getProcessesPage().goTo().editSecondProcessMetadata(); assertEquals("Total number of scans is not correct", "(Anzahl von Scans: 1)", Pages.getMetadataEditorPage().getNumberOfScans()); + Pages.getMetadataEditorPage().closeEditor(); } /** @@ -113,11 +118,14 @@ public void totalNumberOfScansTest() throws Exception { */ @Test public void showPaginationByDefaultTest() throws Exception { + User metadataUser = ServiceManager.getUserService().getByLogin("kowal"); + Pages.getLoginPage().goTo().performLogin(metadataUser); Pages.getProcessesPage().goTo().editSecondProcessMetadata(); assertFalse(Pages.getMetadataEditorPage().isPaginationPanelVisible()); Pages.getUserEditPage().setPaginationToShowByDefault(); Pages.getProcessesPage().goTo().editSecondProcessMetadata(); assertTrue(Pages.getMetadataEditorPage().isPaginationPanelVisible()); + Pages.getMetadataEditorPage().closeEditor(); } @After diff --git a/Kitodo/src/test/java/org/kitodo/selenium/testframework/pages/MetadataEditorPage.java b/Kitodo/src/test/java/org/kitodo/selenium/testframework/pages/MetadataEditorPage.java index 496e1107197..90639a9cc4d 100644 --- a/Kitodo/src/test/java/org/kitodo/selenium/testframework/pages/MetadataEditorPage.java +++ b/Kitodo/src/test/java/org/kitodo/selenium/testframework/pages/MetadataEditorPage.java @@ -44,6 +44,9 @@ public class MetadataEditorPage extends Page { @FindBy(id = "saveExit") private WebElement saveAndExitButton; + @FindBy(id = "close") + private WebElement closeButton; + public MetadataEditorPage() { super("metadataEditor.jsf"); } @@ -98,4 +101,11 @@ public String getNameOfFirstLinkedChildProcess() { public String getNameOfSecondLinkedChildProcess() { return secondChildProcess.getText(); } + + /** + * Close Metadata editor to release metadata lock. + */ + public void closeEditor() { + closeButton.click(); + } }