test: playwright cucumber setup#454
Conversation
|
The Netlify URL pattern always seems to be
|
| await this.page.locator(selectors.marketingPreferences.fields.email).type(email); | ||
| await this.page.locator(selectors.marketingPreferences.options.phone).click(); | ||
| await this.page.locator(selectors.marketingPreferences.fields.phone).type(phone, { delay: 200 }); | ||
| await this.page.locator(selectors.formFields.mobile).click(); |
There was a problem hiding this comment.
should this be selecting the text option? Comparing against the staging one, I think it might mean to be
There was a problem hiding this comment.
Thanks, fixed it
|
Does Cucumber offer us videos and trace reports like Playwright does? I would hate to lose those, they're very handy |
| @@ -0,0 +1,11 @@ | |||
| @sanity @valid-submission | |||
There was a problem hiding this comment.
Small amendment to filename - missing a letter T
|
@seb-cr @curlyfriesplease, I've commented on the questions and made the changes. This is ready for re-review. |
| @@ -43,12 +43,14 @@ jobs: | |||
| FORCE_COLOR: 1 | |||
|
|
|||
| # Test run video was always captured, so this action uses "always()" condition | |||
There was a problem hiding this comment.
Best to amend this code comment as it's out of date now that always() is dropped
| path: playwright-local/test-results/videos/ | ||
| name: playwright-failure-artifacts-mobile | ||
| path: | | ||
| playwright-local/test-results/failed-videos/ |
There was a problem hiding this comment.
Have you seen this work, and save results? Just visually comparing to how we do it in CRCom and there we specify the filetypes, like /**/*.webm for the videos and /**/*.zip for the traces
There was a problem hiding this comment.
Videos and the traces seem to be working now
https://github.com/comicrelief/giftaid-react/actions/runs/27022175929/job/79752714564?pr=454
https://github.com/comicrelief/giftaid-react/actions/runs/27022175929/job/79752714722?pr=454
| if (process.env.CI && videoPath) { | ||
| if (isFailed) { | ||
| const failedVideosDir = 'test-results/failed-videos'; | ||
| fs.mkdirSync(failedVideosDir, { recursive: true }); |
There was a problem hiding this comment.
Do we also need to mkdirSync/copyFileSync the traces folder too?
There was a problem hiding this comment.
I added mkdirSync for the traces directory as well. We don't need a copyFileSync for traces, as Playwright saves the trace zip directly to the path we provide in tracing.stop(), whereas videos are initially saved to the Playwright video directory and then copied into the failed-videos folder.
| "@comicrelief/data-models": "^1.29.6", | ||
| "@comicrelief/test-utils": "^1.5.15", | ||
| "@cucumber/cucumber": "8.9.1", | ||
| "@playwright/test": "1.56.1", |
There was a problem hiding this comment.
Although the lines haven't been changed in this PR, I've noticed that the version of playwright/test is different in the two package.jsons (1.38.1 and 1.56.1). Do you think we should align them?
There was a problem hiding this comment.
I did look at aligning them, but playwright-local currently uses the root package.json, which is still tied to Node 16. When I tried upgrading Playwright there to match staging, the newer Playwright version wasn't supported by the Node version we're using.
playwright-staging has its own separate package.json, so it can use Playwright 1.56.1 without affecting the rest of the project. For now I've left playwright-local on 1.38.1 to avoid introducing wider dependency changes, but once we update the Node version, we can then align the Playwright versions.
| // When steps | ||
| When('I enter the local mobile number {string}', async function (mobile) { | ||
| await this.page.locator(selectors.formFields.mobile).fill(''); | ||
| await this.page.locator(selectors.formFields.mobile).fill(mobile, { delay: 100 }); |
There was a problem hiding this comment.
Just had a quick look at the documentation for some of the playwright functions, I don't think it will accept delay, doesn't seem to be on the list. timeout is there though that's not quite what we want. Looks like delay is an option for press()
https://playwright.dev/docs/api/class-locator#locator-fill
There was a problem hiding this comment.
Thanks, looks like I missed removing the delay when it was updated from type() to fill(). The delay option isn't supported on fill(), so I'll remove it unless we specifically need character-by-character typing for this field
|
Thanks for the review @curlyfriesplease, have pushed all the requsted changes |
This PR migrates both the playwright-local and playwright-staging test suites from the Playwright Test runner to a Cucumber + Playwright framework using Gherkin feature files and reusable step definitions.
As part of the migration, the existing Playwright tests were first refactored and cleaned up before converting them into Cucumber scenarios.