Skip to content

Commit

Permalink
Revert "chore(DGHT-287): Fix dependabot alerts (2) (#5469)"
Browse files Browse the repository at this point in the history
This reverts commit fc2e30f.
  • Loading branch information
yyanwang committed Dec 10, 2024
1 parent 4d47bbe commit bd580a8
Show file tree
Hide file tree
Showing 16 changed files with 401 additions and 303 deletions.
5 changes: 0 additions & 5 deletions .changeset/calm-cats-care.md

This file was deleted.

9 changes: 0 additions & 9 deletions .changeset/stale-pumas-relate.md

This file was deleted.

3 changes: 0 additions & 3 deletions fork/json-schema-form-core/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,5 @@ 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": "^8.1.0",
"@svgr/webpack": "^5.5.0",
"@talend/eslint-config": "^13.2.1",
"@talend/eslint-plugin": "^1.3.1",
"@talend/icons": "^7.10.3",
Expand Down
1 change: 1 addition & 0 deletions packages/http/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"@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: 29 additions & 63 deletions packages/http/src/http.common.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { Headers, Response } from 'node-fetch';
import fetchMock from 'fetch-mock';
import { Response, Headers } from 'node-fetch';

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

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

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

beforeEach(() => {
jest.clearAllMocks();
});
Expand Down Expand Up @@ -202,24 +199,19 @@ 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');

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

fetchMock.mock(url, { body: defaultBody, status: 200 });
const result = await httpFetch(url, {}, HTTP_METHODS.GET, defaultPayload);

expect(result.data).toEqual(defaultBody);
expect(global.self.fetch).toHaveBeenCalledWith(url, {
expect(fetchMock.calls()[0][1]).toEqual({
body: JSON.stringify(defaultPayload),
credentials: 'same-origin',
headers: {
Expand Down Expand Up @@ -247,6 +239,7 @@ 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 @@ -258,17 +251,12 @@ describe('#httpFetch with CSRF handling configuration', () => {
const headers = new Headers();
headers.append('Content-Type', 'application/json');

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

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

expect(result.data).toEqual(defaultBody);
expect(global.self.fetch).toHaveBeenCalledWith(url, {
expect(fetchMock.calls()[0][1]).toEqual({
body: JSON.stringify(defaultPayload),
credentials: 'same-origin',
headers: {
Expand All @@ -288,23 +276,19 @@ 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');
(global.self.fetch as FetchMock).mockResponse = new Response(JSON.stringify(defaultBody), {
status: 200,
headers: {
'Content-Type': 'application/json',
},
});
fetchMock.mock(url, { body: defaultBody, status: 200 });

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

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

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

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

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

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

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

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

Expand All @@ -382,17 +353,16 @@ 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';
(global.self.fetch as FetchMock).mockResponse = new Response(JSON.stringify(defaultBody), {
status: 200,
headers: {
'Content-Type': 'application/json',
},
});
fetchMock.mock(url, { body: defaultBody, status: 200 });

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

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

await httpFetch(url, { context }, HTTP_METHODS.GET, {});
expect(interceptor).toHaveBeenCalledWith(
Expand Down
45 changes: 45 additions & 0 deletions packages/icons/.svgo-filters.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
multipass: true
full: true
js2svg:
pretty: true
indent: ' '

plugins:
- removeDoctype
- removeXMLProcInst
- removeComments
- removeMetadata
- removeEditorsNSData
- cleanupAttrs
- minifyStyles
- convertStyleToAttrs
- removeRasterImages
- cleanupNumericValues
- cleanupListOfValues
- convertColors
- removeUnknownsAndDefaults
- removeNonInheritableGroupAttrs
- removeUselessStrokeAndFill
- removeViewBox
- cleanupEnableBackground
- removeHiddenElems
- removeEmptyText
- convertShapeToPath
- moveElemsAttrsToGroup
- moveGroupAttrsToElems
- collapseGroups
- convertTransform
- removeEmptyAttrs
- removeEmptyContainers
- mergePaths
- removeUnusedNS
- transformsWithOnePath
- sortAttrs
- removeTitle
- removeDesc
- removeDimensions: true
- removeAttrs
- removeElementsByAttr
- addClassesToSVGElement
- removeStyleElement
- addAttributesToSVGElement
46 changes: 46 additions & 0 deletions packages/icons/.svgo-icons.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
multipass: true
full: true
js2svg:
pretty: true
indent: ' '

plugins:
- removeDoctype
- removeXMLProcInst
- removeComments
- removeMetadata
- removeEditorsNSData
- cleanupAttrs
- minifyStyles
- convertStyleToAttrs
- cleanupIDs
- removeRasterImages
- removeUselessDefs
- cleanupNumericValues
- cleanupListOfValues
- convertColors
- removeUnknownsAndDefaults
- removeNonInheritableGroupAttrs
- removeUselessStrokeAndFill
- removeViewBox
- cleanupEnableBackground
- removeHiddenElems
- removeEmptyText
- convertShapeToPath
- moveElemsAttrsToGroup
- moveGroupAttrsToElems
- convertTransform
- removeEmptyAttrs
- removeEmptyContainers
- mergePaths
- removeUnusedNS
- transformsWithOnePath
- sortAttrs
- removeTitle
- removeDesc
- removeDimensions: true
- removeAttrs
- removeElementsByAttr
- addClassesToSVGElement
- removeStyleElement
- addAttributesToSVGElement
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 -rf src/svg --config svgo-icons.config.mjs && svgo -rf src/filters --config svgo-filters.config.mjs"
"svgo": "svgo -f src/svg --config=.svgo-icons.yml && svgo -f src/filters --config=.svgo-filters.yml"
},
"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": "^8.1.0",
"@svgr/webpack": "^5.5.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": "^3.3.2",
"svgo": "^1.3.2",
"webfonts-loader": "^8.0.1",
"webpack": "^5.95.0",
"webpack-cli": "^4.10.0"
Expand Down
Loading

0 comments on commit bd580a8

Please sign in to comment.