-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[e2e] Update playwright eslint plugin #7581
base: master
Are you sure you want to change the base?
Changes from all commits
0590b50
2897ca6
df2d9ab
82326dc
8933baf
a393bfb
d8df0e1
6e1272d
b7b7bc2
444c9ff
6edb3b2
349be42
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,8 @@ module.exports = { | |
browser: true, | ||
es6: true, | ||
jasmine: true, | ||
amd: true | ||
amd: true, | ||
node: true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice |
||
}, | ||
globals: { | ||
_: 'readonly' | ||
|
@@ -150,6 +151,7 @@ module.exports = { | |
'error', | ||
{ | ||
cases: { | ||
camelCase: true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i'm not sure exactly why the robot added this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah we need to remove this. it's supposed to enforce vue files only i think |
||
pascalCase: true | ||
}, | ||
ignore: ['^.*\\.js$'] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -383,7 +383,7 @@ By adhering to this principle, we can create tests that are both robust and refl | |
1. Avoid creating locator aliases. This likely means that you're compensating for a bad locator. Improve the application instead. | ||
1. Leverage `await page.goto('./', { waitUntil: 'domcontentloaded' });` instead of `{ waitUntil: 'networkidle' }`. Tests run against deployments with websockets often have issues with the networkidle detection. | ||
|
||
#### How to make tests faster and more resilient | ||
#### How to make tests faster and more resilient to application changes | ||
1. Avoid app interaction when possible. The best way of doing this is to navigate directly by URL: | ||
|
||
```js | ||
|
@@ -398,6 +398,16 @@ By adhering to this principle, we can create tests that are both robust and refl | |
- Initial navigation should _almost_ always use the `{ waitUntil: 'domcontentloaded' }` option. | ||
1. Avoid repeated setup to test a single assertion. Write longer tests with multiple soft assertions. | ||
This ensures that your changes will be picked up with large refactors. | ||
1. Use [user-facing locators](https://playwright.dev/docs/best-practices#use-locators) (Now a eslint rule!) | ||
|
||
```js | ||
page.getByRole('button', { name: 'Create' } ) | ||
``` | ||
Instead of | ||
```js | ||
page.locator('.c-create-button') | ||
``` | ||
Note: `page.locator()` can be used in performance tests as xk6-browser does not yet support the new `page.getBy` pattern and css lookups can be [1.5x faster](https://serpapi.com/blog/css-selectors-faster-than-getbyrole-playwright/) | ||
Comment on lines
+401
to
+410
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion:
// Recommended
page.getByRole('button', { name: 'Create' }) Instead of the less intuitive: // Not recommended
page.locator('.c-create-button') Note: In performance tests, |
||
|
||
##### Utilizing LocalStorage | ||
1. In order to save test runtime in the case of tests that require a decent amount of initial setup (such as in the case of testing complex displays), you may use [Playwright's `storageState` feature](https://playwright.dev/docs/api/class-browsercontext#browser-context-storage-state) to generate and load localStorage states. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -531,7 +531,7 @@ test.describe('Example Imagery in Flexible layout', () => { | |
|
||
// Click text=OK | ||
await Promise.all([ | ||
page.waitForNavigation({ waitUntil: 'networkidle' }), | ||
page.waitForNavigation({ waitUntil: 'domcontentloaded' }), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. intellisense says this is deprecated |
||
page.click('button:has-text("OK")'), | ||
//Wait for Save Banner to appear | ||
page.waitForSelector('.c-message-banner__message') | ||
|
@@ -575,7 +575,7 @@ test.describe('Example Imagery in Tabs View', () => { | |
|
||
// Click text=OK | ||
await Promise.all([ | ||
page.waitForNavigation({ waitUntil: 'networkidle' }), | ||
page.waitForNavigation({ waitUntil: 'domcontentloaded' }), | ||
page.click('button:has-text("OK")'), | ||
//Wait for Save Banner to appear | ||
page.waitForSelector('.c-message-banner__message') | ||
|
@@ -1023,7 +1023,7 @@ async function createImageryView(page) { | |
|
||
// Click text=OK | ||
await Promise.all([ | ||
page.waitForNavigation({ waitUntil: 'networkidle' }), | ||
page.waitForNavigation({ waitUntil: 'domcontentloaded' }), | ||
page.click('button:has-text("OK")'), | ||
//Wait for Save Banner to appear | ||
page.waitForSelector('.c-message-banner__message') | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -152,7 +152,7 @@ test.describe('ExportAsJSON Disabled Actions', () => { | |
test.describe('ExportAsJSON ProgressBar @couchdb', () => { | ||
let folder; | ||
test.beforeEach(async ({ page }) => { | ||
await page.goto('./', { waitUntil: 'networkidle' }); | ||
await page.goto('./', { waitUntil: 'domcontentloaded' }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i worry about this breaking the couchdb tests |
||
// Perform actions to create the domain object | ||
folder = await createDomainObjectWithDefaults(page, { | ||
type: 'Folder' | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,7 +37,7 @@ test.describe('Notebook Tests with CouchDB @couchdb', () => { | |
|
||
// Create Notebook | ||
testNotebook = await createDomainObjectWithDefaults(page, { type: 'Notebook' }); | ||
await page.goto(testNotebook.url, { waitUntil: 'networkidle' }); | ||
await page.goto(testNotebook.url, { waitUntil: 'domcontentloaded' }); | ||
}); | ||
|
||
test('Inspect Notebook Entry Network Requests', async ({ page }) => { | ||
|
@@ -58,7 +58,7 @@ test.describe('Notebook Tests with CouchDB @couchdb', () => { | |
page.click('[aria-label="Add Page"]') | ||
]); | ||
// Ensures that there are no other network requests | ||
await page.waitForLoadState('networkidle'); | ||
await page.waitForLoadState('domcontentloaded'); | ||
|
||
// Assert that only two requests are made | ||
// Network Requests are: | ||
|
@@ -77,7 +77,7 @@ test.describe('Notebook Tests with CouchDB @couchdb', () => { | |
// 2) The shared worker event from 👆 POST request | ||
notebookElementsRequests = []; | ||
await nbUtils.enterTextEntry(page, 'First Entry'); | ||
await page.waitForLoadState('networkidle'); | ||
await page.waitForLoadState('domcontentloaded'); | ||
expect(notebookElementsRequests.length).toBeLessThanOrEqual(2); | ||
|
||
// Add some tags | ||
|
@@ -141,7 +141,7 @@ test.describe('Notebook Tests with CouchDB @couchdb', () => { | |
// 4) The shared worker event from 👆 POST request | ||
notebookElementsRequests = []; | ||
await nbUtils.enterTextEntry(page, 'Fourth Entry'); | ||
page.waitForLoadState('networkidle'); | ||
page.waitForLoadState('domcontentloaded'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i don't know if these are necessarily 1 to 1 here. The networkidles serve a purpose. I think maybe we need to wait for network events specifically to complete? We should just leave these as warnings for now |
||
|
||
expect(filterNonFetchRequests(notebookElementsRequests).length).toBeLessThanOrEqual(4); | ||
|
||
|
@@ -153,7 +153,7 @@ test.describe('Notebook Tests with CouchDB @couchdb', () => { | |
// 4) The shared worker event from 👆 POST request | ||
notebookElementsRequests = []; | ||
await nbUtils.enterTextEntry(page, 'Fifth Entry'); | ||
page.waitForLoadState('networkidle'); | ||
page.waitForLoadState('domcontentloaded'); | ||
|
||
expect(filterNonFetchRequests(notebookElementsRequests).length).toBeLessThanOrEqual(4); | ||
|
||
|
@@ -164,7 +164,7 @@ test.describe('Notebook Tests with CouchDB @couchdb', () => { | |
// 4) The shared worker event from 👆 POST request | ||
notebookElementsRequests = []; | ||
await nbUtils.enterTextEntry(page, 'Sixth Entry'); | ||
page.waitForLoadState('networkidle'); | ||
page.waitForLoadState('domcontentloaded'); | ||
|
||
expect(filterNonFetchRequests(notebookElementsRequests).length).toBeLessThanOrEqual(4); | ||
}); | ||
|
@@ -227,7 +227,7 @@ async function addTagAndAwaitNetwork(page, tagName) { | |
page.locator(`[aria-label="Autocomplete Options"] >> text=${tagName}`).click(), | ||
expect(page.locator(`[aria-label="Tag"]:has-text("${tagName}")`)).toBeVisible() | ||
]); | ||
await page.waitForLoadState('networkidle'); | ||
await page.waitForLoadState('domcontentloaded'); | ||
} | ||
|
||
/** | ||
|
@@ -246,5 +246,5 @@ async function removeTagAndAwaitNetwork(page, tagName) { | |
) | ||
]); | ||
await expect(page.locator(`[aria-label="Tag"]:has-text("${tagName}")`)).toBeHidden(); | ||
await page.waitForLoadState('networkidle'); | ||
await page.waitForLoadState('domcontentloaded'); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think we can set this to false or remove it altogether