From 2e47cf0abebd830f798a0d48ca152b1b69b5868e Mon Sep 17 00:00:00 2001 From: Liam Stevens <8955671+liamstevens111@users.noreply.github.com> Date: Fri, 3 Mar 2023 18:08:06 +0700 Subject: [PATCH] [#21] Add artifact upload to test workflow for cypress --- .github/workflows/test.yml | 6 ++ .../integration/Authentication/login.spec.ts | 68 +++++++++---------- 2 files changed, 40 insertions(+), 34 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 824e125..cbaf1df 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -33,6 +33,12 @@ jobs: - name: Run integration tests run: npm run cypress + - uses: actions/upload-artifact@v3 + if: failure() + with: + name: my-artifact + path: cypress/videos/ + - name: Merge code coverage reports run: npm run test:merge-coverage diff --git a/cypress/integration/Authentication/login.spec.ts b/cypress/integration/Authentication/login.spec.ts index 1451e52..f6e3ba1 100644 --- a/cypress/integration/Authentication/login.spec.ts +++ b/cypress/integration/Authentication/login.spec.ts @@ -9,24 +9,24 @@ describe('User Authentication', () => { // TODO: The below test fail on CI/CD with the use of Intercept - // context('given valid credentials', () => { - // it('redirects to the home page', () => { - // cy.intercept('POST', '/oauth/token/', { - // statusCode: 200, - // fixture: 'Authentication/valid-credentials.json', - // }); + context('given valid credentials', () => { + it('redirects to the home page', () => { + cy.intercept('POST', '/oauth/token/', { + statusCode: 200, + fixture: 'Authentication/valid-credentials.json', + }); - // cy.visit('/login'); + cy.visit('/login'); - // cy.get('input[name=email]').type('liam@nimblehq.co'); - // cy.get('input[name=password]').type('12345678'); - // cy.get('button[type="submit"]').click(); + cy.get('input[name=email]').type('liam@nimblehq.co'); + cy.get('input[name=password]').type('12345678'); + cy.get('button[type="submit"]').click(); - // cy.location().should((location) => { - // expect(location.pathname).to.eq('/'); - // }); - // }); - // }); + cy.location().should((location) => { + expect(location.pathname).to.eq('/'); + }); + }); + }); context('given NO credentials entered', () => { it('shows field validation errors', () => { @@ -45,28 +45,28 @@ describe('User Authentication', () => { // TODO: The below test fail on CI/CD with the use of Intercept - // context('given INVALID credentials', () => { - // it('shows login error', () => { - // cy.intercept('POST', '/oauth/token/', { - // statusCode: 400, - // fixture: 'Authentication/invalid-credentials.json', - // }); + context('given INVALID credentials', () => { + it('shows login error', () => { + cy.intercept('POST', '/oauth/token/', { + statusCode: 400, + fixture: 'Authentication/invalid-credentials.json', + }); - // cy.visit('/login'); + cy.visit('/login'); - // cy.get('input[name=email]').type('testemail@gmail.com'); - // cy.get('input[name=password]').type('password123'); - // cy.get('button[type="submit"]').click(); + cy.get('input[name=email]').type('testemail@gmail.com'); + cy.get('input[name=password]').type('password123'); + cy.get('button[type="submit"]').click(); - // cy.location().should((location) => { - // expect(location.pathname).to.eq('/login'); - // }); + cy.location().should((location) => { + expect(location.pathname).to.eq('/login'); + }); - // cy.get('.errors').should('be.visible'); + cy.get('.errors').should('be.visible'); - // cy.get('.errors').within(() => { - // cy.findByText('Your email or password is incorrect. Please try again.').should('exist'); - // }); - // }); - // }); + cy.get('.errors').within(() => { + cy.findByText('Your email or password is incorrect. Please try again.').should('exist'); + }); + }); + }); });