-
Notifications
You must be signed in to change notification settings - Fork 9
Automation test for Wiki aliases #1057
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
105 changes: 105 additions & 0 deletions
105
src/org/labkey/test/pages/wiki/ManageWikiConfigurationPage.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| package org.labkey.test.pages.wiki; | ||
|
|
||
| import org.labkey.test.Locator; | ||
| import org.labkey.test.WebDriverWrapper; | ||
| import org.labkey.test.WebTestHelper; | ||
| import org.labkey.test.components.html.Checkbox; | ||
| import org.labkey.test.components.html.Input; | ||
| import org.labkey.test.pages.LabKeyPage; | ||
| import org.openqa.selenium.WebDriver; | ||
| import org.openqa.selenium.WebElement; | ||
|
|
||
| import java.util.Map; | ||
|
|
||
| public class ManageWikiConfigurationPage extends LabKeyPage<ManageWikiConfigurationPage.ElementCache> | ||
| { | ||
| public ManageWikiConfigurationPage(WebDriver driver) | ||
| { | ||
| super(driver); | ||
| } | ||
|
|
||
| public static ManageWikiConfigurationPage beginAt(WebDriverWrapper driver, String containerPath, Map<String, String> values) | ||
| { | ||
| driver.beginAt(WebTestHelper.buildURL("wiki", containerPath, "manage", values)); | ||
| return new ManageWikiConfigurationPage(driver.getDriver()); | ||
| } | ||
|
|
||
| @Override | ||
| protected ManageWikiConfigurationPage.ElementCache newElementCache() | ||
| { | ||
| return new ManageWikiConfigurationPage.ElementCache(); | ||
| } | ||
|
|
||
| public String getNameInput() | ||
| { | ||
| return elementCache().nameInput.get(); | ||
| } | ||
|
|
||
| public ManageWikiConfigurationPage setNameInput(String value) | ||
| { | ||
| elementCache().nameInput.set(value); | ||
| return this; | ||
| } | ||
|
|
||
| public ManageWikiConfigurationPage rename(String newName, boolean addAlias) | ||
| { | ||
| elementCache().renameButton.click(); | ||
| waitFor(() -> elementCache().addAlias.isDisplayed(), WAIT_FOR_PAGE); | ||
| elementCache().newNameInput.set(newName); | ||
| elementCache().addAlias.set(addAlias); | ||
|
|
||
| return this; | ||
| } | ||
|
|
||
| public String getAliases() | ||
| { | ||
| return elementCache().aliases.getText(); | ||
| } | ||
|
|
||
| public ManageWikiConfigurationPage setAliases(String value) | ||
| { | ||
| elementCache().aliases.sendKeys(value); | ||
| return this; | ||
| } | ||
|
|
||
| public ManageWikiConfigurationPage save() | ||
| { | ||
| elementCache().saveButton.click(); | ||
| return this; | ||
| } | ||
|
|
||
| public String saveExpectingErrors() | ||
| { | ||
| elementCache().saveButton.click(); | ||
| return elementCache().errorMsg.getText(); | ||
| } | ||
|
|
||
| public EditPage editContent() | ||
| { | ||
| elementCache().editContentButton.click(); | ||
| return new EditPage(getDriver()); | ||
| } | ||
|
|
||
| protected class ElementCache extends LabKeyPage.ElementCache | ||
| { | ||
| Input nameInput = Input.Input(Locator.name("name"), getDriver()).findWhenNeeded(this); | ||
| WebElement renameButton = Locator.lkButton("Rename").findWhenNeeded(this); | ||
| Input newNameInput = Input.Input(Locator.name("newName"), getDriver()).findWhenNeeded(this); | ||
| Checkbox addAlias = Checkbox.Checkbox(Locator.checkboxByName("addAlias")).findWhenNeeded(this); | ||
|
|
||
| Input titleInput = Input.Input(Locator.name("title"), getDriver()).findWhenNeeded(this); | ||
| Checkbox shouldIndexCheckbox = Checkbox.Checkbox(Locator.checkboxByName("shouldIndex")).findWhenNeeded(this); | ||
|
|
||
| WebElement siblingOrder = Locator.name("siblings").findWhenNeeded(this); | ||
| WebElement moveUpButton = Locator.lkButton("Move Up").findWhenNeeded(this); | ||
| WebElement moveDownButton = Locator.lkButton("Move Down").findWhenNeeded(this); | ||
|
|
||
| WebElement aliases = Locator.textarea("aliases").findWhenNeeded(this); | ||
|
|
||
| WebElement saveButton = Locator.lkButton("Save").findWhenNeeded(this); | ||
| WebElement deleteButton = Locator.lkButton("Delete").findWhenNeeded(this); | ||
| WebElement editContentButton = Locator.lkButton("Edit Content").findWhenNeeded(this); | ||
| WebElement errorMsg = Locator.tagWithClass("span", "labkey-error").findWhenNeeded(this); | ||
| } | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,134 @@ | ||
| package org.labkey.test.tests.wiki; | ||
|
|
||
| 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.categories.Wiki; | ||
| import org.labkey.test.pages.wiki.ManageWikiConfigurationPage; | ||
| import org.labkey.test.util.PortalHelper; | ||
| import org.labkey.test.util.WikiHelper; | ||
| import org.labkey.test.util.search.SearchAdminAPIHelper; | ||
|
|
||
| import java.util.Arrays; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| @Category({Daily.class, Wiki.class}) | ||
| @BaseWebDriverTest.ClassTimeout(minutes = 4) | ||
| public class WikiAliasesTest extends BaseWebDriverTest | ||
| { | ||
| private static String wikiName = "Sample Wiki for testing aliases"; | ||
| private static String wikiName2 = "Sample Wiki for testing aliases - Wiki 2"; | ||
| private static String wikiTitle = "Title for " + wikiName; | ||
| private static String wikiBody = "Wiki body for " + wikiName; | ||
|
|
||
| private static String SUBFOLDER = "Subfolder for wiki"; | ||
|
|
||
| @BeforeClass | ||
| public static void setupProject() | ||
| { | ||
| WikiAliasesTest init = (WikiAliasesTest) getCurrentTest(); | ||
| init.doSetup(); | ||
| } | ||
|
|
||
| @Override | ||
| protected @Nullable String getProjectName() | ||
| { | ||
| return getClass().getSimpleName() + " Project"; | ||
| } | ||
|
|
||
| private void doSetup() | ||
| { | ||
| _containerHelper.createProject(getProjectName(), null); | ||
| _containerHelper.enableModules(Arrays.asList("Wiki")); | ||
|
|
||
| _containerHelper.createSubfolder(getProjectName(), SUBFOLDER); | ||
| _containerHelper.enableModules(Arrays.asList("Wiki")); | ||
|
|
||
| SearchAdminAPIHelper.pauseCrawler(getDriver()); | ||
|
|
||
| goToProjectHome(); | ||
| PortalHelper portalHelper = new PortalHelper(this); | ||
| portalHelper.addBodyWebPart("Wiki"); | ||
|
|
||
| navigateToFolder(getProjectName(), SUBFOLDER); | ||
| portalHelper.addBodyWebPart("Wiki"); | ||
| } | ||
|
|
||
| @Test | ||
| public void testSteps() | ||
| { | ||
| goToProjectHome(); | ||
| WikiHelper wikiHelper = new WikiHelper(this); | ||
| String duplicateAlias = "Alias5"; | ||
| String aliases = "Alias1\n" + "Alias2\n" + "Alias3\n" + "Alias4\n" + duplicateAlias; | ||
| wikiHelper.createWikiPage(wikiName, null, wikiTitle, wikiBody, true, null, false); | ||
|
|
||
| log("Verifying adding new alias with rename button"); | ||
| ManageWikiConfigurationPage manageWikiConfigurationPage = wikiHelper.manageWikiConfiguration(); | ||
| manageWikiConfigurationPage.rename(duplicateAlias + " notAlias", true).save(); | ||
| Assert.assertEquals("Incorrect value for alias after rename operation with add alias checked", wikiName, | ||
| ManageWikiConfigurationPage.beginAt(this, getProjectName(), Map.of("name", duplicateAlias + " notAlias")).getAliases()); | ||
|
|
||
| log("Verifying the add alias checkbox"); | ||
| manageWikiConfigurationPage = wikiHelper.manageWikiConfiguration(); | ||
| manageWikiConfigurationPage.rename(duplicateAlias, false).save(); | ||
| Assert.assertEquals("Incorrect value for alias after rename operation without add alias checked", wikiName, | ||
| ManageWikiConfigurationPage.beginAt(this, getProjectName(), Map.of("name", duplicateAlias)).getAliases()); | ||
|
|
||
| log("Setting aliases in aliases textarea"); | ||
| wikiHelper.manageWikiConfiguration().setAliases(aliases).save(); | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should also verify that the rename worked (before adding aliases)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
| log("Verifying all the aliases added works with wiki-page.view"); | ||
| manageWikiConfigurationPage = wikiHelper.manageWikiConfiguration(); | ||
| String listOfAliases[] = (manageWikiConfigurationPage.getAliases() + "\n" + manageWikiConfigurationPage.getAliases().toLowerCase()).split("\n"); | ||
| for (int i = 0; i < listOfAliases.length; i++) | ||
| { | ||
| beginAt(WebTestHelper.buildURL("wiki", getProjectName(), "page", Map.of("name", listOfAliases[i]))); | ||
| Assert.assertEquals("Incorrect wiki body for alias " + listOfAliases[i], wikiBody, | ||
| Locator.tagWithClass("div", "labkey-wiki").findElement(getDriver()).getText()); | ||
| } | ||
|
|
||
labkey-sweta marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| log("Verifying same alias name is not allowed"); | ||
| manageWikiConfigurationPage = wikiHelper.manageWikiConfiguration(); | ||
| String errMsg = manageWikiConfigurationPage.setAliases("\n" + duplicateAlias) | ||
| .saveExpectingErrors(); | ||
| Assert.assertEquals("Incorrect error message", "Warning: Alias '" + duplicateAlias + "' already exists in this folder.", errMsg); | ||
|
|
||
labkey-sweta marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| log("Testing case insensitive"); | ||
| manageWikiConfigurationPage = wikiHelper.manageWikiConfiguration(); | ||
| errMsg = manageWikiConfigurationPage.setAliases("\n" + duplicateAlias.toLowerCase()).saveExpectingErrors(); | ||
| Assert.assertEquals("Incorrect error message", "Warning: Alias '" + duplicateAlias.toLowerCase() + "' already exists in this folder.", errMsg); | ||
|
|
||
| log("Testing adding same wiki alias on different wiki fails within same folder"); | ||
| wikiHelper.createWikiPage(wikiName2, null, wikiTitle, wikiBody, true, null, false); | ||
| manageWikiConfigurationPage = ManageWikiConfigurationPage.beginAt(this, getProjectName(), Map.of("name", wikiName2)); | ||
| Assert.assertEquals("This alias creation should throw error", "Warning: Alias '" + duplicateAlias + "' already exists in this folder.", | ||
| manageWikiConfigurationPage.setAliases(duplicateAlias).saveExpectingErrors()); | ||
|
|
||
| log("Testing creating new wiki with name same as one of the aliases of different wiki"); | ||
| wikiHelper.createWikiPage(wikiName, null, "Title: New wiki with same alias", "Testing creating new wiki with name same as one of the aliases of different wiki", true, null, false); | ||
| beginAt(WebTestHelper.buildURL("wiki", getProjectName(), "page", Map.of("name", wikiName))); | ||
| Assert.assertEquals("Incorrect wiki body for wiki " + wikiName, "Testing creating new wiki with name same as one of the aliases of different wiki", | ||
| Locator.tagWithClass("div", "labkey-wiki").findElement(getDriver()).getText()); | ||
|
|
||
labkey-sweta marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| log("Creating same name alias in different folder"); | ||
| navigateToFolder(getProjectName(), SUBFOLDER); | ||
| wikiHelper.createWikiPage(wikiName, null, wikiTitle, wikiBody, true, null, false); | ||
|
|
||
| manageWikiConfigurationPage = wikiHelper.manageWikiConfiguration(); | ||
| manageWikiConfigurationPage.setAliases(duplicateAlias).save(); | ||
| } | ||
|
|
||
| @Override | ||
| public List<String> getAssociatedModules() | ||
| { | ||
| return Arrays.asList("wiki"); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.