Skip to content

Commit 9e777c8

Browse files
authored
chore: upgrade react-scripts (#354)
* chore: upgrade react-scripts * chore: node-sass -> sass * chore: upgrade eslint * chore: upgrade webpack * fix: upgrade to Storybook v6 * fix: use buffer polyfill * fix: example app build * ci: don't fail build due to warnings * chore: upgrade to cypress 7.x * chore: upgrade to cypress 8.x * chore: upgrade cypress v10 * test: cy.server -> cy.intercept * chore: better handling of node polyfills * test: fix left-over fixtures * chore: add 'prepack' scripts * chore: use `sass-embedded` instead of `sass` * chore: back to `sass` `sass-embedded` doesn't (yet) have a CLI * chore: upgrade pkgs * chore: upgrade storybook deps * chore: upgrade yarn
1 parent bbbdd99 commit 9e777c8

File tree

43 files changed

+8028
-8163
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+8028
-8163
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
diff --git a/.vscode/diff/vulsCount.txt b/.vscode/diff/vulsCount.txt
2+
new file mode 100644
3+
index 0000000000000000000000000000000000000000..c227083464fb9af8955c90d2924774ee50abb547
4+
--- /dev/null
5+
+++ b/.vscode/diff/vulsCount.txt
6+
@@ -0,0 +1 @@
7+
+0
8+
\ No newline at end of file
9+
diff --git a/config/webpack.config.js b/config/webpack.config.js
10+
index e465d8e7a00ec889e9c4c29ba7812019f8319a41..60e754e0923304b717e42f80b92eab57d1136430 100644
11+
--- a/config/webpack.config.js
12+
+++ b/config/webpack.config.js
13+
@@ -37,6 +37,7 @@ const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin'
14+
const getCacheIdentifier = require('react-dev-utils/getCacheIdentifier');
15+
// @remove-on-eject-end
16+
const createEnvironmentHash = require('./webpack/persistentCache/createEnvironmentHash');
17+
+const NodePolyfillPlugin = require("node-polyfill-webpack-plugin");
18+
19+
// Source maps are resource heavy and can cause out of memory issue for large source files.
20+
const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== 'false';
21+
@@ -303,6 +304,14 @@ module.exports = function (webpackEnv) {
22+
],
23+
},
24+
resolve: {
25+
+ fallback: {
26+
+ // requested by ibm-watson
27+
+ // @see https://github.com/watson-developer-cloud/node-sdk/tree/master/examples/webpack
28+
+ fs: false,
29+
+ module: false,
30+
+ net: false,
31+
+ tls: false,
32+
+ },
33+
// This allows you to set a fallback for where webpack should look for modules.
34+
// We placed these paths second because we want `node_modules` to "win"
35+
// if there are any conflicts. This matches Node resolution mechanism.
36+
@@ -604,6 +613,9 @@ module.exports = function (webpackEnv) {
37+
].filter(Boolean),
38+
},
39+
plugins: [
40+
+ new NodePolyfillPlugin({
41+
+ excludeAliases: ['console']
42+
+ }),
43+
// Generates an `index.html` file with the <script> injected.
44+
new HtmlWebpackPlugin(
45+
Object.assign(

.yarn/releases/yarn-3.1.0.cjs

Lines changed: 0 additions & 768 deletions
This file was deleted.

.yarn/releases/yarn-3.2.3.cjs

Lines changed: 783 additions & 0 deletions
Large diffs are not rendered by default.

.yarnrc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ plugins:
88
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
99
spec: "@yarnpkg/plugin-workspace-tools"
1010

11-
yarnPath: .yarn/releases/yarn-3.1.0.cjs
11+
yarnPath: .yarn/releases/yarn-3.2.3.cjs

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -179,16 +179,16 @@ If you don't have a React application already, start with [create-react-app](htt
179179
npm install --save @ibm-watson/discovery-react-components @ibm-watson/discovery-styles ibm-watson carbon-components carbon-components-react carbon-icons
180180
```
181181
182-
2. Add `node-sass` as a dev dependency
182+
2. Add `sass` (or `sass-embedded`) as a dev dependency
183183
184184
```
185-
yarn add -D node-sass
185+
yarn add -D sass
186186
```
187187
188188
or
189189
190190
```
191-
npm install --save-dev node-sass
191+
npm install --save-dev sass
192192
```
193193
194194
3. Add the `DiscoverySearch` component with corresponding `searchClient` and optionally any components you would like to use to display Discovery Search Results.
@@ -464,10 +464,10 @@ See the following for [more info about Lerna](https://github.com/lerna/lerna) or
464464

465465
#### Styles (packages/discovery-styles)
466466

467-
| Command | Description |
468-
| ------------ | ------------------------------------------------- |
469-
| `yarn start` | runs `node-sass` in `watch` mode |
470-
| `yarn build` | runs `node-sass` to compile `scss` files to `css` |
467+
| Command | Description |
468+
| ------------ | -------------------------------------------- |
469+
| `yarn start` | runs `sass` in `watch` mode |
470+
| `yarn build` | runs `sass` to compile `scss` files to `css` |
471471

472472
### Running the project
473473

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { defineConfig } from 'cypress';
2+
3+
export default defineConfig({
4+
defaultCommandTimeout: 30000,
5+
video: false,
6+
retries: {
7+
runMode: 2,
8+
openMode: 0
9+
},
10+
e2e: {
11+
setupNodeEvents(on, config) {},
12+
baseUrl: 'http://localhost:3000/'
13+
}
14+
});

examples/discovery-search-app/cypress.json

Lines changed: 0 additions & 10 deletions
This file was deleted.

examples/discovery-search-app/cypress/integration/autocomplete/spec.ts renamed to examples/discovery-search-app/cypress/e2e/autocomplete/autocomplete.cy.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ describe('Autocomplete', () => {
44
beforeEach(() => {
55
mockHomePage();
66

7-
// Set up/override routes & fixtures that are specific to this file
8-
cy.fixture('autocompletion/autocompletions.json').as('autocompletionsJSON');
9-
107
// Set an alias for the search input
118
cy.findByPlaceholderText('Search').as('searchInput');
129
});
@@ -16,11 +13,9 @@ describe('Autocomplete', () => {
1613
const expectedAutocompletions = ['have', 'helm', 'how', 'hadoop', 'hive', 'hostname', 'high'];
1714

1815
beforeEach(() => {
19-
cy.route(
20-
'GET',
21-
'**/autocompletion?version=2019-01-01&prefix=h&count=7',
22-
'@autocompletionsJSON'
23-
).as('getAutocompletions');
16+
cy.intercept('GET', '**/autocompletion?version=2019-01-01&prefix=h&count=7', {
17+
fixture: 'autocompletion/autocompletions.json'
18+
}).as('getAutocompletions');
2419
cy.get('@searchInput').type('h');
2520
cy.wait('@getAutocompletions');
2621
});
@@ -56,7 +51,9 @@ describe('Autocomplete', () => {
5651

5752
describe('When typing " " into the search input', () => {
5853
beforeEach(() => {
59-
cy.route('POST', '**/query?version=2019-01-01', '@queryJSON').as('postQuery');
54+
cy.intercept('POST', '**/query?version=2019-01-01', { fixture: 'query/query.json' }).as(
55+
'postQuery'
56+
);
6057
cy.get('@searchInput').type(' ');
6158
});
6259

@@ -72,7 +69,7 @@ describe('Autocomplete', () => {
7269
});
7370

7471
it('performs a query with the correct term', () => {
75-
cy.get('@postQuery').its('requestBody.natural_language_query').should('be.eq', ' ');
72+
cy.get('@postQuery').its('request.body.natural_language_query').should('be.eq', ' ');
7673
});
7774
});
7875
});

examples/discovery-search-app/cypress/integration/basic/spec.ts renamed to examples/discovery-search-app/cypress/e2e/basic/basic.cy.ts

Lines changed: 22 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ describe('Basic search', () => {
44
beforeEach(() => {
55
mockHomePage();
66

7-
// Set up/override routes & fixtures that are specific to this file
8-
cy.fixture('query/noResults.json').as('noResultsJSON');
9-
cy.fixture('query/error500.json').as('error500JSON');
10-
117
// set an alias for the search input, since we're using that a lot
128
cy.findByPlaceholderText('Search').as('searchInput');
139
});
@@ -21,11 +17,11 @@ describe('Basic search', () => {
2117

2218
// Querying with results
2319
cy.get('@searchInput').type('abil{enter}');
24-
cy.get('@postQuery').its('requestBody.natural_language_query').should('eq', 'abil');
20+
cy.get('@postQuery').its('request.body.natural_language_query').should('eq', 'abil');
2521

2622
// query should have values set for `return` param
2723
cy.get('@postQuery')
28-
.its('requestBody.return')
24+
.its('request.body.return')
2925
.should('include.members', [
3026
'document_id',
3127
'document_passages',
@@ -50,14 +46,10 @@ describe('Basic search', () => {
5046
});
5147

5248
describe('When clicking to view document', () => {
53-
beforeEach(() => {
54-
cy.fixture('query/correctedQuery.json').as('correctedQueryJSON');
55-
});
56-
5749
it('should open document preview', () => {
58-
cy.route('POST', '**/query?version=2019-01-01', '@correctedQueryJSON').as(
59-
'postQueryCorrected'
60-
);
50+
cy.intercept('POST', '**/query?version=2019-01-01', {
51+
fixture: 'query/correctedQuery.json'
52+
}).as('postQueryCorrected');
6153
cy.get('@searchInput').type('Watson{enter}');
6254

6355
cy.get('button[data-testid="search-result-element-preview-button"]')
@@ -68,16 +60,18 @@ describe('Basic search', () => {
6860

6961
// When showing document preview, verify that another request is sent
7062
cy.get('@postQueryCorrected')
71-
.its('requestBody.filter')
63+
.its('request.body.filter')
7264
.should('eq', 'document_id:e69fd25f-5cbf-4f53-bef3-67834ac1965b');
73-
cy.get('@postQueryCorrected').its('requestBody.return').should('be.empty');
65+
cy.get('@postQueryCorrected').its('request.body.return').should('be.empty');
7466
});
7567
});
7668

7769
// Querying without results
7870
describe('When entering a query with no results', () => {
7971
beforeEach(() => {
80-
cy.route('POST', '**/query?version=2019-01-01', '@noResultsJSON').as('postQueryNoResults');
72+
cy.intercept('POST', '**/query?version=2019-01-01', { fixture: 'query/noResults.json' }).as(
73+
'postQueryNoResults'
74+
);
8175
cy.get('@searchInput').type('abil{enter}');
8276
cy.wait('@postQueryNoResults');
8377
});
@@ -90,38 +84,30 @@ describe('Basic search', () => {
9084

9185
describe('Basic search errors', () => {
9286
beforeEach(() => {
93-
// start the cypress server
94-
cy.server();
95-
9687
// Sets up and handles the collections, component settings, and initial query requests that run on page-load
97-
cy.fixture('collections/collections').as('collectionsJSON');
98-
cy.route('GET', '**/collections?version=2019-01-01', '@collectionsJSON').as('getCollections');
99-
cy.fixture('component_settings/componentSettings').as('componentSettingsJSON');
100-
cy.route('GET', '**/component_settings?version=2019-01-01', '@componentSettingsJSON').as(
101-
'getComponentSettings'
102-
);
103-
104-
// Set up/override routes & fixtures that are specific to this file
105-
cy.fixture('query/query').as('queryJSON');
106-
cy.fixture('query/error500.json').as('error500JSON');
88+
cy.intercept('GET', '**/collections?version=2019-01-01', {
89+
fixture: 'collections/collections'
90+
}).as('getCollections');
91+
cy.intercept('GET', '**/component_settings?version=2019-01-01', {
92+
fixture: 'component_settings/componentSettings'
93+
}).as('getComponentSettings');
10794
});
10895

10996
describe('When a user search returns an error', () => {
11097
it('SearchResults displays error message', () => {
11198
// query req on initial load
112-
cy.fixture('query/query').as('queryJSON');
113-
cy.route('POST', '**/query?version=2019-01-01', '@queryJSON').as('postQuery');
99+
cy.intercept('POST', '**/query?version=2019-01-01', { fixture: 'query/query' }).as(
100+
'postQuery'
101+
);
114102

115103
visitHomePage(['@getCollections', '@getComponentSettings']);
116104

117105
cy.findByPlaceholderText('Search').as('searchInput');
118106

119107
// user search request
120-
cy.route({
121-
method: 'POST',
122-
url: '**/query?version=2019-01-01',
123-
response: '@error500JSON',
124-
status: 500
108+
cy.intercept('POST', '**/query?version=2019-01-01', {
109+
fixture: 'query/error500.json',
110+
statusCode: 500
125111
}).as('postQueryError');
126112
cy.get('@searchInput').type('abil{enter}');
127113
cy.wait('@postQueryError');

examples/discovery-search-app/cypress/integration/collection_filter/spec.ts renamed to examples/discovery-search-app/cypress/e2e/collection_filter/collection_filter.cy.ts

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ import { mockHomePage } from '../../support/utils';
33
describe('Collection Filter', () => {
44
beforeEach(() => {
55
mockHomePage();
6-
7-
// Set up/override routes & fixtures that are specific to this file
8-
cy.fixture('query/singleCollectionQuery.json').as('singleCollectionQueryJSON');
9-
cy.fixture('query/doubleCollectionQuery.json').as('doubleCollectionQueryJSON');
106
});
117

128
describe('when the example app loads', () => {
@@ -39,16 +35,16 @@ describe('Collection Filter', () => {
3935

4036
describe('and we select a single collection', () => {
4137
beforeEach(() => {
42-
cy.route('POST', '**/query?version=2019-01-01', '@singleCollectionQueryJSON').as(
43-
'postQuerySingleCollection'
44-
);
38+
cy.intercept('POST', '**/query?version=2019-01-01', {
39+
fixture: 'query/singleCollectionQuery.json'
40+
}).as('postQuerySingleCollection');
4541
cy.get('.bx--list-box__menu-item').contains('finnegans wake').click();
4642
cy.wait('@postQuerySingleCollection').as('singleCollectionQueryObject');
4743
});
4844

4945
it('should make a query against only the selected collection', () => {
5046
cy.get('@singleCollectionQueryObject')
51-
.its('requestBody.collection_ids')
47+
.its('request.body.collection_ids')
5248
.should('contain', 'paris19221939')
5349
.and('have.length', 1);
5450
});
@@ -59,7 +55,7 @@ describe('Collection Filter', () => {
5955

6056
describe('and we click the clear selected collections button', () => {
6157
beforeEach(() => {
62-
cy.route('POST', '**/query?version=2019-01-01', '@queryJSON').as(
58+
cy.intercept('POST', '**/query?version=2019-01-01', { fixture: 'query/query.json' }).as(
6359
'postQueryClearedSelections'
6460
);
6561
cy.get('div[aria-label="Clear all selected items"]').click();
@@ -68,38 +64,38 @@ describe('Collection Filter', () => {
6864

6965
it('makes a query against all available collections', () => {
7066
cy.get('@clearedCollectionsQueryObject')
71-
.its('requestBody.collection_ids')
67+
.its('request.body.collection_ids')
7268
.should('be.empty');
7369
});
7470
});
7571

7672
describe('and we select another collection', () => {
7773
beforeEach(() => {
78-
cy.route('POST', '**/query?version=2019-01-01', 'doubleCollectionQueryJSON').as(
79-
'postQueryDoubleCollection'
80-
);
74+
cy.intercept('POST', '**/query?version=2019-01-01', {
75+
fixture: 'query/doubleCollectionQuery.json'
76+
}).as('postQueryDoubleCollection');
8177
cy.get('.bx--list-box__menu-item').contains('deadspin').click();
8278
cy.wait('@postQueryDoubleCollection').as('doubleCollectionQueryObject');
8379
});
8480

8581
it('makes a query against both of the selected collections', () => {
8682
cy.get('@doubleCollectionQueryObject')
87-
.its('requestBody.collection_ids')
83+
.its('request.body.collection_ids')
8884
.should('contain', 'deadspin9876')
8985
.and('contain', 'paris19221939');
9086
});
9187

9288
describe('and we clear the selected collections', () => {
9389
beforeEach(() => {
94-
cy.route('POST', '**/query?version=2019-01-01', '@queryJSON').as(
95-
'postQueryClearedSelections'
96-
);
90+
cy.intercept('POST', '**/query?version=2019-01-01', {
91+
fixture: 'query/query.json'
92+
}).as('postQueryClearedSelections');
9793
cy.get('div[aria-label="Clear all selected items"]').click();
9894
cy.wait('@postQueryClearedSelections').as('originalQueryObject');
9995
});
10096

10197
it('makes a query against all available collections', () => {
102-
cy.get('@originalQueryObject').its('requestBody.collection_ids').should('be.empty');
98+
cy.get('@originalQueryObject').its('request.body.collection_ids').should('be.empty');
10399
});
104100
});
105101
});

0 commit comments

Comments
 (0)