Skip to content

Commit

Permalink
Update LoginPage.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaushikgtm authored Nov 28, 2024
1 parent b1a1fad commit b71eb4c
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions cypress/pageobject/Login/LoginPage.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// LoginPage.ts

class LoginPage {
submitButtonSelector = "login";
languageSelector = "language-selector";
sidebarSelector = "sidebar";
loginAsDisctrictAdmin(): void {
cy.loginByApi("devdistrictadmin", "Coronasafe@123");
}
Expand Down Expand Up @@ -34,6 +37,52 @@ class LoginPage {
cy.get("#sign-out-button").scrollIntoView();
cy.get("#sign-out-button").contains("Sign Out").should("exist");
}

ensurePageLoaded() {
cy.get("body").should("contain", "Login");
}

clickContributeOnGitHub() {
cy.get("https://github.com/ohcnetwork").scrollIntoView().click();
}

clickThirdPartyLicense() {
cy.get("/licenses").scrollIntoView().click();
}

selectLanguage(languageCode: string) {
cy.get(this.languageSelector).select(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.wait(500);
this.verifySubmitButtonText(expectedText);
});
}

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

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

switchLanguageAndVerifySidebars(languageMappings: { [key: string]: string }) {
Object.entries(languageMappings).forEach(([languageCode, expectedText]) => {
this.selectSidebarLanguage(languageCode);
cy.wait(500);
this.verifySidebarText(expectedText);
});
}
}

export default LoginPage;

0 comments on commit b71eb4c

Please sign in to comment.