-
Notifications
You must be signed in to change notification settings - Fork 1
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
Change the logic of NewVersionTest #19
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
package com.tle.webtests.test.workflow.rejection; | ||
|
||
import static org.testng.Assert.assertEquals; | ||
|
||
import static org.testng.Assert.assertTrue; | ||
import org.openqa.selenium.Alert; | ||
import org.openqa.selenium.UnhandledAlertException; | ||
import org.testng.annotations.Test; | ||
|
||
import com.tle.webtests.framework.TestInstitution; | ||
import com.tle.webtests.pageobject.searching.ItemAdminPage; | ||
import com.tle.webtests.pageobject.searching.ItemListPage; | ||
|
@@ -15,81 +16,107 @@ | |
import com.tle.webtests.pageobject.wizard.WizardPageTab; | ||
import com.tle.webtests.test.AbstractCleanupTest; | ||
|
||
|
||
@TestInstitution("workflow") | ||
public class NewVersionTest extends AbstractCleanupTest | ||
{ | ||
private static final String BACKTICK_PASSWORD = "``````"; | ||
private static final String SORTING = "datemodified"; | ||
private static final String ADMIN_USERNAME = "admin"; | ||
private static final String FIRST_MODERATOR_USERNAME = "SimpleModerator"; | ||
private static final String SECOND_MODERATOR_USERNAME = "SecondStepModerator"; | ||
private static final String STEP_NAME_ONE = "moderation step 1"; | ||
private static final String STEP_NAME_TWO = "moderation step 2"; | ||
|
||
public NewVersionTest() | ||
{ | ||
setDeleteCredentials("admin", "``````"); | ||
setDeleteCredentials(ADMIN_USERNAME, BACKTICK_PASSWORD ); | ||
} | ||
|
||
@Test | ||
public void newVersion() | ||
{ | ||
|
||
// Login as admin user and contribute an item to the collection | ||
logon("admin", "``````"); | ||
|
||
logon(ADMIN_USERNAME, BACKTICK_PASSWORD); | ||
WizardPageTab wizard = new ContributePage(context).load().openWizard("Move to Live During Moderation"); | ||
String itemFullName = context.getFullName("item"); | ||
String itemFullName2 = itemFullName + " 2"; | ||
wizard.editbox(1, itemFullName); | ||
wizard.save().submit(); | ||
saveItem(wizard, 1, itemFullName); | ||
logout(); | ||
|
||
// Login as SimpleModerator and moderate the item at the first step. | ||
logon("SimpleModerator", "``````"); | ||
logon(FIRST_MODERATOR_USERNAME, BACKTICK_PASSWORD); | ||
doModeration(STEP_NAME_ONE, itemFullName, false); | ||
logout(); | ||
|
||
TaskListPage taskListPage = new TaskListPage(context).load(); | ||
ModerateListSearchResults modResults = taskListPage.exactQuery(itemFullName); | ||
assertEquals(modResults.getStepName(itemFullName), "moderation step 1"); | ||
modResults.moderate(itemFullName).accept(); | ||
//login as admin to validate that we can't create a new version while an item is still under moderation | ||
logon(ADMIN_USERNAME, BACKTICK_PASSWORD); | ||
Boolean alertDisplayed = false; | ||
try { | ||
SearchPage.searchAndView(context, itemFullName).adminTab().newVersion(); | ||
} | ||
catch(UnhandledAlertException f){ | ||
Alert alert = getContext().getDriver().switchTo().alert(); | ||
alert.accept(); | ||
alertDisplayed = true; | ||
} | ||
assertTrue(alertDisplayed, "Failed to trigger check of new version not allowed when already version in moderation."); | ||
logout(); | ||
|
||
// login as the owner of the item and new version it. | ||
logon("admin", "``````"); | ||
// Login as the SecondStepModerator and moderate again because this workflow needs moderating twice. | ||
logon(SECOND_MODERATOR_USERNAME, BACKTICK_PASSWORD); | ||
doModeration(STEP_NAME_TWO, itemFullName, false); | ||
logout(); | ||
|
||
// Now the item should be in a state where we're allowed to create a new version. | ||
// login as admin and new version it. | ||
logon(ADMIN_USERNAME, BACKTICK_PASSWORD); | ||
wizard = SearchPage.searchAndView(context, itemFullName).adminTab().newVersion(); | ||
wizard.editbox(1, itemFullName2); | ||
wizard.save().submit(); | ||
|
||
// check that there is a version that is live, and one that is | ||
// moderating. | ||
ItemAdminPage adminPage = new ItemAdminPage(context).load(); | ||
adminPage.exactQuery(itemFullName); | ||
adminPage.setSort("datemodified"); | ||
ItemListPage itemList = adminPage.results(); | ||
saveItem(wizard, 1, itemFullName2); | ||
// check that there is a version that is live, and one that is moderating. | ||
ItemListPage itemList = getItemList(itemFullName); | ||
assertEquals(itemList.getResultForTitle(itemFullName, 1).getStatus(), "live"); | ||
assertEquals(itemList.getResultForTitle(itemFullName2, 1).getStatus(), "moderating"); | ||
logout(); | ||
|
||
// Login as SimpleModerator and moderate the item at the first step. | ||
logon("SimpleModerator", "``````"); | ||
|
||
taskListPage = new TaskListPage(context).load(); | ||
modResults = taskListPage.exactQuery(itemFullName2); | ||
assertEquals(modResults.getStepName(itemFullName2), "moderation step 1"); | ||
modResults.moderate(itemFullName2).accept(); | ||
|
||
// After moderation, check that the item has gone life after the first | ||
// moderation step | ||
adminPage = new ItemAdminPage(context).load(); | ||
adminPage.exactQuery(itemFullName2); | ||
adminPage.setSort("datemodified"); | ||
itemList = adminPage.results(); | ||
// Login as SimpleModerator and moderate the new version of this item at the first step. | ||
logon(FIRST_MODERATOR_USERNAME, BACKTICK_PASSWORD); | ||
doModeration(STEP_NAME_ONE, itemFullName2,false); | ||
// After moderation, check that the item has gone live after the first moderation step | ||
itemList = getItemList(itemFullName2); | ||
assertEquals(itemList.getResultForTitle(itemFullName2, 1).getStatus(), "live"); | ||
logout(); | ||
|
||
// Login as the SecondStepModerator and check that the item is still | ||
// there to moderate, and is still live once moderated from second step. | ||
logon("SecondStepModerator", "``````"); | ||
taskListPage = new TaskListPage(context).load(); | ||
modResults = taskListPage.exactQuery(itemFullName2); | ||
ModerationView tasksTab = modResults.moderate(itemFullName2); | ||
tasksTab.assignToMe(); | ||
tasksTab.accept(); | ||
logon(SECOND_MODERATOR_USERNAME, BACKTICK_PASSWORD); | ||
doModeration(null, itemFullName2, true); | ||
logout(); | ||
} | ||
|
||
private void doModeration(String stepName, String itemFullName, Boolean lastModeration) { | ||
TaskListPage taskListPage = new TaskListPage(context).load(); | ||
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.
|
||
ModerateListSearchResults modResults = taskListPage.exactQuery(itemFullName); | ||
if(!lastModeration) { | ||
assertEquals(modResults.getStepName(itemFullName), stepName); | ||
modResults.moderate(itemFullName).accept(); | ||
} | ||
else { | ||
ModerationView tasksTab = modResults.moderate(itemFullName); | ||
tasksTab.assignToMe(); | ||
tasksTab.accept(); | ||
} | ||
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. For this if/else the braces should follow the statement. Shame we don't have formatting here yet, but we will once we merge this repo in. |
||
} | ||
|
||
private ItemListPage getItemList(String itemFullName){ | ||
ItemAdminPage adminPage = new ItemAdminPage(context).load(); | ||
adminPage.exactQuery(itemFullName); | ||
adminPage.setSort(SORTING); | ||
return adminPage.results(); | ||
} | ||
|
||
private void saveItem(WizardPageTab wizard, int ctrlNum, String itemFullName){ | ||
wizard.editbox(ctrlNum, itemFullName); | ||
wizard.save().submit(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since these are all
public static final String
, the whitespaces between each line should be removed.