eab516c7f3
- 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.
38 lines
1.0 KiB
TypeScript
38 lines
1.0 KiB
TypeScript
/// <reference types="cypress" />
|
|
export {};
|
|
|
|
Cypress.env("AUTO_LOGIN", false);
|
|
|
|
describe("admins management - authentication and route protection", () => {
|
|
after(() => {
|
|
Cypress.env("AUTO_LOGIN", true);
|
|
});
|
|
|
|
beforeEach(() => {
|
|
cy.clearCookies();
|
|
cy.clearLocalStorage();
|
|
});
|
|
|
|
it("redirects unauthorized users to login page", () => {
|
|
cy.visit("/admins");
|
|
cy.location("pathname").should("eq", "/auth/sign-in");
|
|
});
|
|
|
|
it("handles expired token by redirecting to login after refresh failure", () => {
|
|
cy.setAuthCookies();
|
|
cy.intercept("GET", "**/api/proxy/users**", {
|
|
statusCode: 401,
|
|
body: { error: { message: "Token expired" } },
|
|
}).as("getAdmins401");
|
|
cy.intercept("POST", "**/api/proxy/profile/refresh-token", {
|
|
statusCode: 401,
|
|
body: { error: { message: "Refresh token expired" } },
|
|
}).as("refresh401");
|
|
|
|
cy.visit("/admins");
|
|
cy.wait("@getAdmins401");
|
|
cy.wait("@refresh401");
|
|
cy.location("pathname").should("eq", "/auth/sign-in");
|
|
});
|
|
});
|