Skip to content

Commit

Permalink
Add test for hiding/showing inactive templates
Browse files Browse the repository at this point in the history
  • Loading branch information
solth committed Apr 17, 2023
1 parent 6e3091b commit 411f7c0
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
24 changes: 24 additions & 0 deletions Kitodo/src/test/java/org/kitodo/selenium/ListingST.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down Expand Up @@ -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();

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
}

0 comments on commit 411f7c0

Please sign in to comment.