Skip to content

Commit c80b2f6

Browse files
committed
Fix search tests
1 parent 6f08502 commit c80b2f6

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

e2e/specs/skeleton/collections.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ test.describe('Collections', () => {
2424
test('displays the sort dropdown on collection pages', async ({page}) => {
2525
await page.goto(COLLECTION_URL);
2626

27-
const sortSelect = page.getByLabel('Sort by:');
27+
const sortSelect = page.getByRole('combobox', {name: 'Sort by:'});
2828
await expect(sortSelect).toBeVisible();
2929
});
3030

@@ -33,7 +33,7 @@ test.describe('Collections', () => {
3333
}) => {
3434
await page.goto(COLLECTION_URL);
3535

36-
const sortSelect = page.getByLabel('Sort by:');
36+
const sortSelect = page.getByRole('combobox', {name: 'Sort by:'});
3737
await sortSelect.selectOption('PRICE_LOW_TO_HIGH');
3838

3939
await expect(page).toHaveURL(/sort_by=PRICE_LOW_TO_HIGH/);
@@ -44,7 +44,7 @@ test.describe('Collections', () => {
4444
}) => {
4545
await page.goto(`${COLLECTION_URL}?sort_by=PRICE_LOW_TO_HIGH`);
4646

47-
const sortSelect = page.getByLabel('Sort by:');
47+
const sortSelect = page.getByRole('combobox', {name: 'Sort by:'});
4848
await expect(sortSelect).toHaveValue('PRICE_LOW_TO_HIGH');
4949

5050
await sortSelect.selectOption('FEATURED');
@@ -55,7 +55,7 @@ test.describe('Collections', () => {
5555
test('preserves sort selection after page reload', async ({page}) => {
5656
await page.goto(`${COLLECTION_URL}?sort_by=PRICE_HIGH_TO_LOW`);
5757

58-
const sortSelect = page.getByLabel('Sort by:');
58+
const sortSelect = page.getByRole('combobox', {name: 'Sort by:'});
5959
await expect(sortSelect).toHaveValue('PRICE_HIGH_TO_LOW');
6060

6161
await page.reload();
@@ -153,7 +153,7 @@ test.describe('Collections', () => {
153153
await expect(page).toHaveURL(/filter\./);
154154

155155
// Change sort
156-
const sortSelect = page.getByLabel('Sort by:');
156+
const sortSelect = page.getByRole('combobox', {name: 'Sort by:'});
157157
await sortSelect.selectOption('PRICE_LOW_TO_HIGH');
158158

159159
// Both should be in the URL

e2e/specs/skeleton/search.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,21 @@ test.describe('Search', () => {
4141
test('displays sort dropdown when results exist', async ({page}) => {
4242
await page.goto(`/search?q=${SEARCH_TERM}`);
4343

44-
const sortSelect = page.getByLabel('Sort by:');
44+
const sortSelect = page.getByRole('combobox', {name: 'Sort by:'});
4545
await expect(sortSelect).toBeVisible();
4646
});
4747

4848
test('does not display sort dropdown with no results', async ({page}) => {
4949
await page.goto('/search?q=xyznonexistentproduct123');
5050

51-
const sortSelect = page.getByLabel('Sort by:');
51+
const sortSelect = page.getByRole('combobox', {name: 'Sort by:'});
5252
await expect(sortSelect).not.toBeVisible();
5353
});
5454

5555
test('changes sort order and updates URL', async ({page}) => {
5656
await page.goto(`/search?q=${SEARCH_TERM}`);
5757

58-
const sortSelect = page.getByLabel('Sort by:');
58+
const sortSelect = page.getByRole('combobox', {name: 'Sort by:'});
5959
await sortSelect.selectOption('PRICE_LOW_TO_HIGH');
6060

6161
// Wait for navigation to complete after sort change
@@ -111,8 +111,8 @@ test.describe('Search', () => {
111111

112112
test.describe('Article Search Results', () => {
113113
test('article links include blog handle in URL', async ({page}) => {
114-
// Search for a term that returns articles in the preview store
115-
await page.goto('/search?q=journal');
114+
// Use the same broad search term that returns products AND articles
115+
await page.goto(`/search?q=${SEARCH_TERM}`);
116116

117117
// The preview store (hydrogen.shop) has articles — assert they appear
118118
await expect(

0 commit comments

Comments
 (0)