Skip to content

Commit

Permalink
ci: fix timezone for test (#4963)
Browse files Browse the repository at this point in the history
  • Loading branch information
romainseb authored Nov 2, 2023
1 parent c76a700 commit 87ecd73
Show file tree
Hide file tree
Showing 19 changed files with 54 additions and 57 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
"lint-staged": "lint-staged",
"lint": "cross-env WORKSPACE_RUN_FAIL=no-bail talend-yarn-workspace run lint",
"lint-merge-report": "talend-yarn-workspace lint-merge-report",
"test": "cross-env TZ=Europe/Paris talend-yarn-workspace run test --silent",
"test:update": "cross-env TZ=Europe/Paris yarn workspaces run test --silent -u",
"test:cov": "cross-env TZ=Europe/Paris talend-yarn-workspace run test:cov",
"test": "cross-env TZ=UTC talend-yarn-workspace run test --silent",
"test:update": "cross-env TZ=UTC yarn workspaces run test --silent -u",
"test:cov": "cross-env TZ=UTC talend-yarn-workspace run test:cov",
"test:demo": "talend-yarn-workspace run test:demo",
"test:cron": "talend-yarn-workspace run test:cron",
"start-components": "yarn workspace @talend/react-components run start",
Expand Down
6 changes: 3 additions & 3 deletions packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
"pre-release": "yarn build:dev && yarn build:prod",
"build:lib": "talend-scripts build && yarn run tsc",
"tsc": "tsc --emitDeclarationOnly --project ./tsconfig.json --outDir ./types",
"test": "cross-env TZ=Europe/Paris talend-scripts test",
"test:watch": "cross-env TZ=Europe/Paris talend-scripts test --watch",
"test:cov": "cross-env TZ=Europe/Paris talend-scripts test --coverage",
"test": "cross-env TZ=UTC talend-scripts test",
"test:watch": "cross-env TZ=UTC talend-scripts test --watch",
"test:cov": "cross-env TZ=UTC talend-scripts test --coverage",
"lint": "talend-scripts lint",
"start": "talend-scripts start -p 6006",
"extract-i18n": "i18next-scanner --config i18next-scanner.config.js"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('Date.Manager', () => {
expect(props).toEqual({
value: {
textInput: '2017-04-04',
date: '2017-04-03T22:00:00.000Z',
date: '2017-04-04T00:00:00.000Z',
},
inputManagement: {
placeholder: 'YYYY-MM-DD',
Expand Down Expand Up @@ -79,7 +79,7 @@ describe('Date.Manager', () => {
name: 'should init state from props',
initialDate: new Date(2015, 3, 4),
expectedTextInput: '2015-04-04',
expectedDate: '2015-04-03T22:00:00.000Z',
expectedDate: '2015-04-04T00:00:00.000Z',
},
])('$name', ({ initialDate, expectedTextInput, expectedDate }) => {
// when
Expand Down Expand Up @@ -115,7 +115,7 @@ describe('Date.Manager', () => {
initialDate: new Date(),
newDate: new Date(2015, 3, 4),
expectedTextInput: '2015-04-04',
expectedDate: '2015-04-03T22:00:00.000Z',
expectedDate: '2015-04-04T00:00:00.000Z',
},
])('$name', ({ initialDate, newDate, expectedTextInput, expectedDate }) => {
// given
Expand Down Expand Up @@ -176,7 +176,7 @@ describe('Date.Manager', () => {
{
name: 'with valid date',
textInput: '2015-01-15',
expectedDate: '2015-01-14T23:00:00.000Z',
expectedDate: '2015-01-15T00:00:00.000Z',
},
{
name: 'with invalid date',
Expand All @@ -191,7 +191,7 @@ describe('Date.Manager', () => {
{
name: 'with custom date format',
textInput: '15/01/2015',
expectedDate: '2015-01-14T23:00:00.000Z',
expectedDate: '2015-01-15T00:00:00.000Z',
dateFormat: 'DD/MM/YYYY',
},
])('$name', async ({ textInput, expectedDate, dateFormat }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('Date.Picker', () => {
expect(props).toMatchObject({
manageFocus: true,
other: 'custom props',
selectedDate: '2007-01-01T23:00:00.000Z',
selectedDate: '2007-01-02T00:00:00.000Z',
useUTC: false,
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ describe('Date extraction', () => {
// then
expect(parts).toEqual({
localDate: new Date(2018, 11, 25),
date: subHours(new Date(2018, 11, 25), 8),
date: subHours(new Date(2018, 11, 25), 9),
textInput,
errorMessage: null,
errors: [],
Expand Down Expand Up @@ -325,7 +325,7 @@ describe('Date extraction', () => {
const date = extractDateOnly(datetime, options);

// then
expect(date).toEqual(new Date(2019, 8, 25));
expect(date).toEqual(new Date(2019, 8, 26));
});
it('should extract date when timezone provided', () => {
// given
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ describe('DateRange.Manager', () => {
const consumer = screen.getByTestId('DateRangeConsumerDiv');
const props = JSON.parse(consumer.getAttribute('data-props'));
expect(props.startDate).toEqual({
value: '2017-04-03T22:00:00.000Z',
value: '2017-04-04T00:00:00.000Z',
textInput: '2017-04-04',
});
expect(props.endDate).toEqual({
value: '2017-04-09T22:00:00.000Z',
value: '2017-04-10T00:00:00.000Z',
textInput: '2017-04-10',
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ describe('Date extraction', () => {

// then
expect(parts).toEqual({
date: new Date(2015, 8, 14),
time: { hours: '23', minutes: '00', seconds: '22' },
date: new Date(2015, 8, 15),
time: { hours: '01', minutes: '00', seconds: '22' },
datetime: new Date(2015, 8, 15, 1, 0, 22),
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,11 @@ describe('Date extraction', () => {

// then
expect(parts).toEqual({
date: new Date(2015, 8, 14),
date: new Date(2015, 8, 15, 0, 0, 0),
datetime: validDate,
textInput: '2015-09-14 23:00:22',
textInput: '2015-09-15 01:00:22',
errors: [],
time: { hours: '23', minutes: '00', seconds: '22' },
time: { hours: '01', minutes: '00', seconds: '22' },
});
});
});
Expand Down Expand Up @@ -435,7 +435,7 @@ describe('Date extraction', () => {
// then
expect(parts).toEqual({
date,
datetime: new Date(2015, 8, 15, 14, 58, 22),
datetime: new Date(2015, 8, 15, 12, 58, 22),
textInput: '2015-09-15 12:58:22',
time,
errorMessage: null,
Expand Down Expand Up @@ -668,7 +668,7 @@ describe('Date extraction', () => {
expect(parts).toEqual({
date: new Date(2018, 11, 25),
time: { hours: '22', minutes: '58', seconds: '12' },
datetime: new Date(2018, 11, 25, 23, 58, 12),
datetime: new Date(2018, 11, 25, 22, 58, 12),
textInput,
errorMessage: null,
errors: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,7 @@ describe('CellDatetime', () => {
const timezoneOffset = new Date(cellData).getTimezoneOffset();
const cellDataWithOffset = cellData + timezoneOffset * 60 * 1000;
const hours = 11 + timezoneOffset / 60;
const isOneDigitHours = hours.toString().length === 1;
const expectedStrDate = `2016-09-22 ${isOneDigitHours ? 0 : ''}${
11 + timezoneOffset / 60
}:00:00`;
const expectedStrDate = '2016-09-22 09:00:00';
const computedStrOffset = computeValue(cellDataWithOffset, columnData, t);
// then
expect(computedStrOffset).toEqual(expectedStrDate);
Expand Down
6 changes: 3 additions & 3 deletions packages/dataviz/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
"extract-i18n": "i18next-scanner --config i18next-scanner.config.js",
"lint": "talend-scripts lint",
"start": "talend-scripts start-storybook -p 6006",
"test": "cross-env TZ=Europe/Paris talend-scripts test",
"test": "cross-env TZ=UTC talend-scripts test",
"test:cy": "cypress run --component --spec **.cy.tsx",
"test:watch": "cross-env TZ=Europe/Paris talend-scripts test --watch",
"test:cov": "cross-env TZ=Europe/Paris talend-scripts test --coverage"
"test:watch": "cross-env TZ=UTC talend-scripts test --watch",
"test:cov": "cross-env TZ=UTC talend-scripts test --coverage"
},
"keywords": [
"react",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ describe('DateRangeHandler', () => {
const ticks = DateRangeHandler.getTicks(limits);
expect(ticks).toEqual({
[limits.min]: '2000-01-01',
'1262300400000': '2010-01-01',
'1577833200000': '2020-01-01',
'1262304000000': '2010-01-01',
'1577836800000': '2020-01-01',
[limits.max]: '2030-01-01',
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('DateTimeRangeHandler', () => {
fireEvent.click(screen.getByText('InputDateTimePicker.onChange 1'));
fireEvent.keyDown(screen.getByRole('textbox'), { key: 'Escape' });

expect(screen.getByRole('textbox')).toHaveValue('2010-01-01 00:00:00');
expect(screen.getByRole('textbox')).toHaveValue('2009-12-31 23:00:00');
});

it('Should reset value on blur with invalid input', () => {
Expand Down Expand Up @@ -82,8 +82,8 @@ describe('DateTimeRangeHandler', () => {
const ticks = DateRangeHandler.getTicks(limits);
expect(ticks).toEqual({
[limits.min]: '2000-01-01',
'1262300400000': '2010-01-01',
'1577833200000': '2020-01-01',
'1262304000000': '2010-01-01',
'1577836800000': '2020-01-01',
[limits.max]: '2030-01-01',
});
});
Expand Down
6 changes: 3 additions & 3 deletions packages/faceted-search/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
"build:prod": "talend-scripts build --umd --prod",
"pre-release": "yarn build:dev && yarn build:prod",
"build:lib": "talend-scripts build",
"test": "cross-env TZ=Europe/Paris talend-scripts test",
"test:watch": "cross-env TZ=Europe/Paris talend-scripts test --watch",
"test:cov": "cross-env TZ=Europe/Paris talend-scripts test --coverage",
"test": "cross-env TZ=UTC talend-scripts test",
"test:watch": "cross-env TZ=UTC talend-scripts test --watch",
"test:cov": "cross-env TZ=UTC talend-scripts test --coverage",
"test:demo": "talend-scripts build-storybook --quiet --docs",
"lint": "talend-scripts lint ./src/**/*.js ./stories/**/*.js ./.storybook/**/*.js",
"start": "talend-scripts start-storybook -p 6006",
Expand Down
2 changes: 1 addition & 1 deletion packages/forms/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"build-storybook": "talend-scripts build-storybook",
"pre-release": "yarn build:dev && yarn build:prod",
"build:lib": "talend-scripts build",
"test": "cross-env TZ=Europe/Paris talend-scripts test",
"test": "cross-env TZ=UTC talend-scripts test",
"test:watch": "talend-scripts test --watch",
"test:cov": "talend-scripts test --coverage",
"lint": "talend-scripts lint",
Expand Down
4 changes: 2 additions & 2 deletions packages/forms/src/UIForm/fields/Date/Date.component.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ describe('Date widget', () => {
// then
expect(onChange).toBeCalledWith(expect.anything(event), {
schema: timestampSchema,
value: 1442786400000,
value: 1442793600000,
});
});

Expand Down Expand Up @@ -227,7 +227,7 @@ describe('Date widget', () => {
// then
expect(onChange).toBeCalledWith(expect.anything(event), {
schema: isoSchema,
value: '2015-09-20T22:00:00.000Z',
value: '2015-09-21T00:00:00.000Z',
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe('DateTime widget', () => {
});
// then
expect(screen.getAllByRole('textbox')[0]).toHaveValue('2018-01-01');
expect(screen.getAllByRole('textbox')[1]).toHaveValue('11:35');
expect(screen.getAllByRole('textbox')[1]).toHaveValue('10:35');
});
it('should trigger onFinish on picker blur', async () => {
// given
Expand Down Expand Up @@ -121,7 +121,7 @@ describe('DateTime widget', () => {

expect(props.onChange.mock.calls[1][1]).toMatchObject({
schema: timestampSchema,
value: new Date(2015, 8, 21, 2, 30, 0).getTime(),
value: new Date(2015, 8, 21, 1, 30, 0).getTime(),
});
});

Expand Down
8 changes: 4 additions & 4 deletions packages/stepper/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
"pre-release": "yarn build:dev && yarn build:prod",
"build:lib": "talend-scripts build",
"extract-i18n": "i18next-scanner --config i18next-scanner.config.js",
"test": "cross-env TZ=Europe/Paris talend-scripts test",
"test:noisy": "cross-env TZ=Europe/Paris talend-scripts test",
"test:watch": "cross-env TZ=Europe/Paris talend-scripts test --watch",
"test:cov": "cross-env TZ=Europe/Paris talend-scripts test --coverage",
"test": "cross-env TZ=UTC talend-scripts test",
"test:noisy": "cross-env TZ=UTC talend-scripts test",
"test:watch": "cross-env TZ=UTC talend-scripts test --watch",
"test:cov": "cross-env TZ=UTC talend-scripts test --coverage",
"lint": "talend-scripts lint",
"start": "talend-scripts start-storybook -p 6006"
},
Expand Down
8 changes: 4 additions & 4 deletions packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
"scripts": {
"build:lib": "talend-scripts build",
"lint": "talend-scripts lint",
"test": "cross-env TZ=Europe/Paris talend-scripts test",
"test:cov": "cross-env TZ=Europe/Paris talend-scripts test --coverage --silent",
"test:noisy": "cross-env TZ=Europe/Paris talend-scripts test",
"test:watch": "cross-env TZ=Europe/Paris talend-scripts test --watch",
"test": "cross-env TZ=UTC talend-scripts test",
"test:cov": "cross-env TZ=UTC talend-scripts test --coverage --silent",
"test:noisy": "cross-env TZ=UTC talend-scripts test",
"test:watch": "cross-env TZ=UTC talend-scripts test --watch",
"extends": "talend-scripts extends"
},
"devDependencies": {
Expand Down
12 changes: 6 additions & 6 deletions packages/utils/src/date/date.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe('date', () => {
const localDate = convertToLocalTime(dateObj, options);

// then
expect(localDate).toEqual(new Date('2020-05-13, 17:00'));
expect(localDate).toEqual(new Date('2020-05-13, 15:00'));
});

it('should convert a date string of a timezone to the locale timezone', () => {
Expand All @@ -54,7 +54,7 @@ describe('date', () => {
const localDate = convertToLocalTime(dateObj, options);

// then
expect(localDate).toEqual(new Date('2020-05-14, 01:00'));
expect(localDate).toEqual(new Date('2020-05-13, 23:00'));
});
});

Expand All @@ -68,7 +68,7 @@ describe('date', () => {
const localDate = convertToTimeZone(dateObj, options);

// then
expect(localDate).toEqual(new Date('2020-05-13, 23:00'));
expect(localDate).toEqual(new Date('2020-05-14, 01:00'));
});

it('should convert a locale date string to the given timezone time', () => {
Expand All @@ -80,7 +80,7 @@ describe('date', () => {
const localDate = convertToTimeZone(dateObj, options);

// then
expect(localDate).toEqual(new Date('2020-05-13, 15:00'));
expect(localDate).toEqual(new Date('2020-05-13, 17:00'));
});

it('should convert a date from a specific timezone to the target timezone time', () => {
Expand Down Expand Up @@ -120,7 +120,7 @@ describe('date', () => {
const localDate = formatToTimeZone(dateObj, formatString, options);

// then
expect(localDate).toEqual('2020-05-13T23:00:00+0500');
expect(localDate).toEqual('2020-05-14T01:00:00+0500');
});

it('should not change timezone tokens that are wrapped in hooks', () => {
Expand All @@ -133,7 +133,7 @@ describe('date', () => {
const localDate = formatToTimeZone(dateObj, formatString, options);

// then
expect(localDate).toEqual('2020-05-13T23:00:00Z');
expect(localDate).toEqual('2020-05-14T01:00:00Z');
});
it('should pass locale to datefns format method', () => {
// given
Expand Down

0 comments on commit 87ecd73

Please sign in to comment.