Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] Make DatePickers tests independent from other packages #13951

Draft
wants to merge 23 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const defaultAlias = {
),
docs: resolveAliasPath('./node_modules/@mui/monorepo/docs'),
test: resolveAliasPath('./test'),
'@unit/date-pickers': resolveAliasPath('./test/unit-date-pickers'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: Do you see a problem with just sticking to the existing test alias? 🤔
I.e.: Have test/pickers/helpers or test/pickers/utils imports. 🤔

For now, the convention seems more or less clear:

  • use @mui for product packages and all external aliases
  • Use the folder name for other internal aliases (with the exception of docs 🙈 )

Copy link
Member Author

@JCQuintas JCQuintas Jul 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't mind much about the naming. I just used what felt best.

  • test is generic so it didn't give much value, eg: test/date-pickers could be confusing if we have e2e-date-pickers in the future.
  • test/pickers could be confusing if we have a color-picker which is a different package.

In general (contradictorily), I find the more precise the better 😅

So I felt @unit/date-pickers to be the most concise and gives all the info necessary. We can def change it to test/unit/date-pickers or test/pickers or anything else if you don't think the considerations above are relevant.

This is quite easy to refactor, we could change at any time if we decide to go with test/pickers and later we have something else there

packages: resolveAliasPath('./packages'),
};

Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"test:regressions:server": "serve test/regressions -p 5001",
"test:argos": "node ./scripts/pushArgos.mjs",
"typescript": "lerna run --no-bail --parallel typescript",
"typescript:ci": "lerna run --concurrency 1 --no-bail --no-sort typescript",
"typescript:ci": "lerna run --concurrency 1 --no-bail typescript",
"use-react-version": "node scripts/useReactVersion.mjs",
"build:codesandbox": "lerna run --concurrency 3 --no-private --scope \"@mui/*\" build",
"install:codesandbox": "pnpm install --no-frozen-lockfile",
Expand All @@ -64,7 +64,8 @@
"release:publish:dry-run": "pnpm publish --recursive --tag latest --registry=\"http://localhost:4873/\"",
"release:tag": "node scripts/releaseTag.mjs",
"validate": "concurrently \"pnpm prettier && pnpm eslint\" \"pnpm proptypes\" \"pnpm docs:typescript:formatted\" \"pnpm docs:api\"",
"clean:node_modules": "rimraf --glob \"**/node_modules\""
"clean:node_modules": "rimraf --glob \"**/node_modules\"",
"test:unit:pickers": "pnpm --filter @mui-x-internal/unit-date-pickers test:unit"
},
"devDependencies": {
"@actions/core": "^1.10.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/x-charts-pro/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
],
"noImplicitAny": false
},
"include": ["src/**/*", "../../test/utils/addChaiAssertions.ts"]
"include": ["src/**/*"]
}
2 changes: 1 addition & 1 deletion packages/x-charts/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
"node"
]
},
"include": ["src/**/*", "../../test/utils/addChaiAssertions.ts", "../../test/utils/init.ts"]
"include": ["src/**/*", "../../test/utils/init.ts"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
buildPickerDragInteractions,
rangeCalendarDayTouches,
createPickerRenderer,
} from 'test/utils/pickers';
} from '@unit/date-pickers/helpers';
import { MockedDataTransfer } from 'test/utils/dragAndDrop';
import {
DateRangeCalendar,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
createPickerRenderer,
getFieldInputRoot,
stubMatchMedia,
} from 'test/utils/pickers';
} from '@unit/date-pickers/helpers';

describe('<DateRangePicker />', () => {
const { render, clock } = createPickerRenderer({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { DateRangePicker } from '@mui/x-date-pickers-pro/DateRangePicker';
import { createPickerRenderer } from 'test/utils/pickers';
import { createPickerRenderer } from '@unit/date-pickers/helpers';
import { describeConformance } from 'test/utils/describeConformance';

describe('<DateRangePicker /> - Describes', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
DateRangePickerDay,
dateRangePickerDayClasses as classes,
} from '@mui/x-date-pickers-pro/DateRangePickerDay';
import { createPickerRenderer, adapterToUse } from 'test/utils/pickers';
import { createPickerRenderer, adapterToUse } from '@unit/date-pickers/helpers';
import { describeConformance } from 'test/utils/describeConformance';

describe('<DateRangePickerDay />', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { createPickerRenderer } from 'test/utils/pickers';
import { createPickerRenderer } from '@unit/date-pickers/helpers';
import { describeConformance } from 'test/utils/describeConformance';
import { DateTimeRangePicker } from '../DateTimeRangePicker';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
openPicker,
getFieldSectionsContainer,
getTextbox,
} from 'test/utils/pickers';
} from '@unit/date-pickers/helpers';

const isJSDOM = /jsdom/.test(window.navigator.userAgent);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
describeRangeValidation,
getFieldInputRoot,
getFieldSectionsContainer,
} from 'test/utils/pickers';
} from '@unit/date-pickers/helpers';
import { DesktopDateRangePicker } from '@mui/x-date-pickers-pro/DesktopDateRangePicker';
import { SingleInputDateRangeField } from '@mui/x-date-pickers-pro/SingleInputDateRangeField';
import { describeConformance } from 'test/utils/describeConformance';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
openPicker,
getFieldSectionsContainer,
expectFieldValueV7,
} from 'test/utils/pickers';
} from '@unit/date-pickers/helpers';
import { DesktopDateTimeRangePicker } from '../DesktopDateTimeRangePicker';

describe('<DesktopDateTimeRangePicker />', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
describePicker,
describeRangeValidation,
getFieldSectionsContainer,
} from 'test/utils/pickers';
} from '@unit/date-pickers/helpers';
import { DesktopDateTimeRangePicker } from '../DesktopDateTimeRangePicker';

describe('<DesktopDateTimeRangePicker /> - Describes', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
adapterToUse,
openPicker,
getFieldSectionsContainer,
} from 'test/utils/pickers';
} from '@unit/date-pickers/helpers';
import { DateRange } from '@mui/x-date-pickers-pro/models';
import { SingleInputDateRangeField } from '@mui/x-date-pickers-pro/SingleInputDateRangeField';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
describeValue,
describePicker,
getFieldSectionsContainer,
} from 'test/utils/pickers';
} from '@unit/date-pickers/helpers';
import { describeConformance } from 'test/utils/describeConformance';

describe('<MobileDateRangePicker /> - Describes', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
describeRangeValidation,
getFieldSectionsContainer,
openPicker,
} from 'test/utils/pickers';
} from '@unit/date-pickers/helpers';
import { MobileDateTimeRangePicker } from '../MobileDateTimeRangePicker';

describe('<MobileDateTimeRangePicker /> - Describes', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
adapterToUse,
describeRangeValidation,
setValueOnFieldInput,
} from 'test/utils/pickers';
} from '@unit/date-pickers/helpers';

describe('<MultiInputDateRangeField />', () => {
const { render, clock } = createPickerRenderer({ clock: 'fake' });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { MultiInputDateRangeField } from '@mui/x-date-pickers-pro/MultiInputDateRangeField';
import { createPickerRenderer } from 'test/utils/pickers';
import { createPickerRenderer } from '@unit/date-pickers/helpers';
import { describeConformance } from 'test/utils/describeConformance';

describe('<MultiInputDateRangeField />', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
adapterToUse,
describeRangeValidation,
setValueOnFieldInput,
} from 'test/utils/pickers';
} from '@unit/date-pickers/helpers';

describe('<MultiInputDateTimeRangeField />', () => {
const { render, clock } = createPickerRenderer({ clock: 'fake' });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { MultiInputDateTimeRangeField } from '@mui/x-date-pickers-pro/MultiInputDateTimeRangeField';
import { createPickerRenderer } from 'test/utils/pickers';
import { createPickerRenderer } from '@unit/date-pickers/helpers';
import { describeConformance } from 'test/utils/describeConformance';

describe('<MultiInputDateTimeRangeField />', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
adapterToUse,
describeRangeValidation,
setValueOnFieldInput,
} from 'test/utils/pickers';
} from '@unit/date-pickers/helpers';

describe('<MultiInputTimeRangeField />', () => {
const { render, clock } = createPickerRenderer({ clock: 'fake' });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { MultiInputTimeRangeField } from '@mui/x-date-pickers-pro/MultiInputTimeRangeField';
import { createPickerRenderer } from 'test/utils/pickers';
import { createPickerRenderer } from '@unit/date-pickers/helpers';
import { describeConformance } from 'test/utils/describeConformance';

describe('<MultiInputTimeRangeField />', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { pickersCalendarHeaderClasses } from '@mui/x-date-pickers/PickersCalenda
import { pickersArrowSwitcherClasses } from '@mui/x-date-pickers/internals';
import { PickersRangeCalendarHeader } from '@mui/x-date-pickers-pro/PickersRangeCalendarHeader';
import { ConformanceOptions } from '@mui/internal-test-utils';
import { adapterToUse, createPickerRenderer } from 'test/utils/pickers';
import { adapterToUse, createPickerRenderer } from '@unit/date-pickers/helpers';
import { describeConformance } from 'test/utils/describeConformance';

const CALENDARS_TO_CLASSES_MAP: Record<1 | 2, ConformanceOptions['classes']> = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import { PickersTextField } from '@mui/x-date-pickers/PickersTextField';
import { SingleInputDateRangeField } from '@mui/x-date-pickers-pro/SingleInputDateRangeField';
import { createPickerRenderer, describeRangeValidation } from 'test/utils/pickers';
import { createPickerRenderer, describeRangeValidation } from '@unit/date-pickers/helpers';
import { describeConformance } from 'test/utils/describeConformance';

describe('<SingleInputDateRangeField /> - Describes', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
expectFieldValueV6,
describeAdapters,
getTextbox,
} from 'test/utils/pickers';
} from '@unit/date-pickers/helpers';

describe('<SingleInputDateRangeField /> - Editing', () => {
describeAdapters(`key: Delete`, SingleInputDateRangeField, ({ adapter, renderWithProps }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
createPickerRenderer,
expectFieldValueV7,
expectFieldValueV6,
} from 'test/utils/pickers';
} from '@unit/date-pickers/helpers';

describe('<SingleInputDateRangeField /> - Selection', () => {
const { render, clock } = createPickerRenderer({ clock: 'fake' });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { SingleInputDateTimeRangeField } from '@mui/x-date-pickers-pro/SingleInputDateTimeRangeField';
import { createPickerRenderer, describeRangeValidation } from 'test/utils/pickers';
import { createPickerRenderer, describeRangeValidation } from '@unit/date-pickers/helpers';
import { describeConformance } from 'test/utils/describeConformance';

describe('<SingleInputDateTimeRangeField /> - Describes', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { SingleInputTimeRangeField } from '@mui/x-date-pickers-pro/SingleInputTimeRangeField';
import { createPickerRenderer, describeRangeValidation } from 'test/utils/pickers';
import { createPickerRenderer, describeRangeValidation } from '@unit/date-pickers/helpers';
import { describeConformance } from 'test/utils/describeConformance';

describe('<SingleInputTimeRangeField /> - Describes', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import { expect } from 'chai';
import { isWeekend } from 'date-fns';
import { StaticDateRangePicker } from '@mui/x-date-pickers-pro/StaticDateRangePicker';
import { screen } from '@mui/internal-test-utils';
import { createPickerRenderer, adapterToUse, describeRangeValidation } from 'test/utils/pickers';
import {
createPickerRenderer,
adapterToUse,
describeRangeValidation,
} from '@unit/date-pickers/helpers';
import { describeConformance } from 'test/utils/describeConformance';

describe('<StaticDateRangePicker />', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from 'chai';
import { adapterToUse } from 'test/utils/pickers';
import { adapterToUse } from '@unit/date-pickers/helpers';
import { calculateRangeChange, calculateRangePreview } from './date-range-manager';
import { DateRange } from '../../models';

Expand Down
2 changes: 1 addition & 1 deletion packages/x-date-pickers-pro/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
],
"noImplicitAny": false
},
"include": ["src/**/*", "../../test/utils/addChaiAssertions.ts"]
"include": ["src/**/*", "../../test/unit-date-pickers/setup/chaiAssertions.d.ts"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
describeGregorianAdapter,
TEST_DATE_ISO_STRING,
buildFieldInteractions,
} from 'test/utils/pickers';
} from '@unit/date-pickers/helpers';
import { enUS, fr, de, ru } from 'date-fns/locale';

describe('<AdapterDateFns />', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
expectFieldValueV7,
describeJalaliAdapter,
buildFieldInteractions,
} from 'test/utils/pickers';
} from '@unit/date-pickers/helpers';
import { enUS } from 'date-fns/locale';
import faIR from 'date-fns-jalali/locale/fa-IR';
import faJalaliIR from 'date-fns-jalali/locale/fa-jalali-IR';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
expectFieldValueV7,
describeJalaliAdapter,
buildFieldInteractions,
} from 'test/utils/pickers';
} from '@unit/date-pickers/helpers';
import { enUS, faIR } from 'date-fns-jalali/locale';
import { AdapterFormats } from '@mui/x-date-pickers/models';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFnsV3';
import { describeGregorianAdapter } from 'test/utils/pickers/describeGregorianAdapter';
import { describeGregorianAdapter } from '@unit/date-pickers/helpers/describeGregorianAdapter';
import { fr } from 'date-fns/locale';

describe('<AdapterDateFnsV3 />', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
describeGregorianAdapter,
TEST_DATE_ISO_STRING,
buildFieldInteractions,
} from 'test/utils/pickers';
} from '@unit/date-pickers/helpers';
import 'dayjs/locale/fr';
import 'dayjs/locale/de';
// We import the plugins here just to have the typing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
describeGregorianAdapter,
TEST_DATE_ISO_STRING,
buildFieldInteractions,
} from 'test/utils/pickers';
} from '@unit/date-pickers/helpers';

describe('<AdapterLuxon />', () => {
describeGregorianAdapter(AdapterLuxon, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
describeGregorianAdapter,
TEST_DATE_ISO_STRING,
buildFieldInteractions,
} from 'test/utils/pickers';
} from '@unit/date-pickers/helpers';
import 'moment/locale/de';
import 'moment/locale/fr';
import 'moment/locale/ko';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
expectFieldValueV7,
describeHijriAdapter,
buildFieldInteractions,
} from 'test/utils/pickers';
} from '@unit/date-pickers/helpers';
import 'moment/locale/ar';

describe('<AdapterMomentHijri />', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
expectFieldValueV7,
describeJalaliAdapter,
buildFieldInteractions,
} from 'test/utils/pickers';
} from '@unit/date-pickers/helpers';
import { AdapterFormats } from '@mui/x-date-pickers/models';
import 'moment/locale/fa';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { spy } from 'sinon';
import { fireEvent, userEvent, screen } from '@mui/internal-test-utils';
import { DateCalendar } from '@mui/x-date-pickers/DateCalendar';
import { PickersDay } from '@mui/x-date-pickers/PickersDay';
import { createPickerRenderer, adapterToUse } from 'test/utils/pickers';
import { createPickerRenderer, adapterToUse } from '@unit/date-pickers/helpers';

const isJSDOM = /jsdom/.test(window.navigator.userAgent);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
createPickerRenderer,
describeValidation,
describeValue,
} from 'test/utils/pickers';
} from '@unit/date-pickers/helpers';
import { describeConformance } from 'test/utils/describeConformance';

describe('<DateCalendar /> - Describes', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import { expect } from 'chai';
import { act, fireEvent, screen } from '@mui/internal-test-utils';
import { DateCalendar } from '@mui/x-date-pickers/DateCalendar';
import { adapterToUse, createPickerRenderer } from 'test/utils/pickers';
import { adapterToUse, createPickerRenderer } from '@unit/date-pickers/helpers';

describe('<DateCalendar /> keyboard interactions', () => {
const { render, clock } = createPickerRenderer({ clock: 'fake' });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import { expect } from 'chai';
import { screen } from '@mui/internal-test-utils';
import { DateCalendar } from '@mui/x-date-pickers/DateCalendar';
import { createPickerRenderer, AdapterName } from 'test/utils/pickers';
import { createPickerRenderer, AdapterName } from '@unit/date-pickers/helpers';
import { he } from 'date-fns/locale';
import 'dayjs/locale/he';
import 'moment/locale/he';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import { spy } from 'sinon';
import { expect } from 'chai';
import { userEvent, screen } from '@mui/internal-test-utils';
import { describeAdapters } from 'test/utils/pickers';
import { describeAdapters } from '@unit/date-pickers/helpers';
import { DateCalendar } from '@mui/x-date-pickers/DateCalendar';

const TIMEZONE_TO_TEST = ['UTC', 'system', 'America/New_York'];
Expand Down
Loading