add prelim website tests
This commit is contained in:
@@ -1,5 +1,24 @@
|
||||
/// <reference types="cypress" />
|
||||
|
||||
Cypress.Commands.add('dataCy', value => {
|
||||
Cypress.Commands.add('dataCy', (value: string) => {
|
||||
return cy.get(`[data-cy=${value}]`);
|
||||
});
|
||||
|
||||
Cypress.Commands.add('login', (username: string, password: string) => {
|
||||
cy.session(
|
||||
[username, password],
|
||||
() => {
|
||||
cy.visit('/login');
|
||||
cy.dataCy('input-username').type(username);
|
||||
cy.dataCy('input-password').type(password);
|
||||
cy.dataCy('button-submit').click();
|
||||
cy.url().should('eq', Cypress.config().baseUrl + '/dashboard');
|
||||
},
|
||||
{
|
||||
validate: () => {
|
||||
cy.visit('/profile');
|
||||
},
|
||||
},
|
||||
);
|
||||
cy.visit('/dashboard');
|
||||
});
|
||||
|
||||
5
cypress/support/index.d.ts
vendored
5
cypress/support/index.d.ts
vendored
@@ -7,5 +7,10 @@ declare namespace Cypress {
|
||||
* @example cy.dataCy('greeting')
|
||||
*/
|
||||
dataCy(value: string): Chainable<JQuery<HTMLElement>>;
|
||||
/**
|
||||
* Custom command to login user into the app.
|
||||
* @example cy.login('admin', 'password)
|
||||
*/
|
||||
login(username: string, password: string): Chainable<JQuery<HTMLElement>>;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user