Skip to content

Commit

Permalink
test(quantic): e2e tests adapted to new rga feedback modal (#4202)
Browse files Browse the repository at this point in the history
## [SFINT-5608](https://coveord.atlassian.net/browse/SFINT-5608)

- Adapted tests to the latest analytics schema when submitting rga
feedback.
- Adapted the e2e to the new rga feedback modal by supporting the new
questions and testing the validity of the feedback form.
- These tests are still skipped because of the flakiness of the
lightning modal but now, if we run them, they pass not like before where
they were only expected to work with the previous feedback modal.


https://github.com/user-attachments/assets/c6c3f101-49e5-40ed-9978-244d15c97c87



[SFINT-5608]:
https://coveord.atlassian.net/browse/SFINT-5608?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
  • Loading branch information
mmitiche authored Jul 22, 2024
1 parent f2363fa commit 8230b9a
Show file tree
Hide file tree
Showing 7 changed files with 198 additions and 162 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@ function generatedAnswerActions(selector: GeneratedAnswerSelector) {
'When clicking on the toggle button of the generated answer'
),

clickFeedbackOption: (index: number) =>
clickFeedbackOption: (value: string, index: number) =>
selector
.feedbackOption(index)
.feedbackOption(value, index)
.click({force: true})
.logAction(`When clicking the feedback option at the index ${index}`),
.logAction(
`When clicking the feedback option ${value} at the question at index ${index}`
),

clickFeedbackSubmitButton: () =>
selector
Expand All @@ -67,6 +69,12 @@ function generatedAnswerActions(selector: GeneratedAnswerSelector) {
.click()
.logAction('When clicking on the feedback modal done button'),

typeInFeedbackDocumentUrlInput: (text: string) =>
selector
.feedbackDocumentUrlInput()
.type(text)
.logAction('When typing in the feedback document url input'),

typeInFeedbackDetailsInput: (text: string) =>
selector
.feedbackDetailsInput()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ function generatedAnswerExpectations(selector: GeneratedAnswerSelector) {
.log(`${should(display)} display the copy to clipboard button`);
},

displaySuccessMessage: (display: boolean) => {
selector
.successMessage()
.should(display ? 'exist' : 'not.exist')
.log(`${should(display)} display the success message`);
},

likeButtonIsChecked: (selected: boolean) => {
selector
.likeButton()
Expand Down Expand Up @@ -521,14 +528,28 @@ function generatedAnswerExpectations(selector: GeneratedAnswerSelector) {
logGeneratedAnswerFeedbackSubmit(
streamId: string,
payload: {
reason: string;
correctTopicValue: string;
documented: string;
hallucinationFree: string;
helpful: boolean;
readable: string;
documentUrl?: string;
details?: string;
}
) {
logGeneratedAnswerEvent(
InterceptAliases.UA.GeneratedAnswer.GeneratedAnswerFeedbackSubmit,
InterceptAliases.UA.GeneratedAnswer.GeneratedAnswerFeedbackSubmitV2,
(analyticsBody: {customData: object; eventType: string}) => {
const customData = analyticsBody?.customData;
const {
helpful,
correctTopicValue,
documented,
hallucinationFree,
readable,
documentUrl,
details,
} = payload;
expect(analyticsBody).to.have.property(
'eventType',
'generatedAnswer'
Expand All @@ -537,9 +558,23 @@ function generatedAnswerExpectations(selector: GeneratedAnswerSelector) {
'generativeQuestionAnsweringId',
streamId
);
expect(customData).to.have.property('reason', payload.reason);
if (payload.details) {
expect(customData).to.have.property('details', payload.details);
expect(customData).to.have.property('helpful', helpful);
expect(customData).to.have.property(
'correctTopicValue',
correctTopicValue
);
expect(customData).to.have.property('documented', documented);
expect(customData).to.have.property(
'hallucinationFree',
hallucinationFree
);
expect(customData).to.have.property('readable', readable);

if (documentUrl) {
expect(customData).to.have.property('documentUrl', documentUrl);
}
if (details) {
expect(customData).to.have.property('details', details);
}
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ export interface GeneratedAnswerSelector extends ComponentSelector {
generatedAnswerContent: () => CypressSelector;
generatedAnswerContentContainer: () => CypressSelector;
feedbackModal: () => CypressSelector;
feedbackOption: (index: number) => CypressSelector;
feedbackSubmitButton: () => CypressSelector;
feedbackCancelButton: () => CypressSelector;
feedbackDoneButton: () => CypressSelector;
feedbackDocumentUrlInput: () => CypressSelector;
feedbackDetailsInput: () => CypressSelector;
rephraseButtons: () => CypressSelector;
rephraseLabel: () => CypressSelector;
Expand All @@ -33,6 +33,8 @@ export interface GeneratedAnswerSelector extends ComponentSelector {
disclaimer: () => CypressSelector;
toggleCollapseButton: () => CypressSelector;
generatingMessage: () => CypressSelector;
feedbackOption: (value: string, index: number) => CypressSelector;
successMessage: () => CypressSelector;
}

export const GeneratedAnswerSelectors: GeneratedAnswerSelector = {
Expand Down Expand Up @@ -83,18 +85,24 @@ export const GeneratedAnswerSelectors: GeneratedAnswerSelector = {
'[data-cy="generated-answer__content-container"]'
),
feedbackModal: () => cy.get('lightning-modal'),
feedbackOption: (index: number) =>
cy.get('lightning-modal').find('lightning-radio-group input').eq(index),
feedbackSubmitButton: () =>
cy.get('lightning-modal').find('[data-cy="feedback-modal-footer__submit"]'),
GeneratedAnswerSelectors.feedbackModal().find(
'[data-cy="feedback-modal-qna-footer__submit"]'
),
feedbackCancelButton: () =>
cy.get('lightning-modal').find('[data-cy="feedback-modal-footer__cancel"]'),
GeneratedAnswerSelectors.feedbackModal().find(
'[data-cy="feedback-modal-footer__cancel"]'
),
feedbackDoneButton: () =>
cy.get('lightning-modal').find('[data-cy="feedback-modal-footer__done"]'),
GeneratedAnswerSelectors.feedbackModal().find(
'[data-cy="feedback-modal-footer__done"]'
),
feedbackDocumentUrlInput: () =>
GeneratedAnswerSelectors.feedbackModal().find('input[name="documentUrl"]'),
feedbackDetailsInput: () =>
cy
.get('lightning-modal')
.find('[data-cy="feedback-modal-body__details-input"] textarea'),
GeneratedAnswerSelectors.feedbackModal().find(
'[data-name="details"] textarea'
),
rephraseButtons: () =>
GeneratedAnswerSelectors.get().find(
'[data-cy="generated-answer__rephrase-buttons"]'
Expand Down Expand Up @@ -150,4 +158,12 @@ export const GeneratedAnswerSelectors: GeneratedAnswerSelector = {
GeneratedAnswerSelectors.get().find(
'div.generated-answer__collapse-generating-message'
),
feedbackOption: (value: string, index: number) =>
GeneratedAnswerSelectors.feedbackModal()
.find(`.feedback-modal-qna__question input[value=${value}]`)
.eq(index),
successMessage: () =>
GeneratedAnswerSelectors.feedbackModal().find(
'[data-cy="feedback-modal-body__success-message"]'
),
};
Loading

0 comments on commit 8230b9a

Please sign in to comment.