Skip to content
Merged
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
8 changes: 0 additions & 8 deletions assets/seed.spec.js

This file was deleted.

7 changes: 0 additions & 7 deletions assets/seed.spec.ts

This file was deleted.

46 changes: 23 additions & 23 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
},
"license": "Apache-2.0",
"scripts": {
"build": "esbuild --bundle src/program.ts --outfile=lib/index.js --platform=node --target=ES2019",
"build": "esbuild --bundle src/cli.ts --outfile=lib/index.js --platform=node --target=ES2019",
"clean": "rm -rf lib",
"watch": "npm run build -- --watch",
"test": "playwright test",
"prepublish": "npm run build"
},
"devDependencies": {
"@playwright/test": "1.56.0-alpha-1758839353000",
"@playwright/test": "^1.49.1",
"@types/ini": "^4.1.1",
"@types/node": "^18.19.33",
"ansi-colors": "^4.1.1",
Expand Down
3 changes: 1 addition & 2 deletions src/program.ts → src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ program
.option('--ct', 'install Playwright Component testing')
.option('--quiet', 'do not ask for interactive input prompts')
.option('--gha', 'install GitHub Actions')
.option('--agents <loop>', 'initialize repository agents for the specified agentic loop provider (vscode, claude or opencode)')
.option('--lang <language>', 'language to use (js, TypeScript)', 'TypeScript')
.action(async (rootDir, options) => {

const cliOptions: CliOptions = {
browser: options.browser,
noBrowsers: !options.browsers,
Expand All @@ -46,7 +46,6 @@ program
ct: options.ct,
quiet: options.quiet,
gha: options.gha,
agents: options.agents,
lang: options.lang,
};
const resolvedRootDir = path.resolve(process.cwd(), rootDir || '.');
Expand Down
15 changes: 0 additions & 15 deletions src/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ export type CliOptions = {
ct?: boolean;
quiet?: boolean;
gha?: boolean;
agents?: string;
};

export class Generator {
Expand Down Expand Up @@ -176,7 +175,6 @@ export class Generator {

let ctPackageName;
let installExamples = !this.options.noExamples;

if (answers.framework) {
ctPackageName = `@playwright/experimental-ct-${answers.framework}`;
installExamples = false;
Expand All @@ -190,11 +188,6 @@ export class Generator {
}, sections));
}

if (this.options.agents) {
installExamples = false;
files.set(path.join(answers.testDir, `seed.spec.${fileExtension}`), this._readAsset(`seed.spec.${fileExtension}`));
}

if (answers.installGitHubActions) {
const npmrcExists = fs.existsSync(path.join(this.rootDir, '.npmrc'));
const packageLockDisabled = npmrcExists && ini.parse(fs.readFileSync(path.join(this.rootDir, '.npmrc'), 'utf-8'))['package-lock'] === false;
Expand Down Expand Up @@ -263,14 +256,6 @@ export class Generator {
});
}

if (this.options.agents) {
commands.push({
name: 'Initializing Playwright agents',
command: this.packageManager.npx('playwright', `init-agents --loop=${this.options.agents}`),
phase: 'post',
});
}

return { files, commands };
}

Expand Down
40 changes: 0 additions & 40 deletions tests/integration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,44 +185,4 @@ test('is proper yarn berry', async ({ packageManager, exec }) => {
test.skip(packageManager !== 'yarn-berry');
const result = await exec('yarn --version', [], { cwd: test.info().outputDir, shell: true });
expect(result.stdout).toMatch(/^4\./);
});

test('should create seed.spec.ts file when --agents=vscode is specified', async ({ run, dir, packageManager }) => {
test.skip(packageManager !== 'npm');

await run(['--agents=vscode', '--next'], { installGitHubActions: false, testDir: 'tests', language: 'TypeScript', installPlaywrightDependencies: false, installPlaywrightBrowsers: false });

expect(fs.existsSync(path.join(dir, 'tests/seed.spec.ts'))).toBeTruthy();

const seedSpecContent = fs.readFileSync(path.join(dir, 'tests/seed.spec.ts'), 'utf8');
expect(seedSpecContent).toContain('test(\'seed\', async ({ page }) => {');
expect(seedSpecContent).toContain('// generate code here.');

// Verify that example.spec.ts is NOT created when agents option is used
expect(fs.existsSync(path.join(dir, 'tests/example.spec.ts'))).toBeFalsy();

// Verify other expected files are still created
expect(fs.existsSync(path.join(dir, 'package.json'))).toBeTruthy();
expect(fs.existsSync(path.join(dir, 'playwright.config.ts'))).toBeTruthy();
});

test('should create seed.spec.js file when --agents=vscode is specified with JavaScript', async ({ run, dir, packageManager }) => {
test.skip(packageManager !== 'npm');

await run(['--agents=vscode', '--next'], { installGitHubActions: false, testDir: 'tests', language: 'JavaScript', installPlaywrightDependencies: false, installPlaywrightBrowsers: false });

// Verify that seed.spec.js file is still created before the command fails
expect(fs.existsSync(path.join(dir, 'tests/seed.spec.js'))).toBeTruthy();

// Verify that the seed.spec.js file has the expected content
const seedSpecContent = fs.readFileSync(path.join(dir, 'tests/seed.spec.js'), 'utf8');
expect(seedSpecContent).toContain('test(\'seed\', async ({ page }) => {');
expect(seedSpecContent).toContain('// generate code here.');

// Verify that example.spec.js is NOT created when agents option is used
expect(fs.existsSync(path.join(dir, 'tests/example.spec.js'))).toBeFalsy();

// Verify other expected files are still created
expect(fs.existsSync(path.join(dir, 'package.json'))).toBeTruthy();
expect(fs.existsSync(path.join(dir, 'playwright.config.js'))).toBeTruthy();
});
Loading