Skip to content

Add e2e test infrastructure with Playwright + node-pty#6899

Open
ryancbahan wants to merge 4 commits intomainfrom
e2e-testing
Open

Add e2e test infrastructure with Playwright + node-pty#6899
ryancbahan wants to merge 4 commits intomainfrom
e2e-testing

Conversation

@ryancbahan
Copy link
Contributor

@ryancbahan ryancbahan commented Feb 26, 2026

WHY are these changes introduced?

The CLI team manually runs a ~30-step QA checklist before every release. This is time-consuming and error-prone. The Cucumber suite tests CLI commands non-interactively but cannot handle interactive CLI prompts, long-running dev servers, auth, or browser verification. We need e2e test infra that automates QA and provides regression testing for CLI features.

WHAT is this pull request doing?

Introduces a new packages/e2e/ package with Playwright + node-pty infrastructure for automated end-to-end testing.

Directory structure:

packages/e2e/
  setup/          → Playwright fixture definitions (DI wiring)
    env.ts          worker-scoped XDG isolation & env var management
    cli.ts          CLI process management (execa + node-pty)
  helpers/        → Pure utility functions
    strip-ansi.ts   ESM wrapper for strip-ansi
  tests/          → Test specs
    smoke.spec.ts       validates execa path (shopify version)
    smoke-pty.spec.ts   validates PTY path (shopify version via node-pty)

Key design decisions:

  • setup/ to distinguish Playwright fixture definitions from static test data
  • cli.ts provides both exec() (non-interactive via execa) and spawn() (interactive via node-pty with output matching, key sending, process lifecycle)
  • Worker-scoped env isolation with XDG directory sandboxing
  • helpers/ contains stateless utility functions with no Playwright dependency

Subsequent PRs in this stack add OAuth login, app scaffold/deploy/dev tests, CI integration, and TOML config regression tests.

How to test your changes?

pnpm test:e2e

Measuring impact

n/a - this is test infrastructure

Copy link
Contributor Author

ryancbahan commented Feb 26, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@ryancbahan ryancbahan changed the title add new section for e2e testing Add new section for e2e testing Feb 27, 2026
@ryancbahan ryancbahan marked this pull request as ready for review February 27, 2026 20:23
@ryancbahan ryancbahan requested a review from a team as a code owner February 27, 2026 20:23
@github-actions
Copy link
Contributor

github-actions bot commented Feb 27, 2026

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements 78.83% 14475/18363
🟡 Branches 73.14% 7200/9844
🟡 Functions 79.06% 3693/4671
🟡 Lines 79.17% 13675/17274

Test suite run success

3791 tests passing in 1448 suites.

Report generated by 🧪jest coverage report action from 6e1ad36

@@ -0,0 +1,19 @@
# Required: Client ID of the primary test app (must be in the genghis account's org)
# CI secret: E2E_CLIENT_ID
SHOPIFY_FLAG_CLIENT_ID=
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For initial E2E tests, we won't create new apps but instead use existing ones. We should 100% evolve this, but we need a starting point to monitor and observe stability of this job.

@binks-code-reviewer
Copy link

binks-code-reviewer bot commented Feb 27, 2026

🤖 Code Review · #projects-dev-ai for questions
React with 👍/👎 or reply — all feedback helps improve the agent.

Complete - No issues

📋 History

✅ 1 findings → ✅ 1 findings → ✅ No issues

@ryancbahan ryancbahan requested a review from amcaplan March 2, 2026 14:30

test.describe('PTY smoke test', () => {
test('shopify version runs via PTY', async ({cli}) => {
const proc = await cli.spawn(['version'])
Copy link
Contributor

Choose a reason for hiding this comment

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

I wasn't able to execute this test initially, i was getting a Error: posix_spawnp failed.
Apparently (and according to claude) pnpm strips the execution permission of binaries installed through it, so the spawn-helper in node-pty didn't have enough permissions. Fixing that this worked, but probably something to account for.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

how did you fix? i didn't run into this problem

Copy link
Contributor

Choose a reason for hiding this comment

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

Claude found the spawn-helper binary inside node_modules and suggested to add execution permission (chmod +x), after that everything worked. Not sure why it happened though, i've installed binaries other times and didn't have this problem. Maybe because I ran pnpm i inside the e2e folder? :thinking_face:

I ran pnpm iagain from the root and it worked fine this time, so maybe we can ignore this

/**
* Polls until a TCP connection to host:port succeeds, or timeout is reached.
*/
export async function waitForPort(port: number, host = '127.0.0.1', timeoutMs = 30_000): Promise<void> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Am I wrong or this isn't used anywhere?

/**
* Replaces text in a file. Useful for modifying source files to trigger hot reload.
*/
export function replaceInFile(filePath: string, search: string | RegExp, replacement: string): void {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same for these functions, they are not used right?

ryancbahan and others added 2 commits March 5, 2026 11:20
Rename the fixtures directory to setup/ to clearly distinguish Playwright
fixture definitions from static test data. Rename cli-process.ts to cli.ts
for brevity.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ryancbahan ryancbahan changed the title Add new section for e2e testing Add e2e test infrastructure with Playwright + node-pty Mar 5, 2026
@ryancbahan ryancbahan requested a review from isaacroldan March 5, 2026 19:20
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.

2 participants