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

Explicitly clear out customers before testing #45229

Merged
merged 1 commit into from Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 10 additions & 10 deletions .github/workflows/smoke-test-pr-merge.yml
Expand Up @@ -11,7 +11,7 @@ permissions: {}
jobs:
api:
name: Run API tests
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
if: (github.event.pull_request.merged == true) && (github.event.pull_request.base.ref == 'trunk')
permissions:
contents: read
Expand All @@ -21,15 +21,15 @@ jobs:
ARTIFACT_NAME: api-pr-merge-${{ github.event.pull_request.number }}-run-${{ github.run_number }}
steps:
- name: Checkout merge commit on trunk
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.merge_commit_sha }}

- name: Setup WooCommerce Monorepo
uses: ./.github/actions/setup-woocommerce-monorepo
with:
install: '@woocommerce/plugin-woocommerce...'
build: '@woocommerce/plugin-woocommerce'
install: '@woocommerce/plugin-woocommerce...'
build: '@woocommerce/plugin-woocommerce'

- name: Setup local test environment
uses: ./.github/actions/tests/setup-local-test-environment
Expand Down Expand Up @@ -75,23 +75,23 @@ jobs:
e2e:
name: Run E2E tests
needs: [api]
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
permissions:
contents: read
env:
ALLURE_RESULTS_DIR: ${{ github.workspace }}/plugins/woocommerce/tests/e2e-pw/test-results/allure-results
ALLURE_REPORT_DIR: ${{ github.workspace }}/plugins/woocommerce/tests/e2e-pw/test-results/allure-report
ARTIFACT_NAME: e2e-pr-merge-${{ github.event.pull_request.number }}-run-${{ github.run_number }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.merge_commit_sha }}

- name: Setup WooCommerce Monorepo
uses: ./.github/actions/setup-woocommerce-monorepo
with:
install: '@woocommerce/plugin-woocommerce...'
build: '@woocommerce/plugin-woocommerce'
install: '@woocommerce/plugin-woocommerce...'
build: '@woocommerce/plugin-woocommerce'

- name: Setup local test environment
uses: ./.github/actions/tests/setup-local-test-environment
Expand Down Expand Up @@ -141,11 +141,11 @@ jobs:
k6:
name: Runs k6 Performance tests
if: (github.event.pull_request.user.login != 'github-actions[bot]') && (github.event.pull_request.merged == true) && (github.event.pull_request.base.ref == 'trunk')
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup WooCommerce Monorepo
uses: ./.github/actions/setup-woocommerce-monorepo
Expand Down
4 changes: 4 additions & 0 deletions plugins/woocommerce/changelog/fix-customer-test-pr-merge
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Fix the customer list e2e test for PR merge workflow
Expand Up @@ -78,6 +78,16 @@
},
} );

test.beforeAll( async ( { api } ) => {
let oldCustomers = {};
await api.get( 'customers' ).then( ( response ) => {
oldCustomers = response.data;
} );
await api.post( `customers/batch`, {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will it create an api error if oldCustomers is empty?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, I tested it locally on my machine where there are no customers and no error is thrown. So it works either way.

delete: oldCustomers.map( ( customer ) => customer.id ),
} );
} );

test.beforeEach( async ( { context } ) => {
// prevents the column picker from saving state between tests
await context.route( '**/users/**', ( route ) => route.abort() );
Expand All @@ -89,7 +99,7 @@
);
await expect(
page.getByRole( 'cell', { name: 'No data to display' } )
).toBeVisible();

Check failure on line 102 in plugins/woocommerce/tests/e2e-pw/tests/merchant/customer-list.spec.js

View workflow job for this annotation

GitHub Actions / Run E2E tests

[Chrome] › merchant/customer-list.spec.js:96:2 › Merchant > Customer List › Merchant can view an empty customer list

1) [Chrome] › merchant/customer-list.spec.js:96:2 › Merchant > Customer List › Merchant can view an empty customer list Error: Timed out 20000ms waiting for expect(locator).toBeVisible() Locator: getByRole('cell', { name: 'No data to display' }) Expected: visible Received: hidden Call log: - expect.toBeVisible with timeout 20000ms - waiting for getByRole('cell', { name: 'No data to display' }) 100 | await expect( 101 | page.getByRole( 'cell', { name: 'No data to display' } ) > 102 | ).toBeVisible(); | ^ 103 | await expect( 104 | page.getByText( '0customers0Average orders$0.' ) 105 | ).toBeVisible(); at /home/runner/work/woocommerce/woocommerce/plugins/woocommerce/tests/e2e-pw/tests/merchant/customer-list.spec.js:102:5

Check failure on line 102 in plugins/woocommerce/tests/e2e-pw/tests/merchant/customer-list.spec.js

View workflow job for this annotation

GitHub Actions / Run E2E tests

[Chrome] › merchant/customer-list.spec.js:96:2 › Merchant > Customer List › Merchant can view an empty customer list

1) [Chrome] › merchant/customer-list.spec.js:96:2 › Merchant > Customer List › Merchant can view an empty customer list Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: Timed out 20000ms waiting for expect(locator).toBeVisible() Locator: getByRole('cell', { name: 'No data to display' }) Expected: visible Received: hidden Call log: - expect.toBeVisible with timeout 20000ms - waiting for getByRole('cell', { name: 'No data to display' }) 100 | await expect( 101 | page.getByRole( 'cell', { name: 'No data to display' } ) > 102 | ).toBeVisible(); | ^ 103 | await expect( 104 | page.getByText( '0customers0Average orders$0.' ) 105 | ).toBeVisible(); at /home/runner/work/woocommerce/woocommerce/plugins/woocommerce/tests/e2e-pw/tests/merchant/customer-list.spec.js:102:5

Check failure on line 102 in plugins/woocommerce/tests/e2e-pw/tests/merchant/customer-list.spec.js

View workflow job for this annotation

GitHub Actions / Run E2E tests

[Chrome] › merchant/customer-list.spec.js:96:2 › Merchant > Customer List › Merchant can view an empty customer list

1) [Chrome] › merchant/customer-list.spec.js:96:2 › Merchant > Customer List › Merchant can view an empty customer list Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── Error: Timed out 20000ms waiting for expect(locator).toBeVisible() Locator: getByRole('cell', { name: 'No data to display' }) Expected: visible Received: hidden Call log: - expect.toBeVisible with timeout 20000ms - waiting for getByRole('cell', { name: 'No data to display' }) 100 | await expect( 101 | page.getByRole( 'cell', { name: 'No data to display' } ) > 102 | ).toBeVisible(); | ^ 103 | await expect( 104 | page.getByText( '0customers0Average orders$0.' ) 105 | ).toBeVisible(); at /home/runner/work/woocommerce/woocommerce/plugins/woocommerce/tests/e2e-pw/tests/merchant/customer-list.spec.js:102:5
await expect(
page.getByText( '0customers0Average orders$0.' )
).toBeVisible();
Expand All @@ -106,7 +116,7 @@
await test.step( 'Check that 3 customers are displayed', async () => {
await expect(
page.getByText( '3customers0Average orders$0.' )
).toBeVisible();

Check failure on line 119 in plugins/woocommerce/tests/e2e-pw/tests/merchant/customer-list.spec.js

View workflow job for this annotation

GitHub Actions / Run E2E tests

[Chrome] › merchant/customer-list.spec.js:108:2 › Merchant > Customer List › Merchant can view a list of all customers

2) [Chrome] › merchant/customer-list.spec.js:108:2 › Merchant > Customer List › Merchant can view a list of all customers, filter and download › Check that 3 customers are displayed Error: Timed out 20000ms waiting for expect(locator).toBeVisible() Locator: getByText('3customers0Average orders$0.') Expected: visible Received: hidden Call log: - expect.toBeVisible with timeout 20000ms - waiting for getByText('3customers0Average orders$0.') 117 | await expect( 118 | page.getByText( '3customers0Average orders$0.' ) > 119 | ).toBeVisible(); | ^ 120 | } ); 121 | 122 | await test.step( 'Check that the customers are displayed in the list', async () => { at /home/runner/work/woocommerce/woocommerce/plugins/woocommerce/tests/e2e-pw/tests/merchant/customer-list.spec.js:119:6 at /home/runner/work/woocommerce/woocommerce/plugins/woocommerce/tests/e2e-pw/tests/merchant/customer-list.spec.js:116:14

Check failure on line 119 in plugins/woocommerce/tests/e2e-pw/tests/merchant/customer-list.spec.js

View workflow job for this annotation

GitHub Actions / Run E2E tests

[Chrome] › merchant/customer-list.spec.js:108:2 › Merchant > Customer List › Merchant can view a list of all customers

2) [Chrome] › merchant/customer-list.spec.js:108:2 › Merchant > Customer List › Merchant can view a list of all customers, filter and download › Check that 3 customers are displayed Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: Timed out 20000ms waiting for expect(locator).toBeVisible() Locator: getByText('3customers0Average orders$0.') Expected: visible Received: hidden Call log: - expect.toBeVisible with timeout 20000ms - waiting for getByText('3customers0Average orders$0.') 117 | await expect( 118 | page.getByText( '3customers0Average orders$0.' ) > 119 | ).toBeVisible(); | ^ 120 | } ); 121 | 122 | await test.step( 'Check that the customers are displayed in the list', async () => { at /home/runner/work/woocommerce/woocommerce/plugins/woocommerce/tests/e2e-pw/tests/merchant/customer-list.spec.js:119:6 at /home/runner/work/woocommerce/woocommerce/plugins/woocommerce/tests/e2e-pw/tests/merchant/customer-list.spec.js:116:14

Check failure on line 119 in plugins/woocommerce/tests/e2e-pw/tests/merchant/customer-list.spec.js

View workflow job for this annotation

GitHub Actions / Run E2E tests

[Chrome] › merchant/customer-list.spec.js:108:2 › Merchant > Customer List › Merchant can view a list of all customers

2) [Chrome] › merchant/customer-list.spec.js:108:2 › Merchant > Customer List › Merchant can view a list of all customers, filter and download › Check that 3 customers are displayed Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── Error: Timed out 20000ms waiting for expect(locator).toBeVisible() Locator: getByText('3customers0Average orders$0.') Expected: visible Received: hidden Call log: - expect.toBeVisible with timeout 20000ms - waiting for getByText('3customers0Average orders$0.') 117 | await expect( 118 | page.getByText( '3customers0Average orders$0.' ) > 119 | ).toBeVisible(); | ^ 120 | } ); 121 | 122 | await test.step( 'Check that the customers are displayed in the list', async () => { at /home/runner/work/woocommerce/woocommerce/plugins/woocommerce/tests/e2e-pw/tests/merchant/customer-list.spec.js:119:6 at /home/runner/work/woocommerce/woocommerce/plugins/woocommerce/tests/e2e-pw/tests/merchant/customer-list.spec.js:116:14
} );

await test.step( 'Check that the customers are displayed in the list', async () => {
Expand Down