-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): Add tests for shipping estimatesg
- Loading branch information
1 parent
6a6af43
commit 629d17b
Showing
4 changed files
with
85 additions
and
4 deletions.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Page } from '@playwright/test'; | ||
|
||
export async function addEstimatedShippingCosts( | ||
page: Page, | ||
country: string, | ||
state: string, | ||
city: string, | ||
zip: string, | ||
): Promise<void> { | ||
await page.getByRole('combobox', { name: 'Country' }).click(); | ||
await page.getByLabel(country).click(); | ||
|
||
await page | ||
.getByRole('combobox', { name: 'State' }) | ||
.filter({ hasNotText: 'Select state' }) | ||
.click(); | ||
await page.getByLabel(state).click(); | ||
|
||
await page.getByLabel('City').fill(city); | ||
await page.getByLabel('Postcode').fill(zip); | ||
|
||
await page.getByRole('button', { name: 'Estimate shipping' }).click(); | ||
await page.getByRole('button', { name: 'Update shipping costs' }).click(); | ||
} | ||
|
||
export * as CartActions from './cart-actions'; |
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,47 @@ | ||
import { expect, test } from '@playwright/test'; | ||
|
||
import { CartActions } from '../../../../actions/cart-actions'; | ||
import { ProductActions } from '../../../../actions/product-actions'; | ||
|
||
const sampleProduct = '[Sample] Able Brewing System'; | ||
|
||
test.beforeEach(async ({ page }) => { | ||
await page.goto('/'); | ||
await page.getByLabel('Main').getByRole('link', { name: 'Kitchen' }).click(); | ||
await expect(page.getByRole('heading', { level: 3, name: sampleProduct })).toBeVisible(); | ||
|
||
await ProductActions.addProductToCart(page, sampleProduct); | ||
|
||
await page.getByRole('link', { name: 'Cart Items 1' }).click(); | ||
|
||
await expect(page.getByRole('heading', { level: 1, name: 'Your cart' })).toBeVisible(); | ||
await expect(page.getByText(sampleProduct, { exact: true })).toBeVisible(); | ||
}); | ||
|
||
test('Add shipping estimates', async ({ page }) => { | ||
await expect(page.getByText('Shipping cost')).toBeVisible(); | ||
await page.getByRole('button', { name: 'Add' }).first().click(); | ||
|
||
await CartActions.addEstimatedShippingCosts(page, 'United States', 'Texas', 'Austin', '76267'); | ||
await expect(page.getByRole('button', { name: 'Change' })).toBeVisible(); | ||
}); | ||
|
||
test('Update shipping estimates', async ({ page }) => { | ||
await expect(page.getByText('Shipping cost')).toBeVisible(); | ||
await page.getByRole('button', { name: 'Add' }).first().click(); | ||
|
||
await CartActions.addEstimatedShippingCosts(page, 'United States', 'Texas', 'Austin', '76267'); | ||
|
||
await expect(page.getByRole('button', { name: 'Change' })).toBeVisible(); | ||
await page.getByRole('button', { name: 'Change' }).click(); | ||
|
||
await CartActions.addEstimatedShippingCosts( | ||
page, | ||
'Canada', | ||
'British Columbia', | ||
'Vancouver', | ||
'98607', | ||
); | ||
|
||
await expect(page.getByRole('button', { name: 'Change' })).toBeVisible(); | ||
}); |