mirror of https://github.com/apache/superset.git
feat(build): uplift `Jest` to v29 (#29118)
Signed-off-by: hainenber <dotronghai96@gmail.com> Co-authored-by: Maxime Beauchemin <maximebeauchemin@gmail.com> Co-authored-by: JUST.in DO IT <justin.park@airbnb.com>
This commit is contained in:
parent
f9f70e3e55
commit
dffad48504
|
@ -116,4 +116,8 @@ docker/requirements-local.txt
|
|||
|
||||
cache/
|
||||
docker/*local*
|
||||
|
||||
.temp_cache
|
||||
|
||||
# Jest test report
|
||||
test-report.html
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -41,10 +41,10 @@
|
|||
"@babel/core": "^7.16.12",
|
||||
"@babel/preset-env": "^7.16.11",
|
||||
"@babel/preset-typescript": "^7.16.7",
|
||||
"@types/jest": "^27.4.1",
|
||||
"@types/jest": "^29.5.12",
|
||||
"axios": "^1.6.0",
|
||||
"babel-loader": "^8.2.3",
|
||||
"jest": "^27.5.1",
|
||||
"jest": "^29.7.0",
|
||||
"typescript": "^4.5.5",
|
||||
"webpack": "^5.67.0",
|
||||
"webpack-cli": "^4.9.2"
|
||||
|
|
|
@ -26,7 +26,7 @@ import {
|
|||
|
||||
describe("guest token refresh", () => {
|
||||
beforeAll(() => {
|
||||
jest.useFakeTimers("modern"); // "modern" allows us to fake the system time
|
||||
jest.useFakeTimers();
|
||||
jest.setSystemTime(new Date("2022-03-03 01:00"));
|
||||
jest.spyOn(global, "setTimeout");
|
||||
});
|
||||
|
|
|
@ -35,7 +35,9 @@ module.exports = {
|
|||
testEnvironment: 'jsdom',
|
||||
modulePathIgnorePatterns: ['<rootDir>/packages/generator-superset'],
|
||||
setupFilesAfterEnv: ['<rootDir>/spec/helpers/setup.ts'],
|
||||
testURL: 'http://localhost',
|
||||
testEnvironmentOptions: {
|
||||
url: 'http://localhost',
|
||||
},
|
||||
collectCoverageFrom: [
|
||||
'src/**/*.{js,jsx,ts,tsx}',
|
||||
'{packages,plugins}/**/src/**/*.{js,jsx,ts,tsx}',
|
||||
|
@ -60,4 +62,13 @@ module.exports = {
|
|||
__DEV__: true,
|
||||
caches: true,
|
||||
},
|
||||
reporters: [
|
||||
'default',
|
||||
[
|
||||
'./node_modules/jest-html-reporter',
|
||||
{
|
||||
pageTitle: 'Test Report',
|
||||
},
|
||||
],
|
||||
],
|
||||
};
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -67,7 +67,7 @@
|
|||
"prune": "rm -rf ./{packages,plugins}/*/{lib,esm,tsconfig.tsbuildinfo,package-lock.json}",
|
||||
"storybook": "cross-env NODE_ENV=development BABEL_ENV=development storybook dev -p 6006",
|
||||
"tdd": "cross-env NODE_ENV=test jest --watch",
|
||||
"test": "cross-env NODE_ENV=test jest",
|
||||
"test": "cross-env NODE_ENV=test jest --max-workers=50%",
|
||||
"type": "tsc --noEmit",
|
||||
"update-maps": "jupyter nbconvert --to notebook --execute --inplace 'plugins/legacy-plugin-chart-country-map/scripts/Country Map GeoJSON Generator.ipynb' -Xfrozen_modules=off",
|
||||
"validate-release": "../RELEASING/validate_this_release.sh"
|
||||
|
@ -167,7 +167,7 @@
|
|||
"react-diff-viewer-continued": "^3.2.5",
|
||||
"react-dnd": "^11.1.3",
|
||||
"react-dnd-html5-backend": "^11.1.3",
|
||||
"react-dom": "^16.13.0",
|
||||
"react-dom": "^16.13.1",
|
||||
"react-draggable": "^4.4.6",
|
||||
"react-hot-loader": "^4.13.1",
|
||||
"react-intersection-observer": "^9.10.2",
|
||||
|
@ -223,7 +223,7 @@
|
|||
"@babel/register": "^7.23.7",
|
||||
"@cypress/react": "^5.10.0",
|
||||
"@emotion/babel-plugin": "^11.11.0",
|
||||
"@emotion/jest": "^11.3.0",
|
||||
"@emotion/jest": "^11.11.0",
|
||||
"@hot-loader/react-dom": "^16.14.0",
|
||||
"@istanbuljs/nyc-config-typescript": "^1.0.1",
|
||||
"@storybook/addon-actions": "^7.6.13",
|
||||
|
@ -248,7 +248,7 @@
|
|||
"@types/enzyme": "^3.10.18",
|
||||
"@types/enzyme-adapter-react-16": "^1.0.6",
|
||||
"@types/fetch-mock": "^7.3.2",
|
||||
"@types/jest": "^26.0.3",
|
||||
"@types/jest": "^29.5.12",
|
||||
"@types/jquery": "^3.5.8",
|
||||
"@types/js-levenshtein": "^1.1.3",
|
||||
"@types/json-bigint": "^1.0.4",
|
||||
|
@ -315,9 +315,11 @@
|
|||
"history": "^4.10.1",
|
||||
"ignore-styles": "^5.0.1",
|
||||
"imports-loader": "^5.0.0",
|
||||
"jest": "^26.6.3",
|
||||
"jest": "^29.7.0",
|
||||
"jest-environment-enzyme": "^7.1.2",
|
||||
"jest-environment-jsdom": "^29.7.0",
|
||||
"jest-enzyme": "^7.1.2",
|
||||
"jest-html-reporter": "^3.10.2",
|
||||
"jest-websocket-mock": "^2.2.0",
|
||||
"jsdom": "^24.0.0",
|
||||
"lerna": "^6.6.2",
|
||||
|
|
|
@ -23,7 +23,7 @@ const TODAY = '2024-06-03';
|
|||
|
||||
// Mock Date to always return 2024-06-03
|
||||
beforeEach(() => {
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
jest.setSystemTime(new Date(TODAY).getTime());
|
||||
});
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ const runTimezoneTest = (
|
|||
};
|
||||
|
||||
test('should handle includeFutureOffsets is null', () => {
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
jest.setSystemTime(new Date(NOW_UTC_IN_EUROPE));
|
||||
timezoneMock.register('Etc/GMT-2');
|
||||
const result = getTimeOffset({
|
||||
|
@ -72,7 +72,7 @@ test('should handle custom range with specific dates', () => {
|
|||
};
|
||||
const shifts = ['custom'];
|
||||
const startDate = '2024-05-29';
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
|
||||
runTimezoneTest(
|
||||
NOW_UTC_IN_EUROPE,
|
||||
|
@ -101,7 +101,7 @@ test('should handle custom range with relative dates (now)', () => {
|
|||
};
|
||||
const shifts = ['custom'];
|
||||
const startDate = '2024-05-30';
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
|
||||
runTimezoneTest(
|
||||
NOW_UTC_IN_EUROPE,
|
||||
|
@ -130,7 +130,7 @@ test('should handle inherit shift', () => {
|
|||
};
|
||||
const shifts = ['inherit'];
|
||||
const startDate = '2024-03-06';
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
runTimezoneTest(
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
|
@ -158,7 +158,7 @@ test('should handle custom and inherit shifts', () => {
|
|||
};
|
||||
const shifts = ['custom', 'inherit'];
|
||||
const startDate = '2024-05-28';
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
runTimezoneTest(
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
|
@ -187,7 +187,7 @@ test('should handle no shifts', () => {
|
|||
};
|
||||
const shifts: any = [];
|
||||
const startDate = '2024-03-06';
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
runTimezoneTest(
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
|
@ -211,7 +211,7 @@ test('should handle null timeRangeFilter', () => {
|
|||
const timeRangeFilter = null;
|
||||
const shifts = ['custom'];
|
||||
const startDate = '2024-06-01';
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
runTimezoneTest(
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
|
@ -239,7 +239,7 @@ test('should handle predefined shifts', () => {
|
|||
};
|
||||
const shifts: any = ['1 year ago'];
|
||||
const startDate = '2024-03-06';
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
|
||||
runTimezoneTest(
|
||||
NOW_UTC_IN_EUROPE,
|
||||
|
@ -269,7 +269,7 @@ test('should handle custom range with DATEADD function', () => {
|
|||
};
|
||||
const shifts = ['custom'];
|
||||
const startDate = '2024-05-21';
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
runTimezoneTest(
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
|
@ -297,7 +297,7 @@ test('should handle custom range with DATEADD function and relative start date',
|
|||
};
|
||||
const shifts = ['custom'];
|
||||
const startDate = '2024-06-01';
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
runTimezoneTest(
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
|
@ -325,7 +325,7 @@ test('should handle custom range with DATEADD function and relative end date', (
|
|||
};
|
||||
const shifts = ['custom'];
|
||||
const startDate = '2024-05-23';
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
|
||||
runTimezoneTest(
|
||||
NOW_UTC_IN_EUROPE,
|
||||
|
@ -354,7 +354,7 @@ test('should handle custom range with specific date and relative end date', () =
|
|||
};
|
||||
const shifts = ['custom'];
|
||||
const startDate = '2024-05-23';
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
|
||||
runTimezoneTest(
|
||||
NOW_UTC_IN_EUROPE,
|
||||
|
@ -383,7 +383,7 @@ test('should handle custom range with specific date and specific end date', () =
|
|||
};
|
||||
const shifts = ['custom'];
|
||||
const startDate = '2024-06-01';
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
runTimezoneTest(
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
|
@ -411,7 +411,7 @@ test('should handle custom range with Last and now', () => {
|
|||
};
|
||||
const shifts = ['custom'];
|
||||
const startDate = '2024-05-30';
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
runTimezoneTest(
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
|
@ -439,7 +439,7 @@ test('should handle custom range with Last week', () => {
|
|||
};
|
||||
const shifts = ['custom'];
|
||||
const startDate = '2024-05-21';
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
runTimezoneTest(
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
|
@ -467,7 +467,7 @@ test('should handle custom range with previous calendar week', () => {
|
|||
};
|
||||
const shifts = ['custom'];
|
||||
const startDate = '2024-05-26';
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
runTimezoneTest(
|
||||
'2024-06-05T02:06:00+02:00',
|
||||
'Etc/GMT-2',
|
||||
|
@ -500,7 +500,7 @@ test('should handle custom range with previous calendar month', () => {
|
|||
};
|
||||
const shifts = ['custom'];
|
||||
const startDate = '2024-04-26';
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
runTimezoneTest(
|
||||
'2024-06-05T02:06:00+02:00',
|
||||
'Etc/GMT-2',
|
||||
|
@ -533,7 +533,7 @@ test('should handle custom range with previous calendar year', () => {
|
|||
};
|
||||
const shifts = ['custom'];
|
||||
const startDate = '2022-12-26';
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
|
||||
runTimezoneTest(
|
||||
'2024-06-05T02:06:00+02:00',
|
||||
|
@ -567,7 +567,7 @@ test('should handle custom range with Advanced 2022-11-01', () => {
|
|||
};
|
||||
const shifts = ['custom'];
|
||||
const startDate = '2022-10-18';
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
|
||||
runTimezoneTest(
|
||||
'2024-06-05T02:06:00+02:00',
|
||||
|
@ -601,7 +601,7 @@ test('should handle future inherit shift with includeFutureOffsets set to true',
|
|||
};
|
||||
const shifts = ['inherit'];
|
||||
const startDate = '2024-06-20';
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
|
||||
runTimezoneTest(
|
||||
NOW_UTC_IN_EUROPE,
|
||||
|
@ -638,7 +638,7 @@ test('should handle future custom shift with includeFutureOffsets set to true',
|
|||
};
|
||||
const shifts = ['custom'];
|
||||
const startDate = '2024-06-15';
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
|
||||
runTimezoneTest(
|
||||
NOW_UTC_IN_EUROPE,
|
||||
|
@ -667,7 +667,7 @@ test('should handle custom range with specific (YYYY-MM) and relative dates', ()
|
|||
};
|
||||
const shifts = ['custom'];
|
||||
const startDate = '2024-05-29';
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
|
||||
runTimezoneTest(
|
||||
NOW_UTC_IN_EUROPE,
|
||||
|
@ -696,7 +696,7 @@ test('should handle custom range with minutes', () => {
|
|||
};
|
||||
const shifts = ['custom'];
|
||||
const startDate = '2024-05-29';
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
|
||||
runTimezoneTest(
|
||||
NOW_UTC_IN_EUROPE,
|
||||
|
@ -725,7 +725,7 @@ test('should handle custom range with undefined startDate', () => {
|
|||
};
|
||||
const shifts = ['custom'];
|
||||
const startDate = undefined;
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
|
||||
runTimezoneTest(
|
||||
NOW_UTC_IN_EUROPE,
|
||||
|
@ -752,7 +752,7 @@ test('should handle future custom shift with different format', () => {
|
|||
};
|
||||
const shifts = ['custom'];
|
||||
const startDate = '2024-06-15';
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
|
||||
runTimezoneTest(
|
||||
NOW_UTC_IN_EUROPE,
|
||||
|
@ -782,7 +782,7 @@ test('should handle custom range with relative dates', () => {
|
|||
};
|
||||
const shifts = ['custom'];
|
||||
const startDate = '2024-05-29';
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
|
||||
runTimezoneTest(
|
||||
NOW_UTC_IN_EUROPE,
|
||||
|
@ -812,7 +812,7 @@ test('should handle custom range with relative dates (minute and seconds)', () =
|
|||
};
|
||||
const shifts = ['custom'];
|
||||
const startDate = '2024-05-29';
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
|
||||
runTimezoneTest(
|
||||
NOW_UTC_IN_EUROPE,
|
||||
|
@ -842,7 +842,7 @@ test('should handle custom range with relative dates (hour)', () => {
|
|||
};
|
||||
const shifts = ['custom'];
|
||||
const startDate = '2024-05-29';
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
|
||||
runTimezoneTest(
|
||||
NOW_UTC_IN_EUROPE,
|
||||
|
@ -871,7 +871,7 @@ test('should handle custom shifts with same day', () => {
|
|||
};
|
||||
const shifts = ['custom'];
|
||||
const startDate = '2024-05-29';
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
|
||||
runTimezoneTest(
|
||||
NOW_UTC_IN_EUROPE,
|
||||
|
@ -900,7 +900,7 @@ test('should handle inherit shifts without filter', () => {
|
|||
};
|
||||
const shifts = ['inherit'];
|
||||
const startDate = '2024-05-29';
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
|
||||
runTimezoneTest(
|
||||
NOW_UTC_IN_EUROPE,
|
||||
|
@ -927,7 +927,7 @@ test('should handle inherit shift same day', () => {
|
|||
};
|
||||
const shifts = ['inherit'];
|
||||
const startDate = '2024-03-06';
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
runTimezoneTest(
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
|
@ -963,7 +963,7 @@ test('should handle inherit shift same day includeFutureOffsets set to false', (
|
|||
};
|
||||
const shifts = ['inherit'];
|
||||
const startDate = '2024-03-06';
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
runTimezoneTest(
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
|
@ -999,7 +999,7 @@ test('should handle custom shift same day includeFutureOffsets set to false', ()
|
|||
};
|
||||
const shifts = ['custom'];
|
||||
const startDate = '2024-03-06';
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
runTimezoneTest(
|
||||
NOW_UTC_IN_EUROPE,
|
||||
'Etc/GMT-2',
|
||||
|
|
|
@ -47,7 +47,7 @@ const runTimezoneTest = (
|
|||
};
|
||||
|
||||
test('should return the current date for "now"', () => {
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
runTimezoneTest(
|
||||
'now',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
|
@ -64,7 +64,7 @@ test('should return the current date for "now"', () => {
|
|||
});
|
||||
|
||||
test('should return the current date for "today"', () => {
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
runTimezoneTest(
|
||||
'today',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
|
@ -81,7 +81,7 @@ test('should return the current date for "today"', () => {
|
|||
});
|
||||
|
||||
test('should return the current date for "No filter"', () => {
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
runTimezoneTest(
|
||||
'No filter',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
|
@ -103,7 +103,7 @@ test('should return the current date for "No filter"', () => {
|
|||
});
|
||||
|
||||
test('should return the current date for an empty string', () => {
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
runTimezoneTest(
|
||||
'',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
|
@ -120,7 +120,7 @@ test('should return the current date for an empty string', () => {
|
|||
});
|
||||
|
||||
test('should return yesterday date for "Last day"', () => {
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
runTimezoneTest(
|
||||
'Last day',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
|
@ -142,7 +142,7 @@ test('should return yesterday date for "Last day"', () => {
|
|||
});
|
||||
|
||||
test('should return the date one week ago for "Last week"', () => {
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
runTimezoneTest(
|
||||
'Last week',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
|
@ -164,7 +164,7 @@ test('should return the date one week ago for "Last week"', () => {
|
|||
});
|
||||
|
||||
test('should return the date one month ago for "Last month"', () => {
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
runTimezoneTest(
|
||||
'Last month',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
|
@ -186,7 +186,7 @@ test('should return the date one month ago for "Last month"', () => {
|
|||
});
|
||||
|
||||
test('should return the date three months ago for "Last quarter"', () => {
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
runTimezoneTest(
|
||||
'Last quarter',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
|
@ -208,7 +208,7 @@ test('should return the date three months ago for "Last quarter"', () => {
|
|||
});
|
||||
|
||||
test('should return the date one year ago for "Last year"', () => {
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
runTimezoneTest(
|
||||
'Last year',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
|
@ -230,7 +230,7 @@ test('should return the date one year ago for "Last year"', () => {
|
|||
});
|
||||
|
||||
test('should return the date for "previous calendar week"', () => {
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
runTimezoneTest(
|
||||
'previous calendar week',
|
||||
'2024-06-04T22:00:00Z',
|
||||
|
@ -252,7 +252,7 @@ test('should return the date for "previous calendar week"', () => {
|
|||
});
|
||||
|
||||
test('should return the date for "previous calendar month"', () => {
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
runTimezoneTest(
|
||||
'previous calendar month',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
|
@ -274,7 +274,7 @@ test('should return the date for "previous calendar month"', () => {
|
|||
});
|
||||
|
||||
test('should return the date for "previous calendar year"', () => {
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
runTimezoneTest(
|
||||
'previous calendar year',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
|
@ -296,7 +296,7 @@ test('should return the date for "previous calendar year"', () => {
|
|||
});
|
||||
|
||||
test('should return the date for "1 day ago"', () => {
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
runTimezoneTest(
|
||||
'1 day ago',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
|
@ -318,7 +318,7 @@ test('should return the date for "1 day ago"', () => {
|
|||
});
|
||||
|
||||
test('should return the date for "1 week ago"', () => {
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
runTimezoneTest(
|
||||
'1 week ago',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
|
@ -340,7 +340,7 @@ test('should return the date for "1 week ago"', () => {
|
|||
});
|
||||
|
||||
test('should return the date for "1 month ago"', () => {
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
runTimezoneTest(
|
||||
'1 month ago',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
|
@ -362,7 +362,7 @@ test('should return the date for "1 month ago"', () => {
|
|||
});
|
||||
|
||||
test('should return the date for "1 year ago"', () => {
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
runTimezoneTest(
|
||||
'1 year ago',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
|
@ -384,7 +384,7 @@ test('should return the date for "1 year ago"', () => {
|
|||
});
|
||||
|
||||
test('should return the date for "2024-03-09"', () => {
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
runTimezoneTest(
|
||||
'2024-03-09',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
|
@ -406,7 +406,7 @@ test('should return the date for "2024-03-09"', () => {
|
|||
});
|
||||
|
||||
test('should return the current date for "Last day" with isEndDate true', () => {
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
runTimezoneTest(
|
||||
'Last day',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
|
@ -431,7 +431,7 @@ test('should return the current date for "Last day" with isEndDate true', () =>
|
|||
});
|
||||
|
||||
test('should return the current date for "Last week" with isEndDate true', () => {
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
runTimezoneTest(
|
||||
'Last week',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
|
@ -456,7 +456,7 @@ test('should return the current date for "Last week" with isEndDate true', () =>
|
|||
});
|
||||
|
||||
test('should return the current date for "Last quarter" with isEndDate true', () => {
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
runTimezoneTest(
|
||||
'Last quarter',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
|
@ -481,7 +481,7 @@ test('should return the current date for "Last quarter" with isEndDate true', ()
|
|||
});
|
||||
|
||||
test('should return the current date for "Last year" with isEndDate true', () => {
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
runTimezoneTest(
|
||||
'Last year',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
|
@ -506,7 +506,7 @@ test('should return the current date for "Last year" with isEndDate true', () =>
|
|||
});
|
||||
|
||||
test('should return the date for "previous calendar week" with isEndDate true', () => {
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
runTimezoneTest(
|
||||
'previous calendar week',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
|
@ -531,7 +531,7 @@ test('should return the date for "previous calendar week" with isEndDate true',
|
|||
});
|
||||
|
||||
test('should return the date for "previous calendar month" with isEndDate true', () => {
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
runTimezoneTest(
|
||||
'previous calendar month',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
|
@ -556,7 +556,7 @@ test('should return the date for "previous calendar month" with isEndDate true',
|
|||
});
|
||||
|
||||
test('should return the date for "previous calendar year" with isEndDate true', () => {
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
runTimezoneTest(
|
||||
'previous calendar year',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
|
@ -581,7 +581,7 @@ test('should return the date for "previous calendar year" with isEndDate true',
|
|||
});
|
||||
|
||||
test('should return the date for "2024" with parts.length === 1', () => {
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
runTimezoneTest(
|
||||
'2024',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
|
@ -598,7 +598,7 @@ test('should return the date for "2024" with parts.length === 1', () => {
|
|||
});
|
||||
|
||||
test('should return the date for "2024-03" with parts.length === 2', () => {
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
runTimezoneTest(
|
||||
'2024-03',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
|
@ -620,7 +620,7 @@ test('should return the date for "2024-03" with parts.length === 2', () => {
|
|||
});
|
||||
|
||||
test('should return the date for "2024-03-06" with parts.length === 3', () => {
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
runTimezoneTest(
|
||||
'2024-03-06',
|
||||
NOW_UTC_IN_EUROPE,
|
||||
|
@ -642,7 +642,7 @@ test('should return the date for "2024-03-06" with parts.length === 3', () => {
|
|||
});
|
||||
|
||||
test('should return the date for "2024-03-06" with computingShifts true', () => {
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
const expectedDate = new Date('2024-03-06T22:00:00Z');
|
||||
expectedDate.setHours(-expectedDate.getTimezoneOffset() / 60, 0, 0, 0);
|
||||
runTimezoneTest(
|
||||
|
@ -656,7 +656,7 @@ test('should return the date for "2024-03-06" with computingShifts true', () =>
|
|||
});
|
||||
|
||||
test('should return the date for "2024-03-06" with computingShifts true and isEndDate true', () => {
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
const expectedDate = new Date('2024-03-06T22:00:00Z');
|
||||
expectedDate.setHours(-expectedDate.getTimezoneOffset() / 60, 0, 0, 0);
|
||||
runTimezoneTest(
|
||||
|
|
|
@ -24,6 +24,11 @@ describe('logging', () => {
|
|||
jest.resetAllMocks();
|
||||
});
|
||||
|
||||
const { console } = window;
|
||||
afterAll(() => {
|
||||
Object.assign(window, { console });
|
||||
});
|
||||
|
||||
it('should pipe to `console` methods', () => {
|
||||
const { logging } = require('@superset-ui/core');
|
||||
|
||||
|
@ -53,7 +58,6 @@ describe('logging', () => {
|
|||
});
|
||||
|
||||
it('should use noop functions when console unavailable', () => {
|
||||
const { console } = window;
|
||||
Object.assign(window, { console: undefined });
|
||||
const { logging } = require('@superset-ui/core');
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
import fetchMock from 'fetch-mock';
|
||||
import { render, waitFor } from 'spec/helpers/testing-library';
|
||||
import { render, act } from 'spec/helpers/testing-library';
|
||||
import ToastContainer from 'src/components/MessageToasts/ToastContainer';
|
||||
import { initialState, defaultQueryEditor } from 'src/SqlLab/fixtures';
|
||||
import { logging } from '@superset-ui/core';
|
||||
|
@ -88,7 +88,9 @@ test('sync the unsaved editor tab state when there are new changes since the las
|
|||
sqlLab: unsavedSqlLabState,
|
||||
},
|
||||
});
|
||||
await waitFor(() => jest.advanceTimersByTime(INTERVAL));
|
||||
await act(async () => {
|
||||
jest.advanceTimersByTime(INTERVAL);
|
||||
});
|
||||
expect(fetchMock.calls(updateEditorTabState)).toHaveLength(1);
|
||||
fetchMock.restore();
|
||||
});
|
||||
|
@ -114,7 +116,9 @@ test('sync the unsaved NEW editor state when there are new in local storage', as
|
|||
},
|
||||
},
|
||||
});
|
||||
await waitFor(() => jest.advanceTimersByTime(INTERVAL));
|
||||
await act(async () => {
|
||||
jest.advanceTimersByTime(INTERVAL);
|
||||
});
|
||||
expect(fetchMock.calls(createEditorTabState)).toHaveLength(1);
|
||||
fetchMock.restore();
|
||||
});
|
||||
|
@ -140,9 +144,13 @@ test('sync the active editor id when there are updates in tab history', async ()
|
|||
},
|
||||
},
|
||||
});
|
||||
await waitFor(() => jest.advanceTimersByTime(INTERVAL));
|
||||
await act(async () => {
|
||||
jest.advanceTimersByTime(INTERVAL);
|
||||
});
|
||||
expect(fetchMock.calls(updateActiveEditorTabState)).toHaveLength(1);
|
||||
await waitFor(() => jest.advanceTimersByTime(INTERVAL));
|
||||
await act(async () => {
|
||||
jest.advanceTimersByTime(INTERVAL);
|
||||
});
|
||||
expect(fetchMock.calls(updateActiveEditorTabState)).toHaveLength(1);
|
||||
});
|
||||
|
||||
|
@ -163,9 +171,13 @@ test('sync the destroyed editor id when there are updates in destroyed editors',
|
|||
},
|
||||
},
|
||||
});
|
||||
await waitFor(() => jest.advanceTimersByTime(INTERVAL));
|
||||
await act(async () => {
|
||||
jest.advanceTimersByTime(INTERVAL);
|
||||
});
|
||||
expect(fetchMock.calls(deleteEditorState)).toHaveLength(1);
|
||||
await waitFor(() => jest.advanceTimersByTime(INTERVAL));
|
||||
await act(async () => {
|
||||
jest.advanceTimersByTime(INTERVAL);
|
||||
});
|
||||
expect(fetchMock.calls(deleteEditorState)).toHaveLength(1);
|
||||
});
|
||||
|
||||
|
@ -188,7 +200,9 @@ test('skip syncing the unsaved editor tab state when the updates are already syn
|
|||
},
|
||||
},
|
||||
});
|
||||
await waitFor(() => jest.advanceTimersByTime(INTERVAL));
|
||||
await act(async () => {
|
||||
jest.advanceTimersByTime(INTERVAL);
|
||||
});
|
||||
expect(fetchMock.calls(updateEditorTabState)).toHaveLength(0);
|
||||
fetchMock.restore();
|
||||
});
|
||||
|
@ -212,7 +226,9 @@ test('renders an error toast when the sync failed', async () => {
|
|||
},
|
||||
},
|
||||
);
|
||||
await waitFor(() => jest.advanceTimersByTime(INTERVAL));
|
||||
await act(async () => {
|
||||
jest.advanceTimersByTime(INTERVAL);
|
||||
});
|
||||
|
||||
expect(logging.warn).toHaveBeenCalledTimes(1);
|
||||
expect(logging.warn).toHaveBeenCalledWith(
|
||||
|
|
|
@ -272,6 +272,7 @@ test('should display options in order of the api response', async () => {
|
|||
});
|
||||
|
||||
test('Should fetch the search keyword when total count exceeds initial options', async () => {
|
||||
fetchMock.reset();
|
||||
fetchMock.get(
|
||||
databaseApiRoute,
|
||||
{
|
||||
|
|
|
@ -151,12 +151,12 @@ describe('ListView', () => {
|
|||
expect(wrapper.find(ListView)).toExist();
|
||||
expect(mockedProps.fetchData.mock.calls[0]).toMatchInlineSnapshot(
|
||||
`
|
||||
Array [
|
||||
Object {
|
||||
"filters": Array [],
|
||||
[
|
||||
{
|
||||
"filters": [],
|
||||
"pageIndex": 0,
|
||||
"pageSize": 1,
|
||||
"sortBy": Array [],
|
||||
"sortBy": [],
|
||||
},
|
||||
]
|
||||
`,
|
||||
|
@ -168,13 +168,13 @@ describe('ListView', () => {
|
|||
expect(mockedProps.fetchData).toHaveBeenCalled();
|
||||
expect(mockedProps.fetchData.mock.calls[0]).toMatchInlineSnapshot(
|
||||
`
|
||||
Array [
|
||||
Object {
|
||||
"filters": Array [],
|
||||
[
|
||||
{
|
||||
"filters": [],
|
||||
"pageIndex": 0,
|
||||
"pageSize": 1,
|
||||
"sortBy": Array [
|
||||
Object {
|
||||
"sortBy": [
|
||||
{
|
||||
"desc": false,
|
||||
"id": "id",
|
||||
},
|
||||
|
@ -199,13 +199,13 @@ describe('ListView', () => {
|
|||
wrapper.update();
|
||||
|
||||
expect(mockedProps.fetchData.mock.calls[0]).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"filters": Array [],
|
||||
[
|
||||
{
|
||||
"filters": [],
|
||||
"pageIndex": 1,
|
||||
"pageSize": 1,
|
||||
"sortBy": Array [
|
||||
Object {
|
||||
"sortBy": [
|
||||
{
|
||||
"desc": false,
|
||||
"id": "id",
|
||||
},
|
||||
|
@ -233,9 +233,9 @@ describe('ListView', () => {
|
|||
|
||||
expect(mockedProps.bulkActions[0].onSelect.mock.calls[0])
|
||||
.toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Array [
|
||||
Object {
|
||||
[
|
||||
[
|
||||
{
|
||||
"age": 10,
|
||||
"id": 1,
|
||||
"name": "data 1",
|
||||
|
@ -264,15 +264,15 @@ describe('ListView', () => {
|
|||
|
||||
expect(mockedProps.bulkActions[0].onSelect.mock.calls[0])
|
||||
.toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Array [
|
||||
Object {
|
||||
[
|
||||
[
|
||||
{
|
||||
"age": 10,
|
||||
"id": 1,
|
||||
"name": "data 1",
|
||||
"time": "2020-11-18T07:53:45.354Z",
|
||||
},
|
||||
Object {
|
||||
{
|
||||
"age": 1,
|
||||
"id": 2,
|
||||
"name": "data 2",
|
||||
|
@ -406,13 +406,13 @@ describe('ListView', () => {
|
|||
});
|
||||
|
||||
expect(mockedProps.fetchData.mock.calls[0]).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"filters": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"filters": [
|
||||
{
|
||||
"id": "id",
|
||||
"operator": "eq",
|
||||
"value": Object {
|
||||
"value": {
|
||||
"label": "bar",
|
||||
"value": "bar",
|
||||
},
|
||||
|
@ -420,8 +420,8 @@ describe('ListView', () => {
|
|||
],
|
||||
"pageIndex": 0,
|
||||
"pageSize": 1,
|
||||
"sortBy": Array [
|
||||
Object {
|
||||
"sortBy": [
|
||||
{
|
||||
"desc": false,
|
||||
"id": "id",
|
||||
},
|
||||
|
@ -431,18 +431,18 @@ describe('ListView', () => {
|
|||
`);
|
||||
|
||||
expect(mockedProps.fetchData.mock.calls[1]).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"filters": Array [
|
||||
Object {
|
||||
[
|
||||
{
|
||||
"filters": [
|
||||
{
|
||||
"id": "id",
|
||||
"operator": "eq",
|
||||
"value": Object {
|
||||
"value": {
|
||||
"label": "bar",
|
||||
"value": "bar",
|
||||
},
|
||||
},
|
||||
Object {
|
||||
{
|
||||
"id": "name",
|
||||
"operator": "ct",
|
||||
"value": "something",
|
||||
|
@ -450,8 +450,8 @@ describe('ListView', () => {
|
|||
],
|
||||
"pageIndex": 0,
|
||||
"pageSize": 1,
|
||||
"sortBy": Array [
|
||||
Object {
|
||||
"sortBy": [
|
||||
{
|
||||
"desc": false,
|
||||
"id": "id",
|
||||
},
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { FC } from 'react';
|
||||
import { render, waitFor, screen } from 'spec/helpers/testing-library';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import type { TimezoneSelectorProps } from './index';
|
||||
|
||||
const loadComponent = (mockCurrentTime?: string) => {
|
||||
if (mockCurrentTime) {
|
||||
jest.useFakeTimers();
|
||||
jest.setSystemTime(new Date(mockCurrentTime));
|
||||
}
|
||||
return new Promise<FC<TimezoneSelectorProps>>(resolve => {
|
||||
const { default: TimezoneSelector } = module.require('./index');
|
||||
resolve(TimezoneSelector);
|
||||
jest.useRealTimers();
|
||||
});
|
||||
};
|
||||
|
||||
test('render timezones in correct order for daylight saving time', async () => {
|
||||
const TimezoneSelector = await loadComponent('2022-07-01');
|
||||
const onTimezoneChange = jest.fn();
|
||||
render(
|
||||
<TimezoneSelector
|
||||
onTimezoneChange={onTimezoneChange}
|
||||
timezone="America/Nassau"
|
||||
/>,
|
||||
);
|
||||
|
||||
const searchInput = screen.getByRole('combobox');
|
||||
userEvent.click(searchInput);
|
||||
|
||||
const options = await waitFor(() =>
|
||||
document.querySelectorAll('.ant-select-item-option-content'),
|
||||
);
|
||||
|
||||
// first option is always current timezone
|
||||
expect(options[0]).toHaveTextContent('GMT -04:00 (Eastern Daylight Time)');
|
||||
expect(options[1]).toHaveTextContent('GMT -11:00 (Pacific/Pago_Pago)');
|
||||
expect(options[2]).toHaveTextContent('GMT -10:00 (Hawaii Standard Time)');
|
||||
expect(options[3]).toHaveTextContent('GMT -09:30 (Pacific/Marquesas)');
|
||||
});
|
|
@ -24,15 +24,13 @@ import type { TimezoneSelectorProps } from './index';
|
|||
|
||||
const loadComponent = (mockCurrentTime?: string) => {
|
||||
if (mockCurrentTime) {
|
||||
jest.useFakeTimers('modern');
|
||||
jest.useFakeTimers();
|
||||
jest.setSystemTime(new Date(mockCurrentTime));
|
||||
}
|
||||
return new Promise<FC<TimezoneSelectorProps>>(resolve => {
|
||||
jest.isolateModules(() => {
|
||||
const { default: TimezoneSelector } = module.require('./index');
|
||||
resolve(TimezoneSelector);
|
||||
jest.useRealTimers();
|
||||
});
|
||||
const { default: TimezoneSelector } = module.require('./index');
|
||||
resolve(TimezoneSelector);
|
||||
jest.useRealTimers();
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -94,24 +92,6 @@ test('render timezones in correct oder for standard time', async () => {
|
|||
expect(options[3]).toHaveTextContent('GMT -10:00 (America/Adak)');
|
||||
});
|
||||
|
||||
test('render timezones in correct order for daylight saving time', async () => {
|
||||
const TimezoneSelector = await loadComponent('2022-07-01');
|
||||
const onTimezoneChange = jest.fn();
|
||||
render(
|
||||
<TimezoneSelector
|
||||
onTimezoneChange={onTimezoneChange}
|
||||
timezone="America/Nassau"
|
||||
/>,
|
||||
);
|
||||
openSelectMenu();
|
||||
const options = await getSelectOptions();
|
||||
// first option is always current timezone
|
||||
expect(options[0]).toHaveTextContent('GMT -04:00 (Eastern Daylight Time)');
|
||||
expect(options[1]).toHaveTextContent('GMT -11:00 (Pacific/Pago_Pago)');
|
||||
expect(options[2]).toHaveTextContent('GMT -10:00 (Hawaii Standard Time)');
|
||||
expect(options[3]).toHaveTextContent('GMT -09:30 (Pacific/Marquesas)');
|
||||
});
|
||||
|
||||
test('can select a timezone values and returns canonical timezone name', async () => {
|
||||
const TimezoneSelector = await loadComponent('2022-01-01');
|
||||
const onTimezoneChange = jest.fn();
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { fireEvent, render, waitFor } from 'spec/helpers/testing-library';
|
||||
import { fireEvent, render } from 'spec/helpers/testing-library';
|
||||
import { OptionControlLabel } from 'src/explore/components/controls/OptionControls';
|
||||
|
||||
import DashboardWrapper from './DashboardWrapper';
|
||||
|
@ -76,7 +76,7 @@ test('should update the style on dragging state', async () => {
|
|||
container.getElementsByClassName('dragdroppable--dragging'),
|
||||
).toHaveLength(0);
|
||||
fireEvent.dragStart(getByText('Label 1'));
|
||||
await waitFor(() => jest.runAllTimers());
|
||||
jest.runAllTimers();
|
||||
expect(
|
||||
container.getElementsByClassName('dragdroppable--dragging'),
|
||||
).toHaveLength(1);
|
||||
|
|
|
@ -16,10 +16,15 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { render } from 'spec/helpers/testing-library';
|
||||
import { styledMount as mount } from 'spec/helpers/theming';
|
||||
import { Provider } from 'react-redux';
|
||||
import fetchMock from 'fetch-mock';
|
||||
|
||||
import { SupersetClient } from '@superset-ui/core';
|
||||
import {
|
||||
supersetTheme,
|
||||
SupersetClient,
|
||||
ThemeProvider,
|
||||
} from '@superset-ui/core';
|
||||
|
||||
import Modal from 'src/components/Modal';
|
||||
import PropertiesModal from 'src/dashboard/components/PropertiesModal';
|
||||
|
@ -53,6 +58,23 @@ fetchMock.get('glob:*/api/v1/dashboard/*', {
|
|||
},
|
||||
});
|
||||
|
||||
const requiredProps = {
|
||||
dashboardId: 1,
|
||||
show: true,
|
||||
addSuccessToast: () => {},
|
||||
};
|
||||
|
||||
const setup = overrideProps =>
|
||||
mount(
|
||||
<Provider store={mockStore}>
|
||||
<PropertiesModal {...requiredProps} {...overrideProps} />
|
||||
</Provider>,
|
||||
{
|
||||
wrappingComponent: ThemeProvider,
|
||||
wrappingComponentProps: { theme: supersetTheme },
|
||||
},
|
||||
);
|
||||
|
||||
// all these tests need to be moved to dashboard/components/PropertiesModal/PropertiesModal.test.tsx
|
||||
describe.skip('PropertiesModal', () => {
|
||||
afterEach(() => {
|
||||
|
@ -60,19 +82,6 @@ describe.skip('PropertiesModal', () => {
|
|||
jest.resetAllMocks();
|
||||
});
|
||||
|
||||
const requiredProps = {
|
||||
dashboardId: 1,
|
||||
show: true,
|
||||
addSuccessToast: () => {},
|
||||
};
|
||||
|
||||
function setup(overrideProps) {
|
||||
return render(<PropertiesModal {...requiredProps} {...overrideProps} />, {
|
||||
useRedux: true,
|
||||
store: mockStore,
|
||||
});
|
||||
}
|
||||
|
||||
describe('onColorSchemeChange', () => {
|
||||
it('sets up a default state', () => {
|
||||
const wrapper = setup({ colorScheme: 'SUPERSET_DEFAULT' });
|
||||
|
@ -109,7 +118,7 @@ describe.skip('PropertiesModal', () => {
|
|||
);
|
||||
});
|
||||
});
|
||||
describe('without color_scheme in the metadata', () => {
|
||||
it('without color_scheme in the metadata', () => {
|
||||
const wrapper = setup();
|
||||
const modalInstance = wrapper.find('PropertiesModal').instance();
|
||||
modalInstance.setState({
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
import handleScroll from '.';
|
||||
|
||||
jest.useFakeTimers();
|
||||
jest.spyOn(global, 'clearInterval');
|
||||
|
||||
const { scroll } = window;
|
||||
|
||||
|
@ -32,7 +33,7 @@ test('calling: "NOT_SCROLL_TOP" ,"SCROLL_TOP", "NOT_SCROLL_TOP"', () => {
|
|||
|
||||
handleScroll('NOT_SCROLL_TOP');
|
||||
|
||||
expect(clearInterval).not.toBeCalled();
|
||||
expect(clearInterval).not.toHaveBeenCalled();
|
||||
|
||||
handleScroll('SCROLL_TOP');
|
||||
|
||||
|
|
|
@ -124,7 +124,7 @@ test('should call exportChart when exportCSV is clicked', async () => {
|
|||
.mockImplementation(() => {});
|
||||
const { findByText, getByRole } = setup({ supersetCanCSV: true });
|
||||
fireEvent.click(getByRole('button', { name: 'More Options' }));
|
||||
fireEvent.mouseOver(getByRole('button', { name: 'Download' }));
|
||||
fireEvent.mouseOver(getByRole('button', { name: 'Download right' }));
|
||||
const exportAction = await findByText('Export to .CSV');
|
||||
fireEvent.click(exportAction);
|
||||
expect(stubbedExportCSV).toHaveBeenCalledTimes(1);
|
||||
|
@ -147,7 +147,7 @@ test('should call exportChart with row_limit props.maxRows when exportFullCSV is
|
|||
.mockImplementation(() => {});
|
||||
const { findByText, getByRole } = setup({ supersetCanCSV: true });
|
||||
fireEvent.click(getByRole('button', { name: 'More Options' }));
|
||||
fireEvent.mouseOver(getByRole('button', { name: 'Download' }));
|
||||
fireEvent.mouseOver(getByRole('button', { name: 'Download right' }));
|
||||
const exportAction = await findByText('Export to full .CSV');
|
||||
fireEvent.click(exportAction);
|
||||
expect(stubbedExportCSV).toHaveBeenCalledTimes(1);
|
||||
|
@ -169,7 +169,7 @@ test('should call exportChart when exportXLSX is clicked', async () => {
|
|||
.mockImplementation(() => {});
|
||||
const { findByText, getByRole } = setup({ supersetCanCSV: true });
|
||||
fireEvent.click(getByRole('button', { name: 'More Options' }));
|
||||
fireEvent.mouseOver(getByRole('button', { name: 'Download' }));
|
||||
fireEvent.mouseOver(getByRole('button', { name: 'Download right' }));
|
||||
const exportAction = await findByText('Export to Excel');
|
||||
fireEvent.click(exportAction);
|
||||
expect(stubbedExportXLSX).toHaveBeenCalledTimes(1);
|
||||
|
@ -191,7 +191,7 @@ test('should call exportChart with row_limit props.maxRows when exportFullXLSX i
|
|||
.mockImplementation(() => {});
|
||||
const { findByText, getByRole } = setup({ supersetCanCSV: true });
|
||||
fireEvent.click(getByRole('button', { name: 'More Options' }));
|
||||
fireEvent.mouseOver(getByRole('button', { name: 'Download' }));
|
||||
fireEvent.mouseOver(getByRole('button', { name: 'Download right' }));
|
||||
const exportAction = await findByText('Export to full Excel');
|
||||
fireEvent.click(exportAction);
|
||||
expect(stubbedExportXLSX).toHaveBeenCalledTimes(1);
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { render, screen } from 'spec/helpers/testing-library';
|
||||
import { render, screen, act } from 'spec/helpers/testing-library';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { stateWithoutNativeFilters } from 'spec/fixtures/mockStore';
|
||||
import * as mockCore from '@superset-ui/core';
|
||||
|
@ -274,6 +274,10 @@ describe('FilterBar', () => {
|
|||
|
||||
renderWrapper(openedBarProps, stateWithDivider);
|
||||
|
||||
await act(async () => {
|
||||
jest.advanceTimersByTime(1000); // 1s
|
||||
});
|
||||
|
||||
const title = await screen.findByText('Select time range');
|
||||
const description = await screen.findByText('Select year/month etc..');
|
||||
|
||||
|
|
|
@ -32,8 +32,7 @@ describe('nativeFilterGate', () => {
|
|||
});
|
||||
|
||||
afterAll(() => {
|
||||
// @ts-ignore
|
||||
isFeatureEnabledMock.restore();
|
||||
isFeatureEnabledMock.mockRestore();
|
||||
});
|
||||
|
||||
it('should return true for regular chart', () => {
|
||||
|
@ -65,8 +64,7 @@ describe('nativeFilterGate', () => {
|
|||
});
|
||||
|
||||
afterAll(() => {
|
||||
// @ts-ignore
|
||||
isFeatureEnabledMock.restore();
|
||||
isFeatureEnabledMock.mockRestore();
|
||||
});
|
||||
|
||||
it('should return true for regular chart', () => {
|
||||
|
|
|
@ -193,8 +193,7 @@ describe('canUserSaveAsDashboard with RBAC feature flag disabled', () => {
|
|||
});
|
||||
|
||||
afterAll(() => {
|
||||
// @ts-ignore
|
||||
isFeatureEnabledMock.restore();
|
||||
isFeatureEnabledMock.mockRestore();
|
||||
});
|
||||
|
||||
it('allows owners', () => {
|
||||
|
@ -221,8 +220,7 @@ describe('canUserSaveAsDashboard with RBAC feature flag enabled', () => {
|
|||
});
|
||||
|
||||
afterAll(() => {
|
||||
// @ts-ignore
|
||||
isFeatureEnabledMock.restore();
|
||||
isFeatureEnabledMock.mockRestore();
|
||||
});
|
||||
|
||||
it('allows owners', () => {
|
||||
|
|
|
@ -406,7 +406,7 @@ describe('AdhocFilterEditPopoverSimpleTabContent Advanced data Type Test', () =>
|
|||
});
|
||||
|
||||
afterAll(() => {
|
||||
isFeatureEnabledMock.restore();
|
||||
isFeatureEnabledMock.mockRestore();
|
||||
});
|
||||
|
||||
it('should not call API when column has no advanced data type', async () => {
|
||||
|
|
|
@ -272,7 +272,7 @@ export default class AdhocMetricEditPopover extends PureComponent {
|
|||
refreshAceEditor() {
|
||||
setTimeout(() => {
|
||||
if (this.aceEditorRef) {
|
||||
this.aceEditorRef.editor.resize();
|
||||
this.aceEditorRef.editor?.resize?.();
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
|
|
|
@ -433,9 +433,12 @@ describe('DatabaseModal', () => {
|
|||
// ---------- Components ----------
|
||||
// <TabHeader> - AntD header
|
||||
const closeButton = screen.getByRole('button', { name: /close/i });
|
||||
|
||||
const basicHeader = screen.getByRole('heading', {
|
||||
name: /connect a database/i,
|
||||
});
|
||||
expect(basicHeader).toBeVisible();
|
||||
|
||||
// <ModalHeader> - Connection header
|
||||
const basicHelper = screen.getByText(/step 2 of 2/i);
|
||||
const basicHeaderTitle = screen.getByText(/enter primary credentials/i);
|
||||
|
@ -495,7 +498,6 @@ describe('DatabaseModal', () => {
|
|||
// ---------- Assertions ----------
|
||||
const visibleComponents = [
|
||||
closeButton,
|
||||
basicHeader,
|
||||
basicHelper,
|
||||
basicHeaderTitle,
|
||||
basicHeaderSubtitle,
|
||||
|
|
|
@ -137,8 +137,7 @@ describe('Header Report Dropdown', () => {
|
|||
});
|
||||
|
||||
afterAll(() => {
|
||||
// @ts-ignore
|
||||
isFeatureEnabledMock.restore();
|
||||
isFeatureEnabledMock.mockRestore();
|
||||
});
|
||||
|
||||
it('renders correctly', () => {
|
||||
|
|
|
@ -64,8 +64,7 @@ describe('Email Report Modal', () => {
|
|||
});
|
||||
|
||||
afterAll(() => {
|
||||
// @ts-ignore
|
||||
isFeatureEnabledMock.restore();
|
||||
isFeatureEnabledMock.mockRestore();
|
||||
});
|
||||
|
||||
it('inputs respond correctly', () => {
|
||||
|
@ -74,6 +73,7 @@ describe('Email Report Modal', () => {
|
|||
const reportNameTextbox = screen.getByTestId('report-name-test');
|
||||
expect(reportNameTextbox).toHaveDisplayValue('Weekly Report');
|
||||
// Type in the textbox and assert that it worked
|
||||
userEvent.clear(reportNameTextbox);
|
||||
userEvent.type(reportNameTextbox, 'Report name text test');
|
||||
expect(reportNameTextbox).toHaveDisplayValue('Report name text test');
|
||||
|
||||
|
|
|
@ -193,6 +193,7 @@ describe('Rule modal', () => {
|
|||
|
||||
const name = await screen.findByTestId('rule-name-test');
|
||||
expect(name).toHaveDisplayValue('rls 1');
|
||||
userEvent.clear(name);
|
||||
userEvent.type(name, 'rls 2');
|
||||
expect(name).toHaveDisplayValue('rls 2');
|
||||
|
||||
|
|
|
@ -71,6 +71,7 @@ it('should cancel previous timeout when value changes', async () => {
|
|||
|
||||
test('should cancel the timeout when unmounting', async () => {
|
||||
jest.useFakeTimers();
|
||||
jest.spyOn(global, 'clearTimeout');
|
||||
const { result, unmount } = renderHook(() => useDebounceValue('hello', 1000));
|
||||
|
||||
expect(result.current).toBe('hello');
|
||||
|
|
|
@ -124,7 +124,7 @@ describe('ChartList', () => {
|
|||
.mockImplementation(feature => feature === 'LISTVIEWS_DEFAULT_CARD_VIEW');
|
||||
|
||||
afterAll(() => {
|
||||
isFeatureEnabledMock.restore();
|
||||
isFeatureEnabledMock.mockRestore();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
|
@ -267,7 +267,7 @@ describe('ChartList - anonymous view', () => {
|
|||
|
||||
afterAll(() => {
|
||||
cleanup();
|
||||
fetch.resetMocks();
|
||||
fetchMock.reset();
|
||||
});
|
||||
|
||||
it('does not render the Favorite Star column in list view for anonymous user', async () => {
|
||||
|
|
|
@ -119,7 +119,7 @@ describe('DashboardList', () => {
|
|||
.mockImplementation(feature => feature === 'LISTVIEWS_DEFAULT_CARD_VIEW');
|
||||
|
||||
afterAll(() => {
|
||||
isFeatureEnabledMock.restore();
|
||||
isFeatureEnabledMock.mockRestore();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
|
@ -282,7 +282,7 @@ describe('DashboardList - anonymous view', () => {
|
|||
|
||||
afterAll(() => {
|
||||
cleanup();
|
||||
fetch.resetMocks();
|
||||
fetchMock.reset();
|
||||
});
|
||||
|
||||
it('does not render the Favorite Star column in list view for anonymous user', async () => {
|
||||
|
|
|
@ -172,6 +172,7 @@ describe('Welcome without sql role', () => {
|
|||
|
||||
afterAll(() => {
|
||||
fetchMock.resetHistory();
|
||||
fetchMock.restore();
|
||||
});
|
||||
|
||||
it('renders', () => {
|
||||
|
@ -218,7 +219,7 @@ describe('Welcome page with toggle switch', () => {
|
|||
});
|
||||
|
||||
afterAll(() => {
|
||||
isFeatureEnabledMock.restore();
|
||||
isFeatureEnabledMock.mockRestore();
|
||||
});
|
||||
|
||||
it('shows a toggle button when feature flags is turned on', async () => {
|
||||
|
|
|
@ -302,9 +302,11 @@ describe('RTL', () => {
|
|||
userEvent.click(bulkSelectButton);
|
||||
|
||||
// Grab and click the "toggle all" checkbox to expose export button
|
||||
const selectAllCheckbox = screen.getByRole('checkbox', {
|
||||
name: /toggle all rows selected/i,
|
||||
});
|
||||
const selectAllCheckbox = screen
|
||||
.getAllByRole('checkbox', {
|
||||
name: '',
|
||||
})
|
||||
.find(checkbox => checkbox.getAttribute('name') === 'header-toggle-all');
|
||||
userEvent.click(selectAllCheckbox);
|
||||
|
||||
// Grab and assert that export button is visible
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -30,6 +30,7 @@
|
|||
"devDependencies": {
|
||||
"@types/cookie": "^0.6.0",
|
||||
"@types/ioredis": "^4.27.8",
|
||||
"@types/lodash": "^4.17.0",
|
||||
"@types/jest": "^27.0.2",
|
||||
"@types/jsonwebtoken": "^9.0.6",
|
||||
"@types/node": "^20.13.0",
|
||||
|
@ -40,9 +41,9 @@
|
|||
"eslint": "^8.57.0",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-plugin-lodash": "^7.4.0",
|
||||
"jest": "^27.3.1",
|
||||
"jest": "^29.7.0",
|
||||
"prettier": "^3.2.5",
|
||||
"ts-jest": "^27.0.7",
|
||||
"ts-jest": "^29.1.2",
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "^4.9.5"
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue