Skip to content

Commit

Permalink
test: fix broken tests (#17)
Browse files Browse the repository at this point in the history
* fix broken unit tests
* fix broken e2e tests
  • Loading branch information
grantwforsythe authored May 29, 2024
1 parent 3ff078e commit e0a29ea
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
16 changes: 8 additions & 8 deletions cypress/e2e/spec.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ describe('Custom Reports for YNAB', () => {
describe('Home', () => {
it('Should logout', () => {
cy.visit('/');
cy.get('header button').last().should('contain', 'Logout').click();
cy.get('header button').should('contain', 'Authenticate');
cy.get('header a').should('not.contain', 'Report');
cy.get('header a').last().should('contain', 'Logout').click();
cy.get('header a').last().should('contain', 'Login');
cy.get('header a').last().should('not.contain', 'Report');
});

it('Should create new issue on GitHub', () => {
cy.visit('/');
cy.get('header a')
.last()
cy.get('header a.mdc-button:nth-child(1)')
.first()
.should('contain', 'Report')
.should(
'have.attr',
Expand All @@ -43,11 +43,11 @@ describe('Custom Reports for YNAB', () => {
cy.get('p a').contains('privacy policy').click();
cy.location().should((location) => expect(location.pathname).to.eq('/privacy'));
cy.get('h1').should('contain', 'Privacy Policy');
cy.get('div a').should('have.attr', 'href', 'https://api.ynab.com/#terms');
cy.get('p a').should('have.attr', 'href', 'https://api.ynab.com/#terms');
});

it('Should access privacy page when not authenticated', () => {
cy.get('header button').last().should('contain', 'Logout').click();
cy.get('header a').last().should('contain', 'Logout').click();
cy.visit('/privacy');
cy.get('h1').should('contain', 'Privacy Policy');
});
Expand All @@ -63,7 +63,7 @@ describe('Custom Reports for YNAB', () => {

it('Should not be able to visit budgets when not authenticated', () => {
cy.visit('/');
cy.get('header button').last().should('contain', 'Logout').click();
cy.get('header a').last().should('contain', 'Logout').click();
cy.visit('/budgets');
cy.location().should((location) => expect(location.pathname).to.eq('/'));
});
Expand Down
8 changes: 4 additions & 4 deletions src/app/login/login.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,16 @@ describe('LoginComponent', () => {

fixture.detectChanges();

const button: HTMLElement = fixture.nativeElement.querySelector('button');
expect(button.textContent).toEqual('Authenticate');
const button: HTMLElement = fixture.nativeElement.querySelector('a[color="accent"]');
expect(button.textContent?.trim()).toEqual('Login');
});

it('should display logout button', () => {
authServiceSpy.isAuthenticated.and.returnValue(true);

fixture.detectChanges();

const button: HTMLElement = fixture.nativeElement.querySelector('button');
expect(button.textContent).toEqual('Logout');
const button: HTMLElement = fixture.nativeElement.querySelector('a[color="accent"]');
expect(button.textContent?.trim()).toEqual('Logout');
});
});

0 comments on commit e0a29ea

Please sign in to comment.