Skip to content

Commit

Permalink
chore(DGHT-287): Fix dependabot alerts (2) (#5469)
Browse files Browse the repository at this point in the history
  • Loading branch information
yyanwang authored Dec 10, 2024
1 parent 2d49ed7 commit fc2e30f
Show file tree
Hide file tree
Showing 16 changed files with 303 additions and 401 deletions.
5 changes: 5 additions & 0 deletions .changeset/calm-cats-care.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@talend/scripts-config-react-webpack': patch
---

add querystring to resolve.fallback
9 changes: 9 additions & 0 deletions .changeset/stale-pumas-relate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@talend/design-system': minor
'@talend/icons': minor
'@talend/http': minor
'@talend/json-schema-form-core': patch
'@talend/scripts-utils': patch
---

Fix remaining dependabot alerts
3 changes: 3 additions & 0 deletions fork/json-schema-form-core/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@ module.exports = {
fallback: {
path: false,
},
alias: {
'json-refs': require.resolve('json-refs/dist/json-refs.js'),
},
},
};
2 changes: 1 addition & 1 deletion packages/design-system/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"@storybook/react": "^7.6.20",
"@storybook/testing-library": "^0.2.2",
"@storybook/theming": "^7.6.20",
"@svgr/webpack": "^5.5.0",
"@svgr/webpack": "^8.1.0",
"@talend/eslint-config": "^13.2.1",
"@talend/eslint-plugin": "^1.3.1",
"@talend/icons": "^7.10.3",
Expand Down
1 change: 0 additions & 1 deletion packages/http/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
"@talend/scripts-config-typescript": "^11.3.0",
"@types/jest": "^29.5.14",
"@types/node-fetch": "^2.6.11",
"fetch-mock": "^9.11.0",
"node-fetch": "^2.7.0",
"react-dom": "^18.3.1",
"react": "^18.3.1"
Expand Down
92 changes: 63 additions & 29 deletions packages/http/src/http.common.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import fetchMock from 'fetch-mock';
import { Response, Headers } from 'node-fetch';
import { Headers, Response } from 'node-fetch';

import {
HTTP,
addHttpResponseInterceptor,
getDefaultConfig,
setDefaultConfig,
HTTP,
HTTP_RESPONSE_INTERCEPTORS,
addHttpResponseInterceptor,
setDefaultConfig,
} from './config';
import { httpFetch, handleBody, encodePayload, handleHttpResponse } from './http.common';
import { encodePayload, handleBody, handleHttpResponse, httpFetch } from './http.common';
import { HTTP_METHODS, HTTP_STATUS } from './http.constants';
import { TalendHttpError } from './http.types';

Expand All @@ -18,6 +17,10 @@ const defaultPayload = {
bar: 42,
};

interface FetchMock extends jest.Mock {
mockResponse?: Response;
}

beforeEach(() => {
jest.clearAllMocks();
});
Expand Down Expand Up @@ -199,19 +202,24 @@ describe('#httpFetch with `CSRF` token', () => {
});

afterAll(() => {
fetchMock.restore();
document.cookie = `csrfToken=${CSRFToken}; dwf_section_edit=True; Max-Age=0`;
});
it('should get the CRFS token', async () => {
const url = '/foo';
const headers = new Headers();
headers.append('Content-Type', 'application/json');

fetchMock.mock(url, { body: defaultBody, status: 200 });
(global.self.fetch as FetchMock).mockResponse = new Response(JSON.stringify(defaultBody), {
status: 200,
headers: {
'Content-Type': 'application/json',
},
});

const result = await httpFetch(url, {}, HTTP_METHODS.GET, defaultPayload);

expect(result.data).toEqual(defaultBody);
expect(fetchMock.calls()[0][1]).toEqual({
expect(global.self.fetch).toHaveBeenCalledWith(url, {
body: JSON.stringify(defaultPayload),
credentials: 'same-origin',
headers: {
Expand Down Expand Up @@ -239,7 +247,6 @@ describe('#httpFetch with CSRF handling configuration', () => {

afterAll(() => {
HTTP.defaultConfig = null;
fetchMock.restore();
document.cookie = `${defaultHttpConfiguration.security.CSRFTokenCookieKey}=${CSRFToken}; dwf_section_edit=True; Max-Age=0`;
});

Expand All @@ -251,12 +258,17 @@ describe('#httpFetch with CSRF handling configuration', () => {
const headers = new Headers();
headers.append('Content-Type', 'application/json');

fetchMock.mock(url, { body: defaultBody, status: 200 });
(global.self.fetch as FetchMock).mockResponse = new Response(JSON.stringify(defaultBody), {
status: 200,
headers: {
'Content-Type': 'application/json',
},
});

const result = await httpFetch(url, {}, HTTP_METHODS.GET, defaultPayload);

expect(result.data).toEqual(defaultBody);
expect(fetchMock.calls()[0][1]).toEqual({
expect(global.self.fetch).toHaveBeenCalledWith(url, {
body: JSON.stringify(defaultPayload),
credentials: 'same-origin',
headers: {
Expand All @@ -276,19 +288,23 @@ describe('#httpFetch with CSRF handling configuration', () => {
describe('#httpFetch', () => {
afterEach(() => {
HTTP.defaultConfig = null;
fetchMock.restore();
});

it('should fetch the request', async () => {
const url = '/foo';
const headers = new Headers();
headers.append('Content-Type', 'application/json');
fetchMock.mock(url, { body: defaultBody, status: 200 });
(global.self.fetch as FetchMock).mockResponse = new Response(JSON.stringify(defaultBody), {
status: 200,
headers: {
'Content-Type': 'application/json',
},
});

const result = await httpFetch(url, {}, HTTP_METHODS.GET, defaultPayload);

expect(result.data).toEqual(defaultBody);
expect(fetchMock.calls()[0][1]).toEqual({
expect(global.self.fetch).toHaveBeenCalledWith(url, {
body: JSON.stringify(defaultPayload),
credentials: 'same-origin',
headers: {
Expand All @@ -310,12 +326,17 @@ describe('#httpFetch', () => {
},
});

fetchMock.mock(url, { body: defaultBody, status: 200 });
(global.self.fetch as FetchMock).mockResponse = new Response(JSON.stringify(defaultBody), {
status: 200,
headers: {
'Content-Type': 'application/json',
},
});

const result = await httpFetch(url, {}, HTTP_METHODS.GET, defaultPayload);

expect(result.data).toEqual(defaultBody);
expect(fetchMock.calls()[0][1]).toEqual({
expect(global.self.fetch).toHaveBeenCalledWith(url, {
body: JSON.stringify(defaultPayload),
credentials: 'same-origin',
headers: {
Expand All @@ -333,14 +354,22 @@ describe('#httpFetch', () => {
headers.append('Content-Type', 'application/json');
const payload = new FormData();

fetchMock.mock(url, { body: '{"foo": 42}', status: 200 });
(global.self.fetch as FetchMock).mockResponse = new Response(JSON.stringify({ foo: 42 }), {
status: 200,
headers: {
'Content-Type': 'application/json',
},
});

const result = await httpFetch(url, {}, HTTP_METHODS.GET, payload);
expect(result.data).toEqual('{"foo": 42}');
expect(result.data).toEqual({ foo: 42 });

const mockCalls = fetchMock.calls();
expect(mockCalls[0][1]?.credentials).toEqual('same-origin');
expect(mockCalls[0][1]?.headers).toEqual({ Accept: 'application/json' });
expect(global.self.fetch).toHaveBeenCalledWith(url, {
body: payload,
credentials: 'same-origin',
headers: { Accept: 'application/json' },
method: 'GET',
});
});
});

Expand All @@ -353,16 +382,17 @@ describe('#httpFetch with interceptors', () => {
}
});

afterEach(() => {
fetchMock.restore();
});

it('should call interceptor', async () => {
const interceptor = jest.fn().mockImplementation((res, _) => res);
addHttpResponseInterceptor('interceptor', interceptor);

const url = '/foo';
fetchMock.mock(url, { body: defaultBody, status: 200 });
(global.self.fetch as FetchMock).mockResponse = new Response(JSON.stringify(defaultBody), {
status: 200,
headers: {
'Content-Type': 'application/json',
},
});

await httpFetch(url, {}, HTTP_METHODS.GET, {});
expect(interceptor).toHaveBeenCalled();
Expand All @@ -374,8 +404,12 @@ describe('#httpFetch with interceptors', () => {

const url = '/foo';
const context = { async: true };
const response = { body: defaultBody, status: 200 };
fetchMock.mock(url, response);
(global.self.fetch as FetchMock).mockResponse = new Response(JSON.stringify(defaultBody), {
status: 200,
headers: {
'Content-Type': 'application/json',
},
});

await httpFetch(url, { context }, HTTP_METHODS.GET, {});
expect(interceptor).toHaveBeenCalledWith(
Expand Down
45 changes: 0 additions & 45 deletions packages/icons/.svgo-filters.yml

This file was deleted.

46 changes: 0 additions & 46 deletions packages/icons/.svgo-icons.yml

This file was deleted.

6 changes: 3 additions & 3 deletions packages/icons/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"build-storybook": "talend-scripts build-storybook",
"start": "talend-scripts start-storybook -p 6010",
"lint": "echo nothing to lint",
"svgo": "svgo -f src/svg --config=.svgo-icons.yml && svgo -f src/filters --config=.svgo-filters.yml"
"svgo": "svgo -rf src/svg --config svgo-icons.config.mjs && svgo -rf src/filters --config svgo-filters.config.mjs"
},
"files": [
"index.js",
Expand All @@ -61,7 +61,7 @@
"@babel/core": "^7.26.0",
"@babel/preset-env": "^7.26.0",
"@babel/preset-react": "^7.25.9",
"@svgr/webpack": "^5.5.0",
"@svgr/webpack": "^8.1.0",
"@talend/eslint-config": "^13.2.1",
"@talend/eslint-plugin": "^1.3.1",
"@talend/scripts-core": "^16.5.1",
Expand All @@ -81,7 +81,7 @@
"react-use": "^17.5.1",
"string-replace-loader": "^2.3.0",
"style-loader": "^1.3.0",
"svgo": "^1.3.2",
"svgo": "^3.3.2",
"webfonts-loader": "^8.0.1",
"webpack": "^5.95.0",
"webpack-cli": "^4.10.0"
Expand Down
Loading

0 comments on commit fc2e30f

Please sign in to comment.