From 9304b999a963b3deb4ea38061465a04051e10b7c Mon Sep 17 00:00:00 2001 From: simonmilord Date: Tue, 4 Feb 2025 15:50:18 -0500 Subject: [PATCH 1/3] added extra feedback modal interaction tests --- .../generated-answer-selectors.ts | 2 +- .../smart-snippet/smart-snippet-selectors.ts | 4 +- .../lwc/quanticFeedbackModal/success.html | 2 +- .../templates/success.html | 2 +- .../__tests__/quanticSmartSnippet.test.js | 16 ------ .../lwc/quanticSmartSnippet/e2e/pageObject.ts | 8 +++ .../e2e/quanticSmartSnippet.e2e.ts | 53 ++++++++++++++++++- 7 files changed, 66 insertions(+), 21 deletions(-) diff --git a/packages/quantic/cypress/e2e/default-2/generatedAnswer/generated-answer-selectors.ts b/packages/quantic/cypress/e2e/default-2/generatedAnswer/generated-answer-selectors.ts index adaa8ace2f5..3eb29973d23 100644 --- a/packages/quantic/cypress/e2e/default-2/generatedAnswer/generated-answer-selectors.ts +++ b/packages/quantic/cypress/e2e/default-2/generatedAnswer/generated-answer-selectors.ts @@ -90,7 +90,7 @@ export const GeneratedAnswerSelectors: GeneratedAnswerSelector = { ), feedbackDoneButton: () => GeneratedAnswerSelectors.feedbackModal().find( - '[data-cy="feedback-modal-footer__done"]' + '[data-testid="feedback-modal-footer__done"]' ), feedbackDocumentUrlInput: () => GeneratedAnswerSelectors.feedbackModal().find('input[name="documentUrl"]'), diff --git a/packages/quantic/cypress/e2e/default-2/smart-snippet/smart-snippet-selectors.ts b/packages/quantic/cypress/e2e/default-2/smart-snippet/smart-snippet-selectors.ts index de0cdccb8b6..dbf2a8ad713 100644 --- a/packages/quantic/cypress/e2e/default-2/smart-snippet/smart-snippet-selectors.ts +++ b/packages/quantic/cypress/e2e/default-2/smart-snippet/smart-snippet-selectors.ts @@ -71,7 +71,9 @@ export const SmartSnippetSelectors: SmartSnippetSelector = { .get('lightning-modal') .find('[data-testid="feedback-modal-footer__cancel"]'), feedbackDoneButton: () => - cy.get('lightning-modal').find('[data-cy="feedback-modal-footer__done"]'), + cy + .get('lightning-modal') + .find('[data-testid="feedback-modal-footer__done"]'), feedbackDetailsInput: () => cy .get('lightning-modal') diff --git a/packages/quantic/force-app/main/default/lwc/quanticFeedbackModal/success.html b/packages/quantic/force-app/main/default/lwc/quanticFeedbackModal/success.html index b348e2fda80..743251c5257 100644 --- a/packages/quantic/force-app/main/default/lwc/quanticFeedbackModal/success.html +++ b/packages/quantic/force-app/main/default/lwc/quanticFeedbackModal/success.html @@ -9,6 +9,6 @@ - + \ No newline at end of file diff --git a/packages/quantic/force-app/main/default/lwc/quanticFeedbackModalQna/templates/success.html b/packages/quantic/force-app/main/default/lwc/quanticFeedbackModalQna/templates/success.html index 213f9d8950b..94e4364814e 100644 --- a/packages/quantic/force-app/main/default/lwc/quanticFeedbackModalQna/templates/success.html +++ b/packages/quantic/force-app/main/default/lwc/quanticFeedbackModalQna/templates/success.html @@ -13,7 +13,7 @@ { }); }); }); - - describe('when interacting with the feedback modal', () => { - describe('when trying to open the feedback modal after executing the same query', () => { - // eslint-disable-next-line jest/no-disabled-tests, jest/expect-expect - it.skip('should not open the feedback modal', async () => { - // TODO: Implement this test - SFINT-5933 - }); - }); - - describe('when trying to open the feedback modal after executing a query that gave a new answer', () => { - // eslint-disable-next-line jest/no-disabled-tests, jest/expect-expect - it.skip('should open the feedback modal', async () => { - // TODO: Implement this test - SFINT-5933 - }); - }); - }); }); }); diff --git a/packages/quantic/force-app/main/default/lwc/quanticSmartSnippet/e2e/pageObject.ts b/packages/quantic/force-app/main/default/lwc/quanticSmartSnippet/e2e/pageObject.ts index e5fa7d65b13..a83a7718c48 100644 --- a/packages/quantic/force-app/main/default/lwc/quanticSmartSnippet/e2e/pageObject.ts +++ b/packages/quantic/force-app/main/default/lwc/quanticSmartSnippet/e2e/pageObject.ts @@ -45,6 +45,10 @@ export class SmartSnippetObject { return this.page.getByTestId('feedback-modal-footer__cancel'); } + get feedbackModalDoneButton(): Locator { + return this.page.getByTestId('feedback-modal-footer__done'); + } + get firstFeedbackOptionLabel(): Locator { const labelFirstOption = "Didn't answer my question at all"; return this.page.getByText(labelFirstOption); @@ -94,6 +98,10 @@ export class SmartSnippetObject { await this.feedbackSubmitButton.click(); } + async clickFeedbackModalDoneButton(): Promise { + await this.feedbackModalDoneButton.click(); + } + async waitForExpandSmartSnippetUaAnalytics(): Promise { return this.waitForSmartSnippetCustomUaAnalytics('expandSmartSnippet'); } diff --git a/packages/quantic/force-app/main/default/lwc/quanticSmartSnippet/e2e/quanticSmartSnippet.e2e.ts b/packages/quantic/force-app/main/default/lwc/quanticSmartSnippet/e2e/quanticSmartSnippet.e2e.ts index de883e283ff..3b810f3991f 100644 --- a/packages/quantic/force-app/main/default/lwc/quanticSmartSnippet/e2e/quanticSmartSnippet.e2e.ts +++ b/packages/quantic/force-app/main/default/lwc/quanticSmartSnippet/e2e/quanticSmartSnippet.e2e.ts @@ -1,5 +1,6 @@ -import {testSearch, testInsight} from './fixture'; +import {testSearch, testInsight, expect} from './fixture'; import {useCaseTestCases} from '../../../../../../playwright/utils/useCase'; +import smartSnippetData from './data'; const maximumSnippetHeight = 250; @@ -113,6 +114,56 @@ useCaseTestCases.forEach((useCase) => { }); }); }); + + test.describe('when trying to open the feedback modal after executing the same query', () => { + test('should not open the feedback modal', async ({ + smartSnippet, + search, + }) => { + await smartSnippet.clickDislikeButton(); + await smartSnippet.clickExplainWhyButton(); + await smartSnippet.selectFirstFeedbackOptionLabel(); + await smartSnippet.clickFeedbackSubmitButton(); + + await smartSnippet.clickFeedbackModalDoneButton(); + + const searchResponsePromise = search.waitForSearchResponse(); + await search.performSearch(); + await searchResponsePromise; + + expect(smartSnippet.dislikeButton).not.toBeNull(); + await smartSnippet.clickDislikeButton(); + + expect(smartSnippet.explainWhyButton).not.toBeVisible(); + }); + }); + + test.describe('when trying to open the feedback modal after executing a query that gave a new answer', () => { + test('should open the feedback modal', async ({ + smartSnippet, + search, + }) => { + await smartSnippet.clickDislikeButton(); + await smartSnippet.clickExplainWhyButton(); + await smartSnippet.selectFirstFeedbackOptionLabel(); + await smartSnippet.clickFeedbackSubmitButton(); + + await smartSnippet.clickFeedbackModalDoneButton(); + + await search.mockSearchWithSmartSnippetResponse({ + ...smartSnippetData, + question: 'new question', + answerSnippet: 'new answer', + }); + const searchResponsePromise = search.waitForSearchResponse(); + await search.performSearch(); + await searchResponsePromise; + + expect(smartSnippet.dislikeButton).not.toBeNull(); + await smartSnippet.clickDislikeButton(); + expect(smartSnippet.explainWhyButton).toBeVisible(); + }); + }); }); }); }); From f4c25b97cb81ad465e37d7745ebe950f72475c43 Mon Sep 17 00:00:00 2001 From: simonmilord Date: Tue, 4 Feb 2025 15:56:36 -0500 Subject: [PATCH 2/3] space --- .../lwc/quanticSmartSnippet/e2e/quanticSmartSnippet.e2e.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/quantic/force-app/main/default/lwc/quanticSmartSnippet/e2e/quanticSmartSnippet.e2e.ts b/packages/quantic/force-app/main/default/lwc/quanticSmartSnippet/e2e/quanticSmartSnippet.e2e.ts index 3b810f3991f..e74d8b3f0bc 100644 --- a/packages/quantic/force-app/main/default/lwc/quanticSmartSnippet/e2e/quanticSmartSnippet.e2e.ts +++ b/packages/quantic/force-app/main/default/lwc/quanticSmartSnippet/e2e/quanticSmartSnippet.e2e.ts @@ -116,7 +116,7 @@ useCaseTestCases.forEach((useCase) => { }); test.describe('when trying to open the feedback modal after executing the same query', () => { - test('should not open the feedback modal', async ({ + test('should not allow to open the feedback modal', async ({ smartSnippet, search, }) => { @@ -133,7 +133,6 @@ useCaseTestCases.forEach((useCase) => { expect(smartSnippet.dislikeButton).not.toBeNull(); await smartSnippet.clickDislikeButton(); - expect(smartSnippet.explainWhyButton).not.toBeVisible(); }); }); From 56b20eb6f5e007cfd48dcc3acf05eaba6e322dd0 Mon Sep 17 00:00:00 2001 From: simonmilord Date: Tue, 4 Feb 2025 15:59:05 -0500 Subject: [PATCH 3/3] updated test desc --- .../lwc/quanticSmartSnippet/e2e/quanticSmartSnippet.e2e.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/quantic/force-app/main/default/lwc/quanticSmartSnippet/e2e/quanticSmartSnippet.e2e.ts b/packages/quantic/force-app/main/default/lwc/quanticSmartSnippet/e2e/quanticSmartSnippet.e2e.ts index e74d8b3f0bc..2d84472f08b 100644 --- a/packages/quantic/force-app/main/default/lwc/quanticSmartSnippet/e2e/quanticSmartSnippet.e2e.ts +++ b/packages/quantic/force-app/main/default/lwc/quanticSmartSnippet/e2e/quanticSmartSnippet.e2e.ts @@ -138,7 +138,7 @@ useCaseTestCases.forEach((useCase) => { }); test.describe('when trying to open the feedback modal after executing a query that gave a new answer', () => { - test('should open the feedback modal', async ({ + test('should allow to open the feedback modal', async ({ smartSnippet, search, }) => {