Skip to content

Commit

Permalink
Update LoginPage.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaushikgtm authored Dec 9, 2024
1 parent 29e045f commit 7fad799
Showing 1 changed file with 35 additions and 38 deletions.
73 changes: 35 additions & 38 deletions cypress/pageobject/Login/LoginPage.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// LoginPage.ts

class LoginPage {
submitButtonSelector = "#login";
submitButtonSelector = "#Login";
languageSelector = "#language-selector";
sidebarSelector = "#sidebar";

loginAsDisctrictAdmin(): void {
cy.loginByApi("devdistrictadmin", "Coronasafe@123");
}
Expand Down Expand Up @@ -52,47 +52,44 @@ class LoginPage {
clickThirdPartyLicense() {
cy.get('a[href="/licenses"]').scrollIntoView().click();
}

switchLanguageAndVerifyButtonText(languageMappings: { [key: string]: string }) {
Object.entries(languageMappings).forEach(([languageCode, expectedText]) => {
cy.get(this.languageSelector)
.find(`option[value="${languageCode}"]`)
.should("exist");

selectLanguage(languageCode: string) {
cy.get(this.languageSelector).select(languageCode);
}
this.selectLanguage(languageCode);

verifySubmitButtonText(expectedText: string) {
cy.get(this.submitButtonSelector).should("have.text", expectedText);
}

switchLanguageAndVerifyButtonText(languageMappings: {
[key: string]: string;
}) {
Object.entries(languageMappings).forEach(([languageCode, expectedText]) => {
this.selectLanguage(languageCode);
+ cy.get(this.languageSelector)
+ .find(`option[value="${languageCode}"]`)
+ .should('exist')
+ .then(() => {
+ cy.get(this.submitButtonSelector, { timeout: 10000 })
+ .should("be.visible")
+ .should("have.text", expectedText);
});
cy.get(this.submitButtonSelector, { timeout: 10000 })
.should("be.visible")
.and("have.text", expectedText);
});
}

selectSidebarLanguage(languageCode: string) {
cy.get(this.languageSelector).select(languageCode);
}
}

verifySidebarText(expectedText: string) {
+ cy.get(this.sidebarSelector).should("have.text", expectedText);
}
switchLanguageAndVerifySidebars(languageMappings: {
[key: string]: { care: string; goal: string; footer_body: string };
}) {
Object.entries(languageMappings).forEach(([languageCode, expectedSidebarText]) => {
cy.get(this.languageSelector)
.find(`option[value="${languageCode}"]`)
.should("exist")
.select(languageCode);

cy.get("#care", { timeout: 10000 })
.should("be.visible")
.and("have.text", expectedSidebarText.care);

cy.get("#goal", { timeout: 10000 })
.should("be.visible")
.and("have.text", expectedSidebarText.goal);

cy.get("#footer_body", { timeout: 10000 })
.should("be.visible")
.and("have.text", expectedSidebarText.footer_body);
});
}

switchLanguageAndVerifySidebars(languageMappings: { [key: string]: string }) {
Object.entries(languageMappings).forEach(([languageCode, expectedText]) => {
this.selectLanguage(languageCode);
cy.get(this.sidebarSelector, { timeout: 10000 })
+ .should("be.visible")
+ .and("have.text", expectedText);
});
}
}

export default LoginPage;

0 comments on commit 7fad799

Please sign in to comment.