-
Notifications
You must be signed in to change notification settings - Fork 69
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
Convert the Merchant Order Status Change E2E spec to Playwright #10243
Merged
Merged
Changes from 4 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
70737dc
Move the unblock ui helper to the generic helpers file
eduardoumpierre b0aca88
Convert the Merchant Orders Status Change spec to Playwright
eduardoumpierre 5aabedc
Remove the Merchant Orders Status Change spec
eduardoumpierre 1963621
Add changelog entry
eduardoumpierre 9f691ef
Merge remote-tracking branch 'origin/develop' into dev/9965-order-sta…
eduardoumpierre 70add24
Replace waitForSelector with locator.waitFor
eduardoumpierre 131a8ed
Merge remote-tracking branch 'origin/develop' into dev/9965-order-sta…
eduardoumpierre d66e572
Merge remote-tracking branch 'origin/develop' into dev/9965-order-sta…
eduardoumpierre 1b31f49
Merge branch 'develop' into dev/9965-order-status-change-spec
tpaksu 073e8f0
Temporarily change the reporter type on CI to see test running order
tpaksu 87bf755
Revert "Temporarily change the reporter type on CI to see test runnin…
tpaksu 6c6e9eb
Test the fix again
tpaksu 23bdb0a
Run restoreCurrencies without changing page after disabling all
tpaksu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: patch | ||
Type: dev | ||
|
||
Convert the merchant orders status change spec from Puppeteer to Playwright. |
177 changes: 177 additions & 0 deletions
177
tests/e2e-pw/specs/merchant/merchant-orders-status-change.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,177 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { test, expect, Page } from '@playwright/test'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { getMerchant, getShopper, isUIUnblocked } from '../../utils/helpers'; | ||
import { placeOrderWithOptions } from '../../utils/shopper'; | ||
import * as navigation from '../../utils/merchant-navigation'; | ||
|
||
const orderStatusDropdownSelector = 'select[name="order_status"]'; | ||
const cancelModalSelector = 'div.wcpay-confirmation-modal'; | ||
const refundModalSelector = 'div.refund-confirmation-modal'; | ||
const refundCancelSelector = | ||
'.refund-confirmation-modal .wcpay-confirmation-modal__footer .is-secondary'; | ||
const refundConfirmSelector = | ||
'.refund-confirmation-modal .wcpay-confirmation-modal__footer .is-primary'; | ||
const selectedOrderStatusSelector = '.wc-order-status > span'; | ||
const orderPriceSelector = | ||
'#woocommerce-order-items .total .woocommerce-Price-amount'; | ||
|
||
const saveOrder = async ( page: Page ) => { | ||
await page.locator( '.save_order' ).click(); | ||
await page.waitForLoadState( 'networkidle' ); | ||
}; | ||
|
||
const verifyOrderStatus = async ( page: Page, status: string ) => { | ||
const selectedOrderStatus = await page.$( selectedOrderStatusSelector ); | ||
await expect( | ||
selectedOrderStatus.evaluate( ( el ) => el.textContent ) | ||
).resolves.toBe( status ); | ||
}; | ||
|
||
test.describe( 'Order > Status Change', () => { | ||
let merchantPage: Page; | ||
let shopperPage: Page; | ||
let orderId: string; | ||
|
||
test.beforeAll( async ( { browser } ) => { | ||
merchantPage = ( await getMerchant( browser ) ).merchantPage; | ||
shopperPage = ( await getShopper( browser ) ).shopperPage; | ||
} ); | ||
|
||
test.describe( 'Change Status of order to Cancelled', () => { | ||
test.beforeAll( async () => { | ||
orderId = await placeOrderWithOptions( shopperPage ); | ||
await navigation.goToOrder( merchantPage, orderId ); | ||
} ); | ||
|
||
test( 'Show Cancel Confirmation modal, do not change status if Do Nothing selected', async () => { | ||
// Select cancel from the order status dropdown. | ||
await merchantPage.selectOption( | ||
orderStatusDropdownSelector, | ||
'Cancelled' | ||
); | ||
|
||
// Verify the confirmation modal shows. | ||
await merchantPage.waitForSelector( cancelModalSelector, { | ||
state: 'visible', | ||
} ); | ||
|
||
// Click on Do Nothing. | ||
await merchantPage | ||
.getByRole( 'button', { name: 'Do Nothing' } ) | ||
.click(); | ||
|
||
// Verify the order status is set to processing. | ||
await verifyOrderStatus( merchantPage, 'Processing' ); | ||
|
||
// Click on the update order button and wait for page reload. | ||
await saveOrder( merchantPage ); | ||
|
||
// Verify the order status is set to processing. | ||
await verifyOrderStatus( merchantPage, 'Processing' ); | ||
} ); | ||
|
||
test( 'When Order Status changed to Cancel, show Cancel Confirmation modal, change status to Cancel if confirmed', async () => { | ||
// Select cancel from the order status dropdown. | ||
await merchantPage.selectOption( | ||
orderStatusDropdownSelector, | ||
'Cancelled' | ||
); | ||
|
||
// Verify the confirmation modal shows. | ||
await merchantPage.waitForSelector( cancelModalSelector, { | ||
state: 'visible', | ||
} ); | ||
|
||
// Click on Cancel order. | ||
await merchantPage | ||
.getByRole( 'button', { name: 'Cancel order' } ) | ||
.click(); | ||
await merchantPage.waitForLoadState( 'networkidle' ); | ||
|
||
// Verify the order status is set to cancel. | ||
await verifyOrderStatus( merchantPage, 'Cancelled' ); | ||
|
||
// Click on the update order button and wait for page reload. | ||
await saveOrder( merchantPage ); | ||
|
||
// Verify the order status is set to cancelled. | ||
await verifyOrderStatus( merchantPage, 'Cancelled' ); | ||
} ); | ||
} ); | ||
|
||
test.describe( 'Change Status of order to Refunded', () => { | ||
test.beforeAll( async () => { | ||
orderId = await placeOrderWithOptions( shopperPage ); | ||
await navigation.goToOrder( merchantPage, orderId ); | ||
} ); | ||
|
||
test( 'Show Refund Confirmation modal, do not change status if Cancel clicked', async () => { | ||
// Select refunded from the order status dropdown. | ||
await merchantPage.selectOption( | ||
orderStatusDropdownSelector, | ||
'Refunded' | ||
); | ||
|
||
// Verify the confirmation modal shows. | ||
await merchantPage.waitForSelector( refundModalSelector, { | ||
state: 'visible', | ||
} ); | ||
|
||
// Click on Cancel. | ||
await merchantPage.locator( refundCancelSelector ).click(); | ||
|
||
// Verify the order status is set to processing. | ||
await verifyOrderStatus( merchantPage, 'Processing' ); | ||
|
||
// Click on the update order button and wait for page reload. | ||
await saveOrder( merchantPage ); | ||
|
||
// Verify the order status is set to processing. | ||
await verifyOrderStatus( merchantPage, 'Processing' ); | ||
} ); | ||
|
||
test( 'Show Refund Confirmation modal, process Refund if confirmed', async () => { | ||
// Select refunded from the order status dropdown. | ||
await merchantPage.selectOption( | ||
orderStatusDropdownSelector, | ||
'Refunded' | ||
); | ||
|
||
// Verify the confirmation modal shows. | ||
await merchantPage.waitForSelector( refundModalSelector, { | ||
state: 'visible', | ||
} ); | ||
|
||
// Click on Refund order. | ||
await merchantPage.locator( refundConfirmSelector ).click(); | ||
|
||
// Wait for refund to be processed | ||
await isUIUnblocked( merchantPage ); | ||
await merchantPage.waitForLoadState( 'networkidle' ); | ||
|
||
// Get the order price | ||
const priceElement = await merchantPage.$( orderPriceSelector ); | ||
const orderAmount = await merchantPage.evaluate( | ||
( el ) => el.textContent, | ||
priceElement | ||
); | ||
|
||
// Verify the refund amount is equal to the order amount. | ||
await expect( | ||
merchantPage.locator( '.refund > .line_cost' ) | ||
).toHaveText( `-${ orderAmount }` ); | ||
|
||
// Click on the update order button and wait for page reload. | ||
await saveOrder( merchantPage ); | ||
|
||
// Verify the order status is set to refunded. | ||
await verifyOrderStatus( merchantPage, 'Refunded' ); | ||
} ); | ||
} ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the doc for
waitForSelector
it says:Would we want to swap these out? The code would be a little more complex from what I see, but it may be a little more future proof, unless I am missing something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great call! I've updated the code to use locator.waitFor() instead on 70add24. Thanks for raising that!