Remove dependency on uuid package

This commit is contained in:
Alejandro Celaya 2024-11-01 12:09:13 +01:00
parent 88ad2e7fc2
commit dc8c749212
5 changed files with 9 additions and 30 deletions

19
package-lock.json generated
View file

@ -32,7 +32,6 @@
"react-router-dom": "^6.27.0", "react-router-dom": "^6.27.0",
"reactstrap": "^9.2.3", "reactstrap": "^9.2.3",
"redux-localstorage-simple": "^2.5.1", "redux-localstorage-simple": "^2.5.1",
"uuid": "^10.0.0",
"workbox-core": "^7.1.0", "workbox-core": "^7.1.0",
"workbox-expiration": "^7.1.0", "workbox-expiration": "^7.1.0",
"workbox-precaching": "^7.1.0", "workbox-precaching": "^7.1.0",
@ -11580,19 +11579,6 @@
"dev": true, "dev": true,
"license": "MIT" "license": "MIT"
}, },
"node_modules/uuid": {
"version": "10.0.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-10.0.0.tgz",
"integrity": "sha512-8XkAphELsDnEGrDxUOHB3RGvXz6TeuYSGEZBOjtTtPm2lwhGBjLgOzLHB63IUWfBpNucQjND6d3AOudO+H3RWQ==",
"funding": [
"https://github.com/sponsors/broofa",
"https://github.com/sponsors/ctavan"
],
"license": "MIT",
"bin": {
"uuid": "dist/bin/uuid"
}
},
"node_modules/validate-npm-package-license": { "node_modules/validate-npm-package-license": {
"version": "3.0.4", "version": "3.0.4",
"resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz",
@ -20190,11 +20176,6 @@
"version": "1.0.2", "version": "1.0.2",
"dev": true "dev": true
}, },
"uuid": {
"version": "10.0.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-10.0.0.tgz",
"integrity": "sha512-8XkAphELsDnEGrDxUOHB3RGvXz6TeuYSGEZBOjtTtPm2lwhGBjLgOzLHB63IUWfBpNucQjND6d3AOudO+H3RWQ=="
},
"validate-npm-package-license": { "validate-npm-package-license": {
"version": "3.0.4", "version": "3.0.4",
"resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz",

View file

@ -49,7 +49,6 @@
"react-router-dom": "^6.27.0", "react-router-dom": "^6.27.0",
"reactstrap": "^9.2.3", "reactstrap": "^9.2.3",
"redux-localstorage-simple": "^2.5.1", "redux-localstorage-simple": "^2.5.1",
"uuid": "^10.0.0",
"workbox-core": "^7.1.0", "workbox-core": "^7.1.0",
"workbox-expiration": "^7.1.0", "workbox-expiration": "^7.1.0",
"workbox-precaching": "^7.1.0", "workbox-precaching": "^7.1.0",

View file

@ -1,9 +1,6 @@
import type { SyntheticEvent } from 'react'; import type { SyntheticEvent } from 'react';
import { v4 } from 'uuid';
export const handleEventPreventingDefault = <T>(handler: () => T) => (e: SyntheticEvent) => { export const handleEventPreventingDefault = <T>(handler: () => T) => (e: SyntheticEvent) => {
e.preventDefault(); e.preventDefault();
handler(); handler();
}; };
export const randomUUID = () => v4();

View file

@ -68,12 +68,15 @@ describe('<ImportServersBtn />', () => {
{ btnName: 'Save anyway',savesDuplicatedServers: true }, { btnName: 'Save anyway',savesDuplicatedServers: true },
{ btnName: 'Discard', savesDuplicatedServers: false }, { btnName: 'Discard', savesDuplicatedServers: false },
])('creates expected servers depending on selected option in modal', async ({ btnName, savesDuplicatedServers }) => { ])('creates expected servers depending on selected option in modal', async ({ btnName, savesDuplicatedServers }) => {
const existingServer: ServerWithId = { const existingServerData: ServerData = {
name: 'existingServer', name: 'existingServer',
id: 'existingserver-s.test',
url: 'http://s.test/existingUrl', url: 'http://s.test/existingUrl',
apiKey: 'existingApiKey', apiKey: 'existingApiKey',
}; };
const existingServer: ServerWithId = {
...existingServerData,
id: 'existingserver-s.test',
};
const newServer: ServerData = { name: 'newServer', url: 'http://s.test/newUrl', apiKey: 'newApiKey' }; const newServer: ServerData = { name: 'newServer', url: 'http://s.test/newUrl', apiKey: 'newApiKey' };
const { user } = setUp({}, { [existingServer.id]: existingServer }); const { user } = setUp({}, { [existingServer.id]: existingServer });
@ -86,7 +89,7 @@ describe('<ImportServersBtn />', () => {
expect(createServersMock).toHaveBeenCalledWith( expect(createServersMock).toHaveBeenCalledWith(
savesDuplicatedServers savesDuplicatedServers
? [existingServer, expect.objectContaining(newServer)] ? [expect.objectContaining(existingServerData), expect.objectContaining(newServer)]
: [expect.objectContaining(newServer)], : [expect.objectContaining(newServer)],
); );
expect(onImportMock).toHaveBeenCalledTimes(1); expect(onImportMock).toHaveBeenCalledTimes(1);

View file

@ -9,7 +9,6 @@ import {
selectedServerReducerCreator, selectedServerReducerCreator,
selectServer as selectServerCreator, selectServer as selectServerCreator,
} from '../../../src/servers/reducers/selectedServer'; } from '../../../src/servers/reducers/selectedServer';
import { randomUUID } from '../../../src/utils/utils';
describe('selectedServerReducer', () => { describe('selectedServerReducer', () => {
const dispatch = vi.fn(); const dispatch = vi.fn();
@ -41,7 +40,7 @@ describe('selectedServerReducer', () => {
['latest', MAX_FALLBACK_VERSION, 'latest'], ['latest', MAX_FALLBACK_VERSION, 'latest'],
['%invalid_semver%', MIN_FALLBACK_VERSION, '%invalid_semver%'], ['%invalid_semver%', MIN_FALLBACK_VERSION, '%invalid_semver%'],
])('dispatches proper actions', async (serverVersion, expectedVersion, expectedPrintableVersion) => { ])('dispatches proper actions', async (serverVersion, expectedVersion, expectedPrintableVersion) => {
const id = randomUUID(); const id = crypto.randomUUID();
const getState = createGetStateMock(id); const getState = createGetStateMock(id);
const expectedSelectedServer = { const expectedSelectedServer = {
id, id,
@ -60,7 +59,7 @@ describe('selectedServerReducer', () => {
}); });
it('dispatches error when health endpoint fails', async () => { it('dispatches error when health endpoint fails', async () => {
const id = randomUUID(); const id = crypto.randomUUID();
const getState = createGetStateMock(id); const getState = createGetStateMock(id);
const expectedSelectedServer = fromPartial<NonReachableServer>({ id, serverNotReachable: true }); const expectedSelectedServer = fromPartial<NonReachableServer>({ id, serverNotReachable: true });
@ -73,7 +72,7 @@ describe('selectedServerReducer', () => {
}); });
it('dispatches error when server is not found', async () => { it('dispatches error when server is not found', async () => {
const id = randomUUID(); const id = crypto.randomUUID();
const getState = vi.fn(() => fromPartial<ShlinkState>({ servers: {} })); const getState = vi.fn(() => fromPartial<ShlinkState>({ servers: {} }));
const expectedSelectedServer: NotFoundServer = { serverNotFound: true }; const expectedSelectedServer: NotFoundServer = { serverNotFound: true };