Skip to content

Commit

Permalink
[#21] Add artifact upload to test workflow for cypress
Browse files Browse the repository at this point in the history
  • Loading branch information
liamstevens111 committed Mar 3, 2023
1 parent 34943f6 commit 2e47cf0
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 34 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
68 changes: 34 additions & 34 deletions cypress/integration/Authentication/login.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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('[email protected]');
// cy.get('input[name=password]').type('12345678');
// cy.get('button[type="submit"]').click();
cy.get('input[name=email]').type('[email protected]');
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', () => {
Expand All @@ -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('[email protected]');
// cy.get('input[name=password]').type('password123');
// cy.get('button[type="submit"]').click();
cy.get('input[name=email]').type('[email protected]');
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');
});
});
});
});

0 comments on commit 2e47cf0

Please sign in to comment.