Skip to content

Commit 7795392

Browse files
committed
Add test case for submit button disabled
1 parent bd27c82 commit 7795392

File tree

1 file changed

+48
-7
lines changed

1 file changed

+48
-7
lines changed

tests/e2e/specs/wcpay/merchant/merchant-admin-multi-currency-on-boarding.spec.js

Lines changed: 48 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/**
22
* External dependencies
33
*/
4-
const { merchant } = require( '@woocommerce/e2e-utils' );
4+
const { merchant, WP_ADMIN_DASHBOARD } = require( '@woocommerce/e2e-utils' );
55
/**
66
* Internal dependencies
77
*/
8-
import { merchantWCP, shopperWCP } from '../../../utils';
8+
import { merchantWCP, uiLoaded } from '../../../utils';
99

1010
let wasMulticurrencyEnabled;
1111

@@ -33,23 +33,64 @@ describe( 'Merchant On-boarding', () => {
3333
} );
3434

3535
describe( 'Currency Selection and Management', () => {
36+
beforeAll( async () => {
37+
await merchantWCP.disableAllEnabledCurrencies();
38+
} );
39+
40+
beforeEach( async () => {
41+
await page.goto(
42+
`${ WP_ADMIN_DASHBOARD }admin.php?page=wc-admin&path=%2Fpayments%2Fmulti-currency-setup`,
43+
{
44+
waitUntil: 'networkidle0',
45+
}
46+
);
47+
await uiLoaded();
48+
} );
49+
3650
it( 'Should disable the submit button when no currencies are selected', async () => {
37-
// Implement test
51+
const checkboxes = await page.$$(
52+
'.enabled-currency-checkbox .components-checkbox-control__input'
53+
);
54+
55+
for ( const checkbox of checkboxes ) {
56+
const isChecked = await (
57+
await checkbox.getProperty( 'checked' )
58+
).jsonValue();
59+
if ( isChecked ) {
60+
// Click the checkbox to uncheck it if it's checked
61+
await checkbox.click();
62+
}
63+
}
64+
65+
await page.waitFor( 1000 );
66+
67+
const button = await page.$(
68+
'.add-currencies-task.is-active .task-collapsible-body.is-active > button.is-primary'
69+
);
70+
71+
expect( button ).not.toBeNull();
72+
73+
const isDisabled = await page.evaluate(
74+
( btn ) => btn.disabled,
75+
button
76+
);
77+
78+
expect( isDisabled ).toBeTruthy();
3879
} );
3980

40-
it( 'Should allow multiple currencies to be selectable', async () => {
81+
it.skip( 'Should allow multiple currencies to be selectable', async () => {
4182
// Implement test
4283
} );
4384

44-
it( 'Should exclude already enabled currencies from the currency screen', async () => {
85+
it.skip( 'Should exclude already enabled currencies from the currency screen', async () => {
4586
// Implement test
4687
} );
4788

48-
it( 'Should display some suggested currencies at the beginning of the list', async () => {
89+
it.skip( 'Should display some suggested currencies at the beginning of the list', async () => {
4990
// Implement test
5091
} );
5192

52-
it( 'Should ensure selected currencies are enabled after submitting the form', async () => {
93+
it.skip( 'Should ensure selected currencies are enabled after submitting the form', async () => {
5394
// Implement test
5495
} );
5596
} );

0 commit comments

Comments
 (0)