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

[e2e] Can Edit and Delete Product Review #44411

Merged
merged 16 commits into from Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
22f8df1
Update product-review
alvarothomas Feb 6, 2024
be58b7f
Add changefile(s) from automation for the following project(s): wooco…
invalid-email-address Feb 6, 2024
173aec4
Add changefile(s) from automation for the following project(s): wooco…
invalid-email-address Feb 6, 2024
286c760
Added test data in fixture and changelog extra line
alvarothomas Feb 8, 2024
f606075
Add changefile(s) from automation for the following project(s): wooco…
invalid-email-address Feb 8, 2024
fa62328
Update changelog
alvarothomas Feb 8, 2024
1c57730
Merge branch 'e2e-can-edit-product-review' of https://github.com/wooc…
alvarothomas Feb 8, 2024
bd40fca
Add changefile(s) from automation for the following project(s): wooco…
invalid-email-address Feb 8, 2024
fcc99df
Update plugins/woocommerce/tests/e2e-pw/tests/merchant/product-review…
alvarothomas Feb 8, 2024
4777ab2
Update plugins/woocommerce/tests/e2e-pw/tests/merchant/product-review…
alvarothomas Feb 8, 2024
898ba1c
Update plugins/woocommerce/tests/e2e-pw/tests/merchant/product-review…
alvarothomas Feb 8, 2024
02cff69
Update plugins/woocommerce/tests/e2e-pw/tests/merchant/product-review…
alvarothomas Feb 8, 2024
d2df92c
Update plugins/woocommerce/tests/e2e-pw/tests/merchant/product-review…
alvarothomas Feb 8, 2024
6d65ad9
Update plugins/woocommerce/tests/e2e-pw/tests/merchant/product-review…
alvarothomas Feb 8, 2024
ee8cd22
Update plugins/woocommerce/tests/e2e-pw/tests/merchant/product-review…
alvarothomas Feb 8, 2024
83067ef
Added Review Edit test
alvarothomas Feb 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1,4 @@
Significance: patch
Type: dev

Add e2e tests to edit and delete product reviews.
adimoldovan marked this conversation as resolved.
Show resolved Hide resolved
Expand Up @@ -5,7 +5,9 @@ const timestamp = Date.now().toString();
const productName = `Review me ${ timestamp }`;
const productReview = `Nice one, Playwright! ${ timestamp }`;
const randomRating = ( Math.random() * ( 5 - 1 ) + 1 ).toFixed( 0 );
const reviewerName = 'John Doe';
const reviewerEmail = `john.doe.${ timestamp }@example.com`;
const updatedReview = `(edited ${ timestamp })`;

test.describe( 'Products > Reviews', () => {
test.use( { storageState: process.env.ADMINSTATE } );
Expand All @@ -31,7 +33,7 @@ test.describe( 'Products > Reviews', () => {
await api.post( 'products/reviews', {
product_id: productId,
review: productReview,
reviewer: 'John Doe',
reviewer: reviewerName,
reviewer_email: reviewerEmail,
rating: randomRating,
} );
Expand Down Expand Up @@ -60,4 +62,66 @@ test.describe( 'Products > Reviews', () => {
page.getByRole( 'link', { name: reviewerEmail } )
).toBeVisible();
} );

test( 'can edit product review', async ( { page } ) => {
await page.goto(
`wp-admin/edit.php?post_type=product&page=product-reviews`
);
await expect(
page.getByRole( 'cell', { name: productReview } )
).toBeVisible();

//Hover over the product review to have 'Edit' displayed
await page.hover( '.comment-text' );
alvarothomas marked this conversation as resolved.
Show resolved Hide resolved

// Select Quick Edit, edit the review and save
await page.getByRole( 'button', { name: 'Quick Edit' } ).click();
alvarothomas marked this conversation as resolved.
Show resolved Hide resolved
await page.locator( '.wp-editor-area' ).first().fill( updatedReview ); //updatedReview
await page.getByRole( 'button', { name: 'Update Comment' } ).click();
await page.waitForTimeout( 2000 );
adimoldovan marked this conversation as resolved.
Show resolved Hide resolved

// Verify that the edited comment is there
const commentTextElement = page.locator( '.comment-text' );
await commentTextElement.waitFor( { state: 'visible' } );
const updatedComment = await commentTextElement.innerText(); //updatedComment
await expect( updatedComment ).toBe( updatedReview ); //updatedComment updatedReview
} );

test( 'can delete product review', async ( { page } ) => {
await page.goto(
`wp-admin/edit.php?post_type=product&page=product-reviews`
);
await expect(
page.getByRole( 'cell', { name: updatedReview } )
).toBeVisible();

//Hover over the product review to have 'Edit' displayed
await page.hover( '.comment-text' );
alvarothomas marked this conversation as resolved.
Show resolved Hide resolved

// Select Trash action, check confirmation prompt and undo
await page.getByRole( 'button', { name: 'Trash' } ).click();
alvarothomas marked this conversation as resolved.
Show resolved Hide resolved
await page.waitForTimeout( 2000 );
adimoldovan marked this conversation as resolved.
Show resolved Hide resolved
await expect(
page.getByText( `Comment by ${ reviewerName } moved to the Trash` )
).toBeVisible();
await page.getByRole( 'button', { name: 'Undo' } ).click();

// Verify that the review has been restored
await expect(
page.getByRole( 'cell', { name: updatedReview } )
).toBeVisible();

// Select Trash action and delete it permanently
await page.getByRole( 'button', { name: 'Trash' } ).click();
alvarothomas marked this conversation as resolved.
Show resolved Hide resolved
await page.waitForTimeout( 2000 );
adimoldovan marked this conversation as resolved.
Show resolved Hide resolved
await expect(
page.getByText( `Comment by ${ reviewerName } moved to the Trash` )
).toBeVisible();
await page.reload();
await page.waitForSelector( 'tr.no-items' );

// Assert that the message is present, indicating an empty comment list
const noReviewsFound = await page.$( 'tr.no-items' );
expect( noReviewsFound ).not.toBeNull();
adimoldovan marked this conversation as resolved.
Show resolved Hide resolved
} );
} );