diff --git a/Kitodo/src/test/java/org/kitodo/selenium/ListingST.java b/Kitodo/src/test/java/org/kitodo/selenium/ListingST.java index ea853f865e6..8c6e7e0859e 100644 --- a/Kitodo/src/test/java/org/kitodo/selenium/ListingST.java +++ b/Kitodo/src/test/java/org/kitodo/selenium/ListingST.java @@ -28,6 +28,7 @@ import org.kitodo.selenium.testframework.pages.ProcessesPage; import org.kitodo.selenium.testframework.pages.ProjectsPage; import org.kitodo.selenium.testframework.pages.TasksPage; +import org.kitodo.selenium.testframework.pages.TemplateEditPage; import org.kitodo.selenium.testframework.pages.UsersPage; public class ListingST extends BaseTestSelenium { @@ -234,4 +235,27 @@ public void listUsersTest() throws Exception { int ldapGroupsDisplayed = usersPage.countListedLdapGroups(); assertEquals("Displayed wrong number of ldap groups!", ldapGroupsInDatabase, ldapGroupsDisplayed); } + + /** + * Test number of displayed templates. Assert deactivated templates are hidden by default and only visible + * when activating the corresponding switch on the projects/templates page. + * + * @throws Exception when thread is interrupted or templates cannot be loaded. + */ + @Test + public void listTemplatesTest() throws Exception { + projectsPage.goToTemplateTab(); + assertEquals("Wrong number of templates before hiding first template", 2, + projectsPage.getTemplateTitles().size()); + TemplateEditPage editTemplatePage = projectsPage.editTemplate(); + editTemplatePage.hideTemplate(); + editTemplatePage.save(); + assertEquals("Wrong number of templates after hiding first template", 1, + projectsPage.getTemplateTitles().size()); + projectsPage.goToTemplateTab(); + Thread.sleep(500); + projectsPage.toggleHiddenTemplates(); + assertEquals("Wrong number of templates after toggling hidden templates", 2, + projectsPage.getTemplateTitles().size()); + } } diff --git a/Kitodo/src/test/java/org/kitodo/selenium/testframework/pages/ProjectsPage.java b/Kitodo/src/test/java/org/kitodo/selenium/testframework/pages/ProjectsPage.java index 980a4cb1750..47cb2ca8883 100644 --- a/Kitodo/src/test/java/org/kitodo/selenium/testframework/pages/ProjectsPage.java +++ b/Kitodo/src/test/java/org/kitodo/selenium/testframework/pages/ProjectsPage.java @@ -175,6 +175,9 @@ public class ProjectsPage extends Page<ProjectsPage> { @FindBy(id = RULESET_TABLE + ":0:actionForm:deleteRuleset") private WebElement deleteFirstRulesetButton; + @FindBy(id = "showInactiveTemplateWrapper") + private WebElement toggleHiddenTemplatesWrapper; + public ProjectsPage() { super("pages/projects.jsf"); } @@ -630,4 +633,12 @@ public Long getNumberOfImportConfigurations() { public Long getNumberOfMappingFiles() { return (long) Browser.getRowsOfTable(Browser.getDriver().findElementById(MAPPING_FILE_TABLE)).size(); } + + /** + * Toggle switch to hide/show inactive templates. + */ + public void toggleHiddenTemplates() { + toggleHiddenTemplatesWrapper.findElement(By.className("ui-chkbox-box")).click(); + + } } diff --git a/Kitodo/src/test/java/org/kitodo/selenium/testframework/pages/TemplateEditPage.java b/Kitodo/src/test/java/org/kitodo/selenium/testframework/pages/TemplateEditPage.java index d210a03d3ce..76f397d38c1 100644 --- a/Kitodo/src/test/java/org/kitodo/selenium/testframework/pages/TemplateEditPage.java +++ b/Kitodo/src/test/java/org/kitodo/selenium/testframework/pages/TemplateEditPage.java @@ -44,6 +44,9 @@ public class TemplateEditPage extends EditPage<TemplateEditPage> { @FindBy(id = TEMPLATE_TAB_VIEW + ":docket") private WebElement docketSelect; + @FindBy(id = "editForm:templateTabView:active") + private WebElement activeSwitch; + @SuppressWarnings("unused") @FindBy(id = TEMPLATE_TAB_VIEW + ":taskTable:0:editTask") private WebElement editTaskLink; @@ -97,4 +100,11 @@ public ProjectsPage save() throws IllegalAccessException, InstantiationException clickButtonAndWaitForRedirect(saveButton, Pages.getProjectsPage().getUrl()); return Pages.getProjectsPage(); } + + /** + * Toggle switch to activate/deactivate template. + */ + public void hideTemplate() { + activeSwitch.findElement(By.className("ui-chkbox-box")).click(); + } }