From bf0614c9783cab03f055babfb4d4bd4845059c10 Mon Sep 17 00:00:00 2001 From: Stefan Ranoszek Date: Mon, 2 Sep 2024 17:24:02 +0100 Subject: [PATCH] feat: asset asserts --- .../Journeys/licence/InternalUIJourney.java | 2 +- .../Journeys/licence/SurrenderJourney.java | 2 +- .../SubmissionPageSteps.java | 2 +- .../framework/stepdefs/vol/BatchProcess.java | 3 ++- .../framework/stepdefs/vol/FinancialEvidence.java | 3 ++- .../stepdefs/vol/GoodVarIncreaseVehicle.java | 6 +++--- .../framework/stepdefs/vol/GoodVarUpgrade.java | 14 +++++++------- .../framework/stepdefs/vol/PsvSurrenders.java | 6 +++--- .../framework/stepdefs/vol/SurrenderLogic.java | 3 +-- .../testing/framework/stepdefs/vol/Surrenders.java | 3 ++- .../framework/stepdefs/vol/VerifySwitchedOff.java | 2 +- 11 files changed, 24 insertions(+), 22 deletions(-) diff --git a/src/test/java/org/dvsa/testing/framework/Journeys/licence/InternalUIJourney.java b/src/test/java/org/dvsa/testing/framework/Journeys/licence/InternalUIJourney.java index 5ec213acb..b6f4a45a7 100644 --- a/src/test/java/org/dvsa/testing/framework/Journeys/licence/InternalUIJourney.java +++ b/src/test/java/org/dvsa/testing/framework/Journeys/licence/InternalUIJourney.java @@ -151,7 +151,7 @@ public void deleteDocument() { public void checkLicenceStatus(String arg0) { waitForElementToBeClickable("menu-admin-dashboard/admin-your-account/details", SelectorType.ID); waitForTextToBePresent("Licence status"); - assertEquals(arg0.toUpperCase(), getElementValueByText("//strong[contains(@class,'govuk-tag')]", SelectorType.XPATH)); + assertTrue(getElementValueByText("//strong[contains(@class,'govuk-tag')]", SelectorType.XPATH).equalsIgnoreCase("surrendered")); } public void closeCase() { diff --git a/src/test/java/org/dvsa/testing/framework/Journeys/licence/SurrenderJourney.java b/src/test/java/org/dvsa/testing/framework/Journeys/licence/SurrenderJourney.java index 5dcb8c8c8..0341ced8c 100644 --- a/src/test/java/org/dvsa/testing/framework/Journeys/licence/SurrenderJourney.java +++ b/src/test/java/org/dvsa/testing/framework/Journeys/licence/SurrenderJourney.java @@ -118,7 +118,7 @@ public void submitSurrender() throws IOException, InterruptedException, IllegalB world.govSignInJourney.changeProtocolForSignInToWorkOnLocal(); checkSignInConfirmation(); refreshPageWithJavascript(); - assertEquals(getText("//*[contains(@class,'govuk-tag govuk-tag')]", SelectorType.XPATH), "SURRENDER UNDER CONSIDERATION"); + assertTrue(getElementValueByText("//*[contains(@class,'govuk-tag govuk-tag')]", SelectorType.XPATH).equalsIgnoreCase("SURRENDER UNDER CONSIDERATION")); axeScanner.scan(true); } diff --git a/src/test/java/org/dvsa/testing/framework/stepdefs/permits/ecmtInternationalRemoval/SubmissionPageSteps.java b/src/test/java/org/dvsa/testing/framework/stepdefs/permits/ecmtInternationalRemoval/SubmissionPageSteps.java index 828bd84f7..5694ad9d3 100644 --- a/src/test/java/org/dvsa/testing/framework/stepdefs/permits/ecmtInternationalRemoval/SubmissionPageSteps.java +++ b/src/test/java/org/dvsa/testing/framework/stepdefs/permits/ecmtInternationalRemoval/SubmissionPageSteps.java @@ -57,7 +57,7 @@ public void theTextsOnTheSubmissionPageAreDisplayedCorrectly() { assertEquals("What happens next", expectedHeading); assertEquals("We will now post your paper permit within the next 3 working days.", expectedAdvisoryText1); assertEquals("Your valid permits will be grouped together under the same licence number that you applied with.", expectedAdvisoryText2); - assertEquals("Warning" + "\n" + "Make sure your correspondence address is correct on all your operator licences and your email address is up-to-date on your account.", expectedWarningMessage); + assertEquals("Warning Make sure your correspondence address is correct on all your operator licences and your email address is up-to-date on your account.", expectedWarningMessage); } @Then("the view receipt of ECMT International hyperlink opens in a new window") diff --git a/src/test/java/org/dvsa/testing/framework/stepdefs/vol/BatchProcess.java b/src/test/java/org/dvsa/testing/framework/stepdefs/vol/BatchProcess.java index a374ac33f..1e5d0ebc4 100644 --- a/src/test/java/org/dvsa/testing/framework/stepdefs/vol/BatchProcess.java +++ b/src/test/java/org/dvsa/testing/framework/stepdefs/vol/BatchProcess.java @@ -62,7 +62,8 @@ public void theRegistrationShouldBeMarkedAsExpired() throws InterruptedException isElementDisplayed = isElementPresent("//*[contains(@class,'govuk-tag govuk-tag--grey')]", SelectorType.XPATH); refreshPage(); } while (!isElementDisplayed && System.currentTimeMillis() < kickOut); - assertEquals(getText("//*[contains(@class,'govuk-tag govuk-tag--grey')]", SelectorType.XPATH), "EXPIRED"); + String actualText = getText("//*[contains(@class,'govuk-tag govuk-tag--grey')]"); + assertTrue(actualText.equalsIgnoreCase("Expired")); } // @When("i trigger the ebsr process queue") diff --git a/src/test/java/org/dvsa/testing/framework/stepdefs/vol/FinancialEvidence.java b/src/test/java/org/dvsa/testing/framework/stepdefs/vol/FinancialEvidence.java index b5d8492e0..a86f82db1 100644 --- a/src/test/java/org/dvsa/testing/framework/stepdefs/vol/FinancialEvidence.java +++ b/src/test/java/org/dvsa/testing/framework/stepdefs/vol/FinancialEvidence.java @@ -245,7 +245,8 @@ public void theValidFinancialStandingRateValuesShouldBePresent() throws HttpExce @Then("i should be prompted to enter financial evidence information") public void iShouldBePromptedToEnterFinancialEvidenceInformation() { world.selfServeNavigation.navigateToPage("variation", SelfServeSection.VIEW); - assertTrue(isElementPresent("//span[contains(text(),'Financial evidence')]/../strong[contains(text(),'REQUIRES ATTENTION')]", SelectorType.XPATH)); + String actualText = getText("//span[contains(text(),'Financial evidence')]/../strong", SelectorType.XPATH); + assertTrue(actualText.equalsIgnoreCase("Requires Attention")); assertTrue(isLinkPresent("Financial evidence", 10)); } diff --git a/src/test/java/org/dvsa/testing/framework/stepdefs/vol/GoodVarIncreaseVehicle.java b/src/test/java/org/dvsa/testing/framework/stepdefs/vol/GoodVarIncreaseVehicle.java index c70638526..327dca2fd 100644 --- a/src/test/java/org/dvsa/testing/framework/stepdefs/vol/GoodVarIncreaseVehicle.java +++ b/src/test/java/org/dvsa/testing/framework/stepdefs/vol/GoodVarIncreaseVehicle.java @@ -1,13 +1,13 @@ package org.dvsa.testing.framework.stepdefs.vol; -import org.dvsa.testing.framework.Injectors.World; import io.cucumber.java.en.And; import io.cucumber.java.en.Then; import io.cucumber.java.en.When; +import org.dvsa.testing.framework.Injectors.World; import org.dvsa.testing.framework.pageObjects.BasePage; import org.dvsa.testing.framework.pageObjects.enums.SelectorType; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class GoodVarIncreaseVehicle extends BasePage { private final World world; @@ -57,7 +57,7 @@ public void theFeeShouldBePaid(String arg0) { clickByLinkText("Fees"); selectValueFromDropDown("//*[@id='status']", SelectorType.XPATH,"All"); waitForTextToBePresent("Grant Fee for application"); - assertEquals(getText("//table//tbody[tr//*[contains(text(),'Variation Fee for application')]]//strong[contains(@class,'govuk-tag govuk-tag--green')]",SelectorType.XPATH),"PAID"); + assertTrue(getElementValueByText("//table//tbody[tr//*[contains(text(),'Variation Fee for application')]]//strong[contains(@class,'govuk-tag govuk-tag--green')]", SelectorType.XPATH).equalsIgnoreCase("PAID")); } @And("a selfserve user creates a variation and adds an operating centre") diff --git a/src/test/java/org/dvsa/testing/framework/stepdefs/vol/GoodVarUpgrade.java b/src/test/java/org/dvsa/testing/framework/stepdefs/vol/GoodVarUpgrade.java index 81bafe25f..0ff99113a 100644 --- a/src/test/java/org/dvsa/testing/framework/stepdefs/vol/GoodVarUpgrade.java +++ b/src/test/java/org/dvsa/testing/framework/stepdefs/vol/GoodVarUpgrade.java @@ -32,19 +32,19 @@ public void iUpgradeMyLicenceTypeToStandardNational() { @Then("correct statuses are shown by the correct seven sections") public void correctStatusesAreShownByTheCorrectSevenSections() { String typeOfLicenceStatus = getText("//a[@id='overview-item__type_of_licence']//strong[1]", SelectorType.XPATH); - assertTrue(typeOfLicenceStatus.contains("UPDATED")); + assertTrue(typeOfLicenceStatus.equalsIgnoreCase("UPDATED")); String addressesStatus = getText("//a[@id='overview-item__addresses']//strong[1]", SelectorType.XPATH); - assertTrue(addressesStatus.contains("REQUIRES ATTENTION")); + assertTrue(addressesStatus.equalsIgnoreCase("REQUIRES ATTENTION")); String financialEvidenceStatus = getText("//a[@id='overview-item__financial_evidence']//strong[1]", SelectorType.XPATH); - assertTrue(financialEvidenceStatus.contains("REQUIRES ATTENTION")); + assertTrue(financialEvidenceStatus.equalsIgnoreCase("REQUIRES ATTENTION")); String transportManagersStatus = getText("//a[@id='overview-item__transport_managers']//strong[1]", SelectorType.XPATH); - assertTrue(transportManagersStatus.contains("REQUIRES ATTENTION")); + assertTrue(transportManagersStatus.equalsIgnoreCase("REQUIRES ATTENTION")); String financialHistoryStatus = getText("//a[@id='overview-item__financial_history']//strong[1]", SelectorType.XPATH); - assertTrue(financialHistoryStatus.contains("REQUIRES ATTENTION")); + assertTrue(financialHistoryStatus.equalsIgnoreCase("REQUIRES ATTENTION")); String convictionsPenaltiesStatus = getText("//a[@id='overview-item__convictions_penalties']//strong[1]", SelectorType.XPATH); - assertTrue(convictionsPenaltiesStatus.contains("REQUIRES ATTENTION")); + assertTrue(convictionsPenaltiesStatus.equalsIgnoreCase("REQUIRES ATTENTION")); String reviewDeclarationsStatus = getText("//div[@class='overview__item']//strong[1]", SelectorType.XPATH); - assertTrue(reviewDeclarationsStatus.contains("CAN'T START YET")); + assertTrue(reviewDeclarationsStatus.equalsIgnoreCase("CAN'T START YET")); } @And("i complete the required five sections") diff --git a/src/test/java/org/dvsa/testing/framework/stepdefs/vol/PsvSurrenders.java b/src/test/java/org/dvsa/testing/framework/stepdefs/vol/PsvSurrenders.java index 962237241..1fff3e46e 100644 --- a/src/test/java/org/dvsa/testing/framework/stepdefs/vol/PsvSurrenders.java +++ b/src/test/java/org/dvsa/testing/framework/stepdefs/vol/PsvSurrenders.java @@ -35,11 +35,11 @@ public void thePostVerifySuccessPageIsDisplayed() { waitAndClick("//*[contains(text(),'home')]", SelectorType.XPATH); } - @And("the surrender status is {string}") - public void theSurrenderStatusIs(String status) { + @And("the surrender status is Surrender under consideration") + public void theSurrenderStatusIs() { waitForTextToBePresent(world.applicationDetails.getLicenceNumber()); refreshPage(); - assertEquals(getText("//*[contains(@class,'govuk-tag govuk-tag--green')]", SelectorType.XPATH), status.toUpperCase()); + assertTrue(isElementPresent("//*[contains(@class,'govuk-tag govuk-tag--green')]", SelectorType.XPATH)); } @And("the correct contact details should be displayed") diff --git a/src/test/java/org/dvsa/testing/framework/stepdefs/vol/SurrenderLogic.java b/src/test/java/org/dvsa/testing/framework/stepdefs/vol/SurrenderLogic.java index 4e0ca07d2..703d69031 100644 --- a/src/test/java/org/dvsa/testing/framework/stepdefs/vol/SurrenderLogic.java +++ b/src/test/java/org/dvsa/testing/framework/stepdefs/vol/SurrenderLogic.java @@ -54,8 +54,7 @@ public void continueWithApplicationLinkIsDisplayed() { public void userIsTakenToInformationChangePageOnClickingContinueApplication() { clickByLinkText("Continue with"); assertTrue(Browser.navigate().getCurrentUrl().contains("information-changed")); - String expectedChangedText = "Warning\n" + - "Since starting your application to surrender your licence, you have made changes to your licence information."; + String expectedChangedText = "Warning Since starting your application to surrender your licence, you have made changes to your licence information."; String actualChangeText = getText("//*[@class='govuk-warning-text__text']", SelectorType.XPATH); assertEquals(expectedChangedText, actualChangeText); } diff --git a/src/test/java/org/dvsa/testing/framework/stepdefs/vol/Surrenders.java b/src/test/java/org/dvsa/testing/framework/stepdefs/vol/Surrenders.java index 43be72cf2..9bf483a9b 100644 --- a/src/test/java/org/dvsa/testing/framework/stepdefs/vol/Surrenders.java +++ b/src/test/java/org/dvsa/testing/framework/stepdefs/vol/Surrenders.java @@ -78,7 +78,8 @@ public void iChooseToSurrenderMyLicenceWith(String surrenderMethod) throws IOExc } waitForTitleToBePresent("Licences"); refreshPage(); - assertEquals(getText("//*[@class='govuk-tag govuk-tag--green']", SelectorType.XPATH), "SURRENDER UNDER CONSIDERATION"); + String actualText = getText("//*[@class='govuk-tag govuk-tag--green']", SelectorType.XPATH); + assertTrue(actualText.equalsIgnoreCase("Surrender Under Consideration")); } @Given("a caseworker views the surrender details") diff --git a/src/test/java/org/dvsa/testing/framework/stepdefs/vol/VerifySwitchedOff.java b/src/test/java/org/dvsa/testing/framework/stepdefs/vol/VerifySwitchedOff.java index 7f8bd63b3..a1c1bd417 100644 --- a/src/test/java/org/dvsa/testing/framework/stepdefs/vol/VerifySwitchedOff.java +++ b/src/test/java/org/dvsa/testing/framework/stepdefs/vol/VerifySwitchedOff.java @@ -42,7 +42,7 @@ public void transportManagerDetailsApprovedBannerAppears() { @And("transport manager status is {string} and {string}") public void transportManagerStatusIs(String classString, String Text) { assertTrue(isElementPresent(String.format("//*[@class='govuk-tag govuk-tag--%s']", classString), SelectorType.XPATH)); - assertTrue(getText(String.format("//*[@class='govuk-tag govuk-tag--%s']", classString), SelectorType.XPATH).equals(Text.toUpperCase())); + assertTrue(getText(String.format("//*[@class='govuk-tag govuk-tag--%s']", classString), SelectorType.XPATH).equalsIgnoreCase(Text)); } @And("submit to operator button is displayed")