package com.intland.codebeamer.functionaltest.test.trackers.trackerviews.documentview;

import com.codeborne.selenide.CollectionCondition;
import com.codeborne.selenide.Condition;
import com.codeborne.selenide.SelenideElement;
import com.codeborne.selenide.testng.ScreenShooter;
import com.intland.codebeamer.functionaltest.helper.Helper;
import com.intland.codebeamer.functionaltest.page.*;
import com.intland.codebeamer.functionaltest.page.common.*;
import com.intland.codebeamer.functionaltest.page.mystart.MyStartPage;
import com.intland.codebeamer.functionaltest.page.trackers.*;
import com.intland.codebeamer.functionaltest.page.trackers.documentview.*;
import com.intland.codebeamer.functionaltest.page.wiki.ProjectWikiPage;
import com.intland.codebeamer.functionaltest.test.BaseTest;
import org.apache.commons.lang3.RandomStringUtils;
import org.openqa.selenium.Keys;
import org.testng.annotations.*;

import java.lang.reflect.Method;
import java.text.SimpleDateFormat;
import java.util.Date;

import static com.codeborne.selenide.CollectionCondition.texts;
import static com.codeborne.selenide.Condition.hidden;
import static com.codeborne.selenide.Condition.visible;
import static com.codeborne.selenide.Selenide.*;
import static org.testng.Assert.*;

/**
 * Copyright by Intland Software
 * <p>
 * All rights reserved.
 * <p>
 * This software is the confidential and proprietary information
 * of Intland Software. ("Confidential Information"). You
 * shall not disclose such Confidential Information and shall use
 * it only in accordance with the terms of the license agreement
 * you entered into with Intland.
 */
@Listeners({ScreenShooter.class})
public class DocumentViewTests {

    private MyStartPage myStartPage;
    private DocumentViewPage documentViewPage;
    private final String ITEM_1 = "Test Requirement 1";
    private final String ITEM_2 = "Test Requirement 2";
    private final String ITEM_3 = "Test Requirement 3";
    private final String text = RandomStringUtils.randomAlphabetic(5);
    private String projectName;
    private final String projectArchiveName = "test-documentview.zip";
    private BaseTest baseTest = new BaseTest();

    private void commonBefore(String trackerName, Method method) {
        baseTest.handleTestMethodName(method);
        SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss dd/MM/yyyy");
        projectName = "test-documentview" + RandomStringUtils.randomAlphabetic(5) + dateFormat.format(new Date().getTime());
        ProjectWikiPage projectWikiPage = baseTest.createProjectFromArchive(projectArchiveName, projectName, "");
        TrackersPage trackersPage = projectWikiPage.clickOnTrackers();
        TrackerItemListPage trackerItemListPage = trackersPage.clickOnTracker(trackerName);
        documentViewPage = page(DocumentViewPage.class);
        documentViewPage.waitForPageToLoad();
    }


    @BeforeClass(alwaysRun = true)
    public void startServer() throws Exception {
        baseTest.startServer();
    }

    @BeforeMethod(groups = "usesNewRequirementsTracker")
    public void beforeMethodUsesNewRequirementsTracker(Method method) {
        commonBefore("New Requirements", method);
    }

    @BeforeMethod(groups = "usesNewerRequirementsTracker")
    public void beforeMethodUsesNewerRequirementsTracker(Method method) {
        commonBefore("Newer Requirements", method);
    }


    @BeforeMethod(groups = {"usesNewTestCasesTracker"})
    public void beforeMethodUsesNewTestCasesTracker(Method method) {
        commonBefore("New Test Cases", method);
    }

    @BeforeMethod(groups = {"usesTest-tracker-wowf-sel10560"})
    public void beforeMethodUsesTestTrackerWowfSel10560(Method method) {
        commonBefore("test-tracker-wowf-sel10560", method);
        BaselinesPage baselinesPage = documentViewPage.clickOnBaselines();
        baselinesPage.clickOnNewBaseline();
        baselinesPage.setName("Test baseline");
        baselinesPage.clickOnOk();
        TrackersPage trackersPage = baselinesPage.clickOnTrackers();
        TrackerItemListPage trackerItemListPage = trackersPage.clickOnTracker("test-tracker-wowf-sel10560");
        documentViewPage = page(DocumentViewPage.class);
        documentViewPage.waitForPageToLoad();
    }

    //https://codebeamer.com/cb/issue/703595
    @Test
    public void testRightAndLeftPanelToggling() {
        //TODO maybe it would be better to set it explicitly
        //starts open by default
        //2 close left pane
        documentViewPage.clickOnLeftCloserTogglingIcon();
        assertTrue(documentViewPage.leftPane.isLeftPaneHidden());
        assertTrue(documentViewPage.centerPane.isCenterPaneExpandedToLeft());
        //3
        refresh();
        assertTrue(documentViewPage.leftPane.isLeftPaneHidden());
        assertTrue(documentViewPage.centerPane.isCenterPaneExpandedToLeft());
        //4 open left pane
        documentViewPage.clickOnLeftOpenerTogglingIcon();
        assertFalse(documentViewPage.leftPane.isLeftPaneHidden());
        assertFalse(documentViewPage.centerPane.isCenterPaneExpandedToLeft());
        //5
        refresh();
        assertFalse(documentViewPage.leftPane.isLeftPaneHidden());
        assertFalse(documentViewPage.centerPane.isCenterPaneExpandedToLeft());
        //6
        documentViewPage.clickOnRightCloserTogglingIcon();
        documentViewPage.rightPane.checkIfRightPaneIsCollapsed();
        documentViewPage.centerPane.isCenterPaneExpandedToRight();
        //7
        refresh();
        documentViewPage.rightPane.checkIfRightPaneIsCollapsed();
        documentViewPage.centerPane.isCenterPaneExpandedToRight();
        //8
        documentViewPage.clickOnRightOpenerTogglingIcon();
        documentViewPage.rightPane.checkIfRightPaneIsNotCollapsed();
        assertFalse(documentViewPage.centerPane.isCenterPaneExpandedToRight());
        //9
        refresh();
        documentViewPage.rightPane.checkIfRightPaneIsNotCollapsed();
        documentViewPage.centerPane.isCenterPaneNotExpandedToRight();
    }

    //https://codebeamer.com/cb/issue/703596
    @Test
    public void testChangingWidthOfLeftAndRightPanel() {
        int originalRightPaneWidth = documentViewPage.getRightPaneWidth();
        //2
        documentViewPage.adjustRightPaneWidthBy(-100);
        int currentRightPaneWidth = documentViewPage.getRightPaneWidth();
        assertEquals(currentRightPaneWidth, originalRightPaneWidth + 100);
        //3
        refresh();
        assertEquals(currentRightPaneWidth, originalRightPaneWidth + 100);
        //4
        documentViewPage.adjustLeftPaneWidthBy(+10000);
        int currentLeftPaneWidth = documentViewPage.leftPane.getLeftPaneWidth();
        final long maxAvailableWidth = Math.round($("html").getSize().width * 0.4);
        assertEquals(currentLeftPaneWidth, maxAvailableWidth);
        //5
        refresh();
        assertEquals(currentLeftPaneWidth, maxAvailableWidth);
        documentViewPage.adjustLeftPaneWidthBy(-10000);
        currentLeftPaneWidth = documentViewPage.leftPane.getLeftPaneWidth();
        final long minAvailableWidth = 280;
        assertEquals(currentLeftPaneWidth, minAvailableWidth);

    }

    @DataProvider(name = "viewNames")
    public Object[][] viewNames() {
        return new Object[][]{{TrackerItemListPage.ViewMenuIcon.TEST_COVERAGE},
//                {TrackerItemListPage.ViewMenuIcon.TRACEABILITY_BROWSER},
                {TrackerItemListPage.ViewMenuIcon.TABLE_VIEW},
                {TrackerItemListPage.ViewMenuIcon.KANBAN_BOARD}};
    }

    //https://codebeamer.com/cb/issue/703597
    @Test(dataProvider = "viewNames")
    public void testChangingViewToViewName(TrackerItemListPage.ViewMenuIcon viewMenuIcon) {
        BasePage page = documentViewPage.clickOnViewMenuIcon(viewMenuIcon);
        assertTrue(page.isPageLoaded());
    }

    @DataProvider(name = "moreMenuItems")
    public Object[][] moreMenuItems() {
        return new Object[][]{
                {CenterPane.MoreMenuItem.CUSTOMIZE},
                {CenterPane.MoreMenuItem.IMPORT},
                {CenterPane.MoreMenuItem.EXPORT_TO_OFFICE},
                {CenterPane.MoreMenuItem.EXPORT_SELECTION},
                {CenterPane.MoreMenuItem.TEST_COVERAGE},
                {CenterPane.MoreMenuItem.TRACEABILITY_BROWSER},
                {CenterPane.MoreMenuItem.RISK_MATRIX_DIAGRAM},
                {CenterPane.MoreMenuItem.WORKFLOW_DIAGRAM},
                {CenterPane.MoreMenuItem.NEW_VIEW},
                {CenterPane.MoreMenuItem.DUPLICATE},
                {CenterPane.MoreMenuItem.REFERENCE_VIEW_SETTINGS},
                {CenterPane.MoreMenuItem.NEW_BASELINE},
                {CenterPane.MoreMenuItem.SEND_TO_REVIEW},
                {CenterPane.MoreMenuItem.SEND_SELECTION_TO_REVIEW},
                {CenterPane.MoreMenuItem.ADD_TAG}
        };
    }

    //https://codebeamer.com/cb/issue/703598
    //https://codebeamer.com/cb/issue/703605
    @Test(dataProvider = "moreMenuItems")
    public void testMoreMenuItems(CenterPane.MoreMenuItem moreMenuItem) {
        if (moreMenuItem.equalsName(CenterPane.MoreMenuItem.EXPORT_SELECTION.text)
                || moreMenuItem.equalsName(CenterPane.MoreMenuItem.SEND_SELECTION_TO_REVIEW.text)) {
            documentViewPage.leftPane.clickOnLeftTreeItem(ITEM_1, 1);
        }
        IsPageLoaded page = documentViewPage.centerPane.clickOnMoreMenuItem(moreMenuItem);
        if (moreMenuItem.isInIframe()) {
            switchTo().frame(0);
        }
        assertTrue(page.isPageLoaded());
    }

    //https://codebeamer.com/cb/issue/703605
    @Test
    public void testMoreMenuItemLockUnlock() {
        //lock
        documentViewPage.centerPane.clickOnMoreMenuItem(CenterPane.MoreMenuItem.LOCK);
        sleep(2000);
        assertTrue(documentViewPage.centerPane.isLocked(), "Tracker item should be locked");
        //unlock
        documentViewPage.centerPane.clickOnMoreMenuItem(CenterPane.MoreMenuItem.UNLOCK);
        sleep(2000);
        assertTrue(documentViewPage.centerPane.isUnlocked(), "Tracker item should be unlocked");
    }

    //https://codebeamer.com/cb/issue/703605
    @Test
    public void testMoreMenuItemFollowUnfollow() {
        //follow
        documentViewPage.centerPane.clickOnMoreMenuItem(CenterPane.MoreMenuItem.FOLLOW);
        documentViewPage.waitForPageToLoad();
        documentViewPage.centerPane.clickOnMoreMenuItem(CenterPane.MoreMenuItem.UNFOLLOW);
    }

    //https://codebeamer.com/cb/issue/703598
    @Test
    public void testSetViewAsDefaultAndClear() {
        //set default view to Table view
        TableViewPage tableView = (TableViewPage) documentViewPage.clickOnViewMenuIcon(TrackerItemListPage.ViewMenuIcon.TABLE_VIEW);
        tableView.clickOnMoreMenuItem(CenterPane.MoreMenuItem.SET_AS_DEFAULT);
        TrackersPage trackersPage = documentViewPage.clickOnTrackers();
        trackersPage.clickOnTracker("New Requirements");
        TableViewPage tableViewPage = page(TableViewPage.class);
        assertTrue(tableViewPage.isPageLoaded());
        //clear default view which means Document view will be the default
        tableView.clickOnMoreMenuItem(CenterPane.MoreMenuItem.CLEAR_DEFAULT);
        trackersPage = documentViewPage.clickOnTrackers();
        trackersPage.clickOnTracker("New Requirements");
        DocumentViewPage documentViewPage = page(DocumentViewPage.class);
        assertTrue(documentViewPage.isPageLoaded());
    }

    public void afterTestSetViewAsDefaultAndClear() {
        //set default back to Document View if anything happens
        documentViewPage.clickOnViewMenuIcon(TrackerItemListPage.ViewMenuIcon.DOCUMENT_VIEW);
        documentViewPage.centerPane.clickOnMoreMenuItem(CenterPane.MoreMenuItem.SET_AS_DEFAULT);

    }

    //https://codebeamer.com/cb/issue/703599
    @Test
    public void testLeftTree() {
        //2
        documentViewPage.leftPane.getAllLeftTreeItems().shouldHave(texts("New Requirements", "Test Requirement 1", "Test Requirement 2", "Test Requirement 3"));
        //3
        documentViewPage.leftPane.dragAndDrop(ITEM_3, 1, "New Requirements", 1, LeftPane.DragAndDropAction.INTO);
        documentViewPage.leftPane.getAllLeftTreeItems().shouldHave(texts("New Requirements", ITEM_3, ITEM_1, ITEM_2));
        //4
        documentViewPage.leftPane.fillTreeFilter(" 2");
        documentViewPage.leftPane.getAllLeftTreeItems().shouldHave(texts("New Requirements", "Test Requirement 1", "Test Requirement 2"));
        refresh();
        //5
        documentViewPage.leftPane.clickOnLeftTreeContextMenuItem(ITEM_2, 1, LeftPane.LeftTreeContextMenuItem.SHOW_TREE_FROM_THIS_ITEM);
        documentViewPage.leftPane.getAllLeftTreeItems().shouldHave(texts(ITEM_2));

    }

    //https://codebeamer.com/cb/issue/703600
    @Test
    public void testLeftTreeContextMenu() {
        //Open
        TrackerItemDetailsPage trackerItemDetailsPage = (TrackerItemDetailsPage) documentViewPage.leftPane.clickOnLeftTreeContextMenuItem(ITEM_1, 1, LeftPane.LeftTreeContextMenuItem.OPEN);
        switchTo().window(1);
        assertTrue(trackerItemDetailsPage.isPageLoaded(), "Item details page has not been loaded");
        switchTo().window(0);
        //Collapse node
        documentViewPage.leftPane.clickOnLeftTreeContextMenuItem(ITEM_1, 1, LeftPane.LeftTreeContextMenuItem.COLLAPSE_NODE);
        documentViewPage.leftPane.getAllLeftTreeItems(false).shouldHave(texts("New Requirements", "Test Requirement 1"));
        //Expand node
        documentViewPage.leftPane.clickOnLeftTreeContextMenuItem(ITEM_1, 1, LeftPane.LeftTreeContextMenuItem.EXPAND_NODE);
        documentViewPage.leftPane.getAllLeftTreeItems(false).shouldHave(texts("New Requirements", "Test Requirement 1", "Test Requirement 2", "Test Requirement 3"));
        //Rename
        documentViewPage.leftPane.clickOnLeftTreeContextMenuItem(ITEM_1, 1, LeftPane.LeftTreeContextMenuItem.RENAME);
        assertTrue(documentViewPage.leftPane.isLeftTreeItemEditable(ITEM_1), "Left tree item is not editable");
        refresh();
        //Show tree from this item
        documentViewPage.leftPane.clickOnLeftTreeContextMenuItem(ITEM_1, 1, LeftPane.LeftTreeContextMenuItem.SHOW_TREE_FROM_THIS_ITEM);
        documentViewPage.leftPane.getAllLeftTreeItems(true).shouldHave(texts("Test Requirement 1", "Test Requirement 2", "Test Requirement 3"));
        //Export to Office
        ExportToOfficeDialogPage exportToOfficeDialogPage = (ExportToOfficeDialogPage) documentViewPage.leftPane.clickOnLeftTreeContextMenuItem(ITEM_1, 1, LeftPane.LeftTreeContextMenuItem.EXPORT_SELECTION);
        switchTo().frame("inlinedPopupIframe");
        assertTrue(exportToOfficeDialogPage.isPageLoaded(), "Export to office dialog has not been loaded");
        close();
    }

    //https://codebeamer.com/cb/issue/703600
    @Test
    public void testLeftTreeContextMenuNewChild() {
        //New child
        documentViewPage.leftPane.clickOnLeftTreeContextMenuItem(ITEM_1, 1, LeftPane.LeftTreeContextMenuItem.NEW_CHILD);
        sleep(500);
        assertTrue(documentViewPage.centerPane.isNewTrackerItemEditorInsertedAfter(ITEM_3, 1));
        refresh();
        //Insert new item after this
        documentViewPage.leftPane.clickOnLeftTreeContextMenuItem(ITEM_2, 1, LeftPane.LeftTreeContextMenuItem.INSERT_NEW_ITEM_AFTER_THIS);
        sleep(500);
        assertTrue(documentViewPage.centerPane.isNewTrackerItemEditorInsertedAfter(ITEM_2, 1));
        refresh();
        //Insert a new item before this
        documentViewPage.leftPane.clickOnLeftTreeContextMenuItem(ITEM_2, 1, LeftPane.LeftTreeContextMenuItem.INSERT_NEW_ITEM_BEFORE_THIS);
        sleep(500);
        assertTrue(documentViewPage.centerPane.isNewTrackerItemEditorInsertedAfter(ITEM_1, 1));
    }

    //https://codebeamer.com/cb/issue/703600
    //https://codebeamer.com/cb/issue/703612
    @Test
    public void testLeftTreeContextMenuCopyPasteAsNewChildDelete() {
        //Copy
        documentViewPage.leftPane.clickOnLeftTreeContextMenuItem(ITEM_1, 1, LeftPane.LeftTreeContextMenuItem.COPY);
        //Paste as new child
        AssociationTypeSelectionDialogPage associationTypeSelectionDialogPage = (AssociationTypeSelectionDialogPage) documentViewPage.leftPane.clickOnLeftTreeContextMenuItem(ITEM_2, 1, LeftPane.LeftTreeContextMenuItem.PASTE_AS_NEW_CHILD);
        associationTypeSelectionDialogPage.clickOnOk();
        sleep(1000);
        assertCopyPasteAsNewChild();
        afterLeftTreeCopyPaste();
    }

    //https://codebeamer.com/cb/issue/703600
    //https://codebeamer.com/cb/issue/703612
    @Test
    public void testLeftTreeContextMenuCopyPasteAboveThisDelete() {
        //Copy
        documentViewPage.leftPane.clickOnLeftTreeContextMenuItem(ITEM_1, 1, LeftPane.LeftTreeContextMenuItem.COPY);
        //Paste above this
        AssociationTypeSelectionDialogPage associationTypeSelectionDialogPage = (AssociationTypeSelectionDialogPage) documentViewPage.leftPane.clickOnLeftTreeContextMenuItem(ITEM_2, 1, LeftPane.LeftTreeContextMenuItem.PASTE_ABOVE_THIS);
        associationTypeSelectionDialogPage.clickOnOk();
        sleep(1000);
        assertCopyPasteAbove();
        afterLeftTreeCopyPaste();
    }

    //https://codebeamer.com/cb/issue/703600
    //https://codebeamer.com/cb/issue/703612
    @Test
    public void testLeftTreeContextMenuCopyPasteBelowThisDelete() {
        //Copy
        documentViewPage.leftPane.clickOnLeftTreeContextMenuItem(ITEM_1, 1, LeftPane.LeftTreeContextMenuItem.COPY);
        //Paste below this
        AssociationTypeSelectionDialogPage associationTypeSelectionDialogPage = (AssociationTypeSelectionDialogPage) documentViewPage.leftPane.clickOnLeftTreeContextMenuItem(ITEM_2, 1, LeftPane.LeftTreeContextMenuItem.PASTE_BELOW_THIS);
        associationTypeSelectionDialogPage.clickOnOk();
        sleep(1000);
        assertCopyPasteBelow();
        afterLeftTreeCopyPaste();
    }

    public void afterLeftTreeCopyPaste() {
        //Delete
        ConfirmationDialogPage confirmationDialogPage = (ConfirmationDialogPage) documentViewPage.leftPane.clickOnLeftTreeContextMenuItem(ITEM_1, 2, LeftPane.LeftTreeContextMenuItem.DELETE);
        confirmationDialogPage.clickOnYes();
        documentViewPage.leftPane.getAllLeftTreeItems(true).shouldHave(
                texts("New Requirements", "Test Requirement 1", "Test Requirement 2", "Test Requirement 3"));
        documentViewPage.centerPane.getAllCenterPaneItems().shouldHave(texts(
                "1 Test Requirement 1 test",
                "1.1 Test Requirement 2",
                "1.2 Test Requirement 3"
        ));
    }

    //https://codebeamer.com/cb/issue/703602
    @Test
    public void testCenterPaneContextMenuItemX() {
        //Open
        TrackerItemDetailsPage trackerItemDetailsPage = (TrackerItemDetailsPage) documentViewPage.centerPane.clickOnCenterPaneContextMenuItem(ITEM_2, 1, CenterPane.CenterPaneContextMenuItem.OPEN);
        switchTo().window(1);
        trackerItemDetailsPage.isPageLoaded();
        switchTo().window(0);
        //New child
        documentViewPage.centerPane.clickOnCenterPaneContextMenuItem(ITEM_2, 1, CenterPane.CenterPaneContextMenuItem.NEW_CHILD);
        assertTrue(documentViewPage.centerPane.isNewTrackerItemEditorInsertedAfter(ITEM_2, 1));
        refresh();
        //Insert a new item before this
        documentViewPage.centerPane.clickOnCenterPaneContextMenuItem(ITEM_2, 1, CenterPane.CenterPaneContextMenuItem.INSERT_NEW_ITEM_BEFORE_THIS);
        assertTrue(documentViewPage.centerPane.isNewTrackerItemEditorInsertedAfter(ITEM_1, 1));
        refresh();
        //Insert a new item after this
        documentViewPage.centerPane.clickOnCenterPaneContextMenuItem(ITEM_2, 1, CenterPane.CenterPaneContextMenuItem.INSERT_NEW_ITEM_AFTER_THIS);
        assertTrue(documentViewPage.centerPane.isNewTrackerItemEditorInsertedAfter(ITEM_2, 1));
        refresh();
        //Add association
        AddAssociationDialog addAssociationDialog = (AddAssociationDialog) documentViewPage.centerPane.clickOnCenterPaneContextMenuItem(ITEM_2, 1, CenterPane.CenterPaneContextMenuItem.ADD_ASSOCIATION);
        switchTo().frame("inlinedPopupIframe");
        assertTrue(addAssociationDialog.isPageLoaded());
        refresh();
        //Add comment
        AddCommentDialog newCommentDialogPage = (AddCommentDialog) documentViewPage.centerPane.clickOnCenterPaneContextMenuItem(ITEM_2, 1, CenterPane.CenterPaneContextMenuItem.ADD_COMMENT);
        switchTo().frame("inlinedPopupIframe");
        assertTrue(newCommentDialogPage.isPageLoaded());
    }

    //https://codebeamer.com/cb/issue/703602
    //https://codebeamer.com/cb/issue/703612
    @Test
    public void testCenterPaneContextMenuCopyPasteAsNewChildDelete() {
        documentViewPage.centerPane.clickOnCenterPaneContextMenuItem(ITEM_1, 1, CenterPane.CenterPaneContextMenuItem.COPY);
        AssociationTypeSelectionDialogPage associationTypeSelectionDialogPage = (AssociationTypeSelectionDialogPage) documentViewPage.centerPane.clickOnCenterPaneContextMenuItem(ITEM_2, 1, CenterPane.CenterPaneContextMenuItem.PASTE_AS_NEW_CHILD);
        associationTypeSelectionDialogPage.clickOnOk();
        sleep(1000);
        documentViewPage.waitForLoaderToDisappear();
        assertCopyPasteAsNewChild();
        afterCopyPaste();
    }

    public void afterCopyPaste() {
        //Delete
        documentViewPage.centerPane.clickOnCenterPaneContextMenuItem(ITEM_1, 2, CenterPane.CenterPaneContextMenuItem.DELETE);
        confirm();
        sleep(1000);
        documentViewPage.leftPane.getAllLeftTreeItems(true).shouldHave(
                texts("New Requirements", "Test Requirement 1", "Test Requirement 2", "Test Requirement 3"));
        documentViewPage.centerPane.getAllCenterPaneItems().shouldHave(texts(
                "1 Test Requirement 1 test",
                "1.1 Test Requirement 2",
                "1.2 Test Requirement 3"
        ));
    }

    //https://codebeamer.com/cb/issue/703602
    //https://codebeamer.com/cb/issue/703612
    @Test
    public void testCenterPaneContextMenuCopyPasteAboveDelete() {
        documentViewPage.centerPane.clickOnCenterPaneContextMenuItem(ITEM_1, 1, CenterPane.CenterPaneContextMenuItem.COPY);
        AssociationTypeSelectionDialogPage associationTypeSelectionDialogPage = (AssociationTypeSelectionDialogPage) documentViewPage.centerPane.clickOnCenterPaneContextMenuItem(ITEM_2, 1, CenterPane.CenterPaneContextMenuItem.PASTE_ABOVE_THIS);
        associationTypeSelectionDialogPage.clickOnOk();
        sleep(1000);
        documentViewPage.waitForLoaderToDisappear();
        assertCopyPasteAbove();
        afterCopyPaste();
    }

    //https://codebeamer.com/cb/issue/703602
    //https://codebeamer.com/cb/issue/703612
    @Test
    public void testCenterPaneContextMenuCopyPasteBelowDelete() {
        documentViewPage.centerPane.clickOnCenterPaneContextMenuItem(ITEM_1, 1, CenterPane.CenterPaneContextMenuItem.COPY);
        AssociationTypeSelectionDialogPage associationTypeSelectionDialogPage = (AssociationTypeSelectionDialogPage) documentViewPage.centerPane.clickOnCenterPaneContextMenuItem(ITEM_2, 1, CenterPane.CenterPaneContextMenuItem.PASTE_BELOW_THIS);
        associationTypeSelectionDialogPage.clickOnOk();
        sleep(1000);
        documentViewPage.waitForLoaderToDisappear();
        assertCopyPasteBelow();
        afterCopyPaste();
    }

    //https://codebeamer.com/cb/issue/703602
    //https://codebeamer.com/cb/issue/703612
    @Test
    public void testCopyFromLeftTreePasteAsNewChildToCenterPaneDelete() {
        //Copy
        documentViewPage.leftPane.clickOnLeftTreeContextMenuItem(ITEM_1, 1, LeftPane.LeftTreeContextMenuItem.COPY);
        AssociationTypeSelectionDialogPage associationTypeSelectionDialogPage = (AssociationTypeSelectionDialogPage) documentViewPage.centerPane.clickOnCenterPaneContextMenuItem(ITEM_2, 1, CenterPane.CenterPaneContextMenuItem.PASTE_AS_NEW_CHILD);
        associationTypeSelectionDialogPage.clickOnOk();
        sleep(1000);
        documentViewPage.waitForLoaderToDisappear();
        assertCopyPasteAsNewChild();
        afterCopyPaste();
    }

    //https://codebeamer.com/cb/issue/703602
    //https://codebeamer.com/cb/issue/703612
    @Test
    public void testCopyFromLeftTreePasteBelowToCenterPaneDelete() {
        //Copy
        documentViewPage.leftPane.clickOnLeftTreeContextMenuItem(ITEM_1, 1, LeftPane.LeftTreeContextMenuItem.COPY);
        AssociationTypeSelectionDialogPage associationTypeSelectionDialogPage = (AssociationTypeSelectionDialogPage) documentViewPage.centerPane.clickOnCenterPaneContextMenuItem(ITEM_2, 1, CenterPane.CenterPaneContextMenuItem.PASTE_BELOW_THIS);
        associationTypeSelectionDialogPage.clickOnOk();
        sleep(1000);
        documentViewPage.waitForLoaderToDisappear();
        assertCopyPasteBelow();
        afterCopyPaste();
    }

    //https://codebeamer.com/cb/issue/703602
    //https://codebeamer.com/cb/issue/703612
    @Test
    public void testCopyFromLeftTreePasteAboveToCenterPaneDelete() {
        //Copy
        documentViewPage.leftPane.clickOnLeftTreeContextMenuItem(ITEM_1, 1, LeftPane.LeftTreeContextMenuItem.COPY);
        AssociationTypeSelectionDialogPage associationTypeSelectionDialogPage = (AssociationTypeSelectionDialogPage) documentViewPage.centerPane.clickOnCenterPaneContextMenuItem(ITEM_2, 1, CenterPane.CenterPaneContextMenuItem.PASTE_ABOVE_THIS);
        associationTypeSelectionDialogPage.clickOnOk();
        sleep(1000);
        documentViewPage.waitForLoaderToDisappear();
        documentViewPage.centerPane.getAllCenterPaneItems().shouldHave(texts(
                "1 Test Requirement 1 test",
                "1.1 Test Requirement 1 test",
                "1.1.1 Test Requirement 2",
                "1.1.2 Test Requirement 3",
                "1.2 Test Requirement 2",
                "1.3 Test Requirement 3"
        ));
        documentViewPage.leftPane.getAllLeftTreeItems().shouldHave(texts(
                "New Requirements",
                "Test Requirement 1",
                "Test Requirement 1",
                "Test Requirement 2",
                "Test Requirement 3",
                "Test Requirement 2",
                "Test Requirement 3"
        ));
        afterCopyPaste();
    }

    //https://codebeamer.com/cb/issue/703602
    //https://codebeamer.com/cb/issue/703612
    @Test
    public void testCopyFromCenterPaneToPasteAboveToLeftTreeDelete() {
        //Copy
        documentViewPage.centerPane.clickOnCenterPaneContextMenuItem(ITEM_1, 1, CenterPane.CenterPaneContextMenuItem.COPY);
        AssociationTypeSelectionDialogPage associationTypeSelectionDialogPage = (AssociationTypeSelectionDialogPage) documentViewPage.leftPane.clickOnLeftTreeContextMenuItem(ITEM_2, 1, LeftPane.LeftTreeContextMenuItem.PASTE_ABOVE_THIS);
        associationTypeSelectionDialogPage.clickOnOk();
        sleep(1000);
        documentViewPage.waitForLoaderToDisappear();
        assertCopyPasteAbove();
        afterCopyPaste();
    }

    //https://codebeamer.com/cb/issue/703602
    //https://codebeamer.com/cb/issue/703612
    @Test
    public void testCopyFromCenterPanePasteBelowToLeftTreeDelete() {
        //Copy
        documentViewPage.centerPane.clickOnCenterPaneContextMenuItem(ITEM_1, 1, CenterPane.CenterPaneContextMenuItem.COPY);
        AssociationTypeSelectionDialogPage associationTypeSelectionDialogPage = (AssociationTypeSelectionDialogPage) documentViewPage.leftPane.clickOnLeftTreeContextMenuItem(ITEM_2, 1, LeftPane.LeftTreeContextMenuItem.PASTE_BELOW_THIS);
        associationTypeSelectionDialogPage.clickOnOk();
        sleep(1000);
        documentViewPage.waitForLoaderToDisappear();
        assertCopyPasteBelow();
        afterCopyPaste();
    }

    //https://codebeamer.com/cb/issue/703602
    //https://codebeamer.com/cb/issue/703612
    @Test
    public void testCopyFromCenterPanePasteAsNewChildToLeftTreeDelete() {
        //Copy
        documentViewPage.centerPane.clickOnCenterPaneContextMenuItem(ITEM_1, 1, CenterPane.CenterPaneContextMenuItem.COPY);
        AssociationTypeSelectionDialogPage associationTypeSelectionDialogPage = (AssociationTypeSelectionDialogPage) documentViewPage.leftPane.clickOnLeftTreeContextMenuItem(ITEM_2, 1, LeftPane.LeftTreeContextMenuItem.PASTE_AS_NEW_CHILD);
        associationTypeSelectionDialogPage.clickOnOk();
        sleep(1000);
        documentViewPage.waitForLoaderToDisappear();
        assertCopyPasteAsNewChild();
        afterCopyPaste();
    }

    public void assertCopyPasteAsNewChild() {
        documentViewPage.centerPane.getAllCenterPaneItems().shouldHave(texts(
                "1 Test Requirement 1 test",
                "1.1 Test Requirement 2",
                "1.1.1 Test Requirement 1 test",
                "1.1.1.1 Test Requirement 2",
                "1.1.1.2 Test Requirement 3",
                "1.2 Test Requirement 3"
        ));
        documentViewPage.leftPane.getAllLeftTreeItems().shouldHave(texts(
                "New Requirements",
                "Test Requirement 1",
                "Test Requirement 2",
                "Test Requirement 1",
                "Test Requirement 2",
                "Test Requirement 3",
                "Test Requirement 3"
        ));
    }

    public void assertCopyPasteBelow() {
        documentViewPage.centerPane.getAllCenterPaneItems().shouldHave(texts(
                "1 Test Requirement 1 test",
                "1.1 Test Requirement 2",
                "1.2 Test Requirement 1 test",
                "1.2.1 Test Requirement 2",
                "1.2.2 Test Requirement 3",
                "1.3 Test Requirement 3"
        ));
        documentViewPage.leftPane.getAllLeftTreeItems().shouldHave(texts(
                "New Requirements",
                "Test Requirement 1",
                "Test Requirement 2",
                "Test Requirement 1",
                "Test Requirement 2",
                "Test Requirement 3",
                "Test Requirement 3"
        ));
    }


    public void assertCopyPasteAbove() {
        documentViewPage.centerPane.getAllCenterPaneItems().shouldHave(texts(
                "1 Test Requirement 1 test",
                "1.1 Test Requirement 1 test",
                "1.1.1 Test Requirement 2",
                "1.1.2 Test Requirement 3",
                "1.2 Test Requirement 2",
                "1.3 Test Requirement 3"
        ));
        documentViewPage.leftPane.getAllLeftTreeItems().shouldHave(texts(
                "New Requirements",
                "Test Requirement 1",
                "Test Requirement 1",
                "Test Requirement 2",
                "Test Requirement 3",
                "Test Requirement 2",
                "Test Requirement 3"
        ));
    }

    //https://codebeamer.com/cb/issue/703613
    @Test
    public void testAddAssociationsLeftTree() {
        //add association during copy paste above this in left tree
        documentViewPage.leftPane.clickOnLeftTreeContextMenuItem(ITEM_2, 1, LeftPane.LeftTreeContextMenuItem.COPY);
        AssociationTypeSelectionDialogPage associationTypeSelectionDialogPage = (AssociationTypeSelectionDialogPage) documentViewPage.leftPane.clickOnLeftTreeContextMenuItem(ITEM_2, 1, LeftPane.LeftTreeContextMenuItem.PASTE_ABOVE_THIS);
        associationTypeSelectionDialogPage.selectAssociationType(AssociationTypeSelectionDialogPage.AssociationType.DEPENDS);
        associationTypeSelectionDialogPage.clickOnOk();
        documentViewPage.rightPane.clickOnPropertiesTab();
        documentViewPage.rightPane.propertiesTab.clickOnRelationsPanel(true);
        documentViewPage.rightPane.propertiesTab.getAllAssociationsOf(ITEM_2, 2).shouldHave(texts("depends on"));
        afterTestAddAssociationsLeftTree();
    }

    public void afterTestAddAssociationsLeftTree() {
        ConfirmationDialogPage confirmationDialogPage = (ConfirmationDialogPage) documentViewPage.leftPane.clickOnLeftTreeContextMenuItem(ITEM_2, 2, LeftPane.LeftTreeContextMenuItem.DELETE);
        confirmationDialogPage.clickOnYes();
    }

    //https://codebeamer.com/cb/issue/703613
    @Test
    public void testAddAssociationsCenterPane() {
        AddAssociationDialog addAssociationDialog = (AddAssociationDialog) documentViewPage.centerPane.clickOnCenterPaneContextMenuItem(ITEM_2, 1, CenterPane.CenterPaneContextMenuItem.ADD_ASSOCIATION);
        switchTo().frame(0);
        addAssociationDialog.selectAssociationType(AddAssociationDialog.AssociationType.DEPENDS);
        addAssociationDialog.clickOnFromSearchTab();
        addAssociationDialog.fillSearchFor("Test Requirement 3");
        addAssociationDialog.clickOnGo();
        AddAssociationDialog.WorkItemsTab workItemsTab = addAssociationDialog.clickOnWorkItemsTab();
        //for debug reasons
        for (SelenideElement workItem : workItemsTab.getAllWorkItems()){
            System.out.println(workItem.text());
        }
        workItemsTab.selectArtifactByIndexFromWorkItemsTab(1, true);
        addAssociationDialog.clickOnAdd();
        documentViewPage.rightPane.clickOnPropertiesTab();
        documentViewPage.rightPane.propertiesTab.clickOnRelationsPanel(true);
        documentViewPage.rightPane.propertiesTab.getAllAssociationsOf(ITEM_2, 1).shouldHave(Helper.matchesText("This item depends on.*Test Requirement 3", "This item depends on.*Test Bug 1"));
        afterTestAddAssociationsCenterPane();
    }

    public void afterTestAddAssociationsCenterPane() {
        TrackerItemDetailsPage trackerItemDetailsPage = (TrackerItemDetailsPage) documentViewPage.leftPane.clickOnLeftTreeContextMenuItem(ITEM_2, 1, LeftPane.LeftTreeContextMenuItem.OPEN);
        switchTo().window(1);
        TrackerItemDetailsPage.AssociationTab associationTab = (TrackerItemDetailsPage.AssociationTab) trackerItemDetailsPage.clickOnTab(TrackerItemDetailsPage.TabType.ASSOCIATIONS);
        associationTab.clickOnContextMenuItemOfItem(ITEM_3, 1, AddAssociationDialog.AssociationType.DEPENDS, TrackerItemDetailsPage.AssociationTab.ContextMenuItem.DELETE);
        confirm("Do you really want to delete this association?");
        sleep(1000);
        close();
    }

    //https://codebeamer.com/cb/issue/703613
    @Test
    public void testAddAssociationsDragAndDropFromLeftToCenter() {
        documentViewPage.addAssociationOrReferenceViaDragAndDropBetweenLeftTreeAndCenterPane(ITEM_2, 1, ITEM_3, 1, DocumentViewPage.DragAndDropAssociationType.DEPENDS_ON);
        documentViewPage.rightPane.clickOnPropertiesTab();
        documentViewPage.rightPane.propertiesTab.clickOnRelationsPanel(true);
        documentViewPage.rightPane.propertiesTab.getAllAssociationsOf(ITEM_2, 1).shouldHave(Helper.matchText("This item depends on.*Test Requirement 3 SUSPECTED", "This item depends on.*Test Bug 1"));
        afterTestAddAssociationsCenterPane();
    }

    //https://codebeamer.com/cb/issue/703613
    //TODO fix drag and drop
    @Test
    public void testAddAssociationsDragAndDropCenter() {
        documentViewPage.addAssociationOrReferenceViaDragAndDropCenterPane(ITEM_2, 1, ITEM_3, 1, DocumentViewPage.DragAndDropAssociationType.DEPENDS_ON);
        documentViewPage.rightPane.clickOnPropertiesTab();
        documentViewPage.rightPane.propertiesTab.getAllAssociationsOf(ITEM_2, 1).shouldHave(Helper.matchText("This item depends on .*Test Requirement 3"));
    }

    //https://codebeamer.com/cb/issue/703606
    @Test
    public void testRightPanelPropertiesSubPanel() {
        //	Click on an item in the center panel
        documentViewPage.centerPane.clickOnCenterPaneItem(ITEM_2, 1);
        // In Properties tab, click on Details link
        RightPane.PropertiesTab propertiesTab = documentViewPage.rightPane.clickOnPropertiesTab();
        propertiesTab.clickOnDetailsPanel(true);
        // Click on item link in properties panel
        TrackerItemDetailsPage trackerItemDetailsPage = propertiesTab.clickOnItemLink(ITEM_2);
        assertTrue(trackerItemDetailsPage.isPageLoaded());
        // Return to document view tab in browser
        back();
        documentViewPage.centerPane.clickOnCenterPaneItem(ITEM_2, 1);
        // In Properties tab, click on Details link
        propertiesTab = documentViewPage.rightPane.clickOnPropertiesTab();
        // Click on Details link again
        propertiesTab.clickOnDetailsPanel(false);
        assertFalse(propertiesTab.isDetailsPanelOpened(), "details panel should be closed");
        // Click on Relations link
        propertiesTab.clickOnRelationsPanel(true);
        assertTrue(propertiesTab.isRelationsPanelOpened(), "relations panel should be opened");
        propertiesTab.getAllAssociationsOf(ITEM_2, 1).shouldHave(CollectionCondition.sizeGreaterThan(0));
        propertiesTab.getAllOutgoingReferencesOf(ITEM_2, 1).shouldHave(CollectionCondition.sizeGreaterThan(0));
        // Click on Relations link again
        propertiesTab.clickOnRelationsPanel(false);
        assertFalse(propertiesTab.isRelationsPanelOpened(), "relations panel should be closed");
        // Click on Comments link
        propertiesTab.clickOnCommentsPanel(true);
        assertTrue(propertiesTab.isCommentsPanelOpened(), "comments panel should be opened");
        // Click on Add Comment/Atachment link
        AddCommentDialog addCommentDialog = propertiesTab.clickOnAddComment();
        switchTo().frame("inlinedPopupIframe");
        assertTrue(addCommentDialog.isPageLoaded(), "add comment dialog has not been appeared");
        MarkupTab markupTab = (MarkupTab) addCommentDialog.editorComponent.clickOnTab(EditorComponent.Tab.MARKUP);
        // Write the comment into the text area, click on Save
        markupTab.fillComment(text);
        addCommentDialog.clickOnSave();
        switchTo().defaultContent();
        propertiesTab.getAllCommentGroup().shouldHave(texts(text));
        // 	Click on Comments link above Comments sup panel again
        propertiesTab.clickOnCommentsPanel(false);
        assertFalse(propertiesTab.isCommentsPanelOpened(), "comments panel should be closed");

        afterTestRightPanelPropertiesSubPanel();
    }

    public void afterTestRightPanelPropertiesSubPanel() {
        documentViewPage.centerPane.clickOnCenterPaneItem(ITEM_2, 1);
        RightPane.PropertiesTab propertiesTab = documentViewPage.rightPane.clickOnPropertiesTab();
        propertiesTab.clickOnDetailsPanel(true);
        // Click on item link in properties panel
        TrackerItemDetailsPage trackerItemDetailsPage = propertiesTab.clickOnItemLink(ITEM_2);
        TrackerItemDetailsPage.CommentsTab commentsTab = (TrackerItemDetailsPage.CommentsTab) trackerItemDetailsPage.clickOnTab(TrackerItemDetailsPage.TabType.COMMENTS_ATTACHMENTS);
        commentsTab.clickOnContextMenuItemOfComment(text, 1, TrackerItemDetailsPage.CommentsTab.ContextMenuItem.DELETE);
        confirm();
        sleep(1000);
    }

    //https://codebeamer.com/cb/issue/703607
    @Test
    public void testRightPanelReleasesSubPanel() {
        final String releaseItemName = "Drop Target";
        documentViewPage.centerPane.clickOnCenterPaneItem(ITEM_2, 1);
        RightPane.ReleasesTab releasesTab = documentViewPage.rightPane.clickOnReleasesTab();
        releasesTab.clickOnReleasesNode(true);
        releasesTab.fillFilter("empty");
        releasesTab.getAllTreeItems().shouldHave(texts("Empty Release", "NotEmpty Release"));
        releasesTab.fillFilter("");
        documentViewPage.leftPane.moveLeftTreeItemToReleaseItem(releaseItemName, 1, ITEM_2, 1);
        RightPane.PropertiesTab propertiesTab = documentViewPage.rightPane.clickOnPropertiesTab();
        propertiesTab.clickOnDetailsPanel(true);
        propertiesTab.getAllReleases().shouldHave(texts("Test Release", releaseItemName));
    }

    //https://codebeamer.com/cb/issue/703609
    @Test
    public void testRightPanelTestCaseLibrarySubPanel() {
        //Click on Tests Case Library tab in the right panel
        RightPane.TestCaseLibraryTab testCaseLibraryTab = documentViewPage.rightPane.clickOnTestCaseLibraryTab();
        //	Expand some of the trackers in the tree
        Helper.openAllRootNodes(testCaseLibraryTab.testTreePane());
        testCaseLibraryTab.selectStatus(RightPane.StatusType.ALL);//since it is remembered we make sure it starts with all
        //Type a text in the filter field
        testCaseLibraryTab.fillFilter("target");
        testCaseLibraryTab.getAllTreeItems().shouldHave(texts(projectName, "Test Cases", "Drop Target"));
        //Select a status in the status filter drop down
        testCaseLibraryTab.selectStatus(RightPane.StatusType.RESOLVED_CLOSED);
        testCaseLibraryTab.getAllTreeItems().shouldHave(texts(projectName, "Test Cases"));
        //Drag and drop a test case item from the library to the left tree
        testCaseLibraryTab.selectStatus(RightPane.StatusType.ALL);
        sleep(3000);
        LinkTestCasesPage linkTestCasesPage = testCaseLibraryTab.moveLibraryItemToLeftTreeItem("Drop Target", 1, ITEM_1, 1);
        switchTo().frame(0);
        //Chose the first option, click OK in the overlay
        linkTestCasesPage.clickOnSave();
        linkTestCasesPage.clickOnClose();
        switchTo().defaultContent();
        documentViewPage.rightPane.propertiesTab.getAllIncomingReferencesOf(ITEM_1, 1).shouldHave(texts("Drop Target"));
    }

    //https://codebeamer.com/cb/issue/703608
    @Test
    public void testRightPanelRequirementsLibrarySubPanel() {
        //Click on Requirements Library tab in the right panel
        RightPane.RequirementsLibraryTab requirementsLibraryTab = documentViewPage.rightPane.clickOnRequirementsLibraryTab();
        //Expand some of the trackers in the tree
        requirementsLibraryTab.openAllRequirementsLibraryTreeItems();
        //Helper.openAllRootNodes(requirementsLibraryTab.requirementsLibraryTreePane());
        //Type a text in the filter field
        requirementsLibraryTab.fillFilter(ITEM_1 + Keys.ENTER);
        requirementsLibraryTab.getAllTreeItems().shouldHave(texts(projectName, "New Requirements", ITEM_1));
        //Select a status in the status filter drop down
        requirementsLibraryTab.selectStatus(RightPane.StatusType.RESOLVED_CLOSED);
        requirementsLibraryTab.getAllTreeItems().shouldHave(texts(projectName, "Newer Requirements", "F1-C1.1", "F1-C1.1.1", "F1-C1.2", "New Requirements", "test-tracker-wowf-sel10560", "test-tracker-wwf-sel15699"));
        //Drag a requirement from library over an item in the center panel. Do not drop it.
        requirementsLibraryTab.selectStatus(RightPane.StatusType.ALL);
        requirementsLibraryTab.moveRequirementsLibraryItemToCenterPaneItem(ITEM_1, 1, ITEM_2, 1, false, RightPane.ActionType.DEPENDS);
        documentViewPage.centerPane.checkIfBlueOverlayVisible(ITEM_2, 1);
        Helper.clickAway();
        //Drag and drop several requirements from the library to the left tree
        requirementsLibraryTab.moveRequirementsLibraryItemToLeftTreeItem(ITEM_2, 1, ITEM_3, 1);
        documentViewPage.leftPane.getAllLeftTreeItems().shouldHave(texts("New Requirements", ITEM_1, ITEM_2, ITEM_3, ITEM_2));
    }

    //https://codebeamer.com/cb/issue/703601
    @Test
    public void testCenterPanelControlBar() {
        //In center panel, click on the icon of an item
        //Click on a transition
        documentViewPage.centerPane.clickOnTransition(ITEM_2, 1, CenterPane.TransitionType.APPROVE);
        RightPane.PropertiesTab propertiesTab = documentViewPage.rightPane.clickOnPropertiesTab();
        propertiesTab.clickOnDetailsPanel(true);
        assertEquals(propertiesTab.getStatus(), "WAITING FOR APPROVAL", "Status of item has not changed");

        //Click on Rating stars icon
        //Select a rating star, add a rating comment, save the overlay
        SettingsDialog settingsDialog = documentViewPage.leftPane.clickOnSettingsIcon();
        switchTo().frame("inlinedPopupIframe");
        settingsDialog.tickOption(SettingsDialog.OptionType.ADD_REVIEW_RATING, true);
        settingsDialog.clickOnSave();
        switchTo().window(0);
        RatingDialog ratingDialog = documentViewPage.centerPane.clickOnRating(ITEM_2, 1);
        ratingDialog.fillComment("comment");
        ratingDialog.clickOnRateStar(5);
        ratingDialog.clickOnRateButton();
        assertEquals(documentViewPage.centerPane.getRatingValue(ITEM_2, 1), 5, "Rating has not been set correctly");

        //Click on Edit icon
        //Change summary, description and Save the editor
        documentViewPage.centerPane.clickOnEditDescription(ITEM_2, 1);
        WYSIWYGTab wysiwygTab = (WYSIWYGTab) documentViewPage.centerPane.editorComponent.clickOnTab(EditorComponent.Tab.WYSIWYG);
        wysiwygTab.fillSummary("summary mod");
        wysiwygTab.fillDescription(true, "desc mod");
        wysiwygTab.clickOnSave();
        documentViewPage.centerPane.centerPaneItem("summary mod", 1).should(visible.because("Renaming of item did not succeed"));

        //Click on Comments icon in control bar left to an item in the center panel
        //Write the text of a comment, and Save the comment
        AddCommentDialog addCommentDialog = documentViewPage.centerPane.clickOnComment(ITEM_3, 1);
        switchTo().frame("inlinedPopupIframe");
        wysiwygTab = (WYSIWYGTab) addCommentDialog.editorComponent.clickOnTab(EditorComponent.Tab.WYSIWYG);
        wysiwygTab.fillDescription(true, "comment2");
        addCommentDialog.clickOnSave();
        switchTo().defaultContent();
        propertiesTab = documentViewPage.rightPane.clickOnPropertiesTab();
        propertiesTab.clickOnCommentsPanel(true);
        propertiesTab.getAllCommentGroup().shouldHave(texts("comment2"));

        //Click on + icon in control bar left to an item in the center panel
        //Select a type of referring item
        //Fill the fields, click on Save
        documentViewPage.centerPane.clickOnNewReferringItem(ITEM_3, 1, projectName + " » New User Stories");
        switchTo().frame("inlinedPopupIframe");
        SubmitWorkItemPage submitWorkItemPage = page(SubmitWorkItemPage.class);
        submitWorkItemPage.fillSummary("summary");
        wysiwygTab = (WYSIWYGTab) submitWorkItemPage.editorComponent.clickOnTab(EditorComponent.Tab.WYSIWYG);
        wysiwygTab.fillDescription(true, "desc");
        submitWorkItemPage.clickOnSave();
        propertiesTab.getAllIncomingReferencesOf(ITEM_3, 1).shouldHave(Helper.matchText("summary"));
    }

    //https://codebeamer.com/cb/issue/721110
    @Test(groups = {"usesNewTestCasesTracker"})
    public void testInlineEditingOfTestSteps() {
        final String itemLabel1 = "F1-C1";
        final String itemLabel2 = "F1-C1.1";
        //Expand the Test Steps section on one of the Test Case. Check the number indicator of the test step section before expad it.
        int testStepCt = documentViewPage.centerPane.getTestStepCountFromIndicator(itemLabel1, 1);
        documentViewPage.centerPane.clickOnTestStepExpander(itemLabel1, 1, true);
        assertEquals(testStepCt, documentViewPage.centerPane.getAllTestSteps(itemLabel1, 1).size(), "The test steps indicator does not show a valid number");
        //Click on "Edit" button.
        documentViewPage.centerPane.clickOnEditTestSteps(itemLabel1, 1);
        documentViewPage.centerPane.checkIfFirstTestStepIsFocused(itemLabel1, 1);
        //Click on "Edit" button on a Test Case does not contain any Steps.
        documentViewPage.centerPane.clickOnTestStepExpander(itemLabel2, 1, true);
        documentViewPage.centerPane.clickOnEditTestSteps(itemLabel2, 1);
        documentViewPage.centerPane.checkIfFirstTestStepIsFocused(itemLabel2, 1);
    }

    //https://codebeamer.com/cb/issue/703616
    @Test(groups = "usesNewTestCasesTracker")
    public void testLeftTreeFilteringThenDeletingItem() {
        documentViewPage.leftPane.fillTreeFilter("F1-C1.1");
        documentViewPage.leftPane.getAllLeftTreeItems().shouldHave(texts("New Test Cases", "F1", "F1-C1", "F1-C1.1", "F1-C1.1.1"));
        ConfirmationDialogPage confirmationDialogPage = (ConfirmationDialogPage) documentViewPage.leftPane.clickOnLeftTreeContextMenuItem("F1-C1.1.1", 1, LeftPane.LeftTreeContextMenuItem.DELETE);
        confirmationDialogPage.clickOnYes();
        documentViewPage.leftPane.getAllLeftTreeItems().shouldHave(texts("New Test Cases", "F1", "F1-C1", "F1-C1.1"));
    }

    //https://codebeamer.com/cb/issue/703616
    @Test(groups = "usesNewTestCasesTracker")
    public void testLeftTreeFilteringThenMovingItem() {
        documentViewPage.leftPane.fillTreeFilter("C1");
        documentViewPage.leftPane.getAllLeftTreeItems().shouldHave(texts("New Test Cases", "F1", "F1-C1", "F1-C1.1", "F1-C1.1.1", "F1-C1.2", "F2", "F2-C1"));
        documentViewPage.leftPane.dragAndDrop("F2-C1", 1, "F1", 1, LeftPane.DragAndDropAction.INTO);
        documentViewPage.leftPane.getAllLeftTreeItems().shouldHave(texts("New Test Cases", "F1", "F2-C1", "F1-C1", "F1-C1.1", "F1-C1.1.1", "F1-C1.2"));
    }

    //https://codebeamer.com/cb/issue/703616
    @Test(groups = "usesNewTestCasesTracker")
    public void testLeftTreeFilteringThenCreatingItem() {
        documentViewPage.leftPane.fillTreeFilter("C1");
        documentViewPage.leftPane.getAllLeftTreeItems().shouldHave(texts("New Test Cases", "F1", "F1-C1", "F1-C1.1", "F1-C1.1.1", "F1-C1.2", "F2", "F2-C1"));
        documentViewPage.leftPane.clickOnLeftTreeContextMenuItem("F2", 1, LeftPane.LeftTreeContextMenuItem.NEW_CHILD);
        WYSIWYGTab wysiwygTab = (WYSIWYGTab) documentViewPage.centerPane.editorComponent.clickOnTab(EditorComponent.Tab.WYSIWYG);
        wysiwygTab.fillSummary("newitem");
        wysiwygTab.clickOnSave();
        documentViewPage.leftPane.getAllLeftTreeItems().shouldHave(texts("New Test Cases", "F1", "F1-C1", "F1-C1.1", "F1-C1.1.1", "F1-C1.2", "F1-C2", "F2", "F2-C1", "newitem"));
        documentViewPage.leftPane.treeFilter().should(Condition.text(""));
    }

    @DataProvider(name = "filtersAndAsserts")
    public Object[][] filtersAndAsserts() {
        return new Object[][]{
                {CenterPane.FilterType.NEW, "New Test Cases", "F1", "F1-C1"},
                {CenterPane.FilterType.IN_DESIGN, "New Test Cases", "F1", "F1-C1", "F1-C1.1"},
                {CenterPane.FilterType.AWAITING_APPROVAL, "New Test Cases", "F1", "F1-C1", "F1-C1.1", "F1-C1.1.1"},
                {CenterPane.FilterType.ACCEPTED, "New Test Cases", "F1", "F1-C1", "F1-C1.2"},
                {CenterPane.FilterType.REJECTED, "New Test Cases", "F2", "F2-C1"},
                {CenterPane.FilterType.OUTDATED, "New Test Cases", "F1", "F1-C2"},
//                {CenterPane.FilterType.SUSPECTED_TEST_CASES, "New Test Cases", "F2-C1"},
//                {CenterPane.FilterType.AVG_RATING1, "New Test Cases", "F1-C1"},
//                {CenterPane.FilterType.AVG_RATING1_5, "New Test Cases", "F1-C1.1"},
//                {CenterPane.FilterType.AVG_RATING1_5, "New Test Cases", "F1-C1.1"},
//                {CenterPane.FilterType.AVG_RATING2_5, "New Test Cases", "F1-C1.1.1"},
//                {CenterPane.FilterType.AVG_RATING3_5, "New Test Cases", "F1-C1.2"},
//                {CenterPane.FilterType.AVG_RATING4_5, "New Test Cases", "F1-C2"},
//                {CenterPane.FilterType.NO_RATING, "New Test Cases", "F2-C1"},
//                {CenterPane.FilterType.RATED_BY_ME, "New Test Cases", "F1-C1", "F1-C1.1", "F1-C1.1.1", "F1-C1.2", "F1-C2"},
//                {CenterPane.FilterType.NOT_RATED_BY_ME, "New Test Cases", "F2-C1"},
                {CenterPane.FilterType.ORPHAN, "New Test Cases", "F1", "F1-C1", "F1-C1.1", "F1-C1.1.1", "F1-C1.2", "F1-C2"},
                {CenterPane.FilterType.SPECIFIED, "New Test Cases", "F2", "F2-C1"}
        };
    }

    //https://codebeamer.com/cb/issue/703603
    //TODO archive does not contain ratings and so on so we have to figure out how to create test data fro those
    @Test(groups = "usesNewTestCasesTracker", dataProvider = "filtersAndAsserts")
    public void testCenterPanelFiltering(CenterPane.FilterType filterType, String... expectedValues) {
        documentViewPage.centerPane.selectFilter(filterType, true);
        documentViewPage.leftPane.getAllLeftTreeItems().shouldHave(texts(expectedValues));
    }

    //https://codebeamer.com/cb/issue/703617
    @Test(groups = "usesNewTestCasesTracker")
    public void testShowSubtreeThenFilterCenterPanel() {
        documentViewPage.leftPane.clickOnLeftTreeContextMenuItem("F1-C1", 1, LeftPane.LeftTreeContextMenuItem.SHOW_TREE_FROM_THIS_ITEM);
        documentViewPage.leftPane.getAllLeftTreeItems().shouldHave(texts("F1-C1", "F1-C1.1", "F1-C1.1.1", "F1-C1.2"));
        documentViewPage.centerPane.selectFilter(CenterPane.FilterType.ACCEPTED, true);
        documentViewPage.leftPane.getAllLeftTreeItems().shouldHave(texts("F1-C1", "F1-C1.2"));
    }

    //https://codebeamer.com/cb/issue/703617
    @Test(groups = "usesNewTestCasesTracker")
    public void testShowSubtreeThenFilterLeftTree() {
        documentViewPage.leftPane.clickOnLeftTreeContextMenuItem("F1-C1", 1, LeftPane.LeftTreeContextMenuItem.SHOW_TREE_FROM_THIS_ITEM);
        documentViewPage.leftPane.getAllLeftTreeItems().shouldHave(texts("F1-C1", "F1-C1.1", "F1-C1.1.1", "F1-C1.2"));
        documentViewPage.leftPane.fillTreeFilter("F1-C1.2");
        documentViewPage.leftPane.getAllLeftTreeItems().shouldHave(texts("F1-C1", "F1-C1.2"));
    }

    //https://codebeamer.com/cb/issue/703619
    @Test
    public void testFilterReleaseTreeThenDragAndDropItemToRelease() {
        RightPane.ReleasesTab releasesTab = documentViewPage.rightPane.clickOnReleasesTab();
        releasesTab.fillFilter("Drop");
        releasesTab.getAllTreeItems().shouldHave(texts("Cardboard Drag And Drop", "Drag And Drop", "Drop Target"));
        documentViewPage.leftPane.moveLeftTreeItemToReleaseItem("Drop Target", 1, ITEM_3, 1);
        releasesTab.getAllTreeItems().shouldHave(texts("Cardboard Drag And Drop", "Drag And Drop", "Drop Target"));
    }

    //https://codebeamer.com/cb/issue/703618
    @Test(groups = "usesNewTestCasesTracker")
    public void testCompactModeThenFilterCenterPanel() {
        documentViewPage.centerPane.clickOnCompactMode(true);
        documentViewPage.centerPane.selectFilter(CenterPane.FilterType.ACCEPTED, true);
        documentViewPage.leftPane.getAllLeftTreeItems().shouldHave(texts("New Test Cases", "F1-C1.2"));
        assertEquals(documentViewPage.centerPane.isInCompactMode(), true, "Compact mode changed because of filtering");
        //revert compact mode
        documentViewPage.centerPane.clickOnCompactMode(false);
    }

    //https://codebeamer.com/cb/issue/703618
    @Test(groups = "usesNewTestCasesTracker")
    public void testCompactModeThenDragAndDrop() {
        documentViewPage.centerPane.clickOnCompactMode(true);
        documentViewPage.leftPane.dragAndDrop("F2-C1", 1, "F1", 1, LeftPane.DragAndDropAction.INTO);
        documentViewPage.leftPane.getAllLeftTreeItems().shouldHave(texts("New Test Cases", "F1", "F2-C1", "F1-C1", "F1-C1.1", "F1-C1.1.1", "F1-C1.2", "F1-C2", "F2"));
        assertEquals(documentViewPage.centerPane.isInCompactMode(), true, "Compact mode changed because of filtering");
        //revert compact mode
        documentViewPage.centerPane.clickOnCompactMode(false);
    }

    //https://codebeamer.com/cb/issue/703611
    @Test(groups = "usesNewerRequirementsTracker")
    public void testCompactMode() {
        //Click on C icon in header of center panel to activate Compact mode
        documentViewPage.centerPane.clickOnCompactMode(true);
        //Verify that the control bars to the left of the center panel items is hidden in this view
        documentViewPage.centerPane.checkIfControlBarIsInCompactMode();
        //Verify that control bars appear on clicking the triangles to the left of the center panel items
        documentViewPage.centerPane.clickOnCompactModeInControlBar("F1-C1", 1);
        documentViewPage.centerPane.checkIfCompactModePopOverIsVisible("F1-C1", 1);
        //Verify that filtering in the left tree does not change compact mode
        documentViewPage.leftPane.fillTreeFilter("F2-C1");
        documentViewPage.leftPane.getAllLeftTreeItems().shouldHave(texts("Newer Requirements", "F2", "F2-C1"));
        documentViewPage.centerPane.checkIfCompactModeIsOn();
        documentViewPage.leftPane.fillTreeFilter("");
        //Verify that creating, reordering, deleting items in the left tree does not change the compact mode
        documentViewPage.leftPane.clickOnLeftTreeContextMenuItem("F2-C1", 1, LeftPane.LeftTreeContextMenuItem.NEW_CHILD);
        WYSIWYGTab wysiwygTab = (WYSIWYGTab) documentViewPage.centerPane.editorComponent.clickOnTab(EditorComponent.Tab.WYSIWYG);
        wysiwygTab.fillSummary("newitem");
        wysiwygTab.clickOnSave();
        documentViewPage.centerPane.checkIfCompactModeIsOn();
        documentViewPage.leftPane.dragAndDrop("newitem", 1, "F1-C2", 1, LeftPane.DragAndDropAction.INTO);
        documentViewPage.centerPane.checkIfCompactModeIsOn();
        ConfirmationDialogPage confirmationDialogPage = (ConfirmationDialogPage) documentViewPage.leftPane.clickOnLeftTreeContextMenuItem("newitem", 1, LeftPane.LeftTreeContextMenuItem.DELETE);
        confirmationDialogPage.clickOnYes();
        documentViewPage.centerPane.checkIfCompactModeIsOn();
        //Verify that using "Show tree from this item" does not change compact mode
        documentViewPage.leftPane.clickOnLeftTreeContextMenuItem("F1-C1.1", 1, LeftPane.LeftTreeContextMenuItem.SHOW_TREE_FROM_THIS_ITEM);
        documentViewPage.centerPane.checkIfCompactModeIsOn();
        documentViewPage.leftPane.clickOnLeftTreeContextMenuItem("F1-C1.1", 1, LeftPane.LeftTreeContextMenuItem.GO_TO_ROOT);
        //Verify that filtering in center panel does not change compact mode
        documentViewPage.centerPane.selectFilter(CenterPane.FilterType.ACCEPTED, true);
        documentViewPage.centerPane.checkIfCompactModeIsOn();
        documentViewPage.centerPane.selectFilter(CenterPane.FilterType.ACCEPTED, false);
        //Verify that changing properties in the right panel Properties tab does not change the compact mode
        documentViewPage.leftPane.clickOnLeftTreeItem("F1-C1", 1);
        RightPane.PropertiesTab propertiesTab = documentViewPage.rightPane.clickOnPropertiesTab();
        propertiesTab.clickOnDetailsPanel(true);
        propertiesTab.selectBusinessValue(RightPane.BusinessValue.NICE_TO_HAVE);
        propertiesTab.clickOnSave();
        documentViewPage.centerPane.checkIfCompactModeIsOn();
        //Verify that drag and dropping requirements from the left tree to the Releases tree does not change compact mode
        documentViewPage.rightPane.clickOnReleasesTab();
        documentViewPage.leftPane.moveLeftTreeItemToReleaseItem("Test Release", 1, "F1-C2", 1);
        documentViewPage.centerPane.checkIfCompactModeIsOn();
        //Verify that reusing requirements from the Requirements Library does not change the compact mode
        documentViewPage.rightPane.clickOnRequirementsLibraryTab();
        documentViewPage.rightPane.requirementsLibraryTab.moveRequirementsLibraryItemToLeftTreeItem(ITEM_2, 1, "F1-C1", 1);
        documentViewPage.centerPane.checkIfCompactModeIsOn();
        //Verify that drag and dropping test cases from Test Case Library does not change compact mode
        RightPane.TestCaseLibraryTab testCaseLibraryTab = documentViewPage.rightPane.clickOnTestCaseLibraryTab();
        LinkTestCasesPage linkTestCasesPage = testCaseLibraryTab.moveLibraryItemToLeftTreeItem("Drop Target", 1, "F1-C2", 1);
        switchTo().frame(0);
        //Chose the first option, click OK in the overlay
        linkTestCasesPage.clickOnSave();
        linkTestCasesPage.clickOnClose();
        switchTo().defaultContent();
        documentViewPage.centerPane.checkIfCompactModeIsOn();
        documentViewPage.centerPane.clickOnCompactMode(false);
    }

    //https://codebeamer.com/cb/issue/703614
    @Test(groups = "usesNewerRequirementsTracker")
    public void testDragAndDropFolderThenCreateItem() {
        documentViewPage.leftPane.dragAndDrop("F2", 1, "F1", 1, LeftPane.DragAndDropAction.INTO);
        documentViewPage.leftPane.clickOnLeftTreeContextMenuItem("F2", 1, LeftPane.LeftTreeContextMenuItem.NEW_CHILD);
        WYSIWYGTab wysiwygTab = (WYSIWYGTab) documentViewPage.centerPane.editorComponent.clickOnTab(EditorComponent.Tab.WYSIWYG);
        wysiwygTab.fillSummary("newitem");
        wysiwygTab.clickOnSave();
        documentViewPage.leftPane.getAllLeftTreeItems().shouldHave(texts("Newer Requirements",
                "F1", "F2", "F2-C1", "newitem", "F1-C1", "F1-C1.1", "F1-C1.1.1", "F1-C1.2", "F1-C2"));
    }

    //https://codebeamer.com/cb/issue/703614
    @Test(groups = "usesNewerRequirementsTracker")
    public void testDragAndDropFolderThenCreateReferringItem() {
        documentViewPage.leftPane.dragAndDrop("F2", 1, "F1", 1, LeftPane.DragAndDropAction.INTO);
        documentViewPage.centerPane.clickOnNewReferringItem("F2", 1, projectName + " » New User Stories");
        switchTo().frame("inlinedPopupIframe");
        SubmitWorkItemPage submitWorkItemPage = page(SubmitWorkItemPage.class);
        submitWorkItemPage.fillSummary("summary");
        WYSIWYGTab wysiwygTab = (WYSIWYGTab) submitWorkItemPage.editorComponent.clickOnTab(EditorComponent.Tab.WYSIWYG);
        wysiwygTab.fillDescription(true, "desc");
        submitWorkItemPage.clickOnSave();
        RightPane.PropertiesTab propertiesTab = documentViewPage.rightPane.clickOnPropertiesTab();
        propertiesTab.getAllIncomingReferencesOf("F2", 1).shouldHave(Helper.matchText("summary"));
    }

    //https://codebeamer.com/cb/issue/703614
    @Test(groups = "usesNewerRequirementsTracker")
    public void testDragAndDropFolderThenUseLeftTreeContextMenu() {
        documentViewPage.leftPane.dragAndDrop("F2", 1, "F1", 1, LeftPane.DragAndDropAction.INTO);
        ConfirmationDialogPage confirmationDialogPage = (ConfirmationDialogPage) documentViewPage.leftPane.clickOnLeftTreeContextMenuItem("F2", 1, LeftPane.LeftTreeContextMenuItem.DELETE);
        confirmationDialogPage.clickOnYes();
        documentViewPage.leftPane.getAllLeftTreeItems().shouldHave(texts("Newer Requirements",
                "F1", "F1-C1", "F1-C1.1", "F1-C1.1.1", "F1-C1.2", "F1-C2"));
    }

    //https://codebeamer.com/cb/issue/703614
    @Test(groups = "usesNewerRequirementsTracker")
    public void testDragAndDropFolderThenUsePropertiesPanel() {
        documentViewPage.leftPane.dragAndDrop("F2", 1, "F1", 1, LeftPane.DragAndDropAction.INTO);
        documentViewPage.leftPane.clickOnLeftTreeItem("F2-C1", 1);
        RightPane.PropertiesTab propertiesTab = documentViewPage.rightPane.clickOnPropertiesTab();
        propertiesTab.clickOnDetailsPanel(true);
        propertiesTab.selectBusinessValue(RightPane.BusinessValue.MUST_HAVE);
        propertiesTab.clickOnSave();

        TrackerItemDetailsPage trackerItemDetailsPage = (TrackerItemDetailsPage) documentViewPage.centerPane.clickOnCenterPaneContextMenuItem("F2-C1", 1, CenterPane.CenterPaneContextMenuItem.OPEN);
        switchTo().window(1);
        assertEquals(trackerItemDetailsPage.getBusinessValue(), RightPane.BusinessValue.MUST_HAVE.toString(), "Business value has not been set");
        switchTo().window(0);
    }

    //https://codebeamer.com/cb/issue/703614
    @Test(groups = "usesNewerRequirementsTracker")
    public void testDragAndDropFolderThenUseCenterPanelContextMenu() {
        documentViewPage.leftPane.dragAndDrop("F2", 1, "F1", 1, LeftPane.DragAndDropAction.INTO);
        ConfirmationDialogPage confirmationDialogPage = (ConfirmationDialogPage) documentViewPage.leftPane.clickOnLeftTreeContextMenuItem("F2-C1", 1, LeftPane.LeftTreeContextMenuItem.DELETE);
        confirmationDialogPage.clickOnYes();
        documentViewPage.leftPane.getAllLeftTreeItems().shouldHave(texts("Newer Requirements",
                "F1", "F2", "F1-C1", "F1-C1.1", "F1-C1.1.1", "F1-C1.2", "F1-C2"));
    }

    //https://codebeamer.com/cb/issue/703610
    @Test(groups = "usesTest-tracker-wowf-sel10560")
    public void testBaselineViews() {
        //Click on Baselines icon in left tree header
        BaselinesDialog baselinesDialog = documentViewPage.leftPane.clickOnBaselinesIcon();
        switchTo().frame("inlinedPopupIframe");
        //Click on a baseline
        baselinesDialog.clickOnBaseline("Test baseline");
        switchTo().defaultContent();
        //Verify that baseline information box appears at the top of center panel
        documentViewPage.centerPane.checkIfBaselineInfo(visible);
        //Verify that in case of paging, the box is still present at the top
        //TODO
        //Verify that there is no + icon in the tree header
        documentViewPage.leftPane.checkIfNewRequirementIcon(hidden);
        documentViewPage.clickOnViewMenuIcon(TrackerItemListPage.ViewMenuIcon.DOCUMENT_VIEW);
        //Verify that creation menu items are missing from tree context menu
        //Verify that Add Association menu item is missing from tree context menu
        documentViewPage.leftPane.checkIfContextMenuItems("test-issue-sel-パスワードを忘れてしまった方へ1226501710", 1,
                        visible,
                        LeftPane.LeftTreeContextMenuItem.OPEN,
                        LeftPane.LeftTreeContextMenuItem.COLLAPSE_NODE,
                        LeftPane.LeftTreeContextMenuItem.EXPAND_NODE,
                        LeftPane.LeftTreeContextMenuItem.SHOW_TREE_FROM_THIS_ITEM,
                        LeftPane.LeftTreeContextMenuItem.EXPORT_SELECTION
                );
        //Verify that it is not possible to drag and drop reorder the tree nodes
        //Verify that using tree header filter text field does not leads out of the baseline mode
        documentViewPage.leftPane.fillTreeFilter("Joghurt");
        documentViewPage.centerPane.checkIfBaselineInfo(visible);
        documentViewPage.leftPane.dragAndDrop("test-issue-sel-Polyfon zwitschernd aßen Mäxchens Vögel Rüben, Joghurt und Quark. 189092201", 1,
                "test-issue-sel-Polyfon zwitschernd aßen Mäxchens Vögel Rüben, Joghurt und Quark. 910124890", 1,
                LeftPane.DragAndDropAction.INTO
        );
        documentViewPage.leftPane.getAllLeftTreeItems().shouldHave(texts("test-tracker-wowf-sel10560", "test-issue-sel-Polyfon zwitschernd aßen Mäxchens Vögel Rüben, Joghurt und Quark. 910124890",
                "test-issue-sel-Polyfon zwitschernd aßen Mäxchens Vögel Rüben, Joghurt und Quark. 333403751",
                "test-issue-sel-Polyfon zwitschernd aßen Mäxchens Vögel Rüben, Joghurt und Quark. 189092201"));
        documentViewPage.leftPane.fillTreeFilter("");
        //Verify that using "Show tree from this item" in tree context menu does not lead out from the baseline mode
        documentViewPage.leftPane.clickOnLeftTreeContextMenuItem("test-issue-sel-パスワードを忘れてしまった方へ1226501710", 1, LeftPane.LeftTreeContextMenuItem.SHOW_TREE_FROM_THIS_ITEM);
        documentViewPage.centerPane.checkIfBaselineInfo(visible);
        //Verify that in the center panel it is not possible to drive the transition of an item
        documentViewPage.centerPane.checkIfTransitionMenu("test-issue-sel-パスワードを忘れてしまった方へ1226501710", 1, hidden);
        //Verify that in the center panel it is not possible to edit the summary and description of items
        documentViewPage.centerPane.checkIfSummaryOrDescriptionEditable("test-issue-sel-パスワードを忘れてしまった方へ1226501710", 1, visible);
        //Verify that the center panel context menu contains only Open
        documentViewPage.centerPane.checkIfCenterPanelContextMenuItems("test-issue-sel-パスワードを忘れてしまった方へ1226501710", 1,
                visible, CenterPane.CenterPaneContextMenuItem.OPEN);
        //Verify that hotkeys for editing items, adding comments, and adding associations do not work
        AddCommentDialog addCommentDialog = (AddCommentDialog) documentViewPage.sendHotkey(BasePage.Hotkey.ADD_COMMENT_TO_SELECTED_ITEM);
        assertFalse(addCommentDialog.isPageLoaded(), "Add comment hotkey worked in baseline view");
        EditorComponent editorComponent = (EditorComponent) documentViewPage.sendHotkey(BasePage.Hotkey.EDIT_SELECTED_ITEM);
        assertFalse(editorComponent.isPageLoaded(), "Edit item worked in baseline view");
        AddAssociationDialog addAssociationDialog = (AddAssociationDialog) documentViewPage.sendHotkey(BasePage.Hotkey.ADD_ASSOCIATION_TO_SELECTED_ITEM);
        assertFalse(addAssociationDialog.isPageLoaded(), "Add association worked in baseline view");
        //Verify that in Properties tab, Details, Relations, and Comments are read only
        RightPane.PropertiesTab propertiesTab = documentViewPage.rightPane.propertiesTab;
        propertiesTab.checkIfPropertiesPanelIs(false);
        //Verify that in more menu, Import Lock, New Baseline are not present, Customize option is present but it opens the page in read only mode.
        documentViewPage.centerPane.checkIfMoreMenuItems(hidden, false, CenterPane.MoreMenuItem.IMPORT, CenterPane.MoreMenuItem.LOCK, CenterPane.MoreMenuItem.NEW_BASELINE);
        TrackersCustomizationPage trackersCustomizationPage = (TrackersCustomizationPage) documentViewPage.centerPane.clickOnMoreMenuItem(CenterPane.MoreMenuItem.CUSTOMIZE);
        trackersCustomizationPage.checkIfSaveIs(hidden);
        back();
        //Verify that clicking on Switch to Head button leads back to normal editing mode
        documentViewPage.centerPane.clickOnSwitchToHead();
        documentViewPage.waitForPageToLoad();
        documentViewPage.centerPane.checkIfBaselineInfo(hidden);
        propertiesTab = documentViewPage.rightPane.clickOnPropertiesTab();
        propertiesTab.checkIfPropertiesPanelIs(true);

    }

    @AfterMethod(alwaysRun = true)
    public void afterMethod(){
        close();
    }

    //because of this I cannot use groups https://github.com/cbeust/testng/issues/549#issuecomment-267655897
    @AfterSuite(alwaysRun = true)
    public void afterSuite() {
        //deleteProject(projectName);
        baseTest.deleteAllProjects("test-documentview.*\\d*:\\d*:\\d*\\s\\d*/\\d*/\\d*");
    }

}
