-
Notifications
You must be signed in to change notification settings - Fork 105
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
Convert end-to-end tests to Playwright #6976
Labels
Comments
I've done some initial experiments with Playwright and think that will work for our end-to-end regtests. I've converted 6 regtests and I'm in the process of converting others. There will be some difficulties:
There is good news about using Playwright:
|
bors bot
added a commit
that referenced
this issue
Aug 24, 2023
7215: Migrate end-to-end tests to Playwright r=jmcameron a=jmcameron This PR enables end-to-end tests that have been migrated from Protractor to Playwright. Note that only 23% of the end-to-end have been converted, but it seems appropriate to start using the tests that have been migrated now to avoid any regressions that they might catch. Note that the old Protractor tests have not been deleted yet, since the obsolete files may still be useful in the migration process. Also the original command `yarn test:ends` are unchanged so it remains broken. Use the new command `yarn test:e2e` instead. Note that a few of these tests still sporadically fail; I'm trying to resolve those problems. See [Issue 6976](#6976) for details about the migration. Note: This PR replaces [PR 7024](#7024). It is essentially a rebase to consolidate all the commit messages (via git diff vs master and patch, not via `git rebase`). ### Testing - Set your .env file for bhima_test - Run `yarn` to update dependencies (you may want to run `yarn upgrade` too) - Install playwright: - `npm install playwright` - Verify the two versions match: - `grep '`@playwright/test@'` yarn.lock` - `npx playwright --version` - Run the tests: `yarn test:e2e` Co-authored-by: Jonathan Cameron <jmcameron@gmail.com>
bors bot
added a commit
that referenced
this issue
Aug 24, 2023
7215: Migrate end-to-end tests to Playwright r=jmcameron a=jmcameron This PR enables end-to-end tests that have been migrated from Protractor to Playwright. Note that only 23% of the end-to-end have been converted, but it seems appropriate to start using the tests that have been migrated now to avoid any regressions that they might catch. Note that the old Protractor tests have not been deleted yet, since the obsolete files may still be useful in the migration process. Also the original command `yarn test:ends` are unchanged so it remains broken. Use the new command `yarn test:e2e` instead. Note that a few of these tests still sporadically fail; I'm trying to resolve those problems. See [Issue 6976](#6976) for details about the migration. Note: This PR replaces [PR 7024](#7024). It is essentially a rebase to consolidate all the commit messages (via git diff vs master and patch, not via `git rebase`). ### Testing - Set your .env file for bhima_test - Run `yarn` to update dependencies (you may want to run `yarn upgrade` too) - Install playwright: - `npm install playwright` - Verify the two versions match: - `grep '`@playwright/test@'` yarn.lock` - `npx playwright --version` - Run the tests: `yarn test:e2e` Co-authored-by: Jonathan Cameron <jmcameron@gmail.com>
Closed by #7215 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Because Protractor is now obsolete for end-to-end tests, we need to convert the end-to-end tests to some other framework.
See Issue #6669 for details. Based on the feedback in that issue and some experimentation, I think we should try to convert the end-to-end tests to Playwright.
Trying the experimental version of the End-to-End tests with Playwright
npm install playwright
yarn test:e2e
Eslint update
sh
orutiliities
directories.Log of updates (open to see list)
2023-08-23 Playwright end-to-end tests working in CI/semaphore
2023-08-17 Got most tests working
npm run test:e2e
npm run test:e2e-stock
2023-08-03 Completed migration
2023-07-21 PM Migrated journal tests
2023-07-21 Migrated reports tests
2023-07-19 Migrated more tests
2023-07-18 Migrated more tests
2023-07-14 Migrated more tests
2023-07-13 Migrated more tests
2023-07-12 Migrated more tests
bhPayrollPeriodSelect, bhPayrollStatusSelect, bhRubricConfigSelect, and bhWeekCofnigSelect
2023-07-10 Migrated more test
2023-07-07 Migrate more tests
2023-07-05 Migrate more tests
2023-07-03 Updates
2023-06-30 Migrated more tests
These tests all work when the directory containing them is run by itself.
2023-06-29 Migrated more tests
2023-06-28 Migrated more tests and components
in order to avoid conflicts when the tests are executed in different orders. Fixed a few tests
by allowing several different counts.
2023-06-14 Migrated more tests
2023-06-13 Migrated more tests
2023-06-08 Migrated another test
2023-06-07 Migrated more tests
2023-06-06 Migrated more tests
2023-06-05 Minor updates
reduce the number timeout failures that the Playwright end-to-end tests are experiencing. It seems to help but
has not eliminated all random failures
2023-06-02 Various updates
2023-04-21 Finished patient tests
2023-04-20 Keep up with master
2023-04-19 Worked on new tests (patient)
2023-04-18 Submitted a PR enable the already-completed Playwright end-to-end tests
2023-04-14 Implemented cashbox and debtors tests
2023-04-13 Implemented more tests
2023-04-12 Implemented more tests
2023-04-11 Got most of account-references test working
2023-04-10 Fixed an issue with TU.locator() chaining
2023-04-07 Working on account-reference tests
2023-04-06 Continuing to work on 'cash' tests
2023-04-05 Continuing working on 'cash' tests
2023-04-04 Continuing working on 'cash' tests
2023-04-03 Started on 'cash' tests
2023-03-31 Got account_statement tests working
2023-03-30 Added depots tests
2023-03-29 Worked to speed up tests
2023-03-28 Worked on the last 'locations' test
2023-03-27 Started script to do partial automatic conversion to playwright (/sh/prot2play).
2023-03-24
2023-03-23 Added progress check list of end-to-end tests in comments below
2023-03-08 I have started converting our end-to-end tests to Playwright.
Progress converting end-to-end tests to Playwright (64, open to see list)
allocationCostCenters/distribution_feescenters* (2 files)breakEvenReference (2 files)receipt_modal (1 file)Progress converting end-to-end shared utilities to Playwright (open to see list)
Progress converting end-to-end components to Playwright (74, open to see list)
Protractor => Playwright Conversion Guide
See Playwright conversion guide for details on converting
element()
,by.css()
, etc.At the top of the test file, insert
const { test, expect } = require('@playwright/test');
The tests run in English. Therefore, it may be necessary to change some French labels and text used to find elements to English counterparts.
Conversions
FU = require('../shared/FormUtils')
TU = require('../shared/TestUtils');
const { expect } = require('chai');
const { test, expect } = require('@playwright/test');
describe(...)
test.describe(...)
before(() => helpers.navigate(path));
test.beforeEach(async ({ page }) => {...});
it('description', async () => <fn>);
test('description', async ({ page }) => <fn>
);element(...)
await TU.locator(...)
await element(by...).click()
await (await page.locator(..)).click();
element(by.css('<css selector>'))
await TU.locator('<css selector>')
test.beforeEach()
: Although the Protractor configuration logged the user into the test BHIMA server at the start of each test file, Playwright is not configured to do that. Therefore we need to do that in the test.beforeEach() call. Alogin()
function has been added to TestUtils to make this simple. Note thattest.beforeEach()
block can be inside thetest.describe()
block or outside of it. Note thatTU.registerPage(page);
(2nd line) must be called once before any TestUtils functions that use thepage
object.page
argument, it can be omitted. Often the necessary operations can be done by usingTestUtils
functions without explicitly referencing thepage
object. Thepage
object is saved inTestUtils
when theregisterPage(p)
function is called and is used internally for mostTestUtils
functions.element()
,by.css()
, etc..all()
requires some recoding. In Protractor, .all() can take an argument; not in Playwright. Also.all()
returns a single protractor object that can contain multiple atomic locators (which has a.count()
function to get it's length). But in Playwright,.all()
is a function of a locator and returns an (possibly empty) array of atomic locator objects (which has a.length
property to get the number of locators it contains).TU.navigate()
to got that page in your test, you cannot always be sure the grid will be loaded immediately after the navigation. It is good to useTU.waitForSelector()
for something in the grid to make sure the grid is actually loaded before continuing. This may not be necessary when running the tests for only one directory, but is often required when running all the tests in parallel.Closes #6669
The text was updated successfully, but these errors were encountered: