Skip to content

Commit

Permalink
test(quantic): added playwright tests and unit test for quantic gener…
Browse files Browse the repository at this point in the history
…ated answer component (#4803)

## [SFINT-5789](https://coveord.atlassian.net/browse/SFINT-5789)

- Playwright E2E tests added for the Quantic Generated Answer component.
- Jest unit tests added for the Quantic Generated Answer component.

## Unit tests:

<img width="800" alt="Screenshot 2024-12-19 at 3 14 07 PM"
src="https://github.com/user-attachments/assets/732acd1d-3d68-48d7-9cb5-67e8f5f3269b"
/>


## E2E tests

<img width="800" alt="Screenshot 2024-12-19 at 3 21 04 PM"
src="https://github.com/user-attachments/assets/1207d32d-05c4-4572-96b3-1398e1ea6301"
/>


[SFINT-5789]:
https://coveord.atlassian.net/browse/SFINT-5789?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

---------

Co-authored-by: erocheleau <erocheleau@coveo.com>
  • Loading branch information
mmitiche and erocheleau authored Dec 31, 2024
1 parent 425a5fa commit 99ed76a
Show file tree
Hide file tree
Showing 12 changed files with 1,200 additions and 48 deletions.
2 changes: 1 addition & 1 deletion packages/quantic/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ npm run e2e:detailed
To run Playwright tests, run:

```bash
npm run e2e:playwright:
npm run e2e:playwright
```

To run Playwright tests only for the scratch org where LWS is enabled, run:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ export const GeneratedAnswerSelectors: GeneratedAnswerSelector = {
get: () => cy.get(generatedAnswerComponent),

generatedAnswerCard: () =>
GeneratedAnswerSelectors.get().find('[data-cy="generated-answer__card"]'),
GeneratedAnswerSelectors.get().find(
'[data-testid="generated-answer__card"]'
),
generatedAnswer: () =>
GeneratedAnswerSelectors.get().find('[data-cy="generated-answer__answer"]'),
likeButton: () =>
Expand All @@ -49,23 +51,23 @@ export const GeneratedAnswerSelectors: GeneratedAnswerSelector = {
),
citations: () =>
GeneratedAnswerSelectors.get().find(
'[data-cy="generated-answer__citations"]'
'[data-testid="generated-answer__citations"]'
),
citationTitle: (index: number) =>
GeneratedAnswerSelectors.get()
.find('[data-cy="generated-answer__citations"] .citation__title')
.find('[data-testid="generated-answer__citations"] .citation__title')
.eq(index),
citationLink: (index: number) =>
GeneratedAnswerSelectors.get()
.find('[data-cy="generated-answer__citations"] .citation__link')
.find('[data-testid="generated-answer__citations"] .citation__link')
.eq(index),
retryButton: () =>
GeneratedAnswerSelectors.get().find(
'[data-cy="generated-answer__retry-button"]'
'[data-testid="generated-answer__retry-button"]'
),
toggleGeneratedAnswerButton: () =>
GeneratedAnswerSelectors.get().find(
'c-quantic-generated-answer-toggle [data-cy="generated-answer__toggle-button"]'
'c-quantic-generated-answer-toggle [data-testid="generated-answer__toggle-button"]'
),
generatedAnswerContent: () =>
GeneratedAnswerSelectors.get().find(
Expand Down Expand Up @@ -96,38 +98,38 @@ export const GeneratedAnswerSelectors: GeneratedAnswerSelector = {
),
copyToClipboardButton: () =>
GeneratedAnswerSelectors.get().find(
'[data-cy="generated-answer__copy-to-clipboard"]'
'[data-testid="generated-answer__copy-to-clipboard"]'
),
citationTooltip: (index: number) =>
GeneratedAnswerSelectors.get()
.find('[data-cy="generated-answer__citations"] [data-cy="tooltip"]')
.find('[data-testid="generated-answer__citations"] [data-cy="tooltip"]')
.eq(index),
citationTooltipUri: (index: number) =>
GeneratedAnswerSelectors.get()
.find(
'[data-cy="generated-answer__citations"] [data-cy="citation__tooltip-uri"]'
'[data-testid="generated-answer__citations"] [data-cy="citation__tooltip-uri"]'
)
.eq(index),
citationTooltipTitle: (index: number) =>
GeneratedAnswerSelectors.get()
.find(
'[data-cy="generated-answer__citations"] [data-cy="citation__tooltip-title"]'
'[data-testid="generated-answer__citations"] [data-cy="citation__tooltip-title"]'
)
.eq(index),

citationTooltipText: (index: number) =>
GeneratedAnswerSelectors.get()
.find(
'[data-cy="generated-answer__citations"] [data-cy="citation__tooltip-text"]'
'[data-testid="generated-answer__citations"] [data-cy="citation__tooltip-text"]'
)
.eq(index),
disclaimer: () =>
GeneratedAnswerSelectors.get().find(
'[data-cy="generated-answer__disclaimer"]'
'[data-testid="generated-answer__disclaimer"]'
),
toggleCollapseButton: () =>
GeneratedAnswerSelectors.get().find(
'[data-cy="generated-answer__answer-toggle"]'
'[data-testid="generated-answer__answer-toggle"]'
),
generatingMessage: () =>
GeneratedAnswerSelectors.get().find(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<div
class="slds-grid slds-grid_align-spread slds-grid_vertical-align-start slds-var-p-bottom_x-small feedback-modal-qna__question"
key={question.id}
data-testid={question.id}
>
<div class="slds-col slds-var-p-top_x-small">
{question.question}
Expand Down
Loading

0 comments on commit 99ed76a

Please sign in to comment.