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 12, 2024
1 parent b1a1fad commit 42745f7
Showing 1 changed file with 59 additions and 1 deletion.
60 changes: 59 additions & 1 deletion cypress/e2e/auth_spec/redirect.cy.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
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";

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

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

const loginPage = new LoginPage();

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

it("Check if login redirects to the right url", () => {
Expand All @@ -28,4 +46,44 @@ describe("redirect", () => {
loginPage.ensureLoggedIn();
cy.url().should("include", "/facility");
});

it("Verify redirection of 'Contribute on GitHub' link", () => {
loginPage.clickContributeOnGitHub();
cy.url({ timeout: 10000 }).should("include", "https://github.com/ohcnetwork");
cy.get("body", { timeout: 10000 })
.should("be.visible")
.and("contain", "Contribute on GitHub");
});

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", () => {
+ // Verify sidebar content for each language
+ 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", ()=> {
+ // Verify sidebar content for each language
+ 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);
+ });
});
});

0 comments on commit 42745f7

Please sign in to comment.