-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(atomic): field sort should be applied when selected
- Loading branch information
1 parent
49bec88
commit 602802c
Showing
5 changed files
with
101 additions
and
1 deletion.
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
58 changes: 58 additions & 0 deletions
58
packages/atomic/src/components/search/atomic-sort-dropdown/e2e/atomic-sort-dropdown.e2e.ts
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,58 @@ | ||
import {expect, test} from './fixture'; | ||
|
||
test.describe('default', () => { | ||
test.beforeEach(async ({sortDropdown}) => { | ||
await sortDropdown.load(); | ||
}); | ||
|
||
test.describe('when selecting a field sort criterion', async () => { | ||
test.beforeEach(async ({sortDropdown}) => { | ||
await sortDropdown.dropdown.selectOption('sncost ascending'); | ||
}); | ||
|
||
test('should properly reflect the selected sort criteria into the URL', async ({ | ||
page, | ||
}) => { | ||
expect(page.url()).toContain('sortCriteria=%40sncost%20ascending'); | ||
}); | ||
}); | ||
|
||
test.describe('when selecting a composite field sort criterion', async () => { | ||
test.beforeEach(async ({sortDropdown}) => { | ||
await sortDropdown.dropdown.selectOption( | ||
'sncost ascending, date descending' | ||
); | ||
}); | ||
|
||
test('should properly reflect the selected sort criteria into the URL', async ({ | ||
page, | ||
}) => { | ||
expect(page.url()).toContain( | ||
// eslint-disable-next-line @cspell/spellchecker | ||
'sortCriteria=%40sncost%20ascending%2Cdate%20descending' | ||
); | ||
}); | ||
}); | ||
|
||
test.describe('when selecting a relevance sort criterion', async () => { | ||
test.beforeEach(async ({sortDropdown}) => { | ||
await sortDropdown.dropdown.selectOption('relevancy'); | ||
}); | ||
|
||
test('should not reflect any sortCriteria in the URL', async ({page}) => { | ||
expect(page.url()).not.toContain('sortCriteria='); | ||
}); | ||
}); | ||
|
||
test.describe('when selecting a date sort criterion', async () => { | ||
test.beforeEach(async ({sortDropdown}) => { | ||
await sortDropdown.dropdown.selectOption('date descending'); | ||
}); | ||
|
||
test('should properly reflect the selected sort criteria into the URL', async ({ | ||
page, | ||
}) => { | ||
expect(page.url()).toContain('sortCriteria=date%20descending'); | ||
}); | ||
}); | ||
}); |
19 changes: 19 additions & 0 deletions
19
packages/atomic/src/components/search/atomic-sort-dropdown/e2e/fixture.ts
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,19 @@ | ||
import {test as base} from '@playwright/test'; | ||
import { | ||
AxeFixture, | ||
makeAxeBuilder, | ||
} from '../../../../../playwright-utils/base-fixture'; | ||
import {AtomicSortDropdownPageObject} from './page-object'; | ||
|
||
type MyFixture = { | ||
sortDropdown: AtomicSortDropdownPageObject; | ||
}; | ||
|
||
export const test = base.extend<MyFixture & AxeFixture>({ | ||
makeAxeBuilder, | ||
sortDropdown: async ({page}, use) => { | ||
await use(new AtomicSortDropdownPageObject(page)); | ||
}, | ||
}); | ||
|
||
export {expect} from '@playwright/test'; |
12 changes: 12 additions & 0 deletions
12
packages/atomic/src/components/search/atomic-sort-dropdown/e2e/page-object.ts
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,12 @@ | ||
import type {Page} from '@playwright/test'; | ||
import {BasePageObject} from '../../../../../playwright-utils/base-page-object'; | ||
|
||
export class AtomicSortDropdownPageObject extends BasePageObject<'atomic-sort-dropdown'> { | ||
constructor(page: Page) { | ||
super(page, 'atomic-sort-dropdown'); | ||
} | ||
|
||
get dropdown() { | ||
return this.page.getByLabel('Sort by'); | ||
} | ||
} |