Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 61 additions & 5 deletions src/org/labkey/test/pages/announcements/EmailPrefsPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,36 +43,92 @@ public static EmailPrefsPage beginAt(WebDriverWrapper driver, String containerPa
return new EmailPrefsPage(driver.getDriver());
}

@Deprecated // Inconsistent name, but leave for backward compatibility
public EmailPrefsPage setNoNotify()
{
return setNotifyNone();
}

public EmailPrefsPage setNotifyNone()
{
elementCache().notifyNone.click();
return new EmailPrefsPage(getDriver());
}

public boolean isNotifyNoneSelected()
{
return elementCache().notifyNone.isSelected();
}

public boolean isNotifyNoneDisabled()
{
return !elementCache().notifyNone.isEnabled();
}

public EmailPrefsPage setNotifyOnMine()
{
elementCache().notifyMine.click();
return new EmailPrefsPage(getDriver());
}

public boolean isNotifyOnMineSelected()
{
return elementCache().notifyMine.isSelected();
}

public boolean isNotifyOnMineDisabled()
{
return !elementCache().notifyMine.isEnabled();
}

public EmailPrefsPage setNotifyOnAll()
{
elementCache().notifyAll.click();
return new EmailPrefsPage(getDriver());
}

public boolean isNotifyOnAllSelected()
{
return elementCache().notifyAll.isSelected();
}

public boolean isNotifyOnAllDisabled()
{
return !elementCache().notifyAll.isEnabled();
}

public EmailPrefsPage setTypeIndividual()
{
elementCache().notifyAll.click();
elementCache().typeIndividual.click();
return new EmailPrefsPage(getDriver());
}

public boolean isTypeIndividualSelected()
{
return elementCache().typeIndividual.isSelected();
}

public boolean isTypeIndividualDisabled()
{
return !elementCache().typeIndividual.isEnabled();
}

public EmailPrefsPage setTypeDigest()
{
elementCache().notifyAll.click();
elementCache().typeDigest.click();
return new EmailPrefsPage(getDriver());
}

public boolean isTypeDigestSelected()
{
return elementCache().typeDigest.isSelected();
}

public boolean isTypeDigestDisabled()
{
return !elementCache().typeDigest.isEnabled();
}

public EmailPrefsPage reset(boolean reset)
{
if (reset)
Expand Down Expand Up @@ -114,10 +170,10 @@ protected class ElementCache extends LabKeyPage.ElementCache
protected WebElement notifyAll = notify.withAttribute("value", "1").findWhenNeeded(this);

private final Locator.XPathLocator type = Locator.radioButtonByName("notificationType");
protected WebElement typeIndividual = notify.withAttribute("value", "3").findWhenNeeded(this);
protected WebElement typeDigest = notify.withAttribute("value", "4").findWhenNeeded(this);
protected WebElement typeIndividual = type.withAttribute("value", "3").findWhenNeeded(this);
protected WebElement typeDigest = type.withAttribute("value", "4").findWhenNeeded(this);

Checkbox resetCheckbox = Checkbox(Locator.tagWithName("input", "emailPreference").withAttribute("value", "1")).findWhenNeeded(this);
Checkbox resetCheckbox = Checkbox(Locator.tagWithId("input", "resetFolderDefault")).findWhenNeeded(this);

WebElement updateButton = Locator.lkButton("Update").findWhenNeeded(this);
WebElement cancelButton = Locator.lkButton("Cancel").findWhenNeeded(this);
Expand Down
45 changes: 37 additions & 8 deletions src/org/labkey/test/tests/MessagesLongTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.labkey.test.components.html.SiteNavBar;
import org.labkey.test.pages.admin.PermissionsPage;
import org.labkey.test.pages.announcements.AdminPage;
import org.labkey.test.pages.announcements.EmailPrefsPage;
import org.labkey.test.pages.announcements.InsertPage;
import org.labkey.test.pages.announcements.RespondPage;
import org.labkey.test.util.ApiPermissionsHelper;
Expand Down Expand Up @@ -170,8 +171,6 @@ private void doSetup()
.assertPermissionSetting("testers1", "No Permissions")
.clickSaveAndFinish();
_containerHelper.enableModule(PROJECT_NAME, "Dumbster");


}

@Test
Expand All @@ -190,10 +189,37 @@ public void testSteps()

clickProject(PROJECT_NAME);
log("Check email preferences");
// Unlike EmailPrefsPage.beginAt(), this ensures returnUrl is passed to the action
_portalHelper.clickWebpartMenuItem("Messages", true, "Email Preferences");
checkCheckbox(Locator.radioButtonByName("emailPreference").index(2));
clickButton("Update");
clickButton("Done");
EmailPrefsPage prefsPage = new EmailPrefsPage(getDriver());
// Verify prefs are "Mine" (doTestEmailPrefsMine() sets this) and "Individual" (folder default)
assertTrue(prefsPage.isNotifyOnMineSelected());
assertTrue(prefsPage.isTypeIndividualSelected());

// Update to settings that differ from the folder default values to test "Reset to folder default setting", Issue 53387
prefsPage = prefsPage
.setNotifyOnAll()
.setTypeDigest()
.update();
assertTrue(prefsPage.isNotifyOnAllSelected());
assertTrue(prefsPage.isTypeDigestSelected());

// After clicking "Reset", all options should be disabled
prefsPage = prefsPage.reset(true);
assertTrue(prefsPage.isNotifyNoneDisabled());
assertTrue(prefsPage.isNotifyOnMineDisabled());
assertTrue(prefsPage.isNotifyOnAllDisabled());
assertTrue(prefsPage.isTypeIndividualDisabled());
assertTrue(prefsPage.isTypeDigestDisabled());

// Submit reset to folder default and verify
prefsPage = prefsPage.update();
assertTrue(prefsPage.isNotifyOnMineSelected());
assertTrue(prefsPage.isTypeIndividualSelected());

prefsPage = prefsPage.setNotifyOnAll().update();
assertTrue(prefsPage.isNotifyOnAllSelected());
prefsPage.done();

SiteNavBar siteNavBar = new SiteNavBar(getDriver());
siteNavBar.enterPageAdminMode();
Expand Down Expand Up @@ -644,10 +670,13 @@ private void doTestEmailPrefsMine()
createUserWithPermissions(RESPONDER, PROJECT_NAME, "Editor");
goToProjectHome(PROJECT_NAME);

// Unlike EmailPrefsPage.beginAt(), this ensures returnUrl is passed to the action
_portalHelper.clickWebpartMenuItem("Messages", true, "Email Preferences");
checkCheckbox(Locator.radioButtonByName("emailPreference").index(1));
clickButton("Update");
clickButton("Done");
EmailPrefsPage prefsPage = new EmailPrefsPage(getDriver())
.setNotifyOnMine()
.update();
assertTrue(prefsPage.isNotifyOnMineSelected());
prefsPage.done();

createNewMessage(_messageTitle, _messageBody);

Expand Down