Skip to content

Commit

Permalink
Merge branch 'master' into KIT-2379
Browse files Browse the repository at this point in the history
  • Loading branch information
alexprudhomme authored Sep 17, 2024
2 parents 6895e10 + 799751a commit 0c1c996
Show file tree
Hide file tree
Showing 20 changed files with 21 additions and 641 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,6 @@ function generatedAnswerActions(selector: GeneratedAnswerSelector) {
.type(text)
.logAction('When typing in the feedback details input'),

clickRephraseButton: (name: string) =>
selector
.rephraseButtonByLabel(name)
.click({force: true})
.logAction(`When clicking on the ${name} rephrase button`),

hoverOverCitation: (index: number) =>
selector
.citationLink(index)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,20 +110,6 @@ function generatedAnswerExpectations(selector: GeneratedAnswerSelector) {
);
},

generatedAnswerFooterRowsIsOnMultiline: (multilineDisplay: boolean) => {
selector
.generatedAnswerFooterRow()
.should(
multilineDisplay ? 'have.class' : 'not.have.class',
'slds-grid_vertical'
)
.log(
`the generated answer footer rows ${should(
multilineDisplay
)} be displayed on multiple lines with slds-grid_vertical`
);
},

generatedAnswerCollapsed: (collapsible: boolean) => {
selector
.generatedAnswer()
Expand Down Expand Up @@ -212,6 +198,20 @@ function generatedAnswerExpectations(selector: GeneratedAnswerSelector) {
);
},

displayFeedbackModal: (display: boolean) => {
selector
.feedbackModal()
.should(display ? 'exist' : 'not.exist')
.log(`${should(display)} display the feedback modal`);
},

displayDisclaimer: (display: boolean) => {
selector
.disclaimer()
.should(display ? 'exist' : 'not.exist')
.log(`${should(display)} display the disclaimer`);
},

sessionStorageContains: (key: string, expectedData: object) => {
cy.getAllSessionStorage()
.then((sessionStorage) => {
Expand All @@ -232,62 +232,13 @@ function generatedAnswerExpectations(selector: GeneratedAnswerSelector) {
);
},

displayFeedbackModal: (display: boolean) => {
selector
.feedbackModal()
.should(display ? 'exist' : 'not.exist')
.log(`${should(display)} display the feedback modal`);
},

displayRephraseButtons: (display: boolean) => {
selector
.rephraseButtons()
.should(display ? 'exist' : 'not.exist')
.log(`${should(display)} display the rephrase buttons`);
},

displayRephraseLabel: (display: boolean) => {
selector
.rephraseLabel()
.should(display ? 'exist' : 'not.exist')
.log(`${should(display)} display the rephrase label`);
},

displayRephraseButtonWithLabel: (label: string) => {
selector
.rephraseButtonByLabel(label)
.should('exist')
.log(`should display the rephrase button with the label ${label}`);
},

displayDisclaimer: (display: boolean) => {
selector
.disclaimer()
.should(display ? 'exist' : 'not.exist')
.log(`${should(display)} display the disclaimer`);
},

disclaimerContains: (text: string) => {
selector
.disclaimer()
.contains(text)
.log(`the disclaimer should contain "${text}"`);
},

rephraseButtonIsSelected: (name: string, selected: boolean) => {
selector
.rephraseButtonByLabel(name)
.should(
selected ? 'have.class' : 'not.have.class',
'radio-button--selected'
)
.should(
selected ? 'not.have.class' : 'have.class',
'radio-button--unselected'
)
.log(`the ${name} rephrase button ${should(selected)} be selected`);
},

citationTooltipIsDisplayed: (index: number, displayed: boolean) => {
selector
.citationTooltip(index)
Expand Down Expand Up @@ -335,38 +286,6 @@ function generatedAnswerExpectations(selector: GeneratedAnswerSelector) {
);
},

searchQueryContainsCorrectRephraseOption: (
expectedAnswerStyle: string,
expectedActionCause: string,
expectedContentFormat?: string[]
) => {
cy.get<Interception>(InterceptAliases.Search)
.then((interception) => {
const body = interception?.request?.body;
const answerStyle =
body?.pipelineRuleParameters?.mlGenerativeQuestionAnswering
?.responseFormat?.answerStyle;
const contentFormat =
body?.pipelineRuleParameters?.mlGenerativeQuestionAnswering
?.responseFormat?.contentFormat;
const analyticsSection = body.analytics;

expect(answerStyle).to.eq(expectedAnswerStyle);
expect(analyticsSection).to.exist;
expect(analyticsSection).to.have.property(
'actionCause',
expectedActionCause
);
if (expectedContentFormat) {
expect(contentFormat).to.exist;
expect(contentFormat).to.deep.equal(expectedContentFormat);
}
})
.log(
`the search query should contain the correct ${expectedAnswerStyle} parameter`
);
},

searchQueryContainsCorrectFieldsToIncludeInCitations: (
expectedFields: string[]
) => {
Expand Down Expand Up @@ -603,23 +522,6 @@ function generatedAnswerExpectations(selector: GeneratedAnswerSelector) {
);
},

logRephraseGeneratedAnswer(expectedAnswerStyle: string, streamId: string) {
logGeneratedAnswerEvent(
InterceptAliases.UA.GeneratedAnswer.RephraseGeneratedAnswer,
(analyticsBody: {customData: object; eventType: string}) => {
const customData = analyticsBody?.customData;
expect(customData).to.have.property(
'generativeQuestionAnsweringId',
streamId
);
expect(customData).to.have.property(
'rephraseFormat',
expectedAnswerStyle
);
}
);
},

logCopyGeneratedAnswer(streamId: string) {
logGeneratedAnswerEvent(
InterceptAliases.UA.GeneratedAnswer.GeneratedAnswerCopyToClipboard,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export interface GeneratedAnswerSelector extends ComponentSelector {
dislikeButton: () => CypressSelector;
citations: () => CypressSelector;
citationTitle: (index: number) => CypressSelector;
citationIndex: (index: number) => CypressSelector;
citationLink: (index: number) => CypressSelector;
retryButton: () => CypressSelector;
toggleGeneratedAnswerButton: () => CypressSelector;
Expand All @@ -21,10 +20,6 @@ export interface GeneratedAnswerSelector extends ComponentSelector {
feedbackDoneButton: () => CypressSelector;
feedbackDocumentUrlInput: () => CypressSelector;
feedbackDetailsInput: () => CypressSelector;
rephraseButtons: () => CypressSelector;
rephraseLabel: () => CypressSelector;
rephraseButtonByLabel: (label: string) => CypressSelector;
generatedAnswerFooterRow: () => CypressSelector;
copyToClipboardButton: () => CypressSelector;
citationTooltip: (index: number) => CypressSelector;
citationTooltipUri: (index: number) => CypressSelector;
Expand Down Expand Up @@ -99,22 +94,6 @@ export const GeneratedAnswerSelectors: GeneratedAnswerSelector = {
GeneratedAnswerSelectors.feedbackModal().find(
'[data-name="details"] textarea'
),
rephraseButtons: () =>
GeneratedAnswerSelectors.get().find(
'[data-cy="generated-answer__rephrase-buttons"]'
),
rephraseLabel: () =>
GeneratedAnswerSelectors.get().find(
'legend[data-cy="radio-buttons-group__legend"]'
),
rephraseButtonByLabel: (label: string) =>
GeneratedAnswerSelectors.get().find(
`c-quantic-radio-buttons-group [data-cy="${label}"]`
),
generatedAnswerFooterRow: () =>
GeneratedAnswerSelectors.get().find(
'[data-cy="generated-answer__footer-row"]'
),
copyToClipboardButton: () =>
GeneratedAnswerSelectors.get().find(
'[data-cy="generated-answer__copy-to-clipboard"]'
Expand Down
Loading

0 comments on commit 0c1c996

Please sign in to comment.