Skip to content
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

test(quantic): Add tests for feedback modal edge cases in quanticSmartSnippet e2e tests #4939

Merged
merged 7 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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"]'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
</div>
</lightning-modal-body>
<lightning-modal-footer>
<lightning-button data-cy="feedback-modal-footer__done" variant="brand" label={labels.done} onclick={closeModal}></lightning-button>
<lightning-button data-testid="feedback-modal-footer__done" variant="brand" label={labels.done} onclick={closeModal}></lightning-button>
</lightning-modal-footer>
</template>
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</lightning-modal-body>
<lightning-modal-footer>
<lightning-button
data-cy="feedback-modal-footer__done"
data-testid="feedback-modal-footer__done"
variant="brand"
label={labels.done}
onclick={closeModal}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,21 +337,5 @@ describe('c-quantic-smart-snippet', () => {
});
});
});

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
});
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -94,6 +98,10 @@ export class SmartSnippetObject {
await this.feedbackSubmitButton.click();
}

async clickFeedbackModalDoneButton(): Promise<void> {
await this.feedbackModalDoneButton.click();
}

async waitForExpandSmartSnippetUaAnalytics(): Promise<Request> {
return this.waitForSmartSnippetCustomUaAnalytics('expandSmartSnippet');
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -113,6 +114,55 @@
});
});
});

test.describe('when trying to open the feedback modal after executing the same query', () => {
test('should not allow to 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();

Check failure on line 136 in packages/quantic/force-app/main/default/lwc/quanticSmartSnippet/e2e/quanticSmartSnippet.e2e.ts

View workflow job for this annotation

GitHub Actions / Run Quantic E2E tests / Run Playwright e2e tests on Quantic

[LWS-enabled] › force-app/main/default/lwc/quanticSmartSnippet/e2e/quanticSmartSnippet.e2e.ts:119:9 › quantic smart snippet in the search use case › feedback modal interactions › when trying to open the feedback modal after executing the same query › should not allow to open the feedback modal

6) [LWS-enabled] › force-app/main/default/lwc/quanticSmartSnippet/e2e/quanticSmartSnippet.e2e.ts:119:9 › quantic smart snippet in the search use case › feedback modal interactions › when trying to open the feedback modal after executing the same query › should not allow to open the feedback modal Error: expect(locator).not.toBeVisible() Locator: getByTestId('feedback__explain-why-button') Expected: not visible Received: visible Call log: - expect.not.toBeVisible with timeout 5000ms - waiting for getByTestId('feedback__explain-why-button') 134 | expect(smartSnippet.dislikeButton).not.toBeNull(); 135 | await smartSnippet.clickDislikeButton(); > 136 | expect(smartSnippet.explainWhyButton).not.toBeVisible(); | ^ 137 | }); 138 | }); 139 | at /home/runner/work/ui-kit/ui-kit/packages/quantic/force-app/main/default/lwc/quanticSmartSnippet/e2e/quanticSmartSnippet.e2e.ts:136:53

Check failure on line 136 in packages/quantic/force-app/main/default/lwc/quanticSmartSnippet/e2e/quanticSmartSnippet.e2e.ts

View workflow job for this annotation

GitHub Actions / Run Quantic E2E tests / Run Playwright e2e tests on Quantic

[LWS-enabled] › force-app/main/default/lwc/quanticSmartSnippet/e2e/quanticSmartSnippet.e2e.ts:119:9 › quantic smart snippet in the insight use case › feedback modal interactions › when trying to open the feedback modal after executing the same query › should not allow to open the feedback modal

8) [LWS-enabled] › force-app/main/default/lwc/quanticSmartSnippet/e2e/quanticSmartSnippet.e2e.ts:119:9 › quantic smart snippet in the insight use case › feedback modal interactions › when trying to open the feedback modal after executing the same query › should not allow to open the feedback modal Error: expect(locator).not.toBeVisible() Locator: getByTestId('feedback__explain-why-button') Expected: not visible Received: visible Call log: - expect.not.toBeVisible with timeout 5000ms - waiting for getByTestId('feedback__explain-why-button') 134 | expect(smartSnippet.dislikeButton).not.toBeNull(); 135 | await smartSnippet.clickDislikeButton(); > 136 | expect(smartSnippet.explainWhyButton).not.toBeVisible(); | ^ 137 | }); 138 | }); 139 | at /home/runner/work/ui-kit/ui-kit/packages/quantic/force-app/main/default/lwc/quanticSmartSnippet/e2e/quanticSmartSnippet.e2e.ts:136:53
SimonMilord marked this conversation as resolved.
Show resolved Hide resolved
});
});

test.describe('when trying to open the feedback modal after executing a query that gave a new answer', () => {
test('should allow to 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();

Check failure on line 163 in packages/quantic/force-app/main/default/lwc/quanticSmartSnippet/e2e/quanticSmartSnippet.e2e.ts

View workflow job for this annotation

GitHub Actions / Run Quantic E2E tests / Run Playwright e2e tests on Quantic

[LWS-enabled] › force-app/main/default/lwc/quanticSmartSnippet/e2e/quanticSmartSnippet.e2e.ts:141:9 › quantic smart snippet in the search use case › feedback modal interactions › when trying to open the feedback modal after executing a query that gave a new answer › should allow to open the feedback modal

7) [LWS-enabled] › force-app/main/default/lwc/quanticSmartSnippet/e2e/quanticSmartSnippet.e2e.ts:141:9 › quantic smart snippet in the search use case › feedback modal interactions › when trying to open the feedback modal after executing a query that gave a new answer › should allow to open the feedback modal Error: expect(locator).toBeVisible() Locator: getByTestId('feedback__explain-why-button') Expected: visible Received: undefined Call log: - expect.toBeVisible with timeout 5000ms - waiting for getByTestId('feedback__explain-why-button') 161 | expect(smartSnippet.dislikeButton).not.toBeNull(); 162 | await smartSnippet.clickDislikeButton(); > 163 | expect(smartSnippet.explainWhyButton).toBeVisible(); | ^ 164 | }); 165 | }); 166 | }); at /home/runner/work/ui-kit/ui-kit/packages/quantic/force-app/main/default/lwc/quanticSmartSnippet/e2e/quanticSmartSnippet.e2e.ts:163:49

Check failure on line 163 in packages/quantic/force-app/main/default/lwc/quanticSmartSnippet/e2e/quanticSmartSnippet.e2e.ts

View workflow job for this annotation

GitHub Actions / Run Quantic E2E tests / Run Playwright e2e tests on Quantic

[LWS-enabled] › force-app/main/default/lwc/quanticSmartSnippet/e2e/quanticSmartSnippet.e2e.ts:141:9 › quantic smart snippet in the insight use case › feedback modal interactions › when trying to open the feedback modal after executing a query that gave a new answer › should allow to open the feedback modal

9) [LWS-enabled] › force-app/main/default/lwc/quanticSmartSnippet/e2e/quanticSmartSnippet.e2e.ts:141:9 › quantic smart snippet in the insight use case › feedback modal interactions › when trying to open the feedback modal after executing a query that gave a new answer › should allow to open the feedback modal Error: expect(locator).toBeVisible() Locator: getByTestId('feedback__explain-why-button') Expected: visible Received: undefined Call log: - expect.toBeVisible with timeout 5000ms - waiting for getByTestId('feedback__explain-why-button') 161 | expect(smartSnippet.dislikeButton).not.toBeNull(); 162 | await smartSnippet.clickDislikeButton(); > 163 | expect(smartSnippet.explainWhyButton).toBeVisible(); | ^ 164 | }); 165 | }); 166 | }); at /home/runner/work/ui-kit/ui-kit/packages/quantic/force-app/main/default/lwc/quanticSmartSnippet/e2e/quanticSmartSnippet.e2e.ts:163:49
});
});
});
});
});
Loading