-
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): dim unselected facet value (#4410)
Make sure to know which facet value link is selected. (applies only to rating facets) when no facet value is selected <img width="395" alt="image" src="https://github.com/user-attachments/assets/84b23df3-1e87-480a-8fee-242203ed2823"> When a facet value is selected <img width="395" alt="image" src="https://github.com/user-attachments/assets/00819f8c-b152-4023-b494-d24dab292346"> https://coveord.atlassian.net/browse/KIT-3472
- Loading branch information
Showing
5 changed files
with
93 additions
and
0 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
33 changes: 33 additions & 0 deletions
33
...es/atomic/src/components/search/facets/atomic-rating-facet/e2e/atomic-rating-facet.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,33 @@ | ||
import {test, expect} from './fixture'; | ||
|
||
test.describe('with facet values as link', () => { | ||
test.beforeEach(async ({facet}) => { | ||
await facet.load({story: 'display-as-link'}); | ||
}); | ||
|
||
test.describe('when no value is selected', () => { | ||
test('should not dim any facet values', async ({facet}) => { | ||
const facetValues = await facet.facetValues.all(); | ||
for (let i = 0; i < facetValues.length; i++) { | ||
await expect(facetValues[i]).toHaveCSS('opacity', '1'); | ||
} | ||
}); | ||
}); | ||
|
||
test.describe('when selecting a value', () => { | ||
test.beforeEach(async ({facet}) => { | ||
await facet.getFacetValueButtonByPosition(0).click(); | ||
}); | ||
|
||
test('should dim unselected facet values', async ({facet}) => { | ||
const facetValues = await facet.facetValues.all(); | ||
for (let i = 1; i < facetValues.length; i++) { | ||
await expect(facetValues[i]).toHaveCSS('opacity', '1'); | ||
} | ||
}); | ||
|
||
test('should not dim selected facet', async ({facet}) => { | ||
await expect(facet.facetValues.nth(0)).toHaveCSS('opacity', '1'); | ||
}); | ||
}); | ||
}); |
19 changes: 19 additions & 0 deletions
19
packages/atomic/src/components/search/facets/atomic-rating-facet/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 {AtomicRatingFacetPageObject as Facet} from './page-object'; | ||
|
||
type MyFixture = { | ||
facet: Facet; | ||
}; | ||
|
||
export const test = base.extend<MyFixture & AxeFixture>({ | ||
makeAxeBuilder, | ||
facet: async ({page}, use) => { | ||
await use(new Facet(page)); | ||
}, | ||
}); | ||
|
||
export {expect} from '@playwright/test'; |
29 changes: 29 additions & 0 deletions
29
packages/atomic/src/components/search/facets/atomic-rating-facet/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,29 @@ | ||
import type {Page} from '@playwright/test'; | ||
import {BasePageObject} from '../../../../../../playwright-utils/base-page-object'; | ||
|
||
export class AtomicRatingFacetPageObject extends BasePageObject<'atomic-rating-facet'> { | ||
constructor(page: Page) { | ||
super(page, 'atomic-rating-facet'); | ||
} | ||
|
||
getFacetValueByPosition(valuePosition: number) { | ||
return this.facetValues.nth(valuePosition); | ||
} | ||
|
||
getFacetValueButtonByPosition(valuePosition: number) { | ||
const value = this.getFacetValueByPosition(valuePosition); | ||
return value.locator('button'); | ||
} | ||
|
||
get clearFilter() { | ||
return this.page.getByRole('button').filter({hasText: /Clear.*filter/}); | ||
} | ||
|
||
get getSelectedFacetValueLink() { | ||
return this.page.locator('[part="value-link value-link-selected"]'); | ||
} | ||
|
||
get facetValues() { | ||
return this.page.getByRole('listitem'); | ||
} | ||
} |