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.
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
/// <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");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user