-
Notifications
You must be signed in to change notification settings - Fork 40
chore(atomic): migrate atomic-insight-history-toggle to Lit #6849
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
alexprudhomme
merged 15 commits into
main
from
copilot/migrate-atomic-insight-component
Jan 14, 2026
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
dd15d6f
Initial plan
Copilot 07a22b1
feat(atomic): migrate atomic-insight-history-toggle component to Lit
Copilot d434389
test(atomic): add comprehensive unit tests for atomic-insight-historyβ¦
Copilot 646823b
docs: update migration status for atomic-insight-history-toggle
Copilot 8c59cd4
Merge branch 'main' into copilot/migrate-atomic-insight-component
alexprudhomme 7583905
Add generated files
developer-experience-bot[bot] e214247
Merge branch 'main' into copilot/migrate-atomic-insight-component
alexprudhomme 69e948f
done
alexprudhomme 633a2fb
Update atomic-insight-history-toggle.new.stories.tsx
alexprudhomme 56571d1
Merge branch 'main' into copilot/migrate-atomic-insight-component
alexprudhomme afad922
merge
alexprudhomme 75816e6
Update atomic-insight-history-toggle.e2e.ts
alexprudhomme bffaa47
Merge branch 'main' into copilot/migrate-atomic-insight-component
alexprudhomme da57a27
make it internal
alexprudhomme cf6a177
Add generated files
developer-experience-bot[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
1 change: 0 additions & 1 deletion
1
...c/src/components/insight/atomic-insight-history-toggle/atomic-insight-history-toggle.pcss
This file was deleted.
Oops, something went wrong.
138 changes: 138 additions & 0 deletions
138
...rc/components/insight/atomic-insight-history-toggle/atomic-insight-history-toggle.spec.ts
This file contains hidden or 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,138 @@ | ||
| import {html} from 'lit'; | ||
| import {describe, expect, it, vi} from 'vitest'; | ||
| import {page} from 'vitest/browser'; | ||
| import {fixture} from '@/vitest-utils/testing-helpers/fixture'; | ||
| import type {AtomicInsightHistoryToggle} from './atomic-insight-history-toggle'; | ||
| import './atomic-insight-history-toggle'; | ||
|
|
||
| describe('atomic-insight-history-toggle', () => { | ||
| let element: AtomicInsightHistoryToggle; | ||
|
|
||
| const renderComponent = async ({ | ||
| clickCallback = () => {}, | ||
| tooltip = '', | ||
| }: { | ||
| clickCallback?: () => void; | ||
| tooltip?: string; | ||
| } = {}) => { | ||
| element = await fixture<AtomicInsightHistoryToggle>( | ||
| html`<atomic-insight-history-toggle | ||
| .clickCallback=${clickCallback} | ||
| .tooltip=${tooltip} | ||
| ></atomic-insight-history-toggle>` | ||
| ); | ||
|
|
||
| await element.updateComplete; | ||
|
|
||
| return { | ||
| element, | ||
| button: page.getByRole('button'), | ||
| parts: { | ||
| container: element.shadowRoot?.querySelector( | ||
| '[part="insight-history-toggle-container"]' | ||
| ), | ||
| button: element.shadowRoot?.querySelector( | ||
| '[part="insight-history-toggle-button"]' | ||
| ), | ||
| icon: element.shadowRoot?.querySelector( | ||
| '[part="insight-history-toggle-icon"]' | ||
| ), | ||
| }, | ||
| }; | ||
| }; | ||
|
|
||
| describe('rendering', () => { | ||
| it('should render the history toggle button', async () => { | ||
| const {button} = await renderComponent(); | ||
| await expect.element(button).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('should render all shadow parts', async () => { | ||
| const {parts} = await renderComponent(); | ||
| expect(parts.container).toBeTruthy(); | ||
| expect(parts.button).toBeTruthy(); | ||
| expect(parts.icon).toBeTruthy(); | ||
| }); | ||
|
|
||
| it('should have aria-label set to "history"', async () => { | ||
| const {button} = await renderComponent(); | ||
| await expect.element(button).toHaveAttribute('aria-label', 'history'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('tooltip property', () => { | ||
| it('should have an empty title attribute when tooltip is empty', async () => { | ||
| const {button} = await renderComponent({tooltip: ''}); | ||
| await expect.element(button).toHaveAttribute('title', ''); | ||
| }); | ||
|
|
||
| it('should have a title attribute when tooltip is provided', async () => { | ||
| const {button} = await renderComponent({ | ||
| tooltip: 'View history', | ||
| }); | ||
| await expect.element(button).toHaveAttribute('title', 'View history'); | ||
| }); | ||
|
|
||
| it('should update title when tooltip changes', async () => { | ||
| const {element, button} = await renderComponent({ | ||
| tooltip: 'Initial tooltip', | ||
| }); | ||
|
|
||
| await expect.element(button).toHaveAttribute('title', 'Initial tooltip'); | ||
|
|
||
| element.tooltip = 'Updated tooltip'; | ||
| await element.updateComplete; | ||
|
|
||
| await expect.element(button).toHaveAttribute('title', 'Updated tooltip'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('clickCallback property', () => { | ||
| it('should call clickCallback when button is clicked', async () => { | ||
| const clickCallback = vi.fn(); | ||
| const {button} = await renderComponent({clickCallback}); | ||
|
|
||
| await button.click(); | ||
|
|
||
| expect(clickCallback).toHaveBeenCalledOnce(); | ||
| }); | ||
|
|
||
| it('should not throw error when clickCallback is not provided', async () => { | ||
| const {button} = await renderComponent(); | ||
|
|
||
| await expect(button.click()).resolves.not.toThrow(); | ||
| }); | ||
|
|
||
| it('should call updated clickCallback after property change', async () => { | ||
| const firstCallback = vi.fn(); | ||
| const secondCallback = vi.fn(); | ||
|
|
||
| const {element, button} = await renderComponent({ | ||
| clickCallback: firstCallback, | ||
| }); | ||
|
|
||
| await button.click(); | ||
| expect(firstCallback).toHaveBeenCalledOnce(); | ||
| expect(secondCallback).not.toHaveBeenCalled(); | ||
|
|
||
| element.clickCallback = secondCallback; | ||
| await element.updateComplete; | ||
|
|
||
| await button.click(); | ||
| expect(firstCallback).toHaveBeenCalledOnce(); | ||
| expect(secondCallback).toHaveBeenCalledOnce(); | ||
| }); | ||
| }); | ||
|
|
||
| describe('accessibility', () => { | ||
| it('should be keyboard accessible', async () => { | ||
| const {button} = await renderComponent(); | ||
| await expect.element(button).toBeEnabled(); | ||
| }); | ||
|
|
||
| it('should have appropriate role', async () => { | ||
| const {button} = await renderComponent(); | ||
| await expect.element(button).toHaveRole('button'); | ||
| }); | ||
| }); | ||
| }); | ||
46 changes: 46 additions & 0 deletions
46
...mic/src/components/insight/atomic-insight-history-toggle/atomic-insight-history-toggle.ts
This file contains hidden or 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,46 @@ | ||
| import {LitElement} from 'lit'; | ||
| import {customElement, property} from 'lit/decorators.js'; | ||
| import {renderIconButton} from '@/src/components/common/icon-button'; | ||
| import {withTailwindStyles} from '@/src/decorators/with-tailwind-styles'; | ||
| import Clockicon from '../../../images/clock.svg'; | ||
|
|
||
| /** | ||
| * The `atomic-insight-history-toggle` component displays a button that toggles the visibility of the User Actions history panel. | ||
| * This is useful for showing an agent the history of actions performed by the user who opened a support case within an insight interface. | ||
| * | ||
| * This is an internal component intended for use by Coveo developers only. | ||
| * | ||
| * @internal | ||
| */ | ||
| @customElement('atomic-insight-history-toggle') | ||
| @withTailwindStyles | ||
| export class AtomicInsightHistoryToggle extends LitElement { | ||
| /** | ||
| * The callback function to execute when the button is clicked. | ||
| */ | ||
| @property({type: Object}) public clickCallback: () => void = () => {}; | ||
|
|
||
| /** | ||
| * The tooltip text to display on the button. | ||
| */ | ||
| @property({type: String}) public tooltip = ''; | ||
|
|
||
| protected render() { | ||
| return renderIconButton({ | ||
| props: { | ||
| partPrefix: 'insight-history-toggle', | ||
| style: 'outline-neutral', | ||
| icon: Clockicon, | ||
| ariaLabel: 'history', | ||
| onClick: this.clickCallback, | ||
| title: this.tooltip, | ||
| }, | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| declare global { | ||
| interface HTMLElementTagNameMap { | ||
| 'atomic-insight-history-toggle': AtomicInsightHistoryToggle; | ||
| } | ||
| } |
30 changes: 0 additions & 30 deletions
30
...ic/src/components/insight/atomic-insight-history-toggle/atomic-insight-history-toggle.tsx
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.