Skip to content

Commit d27e917

Browse files
authored
test(e2e): migrate tests from mock.shop to hydrogen preview store (#3538)
Consolidates e2e test infrastructure by migrating all remaining tests to use the hydrogen preview store instead of mock.shop. Updates smoke and skeleton cart tests: - Updated product references to match available products - Updated page routes for hydrogen preview store - Updated nested line items test with valid variant IDs - Added exact matching to prevent ambiguous product name matches All 21 e2e tests passing (3 smoke + 18 skeleton cart tests).
1 parent c36d02f commit d27e917

File tree

4 files changed

+21
-20
lines changed

4 files changed

+21
-20
lines changed

e2e/specs/skeleton/cart.spec.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import {setTestStore, test, expect} from '../../fixtures';
22
import {CartUtil} from '../../fixtures/cart-utils';
33

4-
setTestStore('mockShop');
4+
setTestStore('hydrogenPreviewStorefront');
55

6-
const PRODUCT_NAME = "Women's T-shirt";
7-
const PRODUCT_HANDLE = 'women-t-shirt';
8-
const UNIT_PRICE = '$30.00';
9-
const TWO_ITEMS_PRICE = '$60.00';
6+
const PRODUCT_NAME = 'The Element';
7+
const PRODUCT_HANDLE = 'the-element';
8+
const UNIT_PRICE = '$749.95';
9+
const TWO_ITEMS_PRICE = '$1,499.90';
1010

1111
test.describe('Cart', () => {
1212
test.describe('Line Items', () => {
@@ -254,12 +254,12 @@ test.describe('Cart', () => {
254254
test('Supports nested line items', async ({page, request}) => {
255255
const cart = new CartUtil(page);
256256
const PARENT_PRODUCT = {
257-
title: 'Slides',
258-
variantId: 'gid://shopify/ProductVariant/43695710371862',
257+
title: 'The Element',
258+
variantId: 'gid://shopify/ProductVariant/43567673344056',
259259
};
260260
const CHILD_PRODUCT = {
261-
title: 'Sweatpants',
262-
variantId: 'gid://shopify/ProductVariant/43696926949398',
261+
title: 'The Elemental',
262+
variantId: 'gid://shopify/ProductVariant/43567673442360',
263263
};
264264

265265
const addedLines = await request
@@ -325,12 +325,13 @@ test.describe('Cart', () => {
325325
const lineItems = cart.getLineItems();
326326
const parentProductLink = lineItems
327327
.first()
328-
.getByRole('link', {name: PARENT_PRODUCT.title});
328+
.getByRole('link', {name: PARENT_PRODUCT.title, exact: true});
329329
const nestedList = lineItems.first().getByRole('list', {
330330
name: `Line items with ${PARENT_PRODUCT.title}`,
331331
});
332332
const childProductLink = nestedList.getByRole('link', {
333333
name: CHILD_PRODUCT.title,
334+
exact: true,
334335
});
335336

336337
await expect(parentProductLink).toBeVisible();

e2e/specs/smoke/cart.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import {setTestStore, test, CartUtil} from '../../fixtures';
22

3-
setTestStore('mockShop');
3+
setTestStore('hydrogenPreviewStorefront');
44

55
test.describe('Cart Functionality', () => {
66
test('When adding a product to cart, it should update the cart', async ({
77
page,
88
}) => {
99
const cart = new CartUtil(page);
10-
const productName = "Women's T-shirt";
11-
const productHandle = 'women-t-shirt';
10+
const productName = 'The Element';
11+
const productHandle = 'the-element';
1212

1313
await page.goto('/');
1414
await cart.assertTotalItems(0);
@@ -18,6 +18,6 @@ test.describe('Cart Functionality', () => {
1818

1919
await cart.assertTotalItems(1);
2020
await cart.assertInCart(productName);
21-
await cart.assertSubtotal('$30.00');
21+
await cart.assertSubtotal('$749.95');
2222
});
2323
});

e2e/specs/smoke/home.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {test, expect, setTestStore} from '../../fixtures';
22

3-
setTestStore('mockShop');
3+
setTestStore('hydrogenPreviewStorefront');
44

55
test.describe('Home Page', () => {
66
test('should display hero image, product grid, and no console errors', async ({
@@ -24,7 +24,7 @@ test.describe('Home Page', () => {
2424

2525
const productGridImage = page
2626
.getByRole('region', {name: 'Recommended Products'})
27-
.getByRole('link', {name: "Women's T-shirt"})
27+
.getByRole('link', {name: 'The Hydrogen Snowboard'})
2828
.getByRole('img');
2929

3030
await expect(heroImage).toBeVisible();

e2e/specs/smoke/pages.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import {test, expect, setTestStore} from '../../fixtures';
22

3-
setTestStore('mockShop');
3+
setTestStore('hydrogenPreviewStorefront');
44

55
test.describe('Pages', () => {
66
test('When visiting static pages, each should display its heading', async ({
77
page,
88
}) => {
99
const pages = [
10-
{url: '/pages/contact', heading: 'Contact'},
10+
{url: '/pages/about', heading: 'About'},
1111
{url: '/collections', heading: 'Collections'},
12-
{url: '/collections/men', heading: 'Men'},
13-
{url: '/blogs/news', heading: 'News'},
12+
{url: '/collections/all', heading: 'Products'},
13+
{url: '/blogs/journal', heading: 'Journal'},
1414
{url: '/search', heading: 'Search'},
1515
{url: '/cart', heading: 'Cart'},
1616
{url: '/policies', heading: 'Policies'},

0 commit comments

Comments
 (0)