Skip to content

Commit 9459297

Browse files
author
Kristófer R
committed
Merge remote-tracking branch 'origin/release/7.0.0' into trunk
2 parents 49a6084 + b792743 commit 9459297

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+2652
-1054
lines changed

.github/workflows/compatibility.yml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
matrix:
1212
woocommerce: [ 'beta' ]
1313
wordpress: [ 'latest' ]
14-
php: [ '7.2', '7.4', '8.0' ]
14+
php: [ '7.3', '7.4', '8.0' ]
1515

1616

1717
name: Beta (PHP=${{ matrix.php }}, WP=${{ matrix.wordpress }}, WC=${{ matrix.woocommerce }})
@@ -35,12 +35,8 @@ jobs:
3535
php-version: ${{ matrix.php }}
3636
coverage: none
3737

38-
- name: If PHP 7.0, set up PHPUnit 6.5 for legacy compatibility
39-
if: ${{ matrix.php == '7.0' }}
40-
run: wget https://phar.phpunit.de/phpunit-6.5.14.phar && mv phpunit-6.5.14.phar phpunit.phar
41-
42-
- name: If PHP 8.0, set up PHPUnit 9.5 for compatibility
43-
if: ${{ matrix.php == '8.0' }}
38+
- name: If PHP >= 8.0, set up PHPUnit 9.5 for compatibility
39+
if: ${{ matrix.php >= '8.0' }}
4440
run: wget https://phar.phpunit.de/phpunit-9.5.13.phar && mv phpunit-9.5.13.phar phpunit.phar
4541

4642
- name: Run CI checks

.github/workflows/linting.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
# setup PHP, but without debug extensions for reasonable performance
2323
- uses: shivammathur/setup-php@v2
2424
with:
25-
php-version: '7.1'
25+
php-version: '7.4'
2626
tools: composer
2727
coverage: none
2828
# install dependencies and run linter

.github/workflows/php-tests.yml

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,25 @@ jobs:
1616
include:
1717
# WooCommerce
1818
- woocommerce_support_policy: L
19-
woocommerce: '6.5.0'
19+
woocommerce: '7.0.0'
2020
- woocommerce_support_policy: L-1
21-
woocommerce: '6.4.1'
21+
woocommerce: '6.9.4'
2222
- woocommerce_support_policy: L-2
23-
woocommerce: '6.3.1'
23+
woocommerce: '6.8.2'
2424
# WordPress
2525
- wordpress_support_policy: L
26-
wordpress: '5.9'
26+
wordpress: '6.0'
2727
- wordpress_support_policy: L-1
28-
wordpress: '5.8'
28+
wordpress: '5.9'
2929
- wordpress_support_policy: L-2
30-
wordpress: '5.7'
30+
wordpress: '5.8'
3131
# PHP
3232
- php_support_policy: L
3333
php: '8.0'
3434
- php_support_policy: L-1
3535
php: '7.4'
3636
- php_support_policy: L-2
37-
php: '7.0'
38-
exclude:
39-
- woocommerce_support_policy: L
40-
php_support_policy: L-2
37+
php: '7.3'
4138

4239
name: Stable (PHP=${{ matrix.php_support_policy }}, WP=${{ matrix.wordpress_support_policy }}, WC=${{ matrix.woocommerce_support_policy }})
4340
env:
@@ -60,12 +57,8 @@ jobs:
6057
php-version: ${{ matrix.php }}
6158
coverage: none
6259

63-
- name: If PHP 7.0, set up PHPUnit 6.5 for legacy compatibility
64-
if: ${{ matrix.php == '7.0' }}
65-
run: wget https://phar.phpunit.de/phpunit-6.5.14.phar && mv phpunit-6.5.14.phar phpunit.phar
66-
67-
- name: If PHP 8.0 and WP 5.9, set up PHPUnit 9.5 for compatibility
68-
if: ${{ matrix.php == '8.0' && matrix.wordpress >= '5.9' }}
60+
- name: If PHP >= 8.0 and >= WP 5.9, set up PHPUnit 9.5 for compatibility
61+
if: ${{ matrix.php >= '8.0' && matrix.wordpress >= '5.9' }}
6962
run: wget https://phar.phpunit.de/phpunit-9.5.13.phar && mv phpunit-9.5.13.phar phpunit.phar
7063

7164
- name: Run CI checks

changelog.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
*** Changelog ***
22

3+
= 7.0.0 - 2022-11-10 =
4+
* Add - Update Express Checkout section UI.
5+
* Add - Auto-complete first and last name on checkout form when using Link payment method.
6+
* Add - Allow subscription orders to be paid with Link payment method.
7+
* Add - Add inbox notification for Link payment method.
8+
* Tweak - Adjust texts and links in WC admin advanced settings.
9+
* Add - Restrict the Link payment method only for US merchants.
10+
311
= 6.9.0 - 2022-10-19 =
412
* Tweak - Remove remaining traces of old Stripe settings.
513
* Add - Add Boleto expiration setting.

client/blocks/upe/fields.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ const UPEField = ( {
8585
state: 'components-form-token-input-1',
8686
postal_code: 'shipping-postcode',
8787
country: 'components-form-token-input-0',
88+
first_name: 'shipping-first_name',
89+
last_name: 'shipping-last_name',
8890
};
8991
const billingAddressFields = {
9092
line1: 'billing-address_1',
@@ -93,6 +95,8 @@ const UPEField = ( {
9395
state: 'components-form-token-input-3',
9496
postal_code: 'billing-postcode',
9597
country: 'components-form-token-input-2',
98+
first_name: 'billing-first_name',
99+
last_name: 'billing-last_name',
96100
};
97101

98102
enableStripeLinkPaymentMethod( {

client/classic/upe/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,8 @@ jQuery( function ( $ ) {
268268
state: 'shipping_state',
269269
postal_code: 'shipping_postcode',
270270
country: 'shipping_country',
271+
first_name: 'shipping_first_name',
272+
last_name: 'shipping_last_name',
271273
},
272274
billing_fields: {
273275
line1: 'billing_address_1',
@@ -276,6 +278,8 @@ jQuery( function ( $ ) {
276278
state: 'billing_state',
277279
postal_code: 'billing_postcode',
278280
country: 'billing_country',
281+
first_name: 'billing_first_name',
282+
last_name: 'billing_last_name',
279283
},
280284
} );
281285
}
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
import { render, screen } from '@testing-library/react';
2+
import userEvent from '@testing-library/user-event';
3+
import PaymentRequestsSettingsSection from '../payment-request-settings-section';
4+
import PaymentRequestButtonPreview from '../payment-request-button-preview';
5+
import {
6+
usePaymentRequestEnabledSettings,
7+
usePaymentRequestLocations,
8+
} from 'wcstripe/data';
9+
10+
jest.mock( 'wcstripe/data', () => ( {
11+
usePaymentRequestEnabledSettings: jest.fn(),
12+
usePaymentRequestLocations: jest.fn(),
13+
usePaymentRequestButtonType: jest.fn().mockReturnValue( [ 'buy' ] ),
14+
usePaymentRequestButtonSize: jest.fn().mockReturnValue( [ 'default' ] ),
15+
usePaymentRequestButtonTheme: jest.fn().mockReturnValue( [ 'dark' ] ),
16+
} ) );
17+
18+
jest.mock( 'wcstripe/data/account/hooks', () => ( {
19+
useAccount: jest.fn().mockReturnValue( { data: {} } ),
20+
} ) );
21+
jest.mock( 'wcstripe/data/account-keys/hooks', () => ( {
22+
useAccountKeys: jest.fn().mockReturnValue( {} ),
23+
useAccountKeysPublishableKey: jest.fn().mockReturnValue( [ '' ] ),
24+
useAccountKeysTestPublishableKey: jest.fn().mockReturnValue( [ '' ] ),
25+
} ) );
26+
27+
jest.mock( '../payment-request-button-preview' );
28+
PaymentRequestButtonPreview.mockImplementation( () => '<></>' );
29+
30+
jest.mock( '../utils/utils', () => ( {
31+
getPaymentRequestData: jest.fn().mockReturnValue( {
32+
publishableKey: 'pk_test_123',
33+
accountId: '0001',
34+
locale: 'en',
35+
} ),
36+
} ) );
37+
38+
const getMockPaymentRequestEnabledSettings = (
39+
isEnabled,
40+
updateIsPaymentRequestEnabledHandler
41+
) => [ isEnabled, updateIsPaymentRequestEnabledHandler ];
42+
43+
const getMockPaymentRequestLocations = (
44+
isCheckoutEnabled,
45+
isProductPageEnabled,
46+
isCartEnabled,
47+
updatePaymentRequestLocationsHandler
48+
) => [
49+
[
50+
isCheckoutEnabled && 'checkout',
51+
isProductPageEnabled && 'product',
52+
isCartEnabled && 'cart',
53+
].filter( Boolean ),
54+
updatePaymentRequestLocationsHandler,
55+
];
56+
57+
describe( 'PaymentRequestsSettingsSection', () => {
58+
beforeEach( () => {
59+
usePaymentRequestEnabledSettings.mockReturnValue(
60+
getMockPaymentRequestEnabledSettings( true, jest.fn() )
61+
);
62+
63+
usePaymentRequestLocations.mockReturnValue(
64+
getMockPaymentRequestLocations( true, true, true, jest.fn() )
65+
);
66+
} );
67+
68+
it( 'should enable express checkout locations when express checkout is enabled', () => {
69+
render( <PaymentRequestsSettingsSection /> );
70+
71+
const [
72+
checkoutCheckbox,
73+
productPageCheckbox,
74+
cartCheckbox,
75+
] = screen.getAllByRole( 'checkbox' );
76+
77+
expect( checkoutCheckbox ).not.toBeDisabled();
78+
expect( checkoutCheckbox ).toBeChecked();
79+
expect( productPageCheckbox ).not.toBeDisabled();
80+
expect( productPageCheckbox ).toBeChecked();
81+
expect( cartCheckbox ).not.toBeDisabled();
82+
expect( cartCheckbox ).toBeChecked();
83+
} );
84+
85+
it( 'should trigger an action to save the checked locations when un-checking the location checkboxes', () => {
86+
const updatePaymentRequestLocationsHandler = jest.fn();
87+
usePaymentRequestEnabledSettings.mockReturnValue( [ true, jest.fn() ] );
88+
usePaymentRequestLocations.mockReturnValue(
89+
getMockPaymentRequestLocations(
90+
true,
91+
true,
92+
true,
93+
updatePaymentRequestLocationsHandler
94+
)
95+
);
96+
97+
render( <PaymentRequestsSettingsSection /> );
98+
99+
// Uncheck each checkbox, and verify them what kind of action should have been called
100+
userEvent.click( screen.getByText( 'Product page' ) );
101+
expect(
102+
updatePaymentRequestLocationsHandler
103+
).toHaveBeenLastCalledWith( [ 'checkout', 'cart' ] );
104+
105+
userEvent.click( screen.getByText( 'Checkout' ) );
106+
expect(
107+
updatePaymentRequestLocationsHandler
108+
).toHaveBeenLastCalledWith( [ 'product', 'cart' ] );
109+
110+
userEvent.click( screen.getByText( 'Cart' ) );
111+
expect(
112+
updatePaymentRequestLocationsHandler
113+
).toHaveBeenLastCalledWith( [ 'checkout', 'product' ] );
114+
} );
115+
116+
it( 'should trigger an action to save the checked locations when checking the location checkboxes', () => {
117+
const updatePaymentRequestLocationsHandler = jest.fn();
118+
usePaymentRequestEnabledSettings.mockReturnValue( [ true, jest.fn() ] );
119+
usePaymentRequestLocations.mockReturnValue(
120+
getMockPaymentRequestLocations(
121+
false,
122+
false,
123+
false,
124+
updatePaymentRequestLocationsHandler
125+
)
126+
);
127+
128+
render( <PaymentRequestsSettingsSection /> );
129+
130+
userEvent.click( screen.getByText( 'Cart' ) );
131+
expect(
132+
updatePaymentRequestLocationsHandler
133+
).toHaveBeenLastCalledWith( [ 'cart' ] );
134+
135+
userEvent.click( screen.getByText( 'Product page' ) );
136+
expect(
137+
updatePaymentRequestLocationsHandler
138+
).toHaveBeenLastCalledWith( [ 'product' ] );
139+
140+
userEvent.click( screen.getByText( 'Checkout' ) );
141+
expect(
142+
updatePaymentRequestLocationsHandler
143+
).toHaveBeenLastCalledWith( [ 'checkout' ] );
144+
} );
145+
} );

client/entrypoints/payment-request-settings/__tests__/payment-request-section.test.js renamed to client/entrypoints/payment-request-settings/__tests__/payment-request-settings.test.js

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
import { render, screen } from '@testing-library/react';
22
import userEvent from '@testing-library/user-event';
3-
import PaymentRequestSection from '../payment-request-section';
3+
import PaymentRequestsSettingsSection from '../payment-request-settings-section';
44
import PaymentRequestButtonPreview from '../payment-request-button-preview';
55
import {
6+
usePaymentRequestEnabledSettings,
7+
usePaymentRequestLocations,
68
usePaymentRequestButtonType,
79
usePaymentRequestButtonSize,
810
usePaymentRequestButtonTheme,
911
} from 'wcstripe/data';
1012

1113
jest.mock( 'wcstripe/data', () => ( {
14+
usePaymentRequestEnabledSettings: jest.fn(),
15+
usePaymentRequestLocations: jest.fn(),
1216
usePaymentRequestButtonType: jest.fn().mockReturnValue( [ 'buy' ] ),
1317
usePaymentRequestButtonSize: jest.fn().mockReturnValue( [ 'default' ] ),
1418
usePaymentRequestButtonTheme: jest.fn().mockReturnValue( [ 'dark' ] ),
@@ -33,25 +37,48 @@ jest.mock( '../utils/utils', () => ( {
3337
} ),
3438
} ) );
3539

36-
jest.mock( 'wcstripe/data', () => ( {
37-
usePaymentRequestButtonType: jest.fn().mockReturnValue( [ 'buy' ] ),
38-
usePaymentRequestButtonSize: jest.fn().mockReturnValue( [ 'default' ] ),
39-
usePaymentRequestButtonTheme: jest.fn().mockReturnValue( [ 'dark' ] ),
40-
} ) );
40+
const getMockPaymentRequestEnabledSettings = (
41+
isEnabled,
42+
updateIsPaymentRequestEnabledHandler
43+
) => [ isEnabled, updateIsPaymentRequestEnabledHandler ];
44+
45+
const getMockPaymentRequestLocations = (
46+
isCheckoutEnabled,
47+
isProductPageEnabled,
48+
isCartEnabled,
49+
updatePaymentRequestLocationsHandler
50+
) => [
51+
[
52+
isCheckoutEnabled && 'checkout',
53+
isProductPageEnabled && 'product',
54+
isCartEnabled && 'cart',
55+
].filter( Boolean ),
56+
updatePaymentRequestLocationsHandler,
57+
];
58+
59+
describe( 'PaymentRequestsSettingsSection', () => {
60+
beforeEach( () => {
61+
usePaymentRequestEnabledSettings.mockReturnValue(
62+
getMockPaymentRequestEnabledSettings( true, jest.fn() )
63+
);
64+
65+
usePaymentRequestLocations.mockReturnValue(
66+
getMockPaymentRequestLocations( true, true, true, jest.fn() )
67+
);
68+
} );
4169

42-
describe( 'PaymentRequestSection', () => {
4370
it( 'renders settings with defaults', () => {
44-
render( <PaymentRequestSection /> );
71+
render( <PaymentRequestsSettingsSection /> );
4572

46-
// confirm settings headings
73+
// confirm settings headings.
4774
expect(
4875
screen.queryByRole( 'heading', { name: 'Call to action' } )
4976
).toBeInTheDocument();
5077
expect(
5178
screen.queryByRole( 'heading', { name: 'Appearance' } )
5279
).toBeInTheDocument();
5380

54-
// confirm radio button groups displayed
81+
// confirm radio button groups displayed.
5582
const [ ctaRadio, sizeRadio, themeRadio ] = screen.queryAllByRole(
5683
'radio'
5784
);
@@ -60,7 +87,7 @@ describe( 'PaymentRequestSection', () => {
6087
expect( sizeRadio ).toBeInTheDocument();
6188
expect( themeRadio ).toBeInTheDocument();
6289

63-
// confirm default values
90+
// confirm default values.
6491
expect( screen.getByLabelText( 'Buy' ) ).toBeChecked();
6592
expect( screen.getByLabelText( 'Default (40 px)' ) ).toBeChecked();
6693
expect( screen.getByLabelText( /Dark/ ) ).toBeChecked();
@@ -70,6 +97,7 @@ describe( 'PaymentRequestSection', () => {
7097
const setButtonTypeMock = jest.fn();
7198
const setButtonSizeMock = jest.fn();
7299
const setButtonThemeMock = jest.fn();
100+
73101
usePaymentRequestButtonType.mockReturnValue( [
74102
'buy',
75103
setButtonTypeMock,
@@ -82,8 +110,9 @@ describe( 'PaymentRequestSection', () => {
82110
'dark',
83111
setButtonThemeMock,
84112
] );
113+
usePaymentRequestEnabledSettings.mockReturnValue( [ true, jest.fn() ] );
85114

86-
render( <PaymentRequestSection /> );
115+
render( <PaymentRequestsSettingsSection /> );
87116

88117
expect( setButtonTypeMock ).not.toHaveBeenCalled();
89118
expect( setButtonSizeMock ).not.toHaveBeenCalled();

0 commit comments

Comments
 (0)