Files
tm_panel/cypress/e2e/auth/sign-in-theme-persistence.cy.ts
T
AmirReza Jamali eab516c7f3 feat(tests, components): enhance Cypress commands and UI elements for improved testing and accessibility
- Added new Cypress commands for mocking admin-related API interactions, including list, create, update, delete, and change status functionalities.
- Introduced data-cy attributes across various components (e.g., Breadcrumbs, Forms, Tables) to improve testability and accessibility.
- Updated existing components to support new data-cy attributes for better integration with Cypress tests.
2026-04-25 13:25:23 +03:30

54 lines
1.4 KiB
TypeScript

/// <reference types="cypress" />
export {};
Cypress.env("AUTO_LOGIN", false);
describe("sign-in theme persistence", () => {
after(() => {
Cypress.env("AUTO_LOGIN", true);
});
beforeEach(() => {
cy.clearCookies();
cy.clearLocalStorage();
cy.intercept("POST", "**/api/proxy/profile/login*", (req) => {
req.reply({
delay: 2500,
statusCode: 200,
body: {
success: true,
message: "ok",
data: {
access_token: "e2e-access-token",
refresh_token: "e2e-refresh-token",
expires_at: Date.now() + 60_000,
user: {
id: "507f1f77bcf86cd799439011",
username: "tester",
email: "tester@example.com",
role: "admin",
},
},
},
});
}).as("loginRequest");
cy.visit("/auth/sign-in");
cy.location("pathname").should("eq", "/auth/sign-in");
});
it("keeps selected theme after user logs in and lands on dashboard", () => {
cy.contains("button", "Switch to dark mode").click();
cy.get("html").should("have.class", "dark");
cy.get('input[name="username"]').type("tester");
cy.get('input[name="password"]').type("Secret123!");
cy.contains('button[type="submit"]', "Sign in").click();
cy.wait("@loginRequest");
cy.location("pathname").should("eq", "/");
cy.get("html").should("have.class", "dark");
});
});