diff --git a/src/org/labkey/test/pages/TourEditor.java b/src/org/labkey/test/pages/TourEditor.java deleted file mode 100644 index 64e828e50f..0000000000 --- a/src/org/labkey/test/pages/TourEditor.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (c) 2015-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.labkey.test.pages; - -import org.labkey.test.Locator; -import org.labkey.test.util.Ext4Helper; -import org.openqa.selenium.WebDriver; - -public class TourEditor extends LabKeyPage -{ - public TourEditor(WebDriver driver) - { - super(driver); - } - - public void save() - { - click(Locators.saveButton); - waitForElement(Locator.id("status").withText("Saved."), 1000, false); - } - - public void saveAndClose() - { - clickAndWait(Locators.saveAndCloseButton); - } - - public void cancel() - { - clickAndWait(Locators.cancelButton); - } - - public void clear() - { - click(Locators.clearButton); - } - - public void addStep() - { - click(Locators.addStepButton); - } - - public void importTour(String JSON) - { - click(Locators.importTourButton); - _extHelper.setCodeMirrorValue("export-script-textarea", JSON); - _ext4Helper.clickWindowButton("Import Tour", "Import", 0, 0); - waitForElementToDisappear(Ext4Helper.Locators.window("Import Tour")); - } - - public String export() - { - click(Locators.exportButton); - waitForElement(Ext4Helper.Locators.window("Export Tour")); - return _extHelper.getCodeMirrorValue("export-script-textarea"); - } - - public void setTitle(String title) - { - setFormElement(Locators.titleTextArea, title); - } - - public void setMode(TourMode mode) - { - switch(mode) - { - case RUNALWAYS: - selectOptionByText(Locators.setModeCombo, "Run Always"); - break; - - case RUNONCE: - selectOptionByText(Locators.setModeCombo, "Run Once"); - break; - - case OFF: - selectOptionByText(Locators.setModeCombo, "Off"); - } - } - - public void setDescription(String description) - { - setFormElement(Locators.descriptionTextArea, description); - } - - //index is 1 based - public void setSelector(int index, String selector) - { - setFormElement(Locators.getSelectorTextArea(index), selector); - } - - //index is 1 based - public void setStep(int index, String step) - { - _extHelper.setCodeMirrorValue("tour-step" + index, step); - } - - public enum TourMode - { - OFF, - RUNONCE, - RUNALWAYS - } - - public static class Locators - { - public static Locator saveButton = Locator.xpath("//span[contains(.,'Save')]"); - public static Locator saveAndCloseButton = Locator.xpath("//span[contains(.,'Save & Close')]"); - public static Locator cancelButton = Locator.xpath("//span[contains(.,'Cancel')]"); - public static Locator clearButton = Locator.xpath("//span[contains(.,'Clear')]"); - public static Locator addStepButton = Locator.xpath("//span[contains(.,'Add Step')]"); - public static Locator importTourButton = Locator.xpath("//span[contains(.,'Import')]"); - public static Locator exportButton = Locator.xpath("//span[contains(.,'Export')]"); - public static Locator.XPathLocator setModeCombo = Locator.tagWithId("select", "tour-mode"); - public static Locator descriptionTextArea = Locator.xpath("//textarea[@id='tour-description']"); - public static Locator titleTextArea = Locator.xpath("//input[@id='tour-title']"); - public static Locator getSelectorTextArea(int index) {return Locator.xpath("//input[@id='tour-selector"+index+"']");} - } -} diff --git a/src/org/labkey/test/tests/TourTest.java b/src/org/labkey/test/tests/TourTest.java deleted file mode 100644 index 156454e5c0..0000000000 --- a/src/org/labkey/test/tests/TourTest.java +++ /dev/null @@ -1,245 +0,0 @@ -/* - * Copyright (c) 2015-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.labkey.test.tests; - -import org.jetbrains.annotations.Nullable; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.labkey.test.BaseWebDriverTest; -import org.labkey.test.Locator; -import org.labkey.test.WebTestHelper; -import org.labkey.test.categories.Daily; -import org.labkey.test.pages.TourEditor; -import org.labkey.test.util.DataRegionTable; -import org.labkey.test.util.LogMethod; - -import java.util.List; - -@Category({Daily.class}) -@BaseWebDriverTest.ClassTimeout(minutes = 4) -public class TourTest extends BaseWebDriverTest -{ - public static final String SUBFOLDER1 = "test project 1"; - public static final String SUBFOLDER2 = "test project 2"; - public static final String TOUR_NAME = "Test Tour"; - public static final String TOUR_DESC = "Test Tour Description"; - public static final int WAIT = 1000; - - @Nullable - @Override - protected String getProjectName() - { - return "Tour Test Project"; - } - - @Override - public List getAssociatedModules() - { - return null; - } - - @Override - protected BrowserType bestBrowser() - { - return BrowserType.CHROME; - } - - @BeforeClass - @LogMethod - public static void setup() throws Exception - { - TourTest initTest = getCurrentTest(); - initTest._containerHelper.createProject(initTest.getProjectName(), "Collaboration"); - initTest._containerHelper.createSubfolder(initTest.getProjectName(), SUBFOLDER1); - initTest._containerHelper.createSubfolder(initTest.getProjectName(), SUBFOLDER2); - initTest.setupBasicTour(); - } - - @LogMethod - public void setupBasicTour() - { - TourEditor tourEditor = navigateToInsertTour(SUBFOLDER1); - tourEditor.setTitle(TOUR_NAME); - tourEditor.setMode(TourEditor.TourMode.RUNONCE); - tourEditor.setDescription(TOUR_DESC); - tourEditor.setSelector(1, ".navbar-nav-lk .fa-search"); - tourEditor.setStep(1, "{\n" + - " placement: \"right\",\n" + - " title: \"This is global search.\",\n" + - " content: \"Search for it all!\",\n" + - "}"); - tourEditor.setSelector(2, ".navbar-nav-lk .fa-cog"); - tourEditor.setStep(2, "{\n" + - " placement: \"left\",\n" + - " title: \"This is the admin menu.\",\n" + - " content: \"Click here to perform administrative tasks.\",\n" + - "}"); - tourEditor.setSelector(3, ".navbar-nav-lk .fa-user"); - tourEditor.setStep(3, "{\n" + - " placement: \"left\",\n" + - " title: \"This is the help menu.\",\n" + - " content: \"Click here for tutorials and various help tasks.\",\n" + - "}"); - tourEditor.addStep(); - tourEditor.setSelector(4, ".lk-body-title h3"); - tourEditor.setStep(4, "{\n" + - " placement: \"bottom\",\n" + - " title: \"This is the page title.\",\n" + - " content: \"Displays the title of the page you are on.\",\n" + - "}"); - sleep(WAIT); - tourEditor.save(); - } - - @Test - public void runTests() - { - getDriver().manage().window().maximize(); - testBasicTour(); - testTourRoundTrip(); - testRunAlways(); - testOffMode(); - } - - public void testBasicTour() - { - TourNavigator tourNavigator = new TourNavigator(); - navigateToFolder(SUBFOLDER1); - assertBasicTour(); - //tour should only run once - navigateToFolder(SUBFOLDER1); - tourNavigator.assertNoTourBubble(); - } - - public void testTourRoundTrip() - { - TourNavigator tourNavigator = new TourNavigator(); - TourEditor tourEditor = navigateToEditTour(SUBFOLDER1, TOUR_NAME); - final String tourJSON = tourEditor.export(); - tourEditor = navigateToInsertTour(SUBFOLDER2); - tourEditor.importTour(tourJSON); - tourEditor.setTitle(TOUR_NAME); - tourEditor.save(); - navigateToFolder(SUBFOLDER2); - assertBasicTour(); - //tour should only run once - navigateToFolder(SUBFOLDER1); - tourNavigator.assertNoTourBubble(); - } - - public void testRunAlways() - { - TourEditor tourEditor = navigateToEditTour(SUBFOLDER1, TOUR_NAME); - tourEditor.setMode(TourEditor.TourMode.RUNALWAYS); - tourEditor.save(); - navigateToFolder(SUBFOLDER1); - assertBasicTour(); - navigateToFolder(SUBFOLDER1); - assertBasicTour(); - } - - public void testOffMode() - { - TourNavigator tourNavigator = new TourNavigator(); - TourEditor tourEditor = navigateToEditTour(SUBFOLDER1, TOUR_NAME); - tourEditor.setMode(TourEditor.TourMode.OFF); - tourEditor.save(); - navigateToFolder(SUBFOLDER1); - tourNavigator.assertNoTourBubble(); - } - - private void assertBasicTour() - { - TourNavigator tourNavigator = new TourNavigator(); - tourNavigator.waitForTourBubble("1"); - tourNavigator.assertTourBubble("1", "This is global search.", "Search for it all!"); - tourNavigator.nextTourBubble(); - tourNavigator.waitForTourBubble("2"); - tourNavigator.assertTourBubble("2", "This is the admin menu.", "Click here to perform administrative tasks."); - tourNavigator.nextTourBubble(); - tourNavigator.waitForTourBubble("3"); - tourNavigator.assertTourBubble("3", "This is the help menu.", "Click here for tutorials and various help tasks."); - tourNavigator.nextTourBubble(); - tourNavigator.waitForTourBubble("4"); - tourNavigator.assertTourBubble("4", "This is the page title.", "Displays the title of the page you are on."); - tourNavigator.doneTourBubble(); - sleep(WAIT); - tourNavigator.assertNoTourBubble(); - } - - private void navigateToFolder(String folder) - { - navigateToFolder(getProjectName(), folder); - } - - private TourEditor navigateToEditTour(String folder, String tourTitle) - { - DataRegionTable table = navigateToTours(folder); - table.clickEditRow(table.getRowIndex("Title", tourTitle)); - waitForText("Tour Builder"); - return new TourEditor(getDriver()); - } - - private TourEditor navigateToInsertTour(String folder) - { - DataRegionTable table = navigateToTours(folder); - table.clickInsertNewRow(); - waitForText("Tour Builder"); - return new TourEditor(getDriver()); - } - - private DataRegionTable navigateToTours(String folder) - { - beginAt(WebTestHelper.buildURL("tours", getProjectName() + "/" + folder, "begin")); - return new DataRegionTable("query", getDriver()); - } - - private class TourNavigator - { - public void nextTourBubble() - { - click(Locator.tagWithClass("button", "hopscotch-nav-button next hopscotch-next").withText("Next")); - } - - public void doneTourBubble() - { - click(Locator.tagWithClass("button", "hopscotch-nav-button next hopscotch-next").withText("Done")); - } - - public void assertNoTourBubble() - { - if (isElementPresent(Locator.tag("div").withAttributeContaining("class", "hopscotch-bubble animated hide"))) - return; - assertElementNotPresent(Locator.tag("div").withAttributeContaining("class", "hopscotch")); - } - - private void assertTourBubble(String number, String title, String content) - { - waitForTourBubble(number); - Assert.assertEquals(number, getText(Locator.tagWithClass("span", "hopscotch-bubble-number"))); - Assert.assertEquals(title, getText(Locator.tagWithClass("h3", "hopscotch-title"))); - Assert.assertEquals(content, getText(Locator.tagWithClass("div", "hopscotch-content"))); - } - - private void waitForTourBubble(String number) - { - waitForElement(Locator.tagWithClass("span", "hopscotch-bubble-number").withText(number)); - sleep(750); // time for animation to complete - } - } -}