Skip to content

Commit

Permalink
Update redirect.cy.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaushikgtm authored Dec 19, 2024
1 parent e85098a commit d1156e7
Showing 1 changed file with 18 additions and 26 deletions.
44 changes: 18 additions & 26 deletions cypress/e2e/homepage_spec/redirect.cy.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import LoginPage from "../../pageobject/Login/LoginPage";
import ta from "../../../src/Locale/ta.json";
import ml from "../../../src/Locale/ml.json";
import mr from "../../../src/Locale/mr.json";
import kn from "../../../src/Locale/kn.json";
import hi from "../../../src/Locale/hi.json";
import * as ta from "../../../public/locale/ta.json";
import * as ml from "../../../public/locale/ml.json";
import * as mr from "../../../public/locale/mr.json";
import * as kn from "../../../public/locale/kn.json";
import * as hi from "../../../public/locale/hi.json";

const locales = { hi, ta, ml, mr, kn };

describe("redirect", () => {
const languageMappings = Object.fromEntries(
Object.entries(locales).map(([langCode, locale]) => [langCode, locale["login"]])
const languageMappings = Object.fromEntries(
Object.entries(locales).map(([langCode, locale]) => [langCode, {
login: locale["login"]
}])
);

const languageSidebars = Object.fromEntries(
Expand All @@ -18,11 +20,12 @@ describe("redirect", () => {
{ care: locale["care"], goal: locale["goal"], footer_body: locale["footer_body"] },
])
);

const loginPage = new LoginPage();

beforeEach(() => {
cy.awaitUrl("/", true);
loginPage.ensurePageLoaded();
loginPage.ensureLoggedIn();
cy.log("Logging in the user devdistrictadmin");
});

Expand Down Expand Up @@ -56,30 +59,19 @@ describe("redirect", () => {
.and("contain", "Contribute on GitHub");
});

it("Verify redirection of 'Third Party Software License'", () => {
it("Verify redirection of 'Third Party Software License'", () => {
loginPage.clickThirdPartyLicense();
cy.url({ timeout: 10000 }).should("include", "/licenses");
cy.get("body", { timeout: 10000 })
.should("be.visible")
.and("contain", "Third Party Software License");
});

it("Switch languages and verify login button text", () => {
Object.entries(languageMappings).forEach(([lang, expected]) => {
cy.log(`Testing login button in language: ${lang}`);
loginPage.switchLanguage(lang);
loginPage.getSubmitButton().should("have.text", expected);
});
it("Switch languages and verify login button text", () => {
loginPage.switchLanguageAndVerifyButtonText(languageMappings);
});

it("Switch languages and verify sidebar items", () => {
Object.entries(languageSidebars).forEach(([lang, expected]) => {
cy.log(`Testing sidebar in language: ${lang}`);
loginPage.switchLanguage(lang);
loginPage.getSidebarItems().should(($items) => {
expect($items).to.contain(expected.care);
expect($items).to.contain(expected.goal);
expect($items).to.contain(expected.footer_body);
});
});
});
it("Switch languages and verify sidebar items", () => {
loginPage.switchLanguageAndVerifySidebars(languageSidebars);
});
});

0 comments on commit d1156e7

Please sign in to comment.