mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
[CB] update frontend deps (#3973)
* dbeaver/pro#7748 updates yarn.locks
* fixes incorrect types
* updates helper libs
* updates vitest + fixes test cases incorrect mocks
* runs tests sequentially with document and windows objects to prevent mock collisions
* Revert "runs tests sequentially with document and windows objects to prevent mock collisions"
This reverts commit f871837df3.
* skips download test
* removes export from resetDeprecatedSettings
* updates react-data-grid to beta-59 and react to 19.2
* updates storybook
* pr fixes
* updates yarn lock
* removes skip for download test
* cleanups download ts with empty body html
* updates vitest for core-connections
* updates yarn.lock
* linter fix + mocks once
* fixes hotkeys
* reverts version of react-hotkeys-hook library
---------
Co-authored-by: mr-anton-t <42037741+mr-anton-t@users.noreply.github.com>
This commit is contained in:
co-authored by
mr-anton-t
parent
50090a3035
commit
78daa21c87
@@ -38,7 +38,7 @@
|
||||
"@dbeaver/react-translate": "workspace:^",
|
||||
"@dbeaver/ui-kit": "workspace:^",
|
||||
"react": "^19",
|
||||
"react-data-grid": "7.0.0-beta.57",
|
||||
"react-data-grid": "7.0.0-beta.59",
|
||||
"react-dom": "^19"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
"@types/react": "^19",
|
||||
"rimraf": "^6",
|
||||
"typescript": "^5",
|
||||
"vitest": "^3"
|
||||
"vitest": "^4"
|
||||
},
|
||||
"dependencies": {
|
||||
"react": "^19"
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
"@types/ws": "^8",
|
||||
"rimraf": "^6",
|
||||
"typescript": "^5",
|
||||
"vitest": "^3",
|
||||
"vitest": "^4",
|
||||
"ws": "^8"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ export function SelectField<T, ItemType extends {} = SelectItem<T>>({
|
||||
return firstEnabledItem ? getItemValue(firstEnabledItem) : undefined;
|
||||
});
|
||||
|
||||
const handleChange = (newValue: string | string[]) => {
|
||||
const handleChange = (newValue: string | readonly string[]) => {
|
||||
// TODO: add support for multi-select
|
||||
|
||||
const newItem = items.find(item => getItemValueSerialized(item) === newValue);
|
||||
|
||||
@@ -19,6 +19,6 @@
|
||||
"happy-dom": "^20",
|
||||
"prettier": "^3.6.2",
|
||||
"rimraf": "^6",
|
||||
"vitest": "^3"
|
||||
"vitest": "^4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,6 @@
|
||||
"@types/node": "^22",
|
||||
"rimraf": "^6",
|
||||
"typescript": "^5",
|
||||
"vitest": "^3"
|
||||
"vitest": "^4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,6 @@
|
||||
"@dbeaver/tsconfig": "workspace:^",
|
||||
"rimraf": "^6",
|
||||
"typescript": "^5",
|
||||
"vitest": "^3"
|
||||
"vitest": "^4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,12 +29,12 @@
|
||||
"@dbeaver/tsconfig": "workspace:^",
|
||||
"rimraf": "^6",
|
||||
"typescript": "^5",
|
||||
"vitest": "^3"
|
||||
"vitest": "^4"
|
||||
},
|
||||
"dependencies": {
|
||||
"async-mutex": "^0",
|
||||
"color": "^5.0.2",
|
||||
"p-debounce": "^4.0.0",
|
||||
"p-debounce": "^5",
|
||||
"p-memoize": "^8.0.0",
|
||||
"quick-lru": "^7.1.0"
|
||||
}
|
||||
|
||||
+2
-2
@@ -14,7 +14,7 @@
|
||||
"react-dom": "^19",
|
||||
"mobx": "^6",
|
||||
"mobx-react-lite": "^4",
|
||||
"glob": "^11.1"
|
||||
"glob": "^13"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "dbeaver-test",
|
||||
@@ -53,7 +53,7 @@
|
||||
"rimraf": "^6",
|
||||
"typescript": "^5.8.3",
|
||||
"typescript-plugin-css-modules": "^5",
|
||||
"vitest": "^3"
|
||||
"vitest": "^4"
|
||||
},
|
||||
"packageManager": "yarn@4.9.2"
|
||||
}
|
||||
|
||||
@@ -51,6 +51,6 @@
|
||||
"msw": "^2",
|
||||
"rimraf": "^6",
|
||||
"typescript": "^5",
|
||||
"vitest": "^3"
|
||||
"vitest": "^4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Licensed under the Apache License, Version 2.0.
|
||||
* you may not use this file except in compliance with the License.
|
||||
*/
|
||||
import { describe, expect, test } from 'vitest';
|
||||
import { beforeEach, describe, expect, test } from 'vitest';
|
||||
|
||||
import { ServerConfigResource } from '@cloudbeaver/core-root';
|
||||
import { createGQLEndpoint } from '@cloudbeaver/core-root/__custom_mocks__/createGQLEndpoint.js';
|
||||
@@ -14,12 +14,18 @@ import { mockAppInit } from '@cloudbeaver/core-root/__custom_mocks__/mockAppInit
|
||||
import { mockGraphQL } from '@cloudbeaver/core-root/__custom_mocks__/mockGraphQL.js';
|
||||
import { mockServerConfig } from '@cloudbeaver/core-root/__custom_mocks__/resolvers/mockServerConfig.js';
|
||||
import { expectNoDeprecatedSettingMessage } from '@cloudbeaver/core-settings/__custom_mocks__/expectDeprecatedSettingMessage.js';
|
||||
import { resetDeprecatedSettings } from '@cloudbeaver/core-settings/createSettingsAliasResolver.test.js';
|
||||
import { createApp, initKnownConsoleMessages } from '@cloudbeaver/tests-runner';
|
||||
|
||||
import { mockAuthentication } from './__custom_mocks__/mockAuthentication.js';
|
||||
import { AuthSettingsService } from './AuthSettingsService.js';
|
||||
import './module.js';
|
||||
import { DEPRECATED_SETTINGS } from '@cloudbeaver/core-settings';
|
||||
|
||||
function resetDeprecatedSettings() {
|
||||
beforeEach(() => {
|
||||
DEPRECATED_SETTINGS.clear();
|
||||
});
|
||||
}
|
||||
|
||||
describe.skip(() => {
|
||||
const endpoint = createGQLEndpoint();
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
"mobx-react-lite": "^4",
|
||||
"react": "^19",
|
||||
"react-dom": "^19",
|
||||
"react-hotkeys-hook": "^5",
|
||||
"react-hotkeys-hook": "5.1.0",
|
||||
"react-minisearch": "^7",
|
||||
"reakit": "^1",
|
||||
"reakit-utils": "^0",
|
||||
@@ -69,6 +69,6 @@
|
||||
"rimraf": "^6",
|
||||
"typescript": "^5",
|
||||
"typescript-plugin-css-modules": "^5",
|
||||
"vitest": "^3"
|
||||
"vitest": "^4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,6 @@
|
||||
"@dbeaver/react-tests": "workspace:*",
|
||||
"rimraf": "^6",
|
||||
"typescript": "^5",
|
||||
"vitest": "^3"
|
||||
"vitest": "^4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
"node": ">=22.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"glob": "^11.1",
|
||||
"glob": "^13",
|
||||
"js-yaml": "^4",
|
||||
"tslib": "^2"
|
||||
},
|
||||
@@ -49,7 +49,7 @@
|
||||
"@types/node": "^22",
|
||||
"enquirer": "^2",
|
||||
"execa": "^9",
|
||||
"glob": "^11.1",
|
||||
"glob": "^13",
|
||||
"hygen": "^6",
|
||||
"typescript": "^5"
|
||||
}
|
||||
|
||||
@@ -35,6 +35,6 @@
|
||||
"@dbeaver/react-tests": "workspace:*",
|
||||
"rimraf": "^6",
|
||||
"typescript": "^5",
|
||||
"vitest": "^3"
|
||||
"vitest": "^4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,18 +9,21 @@ import { beforeEach, describe, expect, it, vitest, afterEach } from 'vitest';
|
||||
|
||||
import { ClientActivityService, INACTIVE_PERIOD_TIME } from './ClientActivityService.js';
|
||||
|
||||
vitest.mock('@cloudbeaver/core-executor', () => ({
|
||||
Executor: vitest.fn(() => ({
|
||||
execute: vitest.fn(),
|
||||
addHandler: vitest.fn(),
|
||||
removeHandler: vitest.fn(),
|
||||
addPostHandler: vitest.fn(),
|
||||
removePostHandler: vitest.fn(),
|
||||
before: vitest.fn(),
|
||||
removeBefore: vitest.fn(),
|
||||
next: vitest.fn(),
|
||||
})),
|
||||
}));
|
||||
vitest.mock('@cloudbeaver/core-executor', () => {
|
||||
class MockExecutor {
|
||||
execute = vitest.fn();
|
||||
addHandler = vitest.fn();
|
||||
removeHandler = vitest.fn();
|
||||
addPostHandler = vitest.fn();
|
||||
removePostHandler = vitest.fn();
|
||||
before = vitest.fn();
|
||||
removeBefore = vitest.fn();
|
||||
next = vitest.fn();
|
||||
}
|
||||
return {
|
||||
Executor: MockExecutor,
|
||||
};
|
||||
});
|
||||
|
||||
describe('ClientActivityService', () => {
|
||||
let clientActivityService: ClientActivityService;
|
||||
|
||||
@@ -53,6 +53,6 @@
|
||||
"@types/react": "^19",
|
||||
"rimraf": "^6",
|
||||
"typescript": "^5",
|
||||
"vitest": "^3"
|
||||
"vitest": "^4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,6 @@
|
||||
"@wroud/di": "^0",
|
||||
"rimraf": "^6",
|
||||
"typescript": "^5",
|
||||
"vitest": "^3"
|
||||
"vitest": "^4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,6 @@
|
||||
"@dbeaver/react-tests": "workspace:*",
|
||||
"rimraf": "^6",
|
||||
"typescript": "^5",
|
||||
"vitest": "^3"
|
||||
"vitest": "^4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,6 @@
|
||||
"@dbeaver/react-tests": "workspace:*",
|
||||
"rimraf": "^6",
|
||||
"typescript": "^5",
|
||||
"vitest": "^3"
|
||||
"vitest": "^4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,6 +47,6 @@
|
||||
"@dbeaver/react-tests": "workspace:*",
|
||||
"rimraf": "^6",
|
||||
"typescript": "^5",
|
||||
"vitest": "^3"
|
||||
"vitest": "^4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,6 @@
|
||||
"mobx": "^6",
|
||||
"rimraf": "^6",
|
||||
"typescript": "^5",
|
||||
"vitest": "^3"
|
||||
"vitest": "^4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,6 +47,6 @@
|
||||
"msw": "^2",
|
||||
"rimraf": "^6",
|
||||
"typescript": "^5",
|
||||
"vitest": "^3"
|
||||
"vitest": "^4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,6 @@
|
||||
"@dbeaver/react-tests": "workspace:*",
|
||||
"rimraf": "^6",
|
||||
"typescript": "^5",
|
||||
"vitest": "^3"
|
||||
"vitest": "^4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,6 @@
|
||||
"@dbeaver/react-tests": "workspace:*",
|
||||
"rimraf": "^6",
|
||||
"typescript": "^5",
|
||||
"vitest": "^3"
|
||||
"vitest": "^4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Licensed under the Apache License, Version 2.0.
|
||||
* you may not use this file except in compliance with the License.
|
||||
*/
|
||||
import { describe, expect, test } from 'vitest';
|
||||
import { beforeEach, describe, expect, test } from 'vitest';
|
||||
|
||||
import {
|
||||
expectDeprecatedSettingMessage,
|
||||
@@ -14,11 +14,10 @@ import {
|
||||
} from './__custom_mocks__/expectDeprecatedSettingMessage.js';
|
||||
import { SettingsResolverSource } from './SettingsResolverSource.js';
|
||||
import { createSettingsLayer, ROOT_SETTINGS_LAYER } from './SettingsLayer.js';
|
||||
import { createSettingsAliasResolver } from './createSettingsAliasResolver.js';
|
||||
import { createSettingsAliasResolver, DEPRECATED_SETTINGS } from './createSettingsAliasResolver.js';
|
||||
import { schema } from '@cloudbeaver/core-utils';
|
||||
import { EditableSettingsSource } from './EditableSettingsSource.js';
|
||||
import { initKnownConsoleMessages } from '@cloudbeaver/tests-runner';
|
||||
import { resetDeprecatedSettings } from './createSettingsAliasResolver.test.js';
|
||||
|
||||
export class MemorySettingsService extends EditableSettingsSource {
|
||||
private readonly settings: Map<string, any>;
|
||||
@@ -73,6 +72,12 @@ export class MemorySettingsService extends EditableSettingsSource {
|
||||
|
||||
const MEMORY_SETTINGS_LAYER = createSettingsLayer(ROOT_SETTINGS_LAYER, 'memory');
|
||||
|
||||
function resetDeprecatedSettings() {
|
||||
beforeEach(() => {
|
||||
DEPRECATED_SETTINGS.clear();
|
||||
});
|
||||
}
|
||||
|
||||
describe('SettingsResolverSource', () => {
|
||||
initKnownConsoleMessages(addDeprecatedSettingPattern);
|
||||
resetDeprecatedSettings();
|
||||
|
||||
@@ -56,7 +56,7 @@ function createResolver(settings: Record<any, any>) {
|
||||
});
|
||||
}
|
||||
|
||||
export function resetDeprecatedSettings() {
|
||||
function resetDeprecatedSettings() {
|
||||
beforeEach(() => {
|
||||
DEPRECATED_SETTINGS.clear();
|
||||
});
|
||||
|
||||
@@ -52,6 +52,6 @@
|
||||
"rimraf": "^6",
|
||||
"typescript": "^5",
|
||||
"typescript-plugin-css-modules": "^5",
|
||||
"vitest": "^3"
|
||||
"vitest": "^4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,6 +55,6 @@
|
||||
"rimraf": "^6",
|
||||
"typescript": "^5",
|
||||
"typescript-plugin-css-modules": "^5",
|
||||
"vitest": "^3"
|
||||
"vitest": "^4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,10 +31,10 @@
|
||||
"tslib": "^2",
|
||||
"underscore": "^1",
|
||||
"uuid": "^13",
|
||||
"vitest": "^3",
|
||||
"vitest": "^4",
|
||||
"whatwg-mimetype": "^4",
|
||||
"zod": "^4",
|
||||
"zod-validation-error": "^4"
|
||||
"zod-validation-error": "^5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@cloudbeaver/core-cli": "workspace:*",
|
||||
@@ -44,11 +44,11 @@
|
||||
"@dbeaver/react-tests": "workspace:*",
|
||||
"@types/md5": "^2",
|
||||
"@types/underscore": "^1",
|
||||
"@types/uuid": "^10",
|
||||
"@types/uuid": "^11",
|
||||
"@types/whatwg-mimetype": "^3",
|
||||
"rimraf": "^6",
|
||||
"typescript": "^5",
|
||||
"vitest": "^3",
|
||||
"vitest": "^4",
|
||||
"zod": "^4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,22 +8,25 @@
|
||||
|
||||
import type { Mock } from 'vitest';
|
||||
|
||||
export function mockFileReader(getResult: (() => string) | (() => Mock)): void {
|
||||
const fileReader = class MockFileReader extends FileReader {
|
||||
constructor() {
|
||||
super();
|
||||
Object.defineProperty(this, 'result', {
|
||||
get: getResult,
|
||||
});
|
||||
}
|
||||
interface MockFileReaderInstance {
|
||||
onload: ((event: ProgressEvent<FileReader>) => void) | null;
|
||||
onerror: ((event: ProgressEvent<FileReader>) => void) | null;
|
||||
result: string | ArrayBuffer | null;
|
||||
readAsDataURL: (blob: Blob) => void;
|
||||
}
|
||||
|
||||
override readAsDataURL() {
|
||||
this.onload?.({} as ProgressEvent<FileReader>);
|
||||
}
|
||||
export function mockFileReader(getResult: (() => string) | (() => Mock)): () => FileReader {
|
||||
return function mockFileReader() {
|
||||
const reader: MockFileReaderInstance = {
|
||||
onload: null,
|
||||
onerror: null,
|
||||
get result() {
|
||||
return getResult() as string;
|
||||
},
|
||||
readAsDataURL() {
|
||||
reader.onload?.({} as ProgressEvent<FileReader>);
|
||||
},
|
||||
};
|
||||
return reader as unknown as FileReader;
|
||||
};
|
||||
|
||||
Object.defineProperty(globalThis, 'FileReader', {
|
||||
writable: true,
|
||||
value: fileReader,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Licensed under the Apache License, Version 2.0.
|
||||
* you may not use this file except in compliance with the License.
|
||||
*/
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { describe, expect, it, vitest } from 'vitest';
|
||||
|
||||
import { blobToBase64 } from './blobToBase64.js';
|
||||
import { mockFileReader } from './__mocks__/mockFileReader.js';
|
||||
@@ -14,8 +14,7 @@ describe('blobToBase64', () => {
|
||||
it('converts blob to base64', async () => {
|
||||
const result = 'data:text/plain;base64,dGVzdA==';
|
||||
const blob = new Blob(['test'], { type: 'text/plain' });
|
||||
|
||||
mockFileReader(() => result);
|
||||
vitest.spyOn(globalThis, 'FileReader').mockImplementationOnce(mockFileReader(() => result));
|
||||
|
||||
const base64 = await blobToBase64(blob);
|
||||
|
||||
@@ -26,7 +25,7 @@ describe('blobToBase64', () => {
|
||||
const result = 'data:text/plain;base64,';
|
||||
const blob = new Blob(['']);
|
||||
|
||||
mockFileReader(() => result);
|
||||
vitest.spyOn(globalThis, 'FileReader').mockImplementationOnce(mockFileReader(() => result));
|
||||
|
||||
const base64 = await blobToBase64(blob);
|
||||
|
||||
@@ -37,7 +36,7 @@ describe('blobToBase64', () => {
|
||||
const result = 'data:application/octet-stream;base64,dGhpcyBpcyBhIHRlc3Qgd2l0aCA=';
|
||||
const blob = new Blob(['this is a test with longer text']);
|
||||
|
||||
mockFileReader(() => result);
|
||||
vitest.spyOn(globalThis, 'FileReader').mockImplementationOnce(mockFileReader(() => result));
|
||||
|
||||
const base64 = await blobToBase64(blob, 20);
|
||||
|
||||
|
||||
@@ -5,33 +5,60 @@
|
||||
* Licensed under the Apache License, Version 2.0.
|
||||
* you may not use this file except in compliance with the License.
|
||||
*/
|
||||
import { beforeAll, describe, expect, it, vitest } from 'vitest';
|
||||
import { afterAll, beforeEach, describe, expect, it, vitest } from 'vitest';
|
||||
|
||||
import { copyToClipboard } from './copyToClipboard.js';
|
||||
|
||||
describe('copyToClipboard', () => {
|
||||
beforeAll(() => {
|
||||
document.execCommand = vitest.fn() as any;
|
||||
const originalExecCommand = document.execCommand;
|
||||
|
||||
beforeEach(() => {
|
||||
document.execCommand = vitest.fn();
|
||||
});
|
||||
|
||||
it('should copy data to clipboard', () => {
|
||||
copyToClipboard('test');
|
||||
|
||||
expect(document.execCommand).toHaveBeenCalledWith('copy');
|
||||
afterAll(() => {
|
||||
document.execCommand = originalExecCommand;
|
||||
});
|
||||
|
||||
it('should focus on active element after copy', () => {
|
||||
const focusSpy = vitest.spyOn(document.body, 'focus');
|
||||
it('should copy text to clipboard', () => {
|
||||
const testData = 'test clipboard data';
|
||||
const execCommandMock = vitest.spyOn(document, 'execCommand').mockReturnValue(true);
|
||||
|
||||
copyToClipboard('test');
|
||||
copyToClipboard(testData);
|
||||
|
||||
expect(document.activeElement).toBe(document.body);
|
||||
expect(focusSpy).toHaveBeenCalled();
|
||||
expect(execCommandMock).toHaveBeenCalledWith('copy');
|
||||
});
|
||||
|
||||
it('should have no children after copy', () => {
|
||||
copyToClipboard('test');
|
||||
it('should create and remove a temporary textarea element', () => {
|
||||
const testData = 'test data';
|
||||
const appendChildSpy = vitest.spyOn(document.body, 'appendChild');
|
||||
const removeChildSpy = vitest.spyOn(document.body, 'removeChild');
|
||||
|
||||
expect(document.body.children.length).toBe(0);
|
||||
copyToClipboard(testData);
|
||||
|
||||
expect(appendChildSpy).toHaveBeenCalledTimes(1);
|
||||
expect(removeChildSpy).toHaveBeenCalledTimes(1);
|
||||
|
||||
const firstCall = appendChildSpy.mock.calls[0];
|
||||
expect(firstCall).toBeDefined();
|
||||
|
||||
const textarea = firstCall![0] as HTMLTextAreaElement;
|
||||
expect(textarea.tagName).toBe('TEXTAREA');
|
||||
expect(textarea.value).toBe(testData);
|
||||
});
|
||||
|
||||
it('should restore focus to the previously active element', () => {
|
||||
const testData = 'test data';
|
||||
const mockElement = document.createElement('input');
|
||||
const focusSpy = vitest.spyOn(mockElement, 'focus');
|
||||
|
||||
document.body.appendChild(mockElement);
|
||||
mockElement.focus();
|
||||
|
||||
copyToClipboard(testData);
|
||||
|
||||
expect(focusSpy).toHaveBeenCalledWith({ preventScroll: true });
|
||||
|
||||
document.body.removeChild(mockElement);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -6,11 +6,16 @@
|
||||
* you may not use this file except in compliance with the License.
|
||||
*/
|
||||
|
||||
import { describe, expect, it, vitest } from 'vitest';
|
||||
import { beforeEach, describe, expect, it, vitest } from 'vitest';
|
||||
|
||||
import { download } from './download.js';
|
||||
|
||||
describe('download', () => {
|
||||
beforeEach(() => {
|
||||
// Clean up any existing links from previous tests
|
||||
document.body.innerHTML = '';
|
||||
});
|
||||
|
||||
it('should not create links after download', () => {
|
||||
const blob = new Blob(['test'], { type: 'text/plain' });
|
||||
const linksBefore = document.querySelectorAll('a');
|
||||
|
||||
@@ -21,6 +21,7 @@ type MockXHR = {
|
||||
|
||||
describe('downloadFromURL', () => {
|
||||
let mockXHR: MockXHR;
|
||||
let originalXMLHttpRequest: typeof globalThis.XMLHttpRequest;
|
||||
|
||||
beforeEach(() => {
|
||||
vi.useFakeTimers();
|
||||
@@ -34,11 +35,15 @@ describe('downloadFromURL', () => {
|
||||
response: null,
|
||||
};
|
||||
|
||||
(globalThis as any).XMLHttpRequest = vi.fn(() => mockXHR);
|
||||
originalXMLHttpRequest = globalThis.XMLHttpRequest;
|
||||
(globalThis as any).XMLHttpRequest = function XMLHttpRequest() {
|
||||
return mockXHR;
|
||||
};
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.useRealTimers();
|
||||
globalThis.XMLHttpRequest = originalXMLHttpRequest;
|
||||
});
|
||||
|
||||
it('should open and send request to the specified URL', () => {
|
||||
|
||||
@@ -13,7 +13,7 @@ import { getTextFileReadingProcess } from './getTextFileReadingProcess.js';
|
||||
describe('getTextFileReadingProcess', () => {
|
||||
let file: File;
|
||||
let mockFileReader: Partial<FileReader>;
|
||||
let fileReaderMock: MockInstance<(this: FileReader) => FileReader>;
|
||||
let fileReaderMock: MockInstance<new (fileReader: FileReader) => FileReader>;
|
||||
|
||||
initKnownConsoleMessages(() => {
|
||||
addKnownError(/Error: Read error/);
|
||||
@@ -29,7 +29,9 @@ describe('getTextFileReadingProcess', () => {
|
||||
onabort: null,
|
||||
};
|
||||
|
||||
fileReaderMock = vitest.spyOn(window, 'FileReader').mockImplementation(() => mockFileReader as FileReader);
|
||||
fileReaderMock = vitest.spyOn(window, 'FileReader').mockImplementation(function FileReader() {
|
||||
return mockFileReader;
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
|
||||
@@ -5,20 +5,26 @@
|
||||
* Licensed under the Apache License, Version 2.0.
|
||||
* you may not use this file except in compliance with the License.
|
||||
*/
|
||||
import { describe, expect, it, vitest } from 'vitest';
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
|
||||
import { withTimestamp } from './withTimestamp.js';
|
||||
|
||||
describe('withTimestamp', () => {
|
||||
beforeEach(() => {
|
||||
vi.useFakeTimers();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.useRealTimers();
|
||||
});
|
||||
|
||||
it('should generate a value with timestamp at the end', () => {
|
||||
const mockDate = new Date('2020-09-09T14:13:20');
|
||||
const spy = vitest.spyOn(globalThis, 'Date').mockImplementation(() => mockDate);
|
||||
vi.setSystemTime(mockDate);
|
||||
|
||||
const value = 'value';
|
||||
const expectedValue = `${value} 2020-09-09 14-13-20`;
|
||||
|
||||
expect(withTimestamp(value)).toEqual(expectedValue);
|
||||
|
||||
spy.mockRestore();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -29,9 +29,9 @@
|
||||
"eslint": "^9",
|
||||
"eslint-config-prettier": "^10",
|
||||
"eslint-plugin-react": "^7",
|
||||
"eslint-plugin-react-hooks": "^5",
|
||||
"eslint-plugin-storybook": "^9",
|
||||
"storybook": "^9",
|
||||
"eslint-plugin-react-hooks": "^7",
|
||||
"eslint-plugin-storybook": "^10",
|
||||
"storybook": "^10",
|
||||
"typescript-eslint": "^8"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,6 +56,6 @@
|
||||
"rimraf": "^6",
|
||||
"typescript": "^5",
|
||||
"typescript-plugin-css-modules": "^5",
|
||||
"vitest": "^3"
|
||||
"vitest": "^4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,6 +53,6 @@
|
||||
"rimraf": "^6",
|
||||
"typescript": "^5",
|
||||
"typescript-plugin-css-modules": "^5",
|
||||
"vitest": "^3"
|
||||
"vitest": "^4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,6 +62,6 @@
|
||||
"rimraf": "^6",
|
||||
"typescript": "^5",
|
||||
"typescript-plugin-css-modules": "^5",
|
||||
"vitest": "^3"
|
||||
"vitest": "^4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,6 +49,6 @@
|
||||
"rimraf": "^6",
|
||||
"typescript": "^5",
|
||||
"typescript-plugin-css-modules": "^5",
|
||||
"vitest": "^3"
|
||||
"vitest": "^4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,6 +55,6 @@
|
||||
"rimraf": "^6",
|
||||
"typescript": "^5",
|
||||
"typescript-plugin-css-modules": "^5",
|
||||
"vitest": "^3"
|
||||
"vitest": "^4"
|
||||
}
|
||||
}
|
||||
|
||||
+2
-4
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* CloudBeaver - Cloud Database Manager
|
||||
* Copyright (C) 2020-2024 DBeaver Corp and others
|
||||
* Copyright (C) 2020-2025 DBeaver Corp and others
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0.
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -30,9 +30,7 @@ export type NavTreeControlProps = {
|
||||
onClick?: (event: React.MouseEvent<HTMLDivElement>) => void;
|
||||
};
|
||||
|
||||
export type NavTreeControlComponent =
|
||||
| React.MemoExoticComponent<React.ForwardRefExoticComponent<React.PropsWithoutRef<NavTreeControlProps> & React.RefAttributes<HTMLDivElement>>>
|
||||
| React.ForwardRefExoticComponent<React.PropsWithoutRef<NavTreeControlProps> & React.RefAttributes<HTMLDivElement>>;
|
||||
export type NavTreeControlComponent = React.ComponentType<React.PropsWithoutRef<NavTreeControlProps> & React.RefAttributes<HTMLDivElement>>;
|
||||
|
||||
export type NavigationNodeComponent = React.FC<{
|
||||
node: NavNode;
|
||||
|
||||
@@ -15,9 +15,7 @@ export interface INodeControlBaseProps extends React.RefAttributes<HTMLDivElemen
|
||||
nodeId: string;
|
||||
}
|
||||
|
||||
export type NodeControlComponent =
|
||||
| React.MemoExoticComponent<React.ForwardRefExoticComponent<React.PropsWithoutRef<INodeControlBaseProps> & React.RefAttributes<HTMLDivElement>>>
|
||||
| React.ForwardRefExoticComponent<React.PropsWithoutRef<INodeControlBaseProps> & React.RefAttributes<HTMLDivElement>>;
|
||||
export type NodeControlComponent = React.ComponentType<React.PropsWithoutRef<INodeControlBaseProps> & React.RefAttributes<HTMLDivElement>>;
|
||||
|
||||
export interface INodeComponentProps extends INodeComponentBaseProps {
|
||||
childrenRenderer: React.FC<INodeComponentBaseProps>;
|
||||
|
||||
@@ -43,6 +43,6 @@
|
||||
"@dbeaver/react-tests": "workspace:*",
|
||||
"rimraf": "^6",
|
||||
"typescript": "^5",
|
||||
"vitest": "^3"
|
||||
"vitest": "^4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,6 +61,6 @@
|
||||
"rimraf": "^6",
|
||||
"typescript": "^5",
|
||||
"typescript-plugin-css-modules": "^5",
|
||||
"vitest": "^3"
|
||||
"vitest": "^4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
import type { StorybookConfig } from '@storybook/react-vite';
|
||||
|
||||
import { join, dirname } from 'path';
|
||||
import { dirname } from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
/**
|
||||
* This function is used to resolve the absolute path of a package.
|
||||
* It is needed in projects that use Yarn PnP or are set up within a monorepo.
|
||||
*/
|
||||
function getAbsolutePath(value: string): any {
|
||||
return dirname(require.resolve(join(value, 'package.json')));
|
||||
function getAbsolutePath(value: string): string {
|
||||
const resolved = import.meta.resolve(`${value}/package.json`);
|
||||
return dirname(fileURLToPath(resolved));
|
||||
}
|
||||
|
||||
const config: StorybookConfig = {
|
||||
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
|
||||
addons: [getAbsolutePath('@storybook/addon-docs')],
|
||||
|
||||
@@ -14,16 +14,17 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@cloudbeaver/tsconfig": "workspace:*",
|
||||
"@storybook/addon-docs": "^9",
|
||||
"@storybook/react-vite": "^9",
|
||||
"@storybook/addon-docs": "^10",
|
||||
"@storybook/react-vite": "^10",
|
||||
"@tailwindcss/vite": "4.0.7",
|
||||
"@types/node": "^22",
|
||||
"@types/react": "^19",
|
||||
"@types/react-dom": "^19",
|
||||
"@vitejs/plugin-react": "^5",
|
||||
"@wroud/vite-plugin-asset-resolver": "^0",
|
||||
"@wroud/vite-plugin-tsc": "^0",
|
||||
"globals": "^16",
|
||||
"storybook": "^9",
|
||||
"storybook": "^10",
|
||||
"tailwindcss": "4.0.7",
|
||||
"typescript": "^5",
|
||||
"vite": "^7"
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
"react": "^19",
|
||||
"react-dom": "^19",
|
||||
"tslib": "^2",
|
||||
"vitest": "^3"
|
||||
"vitest": "^4"
|
||||
},
|
||||
"sideEffects": [
|
||||
"./lib/module.js",
|
||||
@@ -45,6 +45,6 @@
|
||||
"@types/react": "^19",
|
||||
"rimraf": "^6",
|
||||
"typescript": "^5",
|
||||
"vitest": "^3"
|
||||
"vitest": "^4"
|
||||
}
|
||||
}
|
||||
|
||||
+1901
-2084
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user