Skip to content

Commit

Permalink
Prevent caching of Intercom Messenger script during onLoad Cypress test
Browse files Browse the repository at this point in the history
  • Loading branch information
fluidsonic committed Jun 11, 2024
1 parent a58608e commit e7954c5
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions apps/playground/cypress/e2e/loadCallbacks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

describe('onLoad/onLoadFailed', () => {
it('should call onLoad when successful', () => {
cy.intercept('https://widget.intercom.io/widget/jcabc7e3', (request) => {
request.continue((response) => {
response.headers['cache-control'] = 'no-cache';
});
});

cy.visit('/useIntercomWithLoadCallbacks');

cy.get('[data-cy=call]').should(($p) =>
Expand All @@ -10,12 +16,12 @@ describe('onLoad/onLoadFailed', () => {
});

it('should call onLoadFailed when not successful', () => {
cy.visit('/useIntercomWithLoadCallbacks');

cy.intercept('https://widget.intercom.io/widget/jcabc7e3', {
forceNetworkError: true,
});

cy.visit('/useIntercomWithLoadCallbacks');

cy.get('[data-cy=call]').should(($p) =>
expect($p).to.have.text('onLoadFailed was called!'),
);
Expand Down

0 comments on commit e7954c5

Please sign in to comment.