Skip to content

Commit

Permalink
fix: update tests + enable typhoon test AB#17590
Browse files Browse the repository at this point in the history
  • Loading branch information
arsforza committed Jan 27, 2023
1 parent c298635 commit dcde991
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<ion-icon
(click)="switchDisasterType(disasterType)"
class="disaster-type-button"
[ngClass]="disasterType?.activeTrigger ? 'triggered' : ''"
data-test="disaster-type-button"
[src]="
getButtonSvg(disasterType.disasterType, disasterType.activeTrigger)
Expand Down
3 changes: 2 additions & 1 deletion tests/cypress/support/backup_old_tests/logout-button.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ describe('Logout Button', () => {
});

it('loads', () => {
cy.get(selectors.logOut).should('be.visible').should('not.be.disabled');
cy.waitForLogoutButton();
});

it('logs out', () => {
cy.waitForLogoutButton();
cy.get(selectors.logOut).click();
cy.url().should((url) => {
expect(url).to.match(
Expand Down
2 changes: 1 addition & 1 deletion tests/cypress/support/backup_old_tests/master-test.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const testCountry = ({ iso3Code, email }) => {
timelineTest(i, iso3Code);
}
});

cy.waitForLogoutButton();
cy.get(selectors.logOut).click();
});
});
Expand Down
17 changes: 11 additions & 6 deletions tests/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@ import constants from './constants';
import selectors from './selectors';
import 'cypress-wait-until';

Cypress.Commands.add('waitForRequests', () => {
cy.intercept({ method: 'GET', url: '**' }).as('getHttp');
cy.wait('@getHttp', { timeout: 10000 });
});
Cypress.Commands.add('waitForRequests', () =>
cy.get(selectors.loader, { timeout: 20000 }).should('not.exist'),
);

Cypress.Commands.add('waitForLogoutButton', () =>
cy
.get(selectors.logOut, { timeout: 10000 })
.should('be.visible')
.should('not.be.disabled'),
);

// Contains a list of custom Commands
Cypress.Commands.add('login', (countryEmail) => {
Expand All @@ -25,8 +31,7 @@ Cypress.Commands.add('login', (countryEmail) => {
});

cy.visit(constants.dashboardPagePath);
cy.waitForRequests();
cy.waitUntil(() => Cypress.$(selectors.loader).length === 0); // https://github.com/NoriSte/cypress-wait-until/issues/75#issuecomment-572685623
cy.waitForRequests(); // https://github.com/NoriSte/cypress-wait-until/issues/75#issuecomment-572685623
});
/* close all popup windows */
Cypress.Commands.add('closeAllTabs', () => {
Expand Down
5 changes: 1 addition & 4 deletions tests/cypress/support/test-functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ Cypress.Commands.add('timelineTest', (countryName) => {

cy.get(selectors.disasterType.disasterTypeButtons).then((buttons) => {
for (let index = 0; index < buttons.length; index++) {
if (countryName === 'PHILIPPINES' && index === 2) {
return;
}
if (index > 0) {
cy.get(selectors.disasterType.disasterTypeButtons).eq(index).click();
}
Expand All @@ -32,6 +29,6 @@ Cypress.Commands.add('timelineTest', (countryName) => {
);
}
});

cy.waitForLogoutButton();
cy.get(selectors.logOut).click();
});

0 comments on commit dcde991

Please sign in to comment.