34 lines
1.1 KiB
TypeScript
34 lines
1.1 KiB
TypeScript
// ***********************************************
|
|
// This example commands.ts shows you how to
|
|
// create various custom commands and overwrite
|
|
// existing commands.
|
|
//
|
|
// For more comprehensive examples of custom
|
|
// commands please read more here:
|
|
// https://on.cypress.io/custom-commands
|
|
// ***********************************************
|
|
|
|
Cypress.Commands.add("login", (username = "admin", password = "admin123") => {
|
|
cy.visit("/login");
|
|
cy.get('input[name="username"]').type(username);
|
|
cy.get('input[name="password"]').type(password);
|
|
cy.get('button[type="submit"]').click();
|
|
cy.url().should("not.include", "/login");
|
|
cy.contains("داشبورد", { timeout: 10000 }).should("be.visible");
|
|
});
|
|
|
|
Cypress.Commands.add("logout", () => {
|
|
cy.get(".bg-primary-600.rounded-full").first().click();
|
|
cy.contains("خروج").click();
|
|
cy.url().should("include", "/login");
|
|
});
|
|
|
|
Cypress.Commands.add("getByTestId", (testId: string) => {
|
|
return cy.get(`[data-testid="${testId}"]`);
|
|
});
|
|
|
|
Cypress.Commands.add("waitForLoading", () => {
|
|
// Wait for any loading spinner to disappear
|
|
cy.get(".animate-spin", { timeout: 1000 }).should("not.exist");
|
|
});
|