Skip to content

Commit

Permalink
Merge pull request kitodo#6302 from thomaslow/fix-link-page-to-next-d…
Browse files Browse the repository at this point in the history
…ivision-selenium-test

Fix link page to next division selenium test
  • Loading branch information
solth authored Nov 14, 2024
2 parents 6b86067 + 9d66d6d commit c8bf30f
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@
DataEditorForm.structurePanel.selectedLogicalNode.type eq StructurePanel.VIEW_NODE_TYPE and
mediaProvider.hasPreviewVariant(DataEditorForm.galleryPanel.getGalleryMediaContent(DataEditorForm.galleryPanel.lastSelection.key))}"
icon="fa fa-external-link fa-sm"
styleClass="plain"
styleClass="plain viewPageInNewWindow"
outcome="externalView"
target="_blank">
<f:param name="processId" value="#{DataEditorForm.process.id}"/>
Expand All @@ -216,7 +216,7 @@
</p:menuitem>
<p:menuitem value="#{msgs.assignToNextElement}"
icon="fa fa-link fa-sm"
styleClass="plain"
styleClass="plain assignToNextElement"
disabled="#{readOnly}"
rendered="#{DataEditorForm.structurePanel.assignableSeveralTimes and
DataEditorForm.selectedMedia.size() eq 1}"
Expand All @@ -230,7 +230,7 @@
imagePreviewForm:mediaContextMenu"/>
<p:menuitem value="#{msgs.unassign}"
icon="fa fa-chain-broken fa-sm"
styleClass="plain"
styleClass="plain unassign"
disabled="#{readOnly}"
rendered="#{DataEditorForm.structurePanel.assignedSeveralTimes and DataEditorForm.selectedMedia.size() == 1}"
action="#{DataEditorForm.structurePanel.unassign}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@
DataEditorForm.structurePanel.selectedLogicalNode.type eq StructurePanel.VIEW_NODE_TYPE and
mediaProvider.hasPreviewVariant(DataEditorForm.galleryPanel.getGalleryMediaContent(DataEditorForm.galleryPanel.lastSelection.key))}"
icon="fa fa-external-link fa-sm"
styleClass="plain"
styleClass="plain viewPageInNewWindow"
outcome="externalView"
target="_blank">
<f:param name="processId" value="#{DataEditorForm.process.id}"/>
Expand All @@ -196,7 +196,7 @@
update="dialogEditDocStrucTypeDialog"/>
<p:menuitem value="#{msgs.assignToNextElement}"
icon="fa fa-link fa-sm"
styleClass="plain"
styleClass="plain assignToNextElement"
disabled="#{readOnly}"
rendered="#{DataEditorForm.structurePanel.assignableSeveralTimes and not DataEditorForm.structurePanel.selectedLogicalNode.data.linked}"
action="#{DataEditorForm.structurePanel.assign}"
Expand All @@ -209,7 +209,7 @@
imagePreviewForm:mediaContextMenu"/>
<p:menuitem value="#{msgs.unassign}"
icon="fa fa-chain-broken fa-sm"
styleClass="plain"
styleClass="plain unassign"
disabled="#{readOnly}"
rendered="#{DataEditorForm.structurePanel.assignedSeveralTimes and not DataEditorForm.structurePanel.selectedLogicalNode.data.linked}"
action="#{DataEditorForm.structurePanel.unassign}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
update="dialogAddPhysicalDivisionForm"/>
<p:menuitem value="#{msgs.assignToNextElement}"
icon="fa fa-link fa-sm"
styleClass="plain"
styleClass="plain assignToNextElement"
disabled="#{readOnly}"
rendered="#{DataEditorForm.structurePanel.assignableSeveralTimes and not
DataEditorForm.structurePanel.assignedSeveralTimes and DataEditorForm.selectedMedia.size() eq 1}"
Expand All @@ -116,7 +116,7 @@
imagePreviewForm:mediaContextMenu"/>
<p:menuitem value="#{msgs.unassign}"
icon="fa fa-chain-broken fa-sm"
styleClass="plain"
styleClass="plain unassign"
disabled="#{readOnly}"
rendered="#{DataEditorForm.structurePanel.assignedSeveralTimes and DataEditorForm.selectedMedia.size() == 1}"
action="#{DataEditorForm.structurePanel.unassign}"
Expand Down
19 changes: 5 additions & 14 deletions Kitodo/src/test/java/org/kitodo/selenium/MetadataST.java
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ public void linkPageToNextDivision() throws Exception {
metaDataEditor.openContextMenuForStructureTreeNode("0_0_0_0");

// click on 2nd menu entry "assign to next element"
metaDataEditor.clickStructureTreeContextMenuEntry(2);
metaDataEditor.clickStructureTreeContextMenuEntry("assignToNextElement");

// verify page "2" is now marked as "linked"
assertTrue(metaDataEditor.isStructureTreeNodeAssignedSeveralTimes("0_0_0_0"));
Expand All @@ -448,7 +448,7 @@ public void linkPageToNextDivision() throws Exception {
metaDataEditor.openContextMenuForStructureTreeNode("0_1_0_0");

// click on 2nd menu entry "remove assignment"
metaDataEditor.clickStructureTreeContextMenuEntry(2);
metaDataEditor.clickStructureTreeContextMenuEntry("unassign");

// check page "2" is not marked as "linked" any more
assertFalse(metaDataEditor.isStructureTreeNodeAssignedSeveralTimes("0_0_0_0"));
Expand All @@ -475,20 +475,11 @@ public void openPageInSeparateWindowTest() throws Exception {
await().ignoreExceptions().pollDelay(100, TimeUnit.MILLISECONDS).atMost(5, TimeUnit.SECONDS)
.until(() -> Browser.getDriver().findElement(By.id("logicalTree")).isDisplayed());

// right click on first tree node representing image 2
WebElement firstTreeNode = Browser.getDriver().findElement(
By.cssSelector("#logicalTree\\:0_0 .ui-treenode-content")
);
new Actions(Browser.getDriver()).contextClick(firstTreeNode).build().perform();

// wait until menu is visible
await().ignoreExceptions().pollDelay(100, TimeUnit.MILLISECONDS).atMost(5, TimeUnit.SECONDS)
.until(() -> Browser.getDriver().findElement(By.id("contextMenuLogicalTree")).isDisplayed());
// open context menu for linked page "2"
Pages.getMetadataEditorPage().openContextMenuForStructureTreeNode("0_0");

// click second menu entry to open new tab
Browser.getDriver().findElement(By.cssSelector(
"#contextMenuLogicalTree .ui-menuitem:nth-child(2) .ui-menuitem-link"
)).click();
Browser.getDriver().findElement(By.cssSelector("#contextMenuLogicalTree .viewPageInNewWindow")).click();

// find handle of new tab window
String newWindowHandle = Browser.getDriver().getWindowHandles().stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,13 +251,11 @@ public void openContextMenuForStructureTreeNode(String nodeId) {
/**
* Click on a menu entry in the structure tree context menu.
*
* @param menuEntry the menu entry index (starting with 1)
* @param menuItemClassName the class name of the menu entry
*/
public void clickStructureTreeContextMenuEntry(int menuEntry) {
public void clickStructureTreeContextMenuEntry(String menuItemClassName) {
// click on menu entry
contextMenuLogicalTree.findElement(By.cssSelector(
".ui-menuitem:nth-child(" + menuEntry + ") .ui-menuitem-link"
)).click();
contextMenuLogicalTree.findElement(By.className(menuItemClassName)).click();
// wait for context menu to disappear
await().ignoreExceptions().pollDelay(100, TimeUnit.MILLISECONDS).atMost(5, TimeUnit.SECONDS)
.until(() -> !contextMenuLogicalTree.isDisplayed());
Expand Down

0 comments on commit c8bf30f

Please sign in to comment.