Skip to content

Commit 059028f

Browse files
committed
Fix boot test
1 parent 8ba5a9f commit 059028f

1 file changed

Lines changed: 22 additions & 19 deletions

File tree

  • packages/react-use-intercom/cypress/e2e
Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,40 @@
1-
/// <reference types="cypress" />
2-
31
describe('boot', () => {
2+
beforeEach(() => {
3+
cy.visit('/useIntercom');
4+
5+
cy.intercept('https://api-iam.intercom.io/messenger/web/ping').as(
6+
'intercomPing',
7+
);
8+
});
9+
410
afterEach(() => {
511
cy.get('[data-cy=shutdown]').click();
612
});
713

814
it('should boot when calling `boot`', () => {
9-
cy.visit('/useIntercom');
10-
1115
cy.window().should('not.have.property', 'intercomSettings');
1216

1317
cy.get('[data-cy=boot]').click();
14-
cy.contains('.intercom-lightweight-app-launcher-icon-open');
18+
19+
// Wait for the route aliased as 'intercomPing' to respond
20+
// without changing or stubbing its response
21+
cy.wait('@intercomPing');
22+
23+
cy.get('.intercom-lightweight-app-launcher-icon-open').should('exist');
1524
cy.window().should('have.property', 'Intercom');
1625
cy.window().should('have.deep.property', 'intercomSettings', {
1726
app_id: 'jcabc7e3',
1827
});
1928
});
2029

2130
it('should boot with seeded data when calling `boot`', () => {
22-
cy.visit('/useIntercom');
23-
2431
cy.window().should('not.have.property', 'intercomSettings');
2532

2633
cy.get('[data-cy=boot-seeded]').click();
27-
cy.contains('.intercom-lightweight-app-launcher-icon-open');
34+
35+
cy.wait('@intercomPing');
36+
37+
cy.get('.intercom-lightweight-app-launcher-icon-open').should('exist');
2838
cy.window().should('have.property', 'Intercom');
2939
cy.window().should('have.deep.property', 'intercomSettings', {
3040
app_id: 'jcabc7e3',
@@ -33,19 +43,12 @@ describe('boot', () => {
3343
});
3444

3545
it('should disable all methods before calling `boot`', () => {
36-
cy.visit('/useIntercom');
37-
3846
cy.get('[data-cy=update]').click();
39-
cy.get('.intercom-lightweight-app-launcher-icon-open').should(
40-
'not.exist',
41-
);
47+
cy.get('.intercom-lightweight-app-launcher-icon-open').should('not.exist');
4248
cy.get('[data-cy=update-seeded]').click();
43-
cy.get('.intercom-lightweight-app-launcher-icon-open').should(
44-
'not.exist',
45-
);
49+
50+
cy.get('.intercom-lightweight-app-launcher-icon-open').should('not.exist');
4651
cy.get('[data-cy=show]').click();
47-
cy.get('.intercom-lightweight-app-launcher-icon-open').should(
48-
'not.exist',
49-
);
52+
cy.get('.intercom-lightweight-app-launcher-icon-open').should('not.exist');
5053
});
5154
});

0 commit comments

Comments
 (0)