Skip to content

Commit

Permalink
test(core): fix playwright tests (#1622)
Browse files Browse the repository at this point in the history
  • Loading branch information
chanceaclark authored Nov 11, 2024
1 parent d60e916 commit aa78e9b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
9 changes: 8 additions & 1 deletion core/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,14 @@ export default defineConfig({
projects: [
{
name: 'tests-chromium',
use: { ...devices['Desktop Chrome'] },
use: {
...devices['Desktop Chrome'],
launchOptions: {
// When redirected to checkout, BigCommerce blocks preflight requests from a HeadlessChrome user agent.
// We need to disable web security to allow the preflight request to go through.
args: ['--disable-web-security'],
},
},
},
],
});
2 changes: 1 addition & 1 deletion core/tests/ui/e2e/cart.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect, Page, test } from '~/tests/fixtures';
import { expect, test } from '~/tests/fixtures';

const sampleProduct = '[Sample] Able Brewing System';

Expand Down
11 changes: 8 additions & 3 deletions core/tests/ui/e2e/checkout.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ test.describe('desktop', () => {
).toBeVisible();
});

test('Complete checkout as a logged in shopper', async ({ page, isMobile, account }) => {
test('Complete checkout as a logged in shopper', async ({ page, account }) => {
const customer = await account.create();

await customer.login();
Expand All @@ -97,17 +97,22 @@ test.describe('desktop', () => {
await page.getByRole('heading', { level: 1, name: 'Your cart' }).click();
await page.getByRole('button', { name: 'Proceed to checkout' }).click();

await waitForShippingForm(page, isMobile);
await page.waitForRequest('**/internalapi/v1/store/countries');
await page
.locator('.checkout-step--shipping .checkout-view-content[aria-busy="false"]')
.waitFor();

await page.getByText(customer.email).isVisible();

await page.getByRole('button', { name: 'Continue' }).click();
await page.getByRole('heading', { name: 'Payment', exact: true }).waitFor();

await enterCreditCardDetails(page);

await page.getByRole('button', { name: 'Place Order' }).click();
await page.waitForLoadState('networkidle');
await expect(
page.getByRole('heading', { name: `Thank you ${firstName}!`, level: 1 }),
page.getByRole('heading', { name: `Thank you ${customer.firstName}!`, level: 1 }),
).toBeVisible();
});
});
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit aa78e9b

Please sign in to comment.