Skip to content

test: playwright cucumber setup#454

Merged
KrupaPammi merged 57 commits into
masterfrom
test/eng-5100-playwright-cucumber
Jun 8, 2026
Merged

test: playwright cucumber setup#454
KrupaPammi merged 57 commits into
masterfrom
test/eng-5100-playwright-cucumber

Conversation

@KrupaPammi

@KrupaPammi KrupaPammi commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

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.

@KrupaPammi KrupaPammi marked this pull request as draft April 29, 2026 16:52
@KrupaPammi KrupaPammi self-assigned this Apr 29, 2026
@AndyEPhipps

AndyEPhipps commented May 7, 2026

Copy link
Copy Markdown
Contributor

The Netlify URL pattern always seems to be

https://deploy-preview-**THE-PR-NUMBER**--giftaid-react.netlify.app/
so we might be able to easily suss out a way to pass that as an env var of sorts to give you a test env URL?

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();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should this be selecting the text option? Comparing against the staging one, I think it might mean to be

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, fixed it

@curlyfriesplease

curlyfriesplease commented May 26, 2026

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Small amendment to filename - missing a letter T

@KrupaPammi

Copy link
Copy Markdown
Contributor Author

@seb-cr @curlyfriesplease, I've commented on the questions and made the changes. This is ready for re-review.

Comment thread .github/workflows/main.yml Outdated
@@ -43,12 +43,14 @@ jobs:
FORCE_COLOR: 1

# Test run video was always captured, so this action uses "always()" condition

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Best to amend this code comment as it's out of date now that always() is dropped

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment thread .github/workflows/main.yml Outdated
path: playwright-local/test-results/videos/
name: playwright-failure-artifacts-mobile
path: |
playwright-local/test-results/failed-videos/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

if (process.env.CI && videoPath) {
if (isFailed) {
const failedVideosDir = 'test-results/failed-videos';
fs.mkdirSync(failedVideosDir, { recursive: true });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we also need to mkdirSync/copyFileSync the traces folder too?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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 });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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

@KrupaPammi

Copy link
Copy Markdown
Contributor Author

Thanks for the review @curlyfriesplease, have pushed all the requsted changes

@curlyfriesplease curlyfriesplease left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Lovely!

@KrupaPammi KrupaPammi changed the title test: playwright cucumber POC test: playwright cucumber setup Jun 8, 2026
@KrupaPammi KrupaPammi merged commit 9fa04f7 into master Jun 8, 2026
7 checks passed
@KrupaPammi KrupaPammi deleted the test/eng-5100-playwright-cucumber branch June 8, 2026 09:53
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