From d1156e727ab3009842814abf5d86c454019ad42a Mon Sep 17 00:00:00 2001 From: Kaushikgtm <162317291+Kaushikgtm@users.noreply.github.com> Date: Thu, 19 Dec 2024 17:56:05 +0530 Subject: [PATCH] Update redirect.cy.ts --- cypress/e2e/homepage_spec/redirect.cy.ts | 44 ++++++++++-------------- 1 file changed, 18 insertions(+), 26 deletions(-) diff --git a/cypress/e2e/homepage_spec/redirect.cy.ts b/cypress/e2e/homepage_spec/redirect.cy.ts index 71d24288bfe..5e2f3733af8 100644 --- a/cypress/e2e/homepage_spec/redirect.cy.ts +++ b/cypress/e2e/homepage_spec/redirect.cy.ts @@ -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( @@ -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"); }); @@ -56,7 +59,7 @@ 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 }) @@ -64,22 +67,11 @@ describe("redirect", () => { .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); + }); });