diff --git a/functional-test/src/main/java/org/zanata/page/administration/ManageUserAccountPage.java b/functional-test/src/main/java/org/zanata/page/administration/ManageUserAccountPage.java index 671debc730..329fdbd0b6 100644 --- a/functional-test/src/main/java/org/zanata/page/administration/ManageUserAccountPage.java +++ b/functional-test/src/main/java/org/zanata/page/administration/ManageUserAccountPage.java @@ -68,21 +68,6 @@ public ManageUserAccountPage(WebDriver driver) { roleMap.put("user", "4"); } - public ManageUserAccountPage enterUsername(final String username) { - waitForTenSec().until(new Predicate() { - @Override - public boolean apply(WebDriver input) { - WebElement usernameField = input.findElement(usernameBy); - usernameField.clear(); - usernameField.sendKeys(username); - return input.findElement(usernameBy).getAttribute("value") - .equals(username); - } - }); - - return new ManageUserAccountPage(getDriver()); - } - public ManageUserAccountPage enterPassword(String password) { passwordField.sendKeys(password); return new ManageUserAccountPage(getDriver()); @@ -123,17 +108,4 @@ public ManageUserPage cancelEditUser() { return new ManageUserPage(getDriver()); } - public ManageUserAccountPage clearFields() { - waitForTenSec().until(new Predicate() { - @Override - public boolean apply(WebDriver input) { - input.findElement(usernameBy).clear(); - return input.findElement(usernameBy).getAttribute("value") - .isEmpty(); - } - }); - passwordField.clear(); - passwordConfirmField.clear(); - return new ManageUserAccountPage(getDriver()); - } } diff --git a/functional-test/src/test/java/org/zanata/feature/administration/EditHomePageTest.java b/functional-test/src/test/java/org/zanata/feature/administration/EditHomePageTest.java index 42c985f4f6..74a25ab11a 100644 --- a/functional-test/src/test/java/org/zanata/feature/administration/EditHomePageTest.java +++ b/functional-test/src/test/java/org/zanata/feature/administration/EditHomePageTest.java @@ -20,7 +20,6 @@ */ package org.zanata.feature.administration; -import org.hamcrest.Matchers; import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; @@ -34,7 +33,7 @@ import org.zanata.util.AddUsersRule; import org.zanata.workflow.LoginWorkFlow; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.assertj.core.api.Assertions.assertThat; /** * @author Damian Jansen djansen@redhat.com @@ -53,9 +52,9 @@ public class EditTranslationMemoryTest extends ZanataTestCase { @Before public void before() { - assertThat("Admin is logged in", - new LoginWorkFlow().signIn("admin", "admin").loggedInAs(), - Matchers.equalTo("admin")); + assertThat(new LoginWorkFlow().signIn("admin", "admin").loggedInAs()) + .isEqualTo("admin") + .as("Admin is logged in"); } @Test(timeout = ZanataTestCase.MAX_SHORT_TEST_DURATION) @@ -67,17 +66,18 @@ public void createNewTranslationMemory() { new TranslationMemoryWorkFlow().createTranslationMemory( newTMId, tmDescription); - assertThat("The success message is displayed", - translationMemoryPage.getNotificationMessage(), - Matchers.equalTo("Successfully created")); + assertThat(translationMemoryPage + .expectNotification("Successfully created")) + .isTrue() + .as("The success message is displayed"); - assertThat("The new Translation Memory is listed", - translationMemoryPage.getListedTranslationMemorys(), - Matchers.hasItem(newTMId)); + assertThat(translationMemoryPage.getListedTranslationMemorys()) + .contains(newTMId) + .as("The new Translation Memory is listed"); - assertThat("The description is displayed correctly", - translationMemoryPage.getDescription(newTMId), - Matchers.equalTo(tmDescription)); + assertThat(translationMemoryPage.getDescription(newTMId)) + .isEqualTo(tmDescription) + .as("The description is displayed correctly"); } @Test(timeout = ZanataTestCase.MAX_SHORT_TEST_DURATION) @@ -85,15 +85,18 @@ public void abortCreate() { String abortName = "aborttmtest"; String abortDescription = "abort tm description"; - TranslationMemoryPage translationMemoryPage = - new BasicWorkFlow().goToHome().goToAdministration() - .goToTranslationMemoryPage().clickCreateNew() - .enterMemoryID(abortName) - .enterMemoryDescription(abortDescription).cancelTM(); - - assertThat("The Translation Memory was not created", - translationMemoryPage.getListedTranslationMemorys(), - Matchers.not(Matchers.hasItem(abortName))); + TranslationMemoryPage translationMemoryPage = new BasicWorkFlow() + .goToHome() + .goToAdministration() + .goToTranslationMemoryPage() + .clickCreateNew() + .enterMemoryID(abortName) + .enterMemoryDescription(abortDescription) + .cancelTM(); + + assertThat(translationMemoryPage.getListedTranslationMemorys()) + .doesNotContain(abortName) + .as("The Translation Memory was not created"); } @Test(timeout = ZanataTestCase.MAX_SHORT_TEST_DURATION) @@ -105,44 +108,42 @@ public void translationMemoryIdsAreUnique() { new TranslationMemoryWorkFlow() .createTranslationMemory(nonUniqueTMId); - assertThat("The new Translation Memory is listed", - translationMemoryPage.getListedTranslationMemorys(), - Matchers.hasItem(nonUniqueTMId)); + assertThat(translationMemoryPage.getListedTranslationMemorys()) + .contains(nonUniqueTMId) + .as("The new Translation Memory is listed"); TranslationMemoryEditPage translationMemoryEditPage = translationMemoryPage.clickCreateNew() .enterMemoryID(nonUniqueTMId) .enterMemoryDescription("Meh"); - assertThat("The Id Is Not Available error is displayed", - translationMemoryEditPage.waitForErrors(), - Matchers.hasItem(nameError)); + assertThat(translationMemoryEditPage.waitForErrors()) + .contains(nameError) + .as("The Id Is Not Available error is displayed"); translationMemoryEditPage = translationMemoryEditPage.clickSaveAndExpectFailure(); translationMemoryEditPage.assertNoCriticalErrors(); // RHBZ-1010771 - assertThat("The Id Is Not Available error is displayed", - translationMemoryEditPage.waitForErrors(), - Matchers.hasItem(nameError)); + assertThat(translationMemoryEditPage.waitForErrors()) + .contains(nameError) + .as("The Id Is Not Available error is displayed"); } @Test(timeout = ZanataTestCase.MAX_SHORT_TEST_DURATION) public void importTranslationMemory() { String importTMId = "importmtest"; - File importFile = - testFileGenerator - .generateTestFileWithContent( - "importtmtest", - ".tmx", - "\n" - + "\n" - + "\n" - + "
\n" - + " \n" - + "Fedora is an open, innovative, forward looking operating system and platform, based on Linux, that is always free for anyone to use, modify and distribute, now and forever. It is developed by a large community of people who strive to provide and maintain the very best in free, open source software and standards. Fedora is part of the Fedora Project, sponsored by Red Hat, Inc.This is a TM Import Test\n" - + " \n" + ""); + File importFile = testFileGenerator.generateTestFileWithContent( + "importtmtest", + ".tmx", + "\n" + + "\n" + + "\n" + + "
\n" + + " \n" + + "Fedora is an open, innovative, forward looking operating system and platform, based on Linux, that is always free for anyone to use, modify and distribute, now and forever. It is developed by a large community of people who strive to provide and maintain the very best in free, open source software and standards. Fedora is part of the Fedora Project, sponsored by Red Hat, Inc.This is a TM Import Test\n" + + " \n" + ""); TranslationMemoryPage translationMemoryPage = new TranslationMemoryWorkFlow() @@ -151,9 +152,9 @@ public void importTranslationMemory() { .enterImportFileName(importFile.getAbsolutePath()) .clickUploadButtonAndAcknowledge(); - assertThat("The Translation Memory has one entry", - translationMemoryPage.getNumberOfEntries(importTMId), - Matchers.equalTo("1")); + assertThat(translationMemoryPage.getNumberOfEntries(importTMId)) + .isEqualTo("1") + .as("The Translation Memory has one entry"); } @@ -166,14 +167,15 @@ public void rejectEmptyTranslation() { rejectTMId).clickImport(rejectTMId); Alert uploadError = translationMemoryPage.expectFailedUpload(); - assertThat("Error is displayed", uploadError.getText(), - Matchers.startsWith("There was an error uploading the file")); + assertThat(uploadError.getText()) + .startsWith("There was an error uploading the file") + .as("Error is displayed"); translationMemoryPage = translationMemoryPage.dismissError(); - assertThat("No change is recorded", - translationMemoryPage.getNumberOfEntries(rejectTMId), - Matchers.equalTo("0")); + assertThat(translationMemoryPage.getNumberOfEntries(rejectTMId)) + .isEqualTo("0") + .as("No change is recorded"); } @Test(timeout = ZanataTestCase.MAX_SHORT_TEST_DURATION) @@ -184,16 +186,16 @@ public void deleteTranslationMemory() { new TranslationMemoryWorkFlow() .createTranslationMemory(deleteTMId); - assertThat("The new Translation Memory is listed", - translationMemoryPage.getListedTranslationMemorys(), - Matchers.hasItem(deleteTMId)); + assertThat(translationMemoryPage.getListedTranslationMemorys()) + .contains(deleteTMId) + .as("The new Translation Memory is listed"); translationMemoryPage = translationMemoryPage.clickDeleteTmAndAccept(deleteTMId); - assertThat("The new Translation Memory is no longer listed", - translationMemoryPage.getListedTranslationMemorys(), - Matchers.not(Matchers.hasItem(deleteTMId))); + assertThat(translationMemoryPage.getListedTranslationMemorys()) + .doesNotContain(deleteTMId) + .as("The new Translation Memory is no longer listed"); } @Test(timeout = ZanataTestCase.MAX_SHORT_TEST_DURATION) @@ -204,33 +206,31 @@ public void dontDeleteTranslationMemory() { new TranslationMemoryWorkFlow() .createTranslationMemory(dontDeleteTMId); - assertThat("The new Translation Memory is listed", - translationMemoryPage.getListedTranslationMemorys(), - Matchers.hasItem(dontDeleteTMId)); + assertThat(translationMemoryPage.getListedTranslationMemorys()) + .contains(dontDeleteTMId) + .as("The new Translation Memory is listed"); translationMemoryPage = translationMemoryPage.clickDeleteTmAndCancel(dontDeleteTMId); - assertThat("The new Translation Memory is still listed", - translationMemoryPage.getListedTranslationMemorys(), - Matchers.hasItem(dontDeleteTMId)); + assertThat(translationMemoryPage.getListedTranslationMemorys()) + .contains(dontDeleteTMId) + .as("The new Translation Memory is still listed"); } @Test(timeout = ZanataTestCase.MAX_SHORT_TEST_DURATION) public void clearTranslationMemory() { String clearTMId = "cleartmtest"; - File importFile = - testFileGenerator - .generateTestFileWithContent( - "cleartmtest", - ".tmx", - "\n" - + "\n" - + "\n" - + "
\n" - + " \n" - + "Fedora is an open, innovative, forward looking operating system and platform, based on Linux, that is always free for anyone to use, modify and distribute, now and forever. It is developed by a large community of people who strive to provide and maintain the very best in free, open source software and standards. Fedora is part of the Fedora Project, sponsored by Red Hat, Inc.This is a TM Import Test\n" - + " \n" + ""); + File importFile = testFileGenerator.generateTestFileWithContent( + "cleartmtest", + ".tmx", + "\n" + + "\n" + + "\n" + + "
\n" + + " \n" + + "Fedora is an open, innovative, forward looking operating system and platform, based on Linux, that is always free for anyone to use, modify and distribute, now and forever. It is developed by a large community of people who strive to provide and maintain the very best in free, open source software and standards. Fedora is part of the Fedora Project, sponsored by Red Hat, Inc.This is a TM Import Test\n" + + " \n" + ""); TranslationMemoryPage translationMemoryPage = new TranslationMemoryWorkFlow() @@ -239,33 +239,32 @@ public void clearTranslationMemory() { .enterImportFileName(importFile.getAbsolutePath()) .clickUploadButtonAndAcknowledge(); - assertThat("The TM has one item", - translationMemoryPage.getNumberOfEntries(clearTMId), - Matchers.equalTo("1")); + assertThat(translationMemoryPage.getNumberOfEntries(clearTMId)) + .isEqualTo("1") + .as("The TM has one item"); translationMemoryPage = translationMemoryPage.clickClearTMAndAccept(clearTMId); - assertThat("The translation memory entries is empty", - translationMemoryPage.waitForExpectedNumberOfEntries(clearTMId, - "0"), Matchers.equalTo("0")); + assertThat(translationMemoryPage + .waitForExpectedNumberOfEntries(clearTMId, "0")) + .isEqualTo("0") + .as("The translation memory entries is empty"); } @Test(timeout = ZanataTestCase.MAX_SHORT_TEST_DURATION) public void dontClearTranslationMemory() { String clearTMId = "dontcleartmtest"; - File importFile = - testFileGenerator - .generateTestFileWithContent( - "cleartmtest", - ".tmx", - "\n" - + "\n" - + "\n" - + "
\n" - + " \n" - + "Fedora is an open, innovative, forward looking operating system and platform, based on Linux, that is always free for anyone to use, modify and distribute, now and forever. It is developed by a large community of people who strive to provide and maintain the very best in free, open source software and standards. Fedora is part of the Fedora Project, sponsored by Red Hat, Inc.This is a TM Import Test\n" - + " \n" + ""); + File importFile = testFileGenerator.generateTestFileWithContent( + "cleartmtest", + ".tmx", + "\n" + + "\n" + + "\n" + + "
\n" + + " \n" + + "Fedora is an open, innovative, forward looking operating system and platform, based on Linux, that is always free for anyone to use, modify and distribute, now and forever. It is developed by a large community of people who strive to provide and maintain the very best in free, open source software and standards. Fedora is part of the Fedora Project, sponsored by Red Hat, Inc.This is a TM Import Test\n" + + " \n" + ""); TranslationMemoryPage translationMemoryPage = new TranslationMemoryWorkFlow() @@ -274,33 +273,31 @@ public void dontClearTranslationMemory() { .enterImportFileName(importFile.getAbsolutePath()) .clickUploadButtonAndAcknowledge(); - assertThat("The TM has one item", - translationMemoryPage.getNumberOfEntries(clearTMId), - Matchers.equalTo("1")); + assertThat(translationMemoryPage.getNumberOfEntries(clearTMId)) + .isEqualTo("1") + .as("The TM has one item"); translationMemoryPage = translationMemoryPage.clickClearTMAndCancel(clearTMId); - assertThat("The translation memory entries count is the same", - translationMemoryPage.getNumberOfEntries(clearTMId), - Matchers.equalTo("1")); + assertThat(translationMemoryPage.getNumberOfEntries(clearTMId)) + .isEqualTo("1") + .as("The translation memory entries count is the same"); } @Test(timeout = ZanataTestCase.MAX_SHORT_TEST_DURATION) public void mustClearBeforeDelete() { String forceClear = "forcecleartodelete"; - File importFile = - testFileGenerator - .generateTestFileWithContent( - "cleartmtest", - ".tmx", - "\n" - + "\n" - + "\n" - + "
\n" - + " \n" - + "Fedora is an open, innovative, forward looking operating system and platform, based on Linux, that is always free for anyone to use, modify and distribute, now and forever. It is developed by a large community of people who strive to provide and maintain the very best in free, open source software and standards. Fedora is part of the Fedora Project, sponsored by Red Hat, Inc.This is a TM Import Test\n" - + " \n" + ""); + File importFile = testFileGenerator.generateTestFileWithContent( + "cleartmtest", + ".tmx", + "\n" + + "\n" + + "\n" + + "
\n" + + " \n" + + "Fedora is an open, innovative, forward looking operating system and platform, based on Linux, that is always free for anyone to use, modify and distribute, now and forever. It is developed by a large community of people who strive to provide and maintain the very best in free, open source software and standards. Fedora is part of the Fedora Project, sponsored by Red Hat, Inc.This is a TM Import Test\n" + + " \n" + ""); TranslationMemoryPage translationMemoryPage = new TranslationMemoryWorkFlow() @@ -309,26 +306,28 @@ public void mustClearBeforeDelete() { .enterImportFileName(importFile.getAbsolutePath()) .clickUploadButtonAndAcknowledge(); - assertThat("The TM has one item", - translationMemoryPage.getNumberOfEntries(forceClear), - Matchers.equalTo("1")); + assertThat(translationMemoryPage.getNumberOfEntries(forceClear)) + .isEqualTo("1") + .as("The TM has one item"); - assertThat("The item cannot yet be deleted", - !translationMemoryPage.canDelete(forceClear)); + assertThat(translationMemoryPage.canDelete(forceClear)) + .isFalse() + .as("The item cannot yet be deleted"); translationMemoryPage = translationMemoryPage.clickClearTMAndAccept(forceClear); translationMemoryPage.waitForExpectedNumberOfEntries(forceClear, "0"); - assertThat("The item can be deleted", - translationMemoryPage.canDelete(forceClear)); + assertThat(translationMemoryPage.canDelete(forceClear)) + .isTrue() + .as("The item can be deleted"); translationMemoryPage = translationMemoryPage.clickDeleteTmAndAccept(forceClear); - assertThat("The item is deleted", - translationMemoryPage.getListedTranslationMemorys(), - Matchers.not(Matchers.hasItem(forceClear))); + assertThat(translationMemoryPage.getListedTranslationMemorys()) + .doesNotContain(forceClear) + .as("The item is deleted"); } } diff --git a/functional-test/src/test/java/org/zanata/feature/administration/ManageSearchTest.java b/functional-test/src/test/java/org/zanata/feature/administration/ManageSearchTest.java index 6dcff05ce1..275666ca4d 100644 --- a/functional-test/src/test/java/org/zanata/feature/administration/ManageSearchTest.java +++ b/functional-test/src/test/java/org/zanata/feature/administration/ManageSearchTest.java @@ -32,7 +32,7 @@ import org.zanata.util.SampleProjectRule; import org.zanata.workflow.LoginWorkFlow; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.assertj.core.api.Assertions.assertThat; @Category(DetailedTest.class) public class ManageSearchTest extends ZanataTestCase { @@ -54,20 +54,20 @@ public void regenerateSearchIndexes() { .goToManageSeachPage() .clickSelectAll(); - assertThat("All actions are selected", - manageSearchPage.allActionsSelected()); - assertThat("No operations are running", - manageSearchPage.noOperationsRunningIsDisplayed()); + assertThat(manageSearchPage.allActionsSelected()) + .as("All actions are selected"); + assertThat(manageSearchPage.noOperationsRunningIsDisplayed()) + .as("No operations are running"); manageSearchPage = manageSearchPage .performSelectedActions() .waitForActionsToFinish(); - assertThat("Completed is displayed", - manageSearchPage.completedIsDisplayed()); + assertThat(manageSearchPage.completedIsDisplayed()) + .as("Completed is displayed"); - assertThat("No operations are running", - manageSearchPage.noOperationsRunningIsDisplayed()); + assertThat(manageSearchPage.noOperationsRunningIsDisplayed()) + .as("No operations are running"); } @Test(timeout = ZanataTestCase.MAX_SHORT_TEST_DURATION) @@ -78,16 +78,16 @@ public void abortReindexes() { .goToManageSeachPage() .clickSelectAll(); - assertThat("All actions are selected", - manageSearchPage.allActionsSelected()); - assertThat("No operations are running", - manageSearchPage.noOperationsRunningIsDisplayed()); + assertThat(manageSearchPage.allActionsSelected()) + .as("All actions are selected"); + assertThat(manageSearchPage.noOperationsRunningIsDisplayed()) + .as("No operations are running"); manageSearchPage = manageSearchPage .performSelectedActions() .abort(); - assertThat("Aborted is displayed", - manageSearchPage.abortedIsDisplayed()); + assertThat(manageSearchPage.abortedIsDisplayed()) + .as("Aborted is displayed"); } } diff --git a/functional-test/src/test/java/org/zanata/feature/administration/ManageUsersFullTest.java b/functional-test/src/test/java/org/zanata/feature/administration/ManageUsersTest.java similarity index 70% rename from functional-test/src/test/java/org/zanata/feature/administration/ManageUsersFullTest.java rename to functional-test/src/test/java/org/zanata/feature/administration/ManageUsersTest.java index 35c438ad48..bbfe36ab2b 100644 --- a/functional-test/src/test/java/org/zanata/feature/administration/ManageUsersFullTest.java +++ b/functional-test/src/test/java/org/zanata/feature/administration/ManageUsersTest.java @@ -20,7 +20,6 @@ */ package org.zanata.feature.administration; -import org.hamcrest.Matchers; import org.junit.Before; import org.junit.ClassRule; import org.junit.Rule; @@ -28,21 +27,19 @@ import org.junit.experimental.categories.Category; import org.zanata.feature.testharness.ZanataTestCase; import org.zanata.feature.testharness.TestPlan.DetailedTest; -import org.zanata.page.administration.ManageUserAccountPage; -import org.zanata.page.administration.ManageUserPage; import org.zanata.page.dashboard.DashboardBasePage; import org.zanata.util.AddUsersRule; import org.zanata.util.HasEmailRule; import org.zanata.workflow.LoginWorkFlow; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.assertj.core.api.Assertions.assertThat; /** * @author Damian Jansen djansen@redhat.com */ @Category(DetailedTest.class) -public class ManageUsersFullTest extends ZanataTestCase { +public class ManageUsersTest extends ZanataTestCase { @Rule public AddUsersRule addUsersRule = new AddUsersRule(); @@ -57,18 +54,20 @@ public void before() { } @Test(timeout = ZanataTestCase.MAX_SHORT_TEST_DURATION) - public void changeAUsersUsername() { - String username = "administratornamechange"; - ManageUserPage manageUserPage = - dashboardPage.goToAdministration().goToManageUserPage(); + public void changeAUsersPassword() { + dashboardPage.goToAdministration() + .goToManageUserPage() + .editUserAccount("translator") + .enterPassword("newpassword") + .enterConfirmPassword("newpassword") + .saveUser() + .logout(); - ManageUserAccountPage manageUserAccountPage = - manageUserPage.editUserAccount("admin"); - manageUserPage = - manageUserAccountPage.clearFields().enterUsername(username) - .saveUser(); - assertThat("Administrator is displayed", manageUserPage.getUserList(), - Matchers.hasItem(username)); + dashboardPage = new LoginWorkFlow().signIn("translator", "newpassword"); + + assertThat(dashboardPage.loggedInAs()) + .isEqualTo("translator") + .as("User logged in with new password"); } } diff --git a/functional-test/src/test/java/org/zanata/feature/testharness/TestPlan.java b/functional-test/src/test/java/org/zanata/feature/testharness/TestPlan.java index 21c53d1ff0..31d6f12f3d 100644 --- a/functional-test/src/test/java/org/zanata/feature/testharness/TestPlan.java +++ b/functional-test/src/test/java/org/zanata/feature/testharness/TestPlan.java @@ -76,7 +76,7 @@ EditTranslationMemoryTest.class, EditTranslationMemoryTest.class, ManageSearchTest.class, - ManageUsersFullTest.class, + ManageUsersTest.class, /* Client-Server * Usage of the mvn client