Skip to content

Commit

Permalink
fix(e2e): fix to fixtures in e2e integration tests (#8350)
Browse files Browse the repository at this point in the history
### Related Ticket(s)

No related issue

### Description

This makes adjustments to the fixtures in cypress for the e2e integration tests to behave properly (like the e2e storybook tests).

### Changelog

**Changed**

- Moved cypress fixtures to load globally in all tests
- Removed the custom command for mocking fixtures
  • Loading branch information
jeffchew authored Feb 25, 2022
1 parent f1502ae commit 47e207c
Show file tree
Hide file tree
Showing 25 changed files with 3,307 additions and 99 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ carbon-tools
.yarn
CHANGELOG.md
packages/**/src/internal/vendor
packages/**/tests/e2e/cypress
packages/**/tests/e2e-storybook/cypress
packages/web-components/tests/snapshots
packages/web-components/tests/e2e/build/examples-scaffold
Expand Down
8 changes: 8 additions & 0 deletions packages/react/tests/e2e/cypress/fixtures/ibm-common.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Copyright IBM Corp. 2022
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/

module.exports = {}
1,567 changes: 1,567 additions & 0 deletions packages/react/tests/e2e/cypress/fixtures/translation-raw.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions packages/react/tests/e2e/cypress/fixtures/typeahead.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "response" : [ ["test", "0"],["testing", "1"],["tester", "2"],["test automation", "3"],["testing jobs", "4"],["test realtime", "5"],["test of between subjects effects", "6"],["test data management", "7"],["test specialist", "8"],["test tls 1.2", "9"] ] }
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright IBM Corp. 2021
* Copyright IBM Corp. 2021, 2022
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
Expand All @@ -8,10 +8,6 @@
'use strict';

describe('DotcomShell', () => {
beforeEach(() => {
cy.mockMastheadFooterData();
});

it('should load the default DotcomShell example', () => {
cy.visit('/DotcomShell');

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright IBM Corp. 2021
* Copyright IBM Corp. 2021, 2022
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
Expand All @@ -8,10 +8,6 @@
'use strict';

describe('Footer', () => {
beforeEach(() => {
cy.mockMastheadFooterData();
});

it('should load the default Footer example', () => {
cy.visit('/Footer');

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright IBM Corp. 2021
* Copyright IBM Corp. 2021, 2022
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
Expand All @@ -8,10 +8,6 @@
'use strict';

describe('LocaleModal', () => {
beforeEach(() => {
cy.mockMastheadFooterData();
});

it('should load the default LocaleModal example', () => {
cy.visit('/LocaleModal');

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright IBM Corp. 2021
* Copyright IBM Corp. 2021, 2022
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
Expand All @@ -8,10 +8,6 @@
'use strict';

describe('Masthead', () => {
beforeEach(() => {
cy.mockMastheadFooterData();
});

it('should load the default Masthead example', () => {
cy.visit('/Masthead');

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright IBM Corp. 2021
* Copyright IBM Corp. 2021, 2022
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
Expand All @@ -8,10 +8,6 @@
'use strict';

describe('Masthead L1', () => {
beforeEach(() => {
cy.mockMastheadFooterData();
});

it('should load the default Masthead L1 example', () => {
cy.visit('/MastheadL1');

Expand Down
19 changes: 1 addition & 18 deletions packages/react/tests/e2e/cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,6 @@
/**
* Copyright IBM Corp. 2021
* Copyright IBM Corp. 2021, 2022
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/

/**
* Mocks the Masthead/Footer data
*/
Cypress.Commands.add('mockMastheadFooterData', () => {
cy.intercept(
'https://1.www.s81c.com/common/js/dynamicnav/www/countrylist/jsononly/usen-utf8.json',
{ fixture: 'countrylist.json' }
);
cy.intercept(
'https://1.www.s81c.com/common/carbon-for-ibm-dotcom/translations/masthead-footer/usen.json',
{ fixture: 'translation.json' }
);
cy.intercept('https://login.ibm.com/v1/mgmt/idaas/user/status/', {
fixture: 'status.json',
});
});
74 changes: 73 additions & 1 deletion packages/react/tests/e2e/cypress/support/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,81 @@
/**
* Copyright IBM Corp. 2021
* Copyright IBM Corp. 2021, 2022
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/

import '@percy/cypress';
import './commands';

beforeEach(() => {
// Mock the country list
cy.intercept(
'https://1.www.s81c.com/common/js/dynamicnav/www/countrylist/jsononly/usen-utf8.json',
{
fixture: 'countrylist.json',
}
);

// Mock the translation file
cy.intercept(
'https://1.www.s81c.com/common/carbon-for-ibm-dotcom/translations/masthead-footer/usen.json',
{
fixture: 'translation-raw.json',
}
);

// Mock the user status
cy.intercept('https://login.ibm.com/v1/mgmt/idaas/user/status/\n', {
fixture: 'status.json',
});

cy.intercept('https://prepiam.ice.ibmcloud.com/v1/mgmt/idaas/user/status/', {
fixture: 'status.json',
});

// Mock search typeahead API
cy.intercept('**/search/typeahead/v1?*', {
fixture: 'typeahead.json',
});

// Block ibm-common.js
cy.intercept('https://1.www.s81c.com/common/stats/ibm-common.js', {
fixture: 'ibm-common.js',
});

// Mock Kaltura API
// cy.intercept('https://cdnapisec.kaltura.com/api_v3/index.php?*', {
// fixture: 'kaltura.json',
// });

// Set an initial `digitalData` object
cy.window().then(win => {
win.digitalData = {
page: {
category: {
primaryCategory: '',
},
pageInfo: {
effectiveDate: '',
expiryDate: '',
language: 'en-US',
publishDate: '',
publisher: '',
version: 'Carbon for IBM.com',
ibm: {
contentDelivery: '',
contentProducer: '',
country: 'US',
industry: '',
owner: '',
siteID: '',
subject: '',
type: '',
},
},
isDataLayerReady: true,
},
};
});
});
1 change: 1 addition & 0 deletions packages/web-components/.prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ docs
storybook-static
storybook-static-react
CHANGELOG.md
tests/e2e/cypress/fixtures
tests/e2e-storybook/cypress/fixtures
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Copyright IBM Corp. 2022
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/

module.exports = {}
Loading

0 comments on commit 47e207c

Please sign in to comment.