Merge branch 'main' into v4/generator-migration

This commit is contained in:
Bassel Kanso 2023-01-16 11:32:56 +02:00 committed by GitHub
commit 6f8f46cbef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 123 additions and 6 deletions

View File

@ -0,0 +1,3 @@
last 3 major versions
Firefox ESR
last 2 Opera versions

View File

@ -37,6 +37,23 @@ jest.spyOn(axiosInstance, 'get').mockResolvedValue({
jest.spyOn(Date, 'now').mockImplementation(() => new Date('2015-10-01T08:00:00.000Z'));
// TO BE REMOVED: we have added this mock to prevent errors in the snapshots caused by the Unicode space character
// before AM/PM in the dates, after the introduction of node 18.13
jest.mock('react-intl', () => {
const reactIntl = jest.requireActual('react-intl');
const intl = reactIntl.createIntl({
locale: 'en',
});
intl.formatDate = jest.fn(() => '11/15/2021');
intl.formatTime = jest.fn(() => '12:00 AM');
return {
...reactIntl,
useIntl: () => intl,
};
});
const client = new QueryClient({
defaultOptions: {
queries: {

View File

@ -57,6 +57,7 @@
"babel-loader": "8.2.5",
"babel-plugin-styled-components": "2.0.2",
"bcryptjs": "2.4.3",
"browserslist-to-esbuild": "1.2.0",
"chalk": "^4.1.1",
"chokidar": "^3.5.1",
"codemirror": "^5.65.11",

View File

@ -10,6 +10,7 @@ const { ESBuildMinifyPlugin } = require('esbuild-loader');
const WebpackBar = require('webpackbar');
const NodePolyfillPlugin = require('node-polyfill-webpack-plugin');
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
const browserslistToEsbuild = require('browserslist-to-esbuild');
const alias = require('./webpack.alias');
const getClientEnvironment = require('./env');
@ -52,6 +53,8 @@ module.exports = ({
const excludeRegex = createPluginsExcludePath(pluginsPath);
const buildTarget = browserslistToEsbuild();
return {
mode: isProduction ? 'production' : 'development',
bail: !!isProduction,
@ -72,7 +75,7 @@ module.exports = ({
minimize: optimize,
minimizer: [
new ESBuildMinifyPlugin({
target: 'es2015',
target: buildTarget,
css: true, // Apply minification to CSS assets
}),
],
@ -88,7 +91,7 @@ module.exports = ({
exclude: excludeRegex,
options: {
loader: 'tsx',
target: 'es2015',
target: buildTarget,
},
},
{
@ -152,7 +155,7 @@ module.exports = ({
loader: require.resolve('esbuild-loader'),
options: {
loader: 'jsx',
target: 'es2015',
target: buildTarget,
},
},
},
@ -165,7 +168,7 @@ module.exports = ({
loader: require.resolve('esbuild-loader'),
options: {
loader: 'jsx',
target: 'es2015',
target: buildTarget,
},
},
},

View File

@ -0,0 +1,3 @@
last 3 major versions
Firefox ESR
last 2 Opera versions

View File

@ -13,6 +13,38 @@ import { createMemoryHistory } from 'history';
import qs from 'qs';
import FilterListURLQuery from '../index';
// TO BE REMOVED: we have added this mock to prevent errors in the snapshots caused by the Unicode space character
// before AM/PM in the dates, after the introduction of node 18.13
jest.mock('react-intl', () => {
const reactIntl = jest.requireActual('react-intl');
const intl = reactIntl.createIntl({
locale: 'en',
messages: {
'components.FilterOptions.FILTER_TYPES.$eq': 'is',
'components.FilterOptions.FILTER_TYPES.$ne': 'is not',
'components.FilterOptions.FILTER_TYPES.$contains': 'contains (case sensitive)',
'components.FilterOptions.FILTER_TYPES.$notContains': 'does not contain (case sensitive)',
'components.FilterOptions.FILTER_TYPES.$gt': 'is greater than',
'components.FilterOptions.FILTER_TYPES.$gte': 'is greater than or equal to',
'components.FilterOptions.FILTER_TYPES.$lt': 'is lower than',
'components.FilterOptions.FILTER_TYPES.$lte': 'is lower than or equal to',
'components.FilterOptions.FILTER_TYPES.$startsWith': 'starts with',
'components.FilterOptions.FILTER_TYPES.$endsWith': 'ends with',
'components.FilterOptions.FILTER_TYPES.$null': 'is null',
'components.FilterOptions.FILTER_TYPES.$notNull': 'is not null',
},
textComponent: 'span',
});
intl.formatDate = jest.fn(() => 'Wednesday, September 1, 2021');
intl.formatTime = jest.fn(() => '12:45 AM');
return {
...reactIntl,
useIntl: () => intl,
};
});
const makeApp = (history, filtersSchema) => (
<Router history={history}>
<ThemeProvider theme={lightTheme}>

View File

@ -1,6 +1,6 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import { IntlProvider } from 'react-intl';
import { IntlProvider, useIntl } from 'react-intl';
import { ThemeProvider, lightTheme } from '@strapi/design-system';
import RelativeTime from '../index';
@ -12,6 +12,17 @@ const App = (
</ThemeProvider>
);
// TO BE REMOVED: we have added this mock to prevent errors in the snapshots caused by the Unicode space character
// before AM/PM in the dates, after the introduction of node 18.13
jest.mock('react-intl', () => ({
...jest.requireActual('react-intl'),
useIntl: jest.fn(() => ({
formatDate: jest.fn(() => '10/1/2015'),
formatTime: jest.fn(() => '7:55 AM'),
formatRelativeTime: jest.fn(() => '5 minutes ago'),
})),
}));
describe('RelativeTime', () => {
beforeEach(() => {
jest.spyOn(Date, 'now').mockImplementation(() => new Date('2015-10-01 08:00:00'));
@ -37,6 +48,11 @@ describe('RelativeTime', () => {
});
it('can display the relative time for a future date', () => {
useIntl.mockReturnValueOnce({
formatDate: jest.fn(() => '10/1/2015'),
formatTime: jest.fn(() => '7:50 AM'),
formatRelativeTime: jest.fn(() => 'in 5 minutes'),
});
jest.spyOn(Date, 'now').mockImplementation(() => new Date('2015-10-01 07:50:00'));
render(App);
@ -45,6 +61,11 @@ describe('RelativeTime', () => {
});
it('can display the relative time for a past date', () => {
useIntl.mockReturnValueOnce({
formatDate: jest.fn(() => '10/1/2015'),
formatTime: jest.fn(() => '8:00 AM'),
formatRelativeTime: jest.fn(() => '5 minutes ago'),
});
jest.spyOn(Date, 'now').mockImplementation(() => new Date('2015-10-01 08:00:00'));
render(App);

View File

@ -68,6 +68,7 @@
"@strapi/icons": "1.4.1",
"@testing-library/react": "12.1.4",
"@testing-library/react-hooks": "8.0.1",
"browserslist-to-esbuild": "1.2.0",
"cross-env": "^7.0.3",
"esbuild-loader": "^2.20.0",
"react-test-renderer": "^17.0.2",

View File

@ -1,5 +1,6 @@
const webpack = require('webpack');
const { ESBuildMinifyPlugin } = require('esbuild-loader');
const browserslistToEsbuild = require('browserslist-to-esbuild');
const packageJson = require('./package.json');
@ -42,7 +43,7 @@ module.exports = {
loader: require.resolve('esbuild-loader'),
options: {
loader: 'jsx',
target: 'es2015',
target: browserslistToEsbuild(),
},
},
},

View File

@ -7930,6 +7930,13 @@ browserify-zlib@^0.2.0:
dependencies:
pako "~1.0.5"
browserslist-to-esbuild@1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/browserslist-to-esbuild/-/browserslist-to-esbuild-1.2.0.tgz#5c5b9ca73106da02e0168007396c4ec4c1e6d643"
integrity sha512-ftrrbI/VHBgEnmnSyhkqvQVMp6jAKybfs0qMIlm7SLBrQTGMsdCIP4q3BoKeLsZTBQllIQtY9kbxgRYV2WU47g==
dependencies:
browserslist "^4.17.3"
browserslist@^4.12.0, browserslist@^4.14.5:
version "4.20.2"
resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.20.2.tgz#567b41508757ecd904dab4d1c646c612cd3d4f88"
@ -7941,6 +7948,16 @@ browserslist@^4.12.0, browserslist@^4.14.5:
node-releases "^2.0.2"
picocolors "^1.0.0"
browserslist@^4.17.3:
version "4.21.4"
resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.21.4.tgz#e7496bbc67b9e39dd0f98565feccdcb0d4ff6987"
integrity sha512-CBHJJdDmgjl3daYjN5Cp5kbTf1mUhZoS+beLklHIvkOWscs83YAhLlF3Wsh/lciQYAcbBJgTOD44VtG31ZM4Hw==
dependencies:
caniuse-lite "^1.0.30001400"
electron-to-chromium "^1.4.251"
node-releases "^2.0.6"
update-browserslist-db "^1.0.9"
browserslist@^4.20.2:
version "4.21.0"
resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.21.0.tgz#7ab19572361a140ecd1e023e2c1ed95edda0cefe"
@ -8283,6 +8300,11 @@ caniuse-lite@^1.0.30001370:
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001373.tgz#2dc3bc3bfcb5d5a929bec11300883040d7b4b4be"
integrity sha512-pJYArGHrPp3TUqQzFYRmP/lwJlj8RCbVe3Gd3eJQkAV8SAC6b19XS9BjMvRdvaS8RMkaTN8ZhoHP6S1y8zzwEQ==
caniuse-lite@^1.0.30001400:
version "1.0.30001442"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001442.tgz#40337f1cf3be7c637b061e2f78582dc1daec0614"
integrity sha512-239m03Pqy0hwxYPYR5JwOIxRJfLTWtle9FV8zosfV5pHg+/51uD4nxcUlM8+mWWGfwKtt8lJNHnD3cWw9VZ6ow==
capture-exit@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/capture-exit/-/capture-exit-2.0.0.tgz#fb953bfaebeb781f62898239dabb426d08a509a4"
@ -10149,6 +10171,11 @@ electron-to-chromium@^1.4.202:
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.208.tgz#ecb5b47c8cc212a43172ffc5ce50178a638a5d74"
integrity sha512-diMr4t69FigAGUk2KovP0bygEtN/9AkqEVkzjEp0cu+zFFbZMVvwACpTTfuj1mAmFR5kNoSW8wGKDFWIvmThiQ==
electron-to-chromium@^1.4.251:
version "1.4.284"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.284.tgz#61046d1e4cab3a25238f6bf7413795270f125592"
integrity sha512-M8WEXFuKXMYMVr45fo8mq0wUrrJHheiKZf6BArTKk9ZBYCKJEOU5H8cdWgDT+qCVZf7Na4lVUaZsA+h6uA9+PA==
electron-to-chromium@^1.4.84:
version "1.4.106"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.106.tgz#e7a3bfa9d745dd9b9e597616cb17283cc349781a"
@ -21516,6 +21543,14 @@ update-browserslist-db@^1.0.0, update-browserslist-db@^1.0.5:
escalade "^3.1.1"
picocolors "^1.0.0"
update-browserslist-db@^1.0.9:
version "1.0.10"
resolved "https://registry.yarnpkg.com/update-browserslist-db/-/update-browserslist-db-1.0.10.tgz#0f54b876545726f17d00cd9a2561e6dade943ff3"
integrity sha512-OztqDenkfFkbSG+tRxBeAnCVPckDBcvibKd35yDONx6OU8N7sqgwc7rCbkJ/WcYtVRZ4ba68d6byhC21GFh7sQ==
dependencies:
escalade "^3.1.1"
picocolors "^1.0.0"
upper-case-first@^1.1.0, upper-case-first@^1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/upper-case-first/-/upper-case-first-1.1.2.tgz#5d79bedcff14419518fd2edb0a0507c9b6859115"