Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/e2e/setup/auth.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-restricted-imports */
import {cliFixture} from './cli.js'
import {executables} from './env.js'
import {stripAnsi} from '../helpers/strip-ansi.js'
Expand Down
66 changes: 66 additions & 0 deletions packages/e2e/tests/hydrogen.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/* eslint-disable no-restricted-imports */
import {cliFixture as test} from '../setup/cli.js'
import {expect} from '@playwright/test'
import * as path from 'path'

test.describe('Hydrogen basic flow (mock shop)', () => {
test('init, build, dev', async ({cli, env}) => {
// No store credentials needed — uses mock.shop as data source
test.setTimeout(10 * 60 * 1000)

const hydrogenDir = path.join(env.tempDir, 'hydrogen-app')

// Step 1: Scaffold and install dependencies via hydrogen init.
// Force npm by overriding npm_config_user_agent (otherwise pnpm is detected
// from the monorepo environment and used to install deps in the temp project).
const initResult = await cli.exec(
[
'hydrogen',
'init',
'--path',
hydrogenDir,
'--mock-shop',
'--language',
'js',
'--markets',
'none',
'--no-shortcut',
'--no-git',
'--install-deps',
'--styling',
'tailwind',
],
{
env: {npm_config_user_agent: 'npm'},
timeout: 5 * 60 * 1000,
},
)
const initOutput = initResult.stdout + initResult.stderr
expect(initResult.exitCode, `hydrogen init failed:\n${initOutput}`).toBe(0)
expect(initOutput).toContain('Storefront setup complete!')
expect(initOutput).toContain('Mock.shop')

// Step 2: Build for production
const buildResult = await cli.exec(['hydrogen', 'build', '--path', hydrogenDir], {
timeout: 3 * 60 * 1000,
})
const buildOutput = buildResult.stdout + buildResult.stderr
expect(buildResult.exitCode, `hydrogen build failed:\n${buildOutput}`).toBe(0)

// Step 3: Start dev server and verify it serves requests
// fixed port to avoid conflicts
const port = 14712
const dev = await cli.spawn(['hydrogen', 'dev', '--path', hydrogenDir, '--port', String(port)], {
env: {CI: ''},
})
try {
await dev.waitForOutput('View Hydrogen app:', 3 * 60 * 1000)

// eslint-disable-next-line no-restricted-globals
const response = await fetch(`http://localhost:${port}/`)
expect(response.status, `hydrogen dev server returned unexpected status`).toBe(200)
} finally {
dev.kill()
}
})
})
Loading