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): SFINT-5832 Sort E2E tests migrate from Cypress to Playwright #4777

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

lvu285
Copy link
Contributor

@lvu285 lvu285 commented Dec 6, 2024

https://coveord.atlassian.net/browse/SFINT-5832

IN THIS PR:

  • Added Playwright E2E tests for the quantic-sort component

UNIT TESTS:

  • No need, as UTs already there

E2E PLAYWRIGHT TESTS:

  • Playwright for Sort component

@lvu285 lvu285 requested a review from a team as a code owner December 6, 2024 21:51
Copy link

github-actions bot commented Dec 6, 2024

Pull Request Report

PR Title

❌ Title should follow the conventional commit spec:
<type>(optional scope): <description>

Example: feat(headless): add result-list controller

Live demo links

Bundle Size

File Old (kb) New (kb) Change (%)
case-assist 244 244 0
commerce 355.3 355.3 0
search 415.2 415.2 0
insight 406.4 406.4 0
recommendation 256.2 256.2 0
ssr 409 409 0
ssr-commerce 373 373 0

SSR Progress

Use case SSR (#) CSR (#) Progress (%)
search 39 44 89
recommendation 0 4 0
case-assist 0 6 0
insight 0 27 0
commerce 0 15 0
Detailed logs search : buildInteractiveResult
search : buildInteractiveInstantResult
search : buildInteractiveRecentResult
search : buildInteractiveCitation
search : buildGeneratedAnswer
recommendation : missing SSR support
case-assist : missing SSR support
insight : missing SSR support
commerce : missing SSR support

@lvu285 lvu285 changed the title SFINT-5832: Sorts e2e migrate from Cypress to Playwright SFINT-5832: Sort E2E tests migrate from Cypress to Playwright Dec 6, 2024
@mmitiche
Copy link
Contributor

@erocheleau I will integrate the content from this PR: #4782 in this PR as well, to have more unit tests to test the component rather going E2E only.

@lvu285 lvu285 requested a review from mmitiche December 27, 2024 22:16
Copy link
Contributor

@SimonMilord SimonMilord left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-read the comments that were addressed, ltgm! thank you

Copy link
Collaborator

@erocheleau erocheleau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not done yet :)

Will review the playwright tests later

await this.sortDropDown.click();
}

async focusSortDropDownEnter(): Promise<void> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does the "focusSortDropDownEnter" mean here?
The function clicks on the preview button and then presses Tab?

Comment on lines 41 to 45
await this.page.keyboard.press('Enter');
await this.sortButton('Oldest').isVisible();
await this.page.waitForTimeout(500);
await this.page.keyboard.press('ArrowDown');
await this.page.keyboard.press('Enter');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name of this function doesn't describe what is being done with the steps within this function, what are you trying to accomplish with that?

Comment on lines 206 to 208
afterAll(() => {
mockSuccessfulHeadlessInitialization();
});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't need to do that, since your higher beforeEach will already mockSuccessfulHeadlessInitialization()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's true indeed 👍

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be able to remove that afterAll entirely @lvu285

Copy link
Collaborator

@erocheleau erocheleau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some suggestions

Comment on lines 42 to 47
async selectSortOptionUsingArrow(): Promise<void> {
await this.sortButton('Oldest').isVisible();
await this.page.waitForTimeout(500);
await this.page.keyboard.press('ArrowDown');
await this.page.keyboard.press('Enter');
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is weird for me, why you rely on 'Oldest' specifically, and also why do you have to wait for 500ms?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After seeing the test, it shouldn't be in the pageObject just in your test, put this:

await this.page.keyboard.press('ArrowDown');
await this.page.keyboard.press('Enter');

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the wait for 500ms is to make the test for Insight use case more stable, otherwise the next keyboard action sometimes will fail.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes I remember that, it's true, I think you should put indeed a small delay in between all keyboard press if I remember correctly.

Comment on lines 16 to 21
let test;
if (useCase.value === useCaseEnum.search) {
test = fixtures[useCase.value] as typeof testSearch;
} else {
test = fixtures[useCase.value] as typeof testInsight;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need the as typeof ?

Suggested change
let test;
if (useCase.value === useCaseEnum.search) {
test = fixtures[useCase.value] as typeof testSearch;
} else {
test = fixtures[useCase.value] as typeof testInsight;
}
const test = fixtures[useCase.value];

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I won't fix it now, as it's bit complicated. Mehdi will review and fix them later

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mmitiche any insight here?

await sort.openSortDropdownUsingEnter();
await sort.selectSortOptionUsingArrow();
selectedSortLabel = await sort.sortDropDown.textContent();
expect(selectedSortLabel).toEqual(defaultSortLabels[1]);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again here, I would go fetch what the loaded sorts are available on the page instead of relying on the default sorts.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above, we want to be sure the sort displays in correct order

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Order of sorts is not in the contract of our component. It's a parameter we receive and then display. We have unit tests to check that the sort are displayed in the order we've received them.

The e2e test shouldn't rely on the order of sort options to pass or fail. Please make this small change :)

@lvu285 lvu285 requested a review from erocheleau January 29, 2025 15:43
@lvu285 lvu285 changed the title SFINT-5832: Sort E2E tests migrate from Cypress to Playwright test(quantic): SFINT-5832 Sort E2E tests migrate from Cypress to Playwright Feb 4, 2025
Copy link
Collaborator

@erocheleau erocheleau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still the need to not have our e2e break if we change the sort options names or labels ;)

Otherwise a few things to resolve still.

Comment on lines 206 to 208
afterAll(() => {
mockSuccessfulHeadlessInitialization();
});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be able to remove that afterAll entirely @lvu285

Comment on lines 16 to 21
let test;
if (useCase.value === useCaseEnum.search) {
test = fixtures[useCase.value] as typeof testSearch;
} else {
test = fixtures[useCase.value] as typeof testInsight;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mmitiche any insight here?

@lvu285 lvu285 deployed to PR Artifacts February 7, 2025 22:24 — with GitHub Actions Active
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants