Skip to content

Commit

Permalink
test(core): add order details test
Browse files Browse the repository at this point in the history
  • Loading branch information
bc-alexsaiannyi authored and chanceaclark committed Dec 9, 2024
1 parent addf5ce commit 12b3723
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
4 changes: 2 additions & 2 deletions core/tests/fixtures/utils/order/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ export class OrderFactory {

constructor(private readonly page: Page) {}

async create(customerId: number, productId: number) {
const orderData = await createOrder(customerId, productId);
async create(productId: number, customerId: number) {
const orderData = await createOrder(productId, customerId);

const order = new Order(
this.page,
Expand Down
20 changes: 20 additions & 0 deletions core/tests/ui/e2e/order-details.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { expect, test } from '~/tests/fixtures';

test('Order contains all necessary info and sections on Order Details page', async ({ page, account, order }) => {
const customer = await account.create();

await customer.login();

const orderDetails = await order.create(98, customer.id);

await page.goto('/account/orders/');
await expect(page.getByRole('link', { name: `Order # ${orderDetails.id}` })).toBeVisible();

await page.getByRole('link', { name: 'View Details' }).click();
await page.waitForURL(`/account/order/${orderDetails.id}/`);

await expect(page.getByRole('heading', { name: `Order #${orderDetails.id}` })).toBeVisible();
await expect(page.getByText('Order contents')).toBeVisible();
await expect(page.getByText('Order Summary')).toBeVisible();
await expect(page.getByText('Shipping', { exact: true })).toBeVisible();
});
4 changes: 2 additions & 2 deletions core/tests/ui/e2e/order.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ test('Order details are visible on Orders page', async ({ page, account, order }

await customer.login();

const orderDetails = await order.create(94, customer.id);
const orderDetails = await order.create(98, customer.id);

await page.goto('/account/orders/');

Expand All @@ -44,5 +44,5 @@ test('Order details are visible on Orders page', async ({ page, account, order }
await expect(page.getByText('Total')).toBeVisible();
await expect(page.getByText(formattedTotal).first()).toBeVisible();
await expect(page.getByText(orderDetails.status)).toBeVisible();
await expect(page.getByRole('link', { name: '[Sample] Oak Cheese Grater' })).toBeVisible();
await expect(page.getByRole('link', { name: '[Sample] Laundry Detergent' })).toBeVisible();
});

0 comments on commit 12b3723

Please sign in to comment.