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

Dev - Upgrade to Node v20 #9121

Merged
merged 54 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
f57deef
Update the required packages and configurations to be able to run bot…
danielmx-dev Jul 17, 2024
3d9ca68
Update test snapshots
danielmx-dev Jul 17, 2024
ff73ec4
Update deprecated type definition
danielmx-dev Jul 17, 2024
d5ede0d
Perform simple test fixes related to new dependencies
danielmx-dev Jul 17, 2024
bbc8539
Restore eslint dependencies that didn't need an upgrade
danielmx-dev Jul 17, 2024
a0b59fc
Fix tests related to advanced filters
danielmx-dev Jul 17, 2024
7ee18ca
Update eslint plugins once again
danielmx-dev Jul 17, 2024
0199b26
Fix tooltip test
danielmx-dev Jul 17, 2024
6b7b4ce
Fix the remaining tests
danielmx-dev Jul 17, 2024
4641299
Add newline
danielmx-dev Jul 17, 2024
02b8b5b
Add changelog
danielmx-dev Jul 17, 2024
d035c2f
Restore eslint prettier versions and fix existing errors
danielmx-dev Jul 17, 2024
a82a21e
Restore stylelint version
danielmx-dev Jul 17, 2024
c9f710e
Upgrade jest to match ts-jest version
danielmx-dev Jul 18, 2024
e043654
upgrade e2e environment package
danielmx-dev Jul 18, 2024
bd5fa27
Merge branch 'develop' into dev/upgrade-support-to-node-20
danielmx-dev Jul 22, 2024
b883adf
Restore expect call in tooltip test
danielmx-dev Jul 23, 2024
1cc1adb
Upgrade E2E tests to support node 20
danielmx-dev Jul 18, 2024
9107fe5
Upgrade expect puppeteer and assertions
danielmx-dev Jul 18, 2024
a06c748
Add conditional logout functionality. Fix matchers calls
danielmx-dev Jul 19, 2024
2087f11
Update klarna test
danielmx-dev Jul 19, 2024
6cd0a69
Fix multi-currency tests
danielmx-dev Jul 19, 2024
3e4ab42
Fix admin multi currency setup tests
danielmx-dev Jul 19, 2024
73d18eb
Fix merchant refund test
danielmx-dev Jul 19, 2024
67547c1
Fix blocks checkout page setup for e2e tests
danielmx-dev Jul 19, 2024
b9551e1
Fix e2e blocks payment flow to fill card details
danielmx-dev Jul 19, 2024
2bb6479
Fix e2e blocks notices location
danielmx-dev Jul 19, 2024
1e4a4f4
Fix e2e blocks saved card tests
danielmx-dev Jul 19, 2024
f11a66d
Fix e2e blocks purchase tests
danielmx-dev Jul 19, 2024
e5fc127
Fix flappy refund e2e test
danielmx-dev Jul 19, 2024
72f3754
Fix setup for upe methods e2e tests
danielmx-dev Jul 19, 2024
ceedf1a
Fix setup for klarna e2e tests
danielmx-dev Jul 19, 2024
e35900d
Fix blocks test when address already exists for customer
danielmx-dev Jul 19, 2024
4d80b26
Try to improve blocks setup reliability
danielmx-dev Jul 19, 2024
f4b6013
Try the new headless mode
danielmx-dev Jul 19, 2024
1afdea8
Clean some of the console output
danielmx-dev Jul 19, 2024
8185de6
Clean some of the console output
danielmx-dev Jul 19, 2024
36defb2
Increase timeout for flappy e2e test
danielmx-dev Jul 19, 2024
90f9eea
Fix the setup function of upe e2e test
danielmx-dev Jul 20, 2024
4f7a467
Add puppeteerrc to save chromium to node_modules
danielmx-dev Jul 20, 2024
010ac15
Take screenshots during flaky e2e tests
danielmx-dev Jul 20, 2024
c55001d
Rename screenshots
danielmx-dev Jul 20, 2024
4febc30
Remove screenshots from failures spec
danielmx-dev Jul 20, 2024
d642dd6
Make sure to always restore dialog handler
danielmx-dev Jul 20, 2024
1b76562
Remove dialog listeners right before it becomes necessary
danielmx-dev Jul 20, 2024
a177367
Upgrade package versions to allow taking screenshots on failures
danielmx-dev Jul 22, 2024
b299716
Take screenshot of flaky test
danielmx-dev Jul 22, 2024
d1ac749
Try to fix timeout issues with refund failures test
danielmx-dev Jul 22, 2024
fd1834e
add timeouts to expect functions
danielmx-dev Jul 22, 2024
70c854c
Restore refund failures file as much as possible
danielmx-dev Jul 22, 2024
035d462
Remove unnecessary wait in custom test environment
danielmx-dev Jul 23, 2024
2067c3a
Merge branch 'develop' into dev/upgrade-support-to-node-20
danielmx-dev Jul 23, 2024
f91877b
Small klarna e2e adjustment
danielmx-dev Jul 23, 2024
4579ce1
Merge branch 'develop' into dev/upgrade-support-to-node-20
danielmx-dev Jul 23, 2024
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
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16.17
v20
9 changes: 9 additions & 0 deletions .puppeteerrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const {join} = require('path');

/**
* @type {import("puppeteer").Configuration}
*/
module.exports = {
// Changes the cache location for Puppeteer.
cacheDirectory: join(__dirname, 'node_modules', '.cache', 'puppeteer'),
};
4 changes: 4 additions & 0 deletions changelog/dev-upgrade-support-to-node-20
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: dev

Update node to v20
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,13 @@ describe( 'AddPaymentMethodsTask', () => {

userEvent.click( screen.getByText( 'Continue' ) );

await jest.runAllTimersAsync();

expect( updateEnabledPaymentMethodsMock ).toHaveBeenCalledWith( [
'card',
'p24',
] );

await waitFor( () =>
expect( setCompletedMock ).toHaveBeenCalledWith(
{ initialMethods: [ 'card' ] },
Expand Down Expand Up @@ -335,6 +338,8 @@ describe( 'AddPaymentMethodsTask', () => {

userEvent.click( screen.getByText( 'Continue' ) );

await jest.runAllTimersAsync();

// Methods are removed.
expect( updateEnabledPaymentMethodsMock ).toHaveBeenCalledWith( [
'card',
Expand Down
3 changes: 1 addition & 2 deletions client/components/banner-notice/tests/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import user from '@testing-library/user-event';
import { mocked } from 'ts-jest/utils';
import { speak } from '@wordpress/a11y';

/**
Expand All @@ -16,7 +15,7 @@ jest.mock( '@wordpress/a11y', () => ( { speak: jest.fn() } ) );

describe( 'BannerNotice', () => {
beforeEach( () => {
mocked( speak ).mockClear();
jest.mocked( speak ).mockClear();
} );

it( 'should match snapshot', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Loadable checkbox renders correctly 1`] = `
Object {
{
"asFragment": [Function],
"baseElement": <body>
<p
Expand Down
8 changes: 4 additions & 4 deletions client/components/loadable-checkbox/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ describe( 'Loadable checkbox', () => {
jest.useFakeTimers();
act( () => {
userEvent.click( container.queryByLabelText( 'Foo' ) );
jest.runTimersToTime( 400 );
jest.advanceTimersByTime( 400 );
} );
container.rerender( getLoadableCheckbox( false, 1500, 0 ) );
expect( mockOnChangeEvent ).not.toHaveBeenCalled();

act( () => {
jest.runTimersToTime( 1200 );
jest.advanceTimersByTime( 1200 );
} );
container.rerender( getLoadableCheckbox( false, 1500, 0 ) );
expect( mockOnChangeEvent ).toHaveBeenCalled();
Expand All @@ -122,12 +122,12 @@ describe( 'Loadable checkbox', () => {
jest.useFakeTimers();
act( () => {
userEvent.click( container.queryByLabelText( 'Foo' ) );
jest.runTimersToTime( 400 );
jest.advanceTimersByTime( 400 );
} );
container.rerender( getLoadableCheckbox( false, 0, 1500 ) );
expect( mockOnChangeEvent ).not.toHaveBeenCalled();
act( () => {
jest.runTimersToTime( 1200 );
jest.advanceTimersByTime( 1200 );
} );
container.rerender( getLoadableCheckbox( false, 0, 1500 ) );
expect( mockOnChangeEvent ).toHaveBeenCalledWith( false );
Expand Down
3 changes: 3 additions & 0 deletions client/components/tooltip/test/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ describe( 'ClickTooltip', () => {

act( () => {
userEvent.click( screen.getByText( 'Trigger element' ) );
} );

act( () => {
jest.runAllTimers();
} );

Expand Down
3 changes: 1 addition & 2 deletions client/connect-account-page/test/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import React from 'react';
import { render, screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import apiFetch from '@wordpress/api-fetch';
import { mocked } from 'ts-jest/utils';

/**
* Internal dependencies
Expand Down Expand Up @@ -103,7 +102,7 @@ describe( 'ConnectAccountPage', () => {
render( <ConnectAccountPage /> );

// mockApiFetch.mockRejectedValueOnce( {} );
mocked( apiFetch ).mockRejectedValueOnce( new Error() );
jest.mocked( apiFetch ).mockRejectedValueOnce( new Error() );

userEvent.click(
screen.getByRole( 'button', { name: 'Verify business details' } )
Expand Down
10 changes: 9 additions & 1 deletion client/deposits/filters/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,18 @@ import { DepositsFilters } from '../';
// TODO: this is a bit of a hack as we're mocking an old version of WC, we should relook at this.
jest.mock( '@woocommerce/settings', () => ( {
...jest.requireActual( '@woocommerce/settings' ),
getSetting: jest.fn( ( key ) => ( key === 'wcVersion' ? 7.7 : '' ) ),
getSetting: jest.fn( ( key ) => ( key === 'wcVersion' ? 7.8 : '' ) ),
} ) );

describe( 'Deposits filters', () => {
beforeAll( () => {
jest.useFakeTimers();
} );

afterAll( () => {
jest.useRealTimers();
} );

beforeEach( () => {
// the query string is preserved across tests, so we need to reset it
updateQueryString( {}, '/', {} );
Expand Down
10 changes: 4 additions & 6 deletions client/deposits/list/test/__snapshots__/index.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ exports[`Deposits list renders correctly a single deposit 1`] = `
data-wp-component="CardBody"
>
<div
aria-hidden="false"
aria-labelledby="caption-1"
class="woocommerce-table__table"
role="group"
Expand Down Expand Up @@ -535,13 +534,13 @@ exports[`Deposits list renders correctly a single deposit 1`] = `
</div>
<div
aria-hidden="true"
class="components-elevation css-91yjwm-View-Elevation-sx-Base-elevationClassName em57xhy0"
class="components-elevation css-15t1t3g-View-Elevation-sx-Base-elevationClassName em57xhy0"
data-wp-c16t="true"
data-wp-component="Elevation"
/>
<div
aria-hidden="true"
class="components-elevation css-91yjwm-View-Elevation-sx-Base-elevationClassName em57xhy0"
class="components-elevation css-15t1t3g-View-Elevation-sx-Base-elevationClassName em57xhy0"
data-wp-c16t="true"
data-wp-component="Elevation"
/>
Expand Down Expand Up @@ -711,7 +710,6 @@ exports[`Deposits list renders correctly with multiple currencies 1`] = `
data-wp-component="CardBody"
>
<div
aria-hidden="false"
aria-labelledby="caption-0"
class="woocommerce-table__table"
role="group"
Expand Down Expand Up @@ -1071,13 +1069,13 @@ exports[`Deposits list renders correctly with multiple currencies 1`] = `
</div>
<div
aria-hidden="true"
class="components-elevation css-91yjwm-View-Elevation-sx-Base-elevationClassName em57xhy0"
class="components-elevation css-15t1t3g-View-Elevation-sx-Base-elevationClassName em57xhy0"
data-wp-c16t="true"
data-wp-component="Elevation"
/>
<div
aria-hidden="true"
class="components-elevation css-91yjwm-View-Elevation-sx-Base-elevationClassName em57xhy0"
class="components-elevation css-15t1t3g-View-Elevation-sx-Base-elevationClassName em57xhy0"
data-wp-c16t="true"
data-wp-component="Elevation"
/>
Expand Down
1 change: 1 addition & 0 deletions client/deposits/list/test/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ jest.mock( '@wordpress/data', () => ( {
dispatch: jest.fn( () => ( {
setIsMatching: jest.fn(),
onLoad: jest.fn(),
onHistoryChange: jest.fn(),
} ) ),
registerStore: jest.fn(),
select: jest.fn(),
Expand Down
2 changes: 1 addition & 1 deletion client/disputes/filters/test/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { formatCurrencyName } from '../../../utils/currency';
// TODO: this is a bit of a hack as we're mocking an old version of WC, we should relook at this.
jest.mock( '@woocommerce/settings', () => ( {
...jest.requireActual( '@woocommerce/settings' ),
getSetting: jest.fn( ( key ) => ( key === 'wcVersion' ? 7.7 : '' ) ),
getSetting: jest.fn( ( key ) => ( key === 'wcVersion' ? 7.8 : '' ) ),
} ) );

function addAdvancedFilter( filter: string ) {
Expand Down
5 changes: 2 additions & 3 deletions client/disputes/test/__snapshots__/index.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ exports[`Disputes list renders correctly 1`] = `
data-wp-component="CardBody"
>
<div
aria-hidden="false"
aria-labelledby="caption-0"
class="woocommerce-table__table"
role="group"
Expand Down Expand Up @@ -761,13 +760,13 @@ exports[`Disputes list renders correctly 1`] = `
</div>
<div
aria-hidden="true"
class="components-elevation css-91yjwm-View-Elevation-sx-Base-elevationClassName em57xhy0"
class="components-elevation css-15t1t3g-View-Elevation-sx-Base-elevationClassName em57xhy0"
data-wp-c16t="true"
data-wp-component="Elevation"
/>
<div
aria-hidden="true"
class="components-elevation css-91yjwm-View-Elevation-sx-Base-elevationClassName em57xhy0"
class="components-elevation css-15t1t3g-View-Elevation-sx-Base-elevationClassName em57xhy0"
data-wp-c16t="true"
data-wp-component="Elevation"
/>
Expand Down
10 changes: 9 additions & 1 deletion client/documents/filters/test/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { DocumentsFilters } from '../';
// TODO: this is a bit of a hack as we're mocking an old version of WC, we should relook at this.
jest.mock( '@woocommerce/settings', () => ( {
...jest.requireActual( '@woocommerce/settings' ),
getSetting: jest.fn( ( key ) => ( key === 'wcVersion' ? 7.7 : '' ) ),
getSetting: jest.fn( ( key ) => ( key === 'wcVersion' ? 7.8 : '' ) ),
} ) );

function addAdvancedFilter( filter: string ) {
Expand Down Expand Up @@ -49,6 +49,14 @@ describe( 'Documents filters', () => {
describe( 'when filtering by date', () => {
let ruleSelector: HTMLElement;

beforeAll( () => {
jest.useFakeTimers();
} );

afterAll( () => {
jest.useRealTimers();
} );

beforeEach( () => {
addAdvancedFilter( 'Date' );
ruleSelector = screen.getByRole( 'combobox', {
Expand Down
10 changes: 4 additions & 6 deletions client/documents/list/test/__snapshots__/index.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ exports[`Documents list renders correctly 1`] = `
data-wp-component="CardBody"
>
<div
aria-hidden="false"
aria-labelledby="caption-0"
class="woocommerce-table__table"
role="group"
Expand Down Expand Up @@ -299,13 +298,13 @@ exports[`Documents list renders correctly 1`] = `
</div>
<div
aria-hidden="true"
class="components-elevation css-91yjwm-View-Elevation-sx-Base-elevationClassName em57xhy0"
class="components-elevation css-15t1t3g-View-Elevation-sx-Base-elevationClassName em57xhy0"
data-wp-c16t="true"
data-wp-component="Elevation"
/>
<div
aria-hidden="true"
class="components-elevation css-91yjwm-View-Elevation-sx-Base-elevationClassName em57xhy0"
class="components-elevation css-15t1t3g-View-Elevation-sx-Base-elevationClassName em57xhy0"
data-wp-c16t="true"
data-wp-component="Elevation"
/>
Expand Down Expand Up @@ -423,7 +422,6 @@ exports[`Documents list renders table summary only when the documents summary da
data-wp-component="CardBody"
>
<div
aria-hidden="false"
aria-labelledby="caption-7"
class="woocommerce-table__table"
role="group"
Expand Down Expand Up @@ -613,13 +611,13 @@ exports[`Documents list renders table summary only when the documents summary da
</div>
<div
aria-hidden="true"
class="components-elevation css-91yjwm-View-Elevation-sx-Base-elevationClassName em57xhy0"
class="components-elevation css-15t1t3g-View-Elevation-sx-Base-elevationClassName em57xhy0"
data-wp-c16t="true"
data-wp-component="Elevation"
/>
<div
aria-hidden="true"
class="components-elevation css-91yjwm-View-Elevation-sx-Base-elevationClassName em57xhy0"
class="components-elevation css-15t1t3g-View-Elevation-sx-Base-elevationClassName em57xhy0"
data-wp-c16t="true"
data-wp-component="Elevation"
/>
Expand Down
3 changes: 1 addition & 2 deletions client/documents/list/test/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { getQuery, updateQueryString } from '@woocommerce/navigation';
import { DocumentsList } from '../';
import { useDocuments, useDocumentsSummary } from 'data/index';
import type { Document } from 'data/documents/hooks';
import { mocked } from 'ts-jest/utils';
import VatForm from 'wcpay/vat/form';

jest.mock( 'data/index', () => ( {
Expand Down Expand Up @@ -182,7 +181,7 @@ describe( 'Document download button', () => {
documentsError: undefined,
} );

mocked( VatForm ).mockImplementation( ( { onCompleted } ) => (
jest.mocked( VatForm ).mockImplementation( ( { onCompleted } ) => (
<button
onClick={ () =>
onCompleted(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Multi-Currency Settings page renders correctly: snapshot-multi-currency-setup-wizard 1`] = `
Object {
{
"asFragment": [Function],
"baseElement": <body>
<p
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ exports[`Single currency settings screen Page renders correctly 1`] = `
</h4>
<div>
<div
class="components-base-control with-value css-wdf2ti-Wrapper ej5x27r4"
class="components-base-control with-value css-ij2po-Wrapper-boxSizingReset ej5x27r4"
>
<div
class="components-base-control__field css-10urnh1-StyledField-deprecatedMarginField ej5x27r3"
Expand Down
7 changes: 3 additions & 4 deletions client/onboarding/steps/test/business-details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import user from '@testing-library/user-event';
import { mocked } from 'ts-jest/utils';

/**
* Internal dependencies
Expand Down Expand Up @@ -41,7 +40,7 @@ const countries = [
},
];

mocked( getAvailableCountries ).mockReturnValue( countries );
jest.mocked( getAvailableCountries ).mockReturnValue( countries );

const businessTypes = [
{
Expand Down Expand Up @@ -97,7 +96,7 @@ const businessTypes = [
},
];

mocked( getBusinessTypes ).mockReturnValue( businessTypes );
jest.mocked( getBusinessTypes ).mockReturnValue( businessTypes );

const mccsFlatList = [
{
Expand Down Expand Up @@ -168,7 +167,7 @@ const mccsFlatList = [
},
];

mocked( getMccsFlatList ).mockReturnValue( mccsFlatList );
jest.mocked( getMccsFlatList ).mockReturnValue( mccsFlatList );

describe( 'BusinessDetails', () => {
it( 'renders and updates fields data when they are changed', async () => {
Expand Down
Loading
Loading