aboutsummaryrefslogtreecommitdiff
path: root/cypress/e2e/login.cy.ts
diff options
context:
space:
mode:
Diffstat (limited to 'cypress/e2e/login.cy.ts')
-rw-r--r--cypress/e2e/login.cy.ts36
1 files changed, 36 insertions, 0 deletions
diff --git a/cypress/e2e/login.cy.ts b/cypress/e2e/login.cy.ts
new file mode 100644
index 0000000..507b1b5
--- /dev/null
+++ b/cypress/e2e/login.cy.ts
@@ -0,0 +1,36 @@
+describe('Login tests', () => {
+ beforeEach(() => {
+ cy.visit('/login');
+ });
+
+ it(
+ 'logs user in with correct credentials and logs user out',
+ {
+ defaultCommandTimeout: 10000,
+ },
+ () => {
+ cy.getDataTest('input-username').find('input').as('inputUsername').click();
+ cy.get('@inputUsername').type(Cypress.env('umami_user'), { delay: 0 });
+ cy.get('@inputUsername').click();
+ cy.getDataTest('input-password')
+ .find('input')
+ .type(Cypress.env('umami_password'), { delay: 0 });
+ cy.getDataTest('button-submit').click();
+ cy.url().should('eq', Cypress.config().baseUrl + '/dashboard');
+ cy.logout();
+ },
+ );
+
+ it('login with blank inputs or incorrect credentials', () => {
+ cy.getDataTest('button-submit').click();
+ cy.contains(/Required/i).should('be.visible');
+
+ cy.getDataTest('input-username').find('input').as('inputUsername');
+ cy.get('@inputUsername').click();
+ cy.get('@inputUsername').type(Cypress.env('umami_user'), { delay: 0 });
+ cy.get('@inputUsername').click();
+ cy.getDataTest('input-password').find('input').type('wrongpassword', { delay: 0 });
+ cy.getDataTest('button-submit').click();
+ cy.contains(/Incorrect username and\/or password./i).should('be.visible');
+ });
+});