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): first setup of playwright added in Quantic #4597

Open
wants to merge 34 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
0b0f35b
first setup of playwright added in Quantic
mmitiche Oct 25, 2024
5db6159
first setup of playwright added in Quantic
mmitiche Oct 25, 2024
5cbb204
few adjustments
mmitiche Oct 29, 2024
dd0e45b
typo fixed
mmitiche Oct 29, 2024
438ee6c
Merge branch 'master' into SFINT-5768
mmitiche Oct 29, 2024
389aef4
refactored fixtures
mmitiche Oct 30, 2024
56518c5
Merge branch 'SFINT-5768' of https://github.com/coveo/ui-kit into SFI…
mmitiche Oct 30, 2024
4a9bef5
typo fixed
mmitiche Oct 31, 2024
9ce1e39
added checks on page selection
mmitiche Oct 31, 2024
638fdd7
Update packages/quantic/playwright.config.ts
mmitiche Oct 31, 2024
633199a
Merge branch 'SFINT-5768' of https://github.com/coveo/ui-kit into SFI…
mmitiche Oct 31, 2024
ec9389b
config updated
mmitiche Oct 31, 2024
8b977e3
Update packages/quantic/force-app/main/default/lwc/quanticPager/e2e/q…
mmitiche Oct 31, 2024
f9cb518
Update packages/quantic/force-app/main/default/lwc/quanticPager/e2e/q…
mmitiche Oct 31, 2024
95e305e
setup improved
mmitiche Nov 5, 2024
4fbdab8
Merge branch 'SFINT-5768' of https://github.com/coveo/ui-kit into SFI…
mmitiche Nov 5, 2024
18f60ce
comment updated
mmitiche Nov 5, 2024
5657e80
decisions folder added
mmitiche Nov 6, 2024
41d6065
decisions folder added
mmitiche Nov 6, 2024
b7163a5
Merge branch 'master' into SFINT-5768
mmitiche Nov 6, 2024
f99a550
feedback applied
mmitiche Nov 6, 2024
b8228b7
md file updated
mmitiche Nov 6, 2024
2ff3fe7
Merge branch 'SFINT-5768' of https://github.com/coveo/ui-kit into SFI…
mmitiche Nov 6, 2024
a8466e1
comment deleted
mmitiche Nov 6, 2024
4cfbda2
unnecessary await removed
mmitiche Nov 7, 2024
8df0cd4
Update packages/quantic/decisions/0001-testing-strategy.md
mmitiche Nov 12, 2024
804495d
Update packages/quantic/decisions/0001-testing-strategy.md
mmitiche Nov 12, 2024
60472e8
Update packages/quantic/decisions/0001-testing-strategy.md
mmitiche Nov 12, 2024
ba69882
Update packages/quantic/decisions/0001-testing-strategy.md
mmitiche Nov 12, 2024
0cafffa
Update packages/quantic/decisions/0001-testing-strategy.md
mmitiche Nov 12, 2024
4b08487
Update packages/quantic/decisions/0001-testing-strategy.md
mmitiche Nov 12, 2024
04ad5c8
feedback applied
mmitiche Nov 13, 2024
ea8b9d0
Merge branch 'master' of https://github.com/coveo/ui-kit into SFINT-5768
mmitiche Nov 13, 2024
446457f
feedback applied
mmitiche Nov 14, 2024
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
76 changes: 76 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions packages/quantic/.forceignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ package.xml
**/__tests__/**
**/testUtils/**/*

# LWC E2E
mmitiche marked this conversation as resolved.
Show resolved Hide resolved
**/e2e/**

**/README.md
6 changes: 5 additions & 1 deletion packages/quantic/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ force-app/main/default/staticresources/dompurify
# Test Coverage & Report
coverage
reports
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/

# Cypress artifacts
.cache/
Expand All @@ -56,4 +60,4 @@ cypress/plugins/config/examples-community.json
docs/out/*

# Environment Variables
.env
.env
7 changes: 7 additions & 0 deletions packages/quantic/force-app/main/default/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@
"rules": {
"@lwc/lwc/no-async-operation": "off"
}
},
{
"files": ["**/e2e/*.ts"],
"parser": "@typescript-eslint/parser",
"rules": {
"no-redeclare": ["error", {"builtinGlobals": false}]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why those rules overrides?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's because Jest defines expect as a global variable, and in the e2e tests we importing expect from playwright,
so eslint creates an error saying that we can't re-declare a global variable.

this rule avoids this error.
An alternative solution would be to do:

import { expect as testExpect } from '@playwright/test';

by changing the alias of the imported expect playwright.

}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
"../../../../typings/lwc/**/*.d.ts",
"../../../../coveo.d.ts"
],
"exclude": ["**/e2e/**"],
"typeAcquisition": {
"include": ["jest"]
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import {PagerObject} from './page-object';
import {quanticBase} from '../../../../../../playwright/fixtures/base-fixture';

import {SearchObject} from '../../../../../../playwright/page-object/search-object';

type QuanticPagerE2EFixtures = {
pager: PagerObject;
};

export const testSearch = quanticBase.extend<QuanticPagerE2EFixtures>({
mmitiche marked this conversation as resolved.
Show resolved Hide resolved
pager: async ({page}, use) => {
await use(new PagerObject(page));
},
search: async ({page}, use) => {
await use(new SearchObject(page, 'search'));
},
});

export const testInsight = quanticBase.extend<QuanticPagerE2EFixtures>({
pager: async ({page}, use) => {
await use(new PagerObject(page));
},
search: async ({page}, use) => {
mmitiche marked this conversation as resolved.
Show resolved Hide resolved
await use(new SearchObject(page, 'insight'));
},
});

export {expect} from '@playwright/test';
mmitiche marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import {Page} from '@playwright/test';
import {isUaCustomEvent} from '../../../../../../playwright/utils/requests';
mmitiche marked this conversation as resolved.
Show resolved Hide resolved

export class PagerObject {
mmitiche marked this conversation as resolved.
Show resolved Hide resolved
constructor(public page: Page) {
this.page = page;
}

get nextPageButton() {
return this.page.locator('button[title="Next Page"]');
}

get previousPageButton() {
return this.page.locator('button[title="Previous Page"]');
}

get pageButtons() {
return this.page.locator('c-quantic-number-button button');
}

async goToLastPage() {
await this.pageButtons.nth(-1).click();
}

async clickNextPageButton() {
await this.nextPageButton.click();
}

async clickPreviousPageButton() {
await this.previousPageButton.click();
}

async clickPageNumberButton(pageNumber: number) {
await this.pageButtons.nth(pageNumber - 1).click();
}

async waitForPagerUaAnalytics(eventValue) {
mmitiche marked this conversation as resolved.
Show resolved Hide resolved
const uaRequest = this.page.waitForRequest((request) => {
if (isUaCustomEvent(request)) {
const requestBody = request.postDataJSON?.();
const expectedFields = {
eventType: 'getMoreResults',
eventValue: eventValue,
};
return Object.keys(expectedFields).every(
(key) => requestBody?.[key] === expectedFields[key]
);
}
return false;
});
return uaRequest;
}
}
Loading
Loading