|
f7eb47b…
|
lmata
|
1 |
"use strict"; |
|
f7eb47b…
|
lmata
|
2 |
var __create = Object.create; |
|
f7eb47b…
|
lmata
|
3 |
var __defProp = Object.defineProperty; |
|
f7eb47b…
|
lmata
|
4 |
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; |
|
f7eb47b…
|
lmata
|
5 |
var __getOwnPropNames = Object.getOwnPropertyNames; |
|
f7eb47b…
|
lmata
|
6 |
var __getProtoOf = Object.getPrototypeOf; |
|
f7eb47b…
|
lmata
|
7 |
var __hasOwnProp = Object.prototype.hasOwnProperty; |
|
f7eb47b…
|
lmata
|
8 |
var __export = (target, all) => { |
|
f7eb47b…
|
lmata
|
9 |
for (var name in all) |
|
f7eb47b…
|
lmata
|
10 |
__defProp(target, name, { get: all[name], enumerable: true }); |
|
f7eb47b…
|
lmata
|
11 |
}; |
|
f7eb47b…
|
lmata
|
12 |
var __copyProps = (to, from, except, desc) => { |
|
f7eb47b…
|
lmata
|
13 |
if (from && typeof from === "object" || typeof from === "function") { |
|
f7eb47b…
|
lmata
|
14 |
for (let key of __getOwnPropNames(from)) |
|
f7eb47b…
|
lmata
|
15 |
if (!__hasOwnProp.call(to, key) && key !== except) |
|
f7eb47b…
|
lmata
|
16 |
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); |
|
f7eb47b…
|
lmata
|
17 |
} |
|
f7eb47b…
|
lmata
|
18 |
return to; |
|
f7eb47b…
|
lmata
|
19 |
}; |
|
f7eb47b…
|
lmata
|
20 |
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( |
|
f7eb47b…
|
lmata
|
21 |
// If the importer is in node compatibility mode or this is not an ESM |
|
f7eb47b…
|
lmata
|
22 |
// file that has been converted to a CommonJS file using a Babel- |
|
f7eb47b…
|
lmata
|
23 |
// compatible transform (i.e. "__esModule" has not been set), then set |
|
f7eb47b…
|
lmata
|
24 |
// "default" to the CommonJS "module.exports" for node compatibility. |
|
f7eb47b…
|
lmata
|
25 |
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, |
|
f7eb47b…
|
lmata
|
26 |
mod |
|
f7eb47b…
|
lmata
|
27 |
)); |
|
f7eb47b…
|
lmata
|
28 |
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); |
|
f7eb47b…
|
lmata
|
29 |
var seed_exports = {}; |
|
f7eb47b…
|
lmata
|
30 |
__export(seed_exports, { |
|
f7eb47b…
|
lmata
|
31 |
defaultSeedFile: () => defaultSeedFile, |
|
f7eb47b…
|
lmata
|
32 |
ensureSeedFile: () => ensureSeedFile, |
|
f7eb47b…
|
lmata
|
33 |
findSeedFile: () => findSeedFile, |
|
f7eb47b…
|
lmata
|
34 |
seedFileContent: () => seedFileContent, |
|
f7eb47b…
|
lmata
|
35 |
seedProject: () => seedProject |
|
f7eb47b…
|
lmata
|
36 |
}); |
|
f7eb47b…
|
lmata
|
37 |
module.exports = __toCommonJS(seed_exports); |
|
f7eb47b…
|
lmata
|
38 |
var import_fs = __toESM(require("fs")); |
|
f7eb47b…
|
lmata
|
39 |
var import_path = __toESM(require("path")); |
|
f7eb47b…
|
lmata
|
40 |
var import_utils = require("playwright-core/lib/utils"); |
|
f7eb47b…
|
lmata
|
41 |
var import_projectUtils = require("../../runner/projectUtils"); |
|
f7eb47b…
|
lmata
|
42 |
function seedProject(config, projectName) { |
|
f7eb47b…
|
lmata
|
43 |
if (!projectName) |
|
f7eb47b…
|
lmata
|
44 |
return (0, import_projectUtils.findTopLevelProjects)(config)[0]; |
|
f7eb47b…
|
lmata
|
45 |
const project = config.projects.find((p) => p.project.name === projectName); |
|
f7eb47b…
|
lmata
|
46 |
if (!project) |
|
f7eb47b…
|
lmata
|
47 |
throw new Error(`Project ${projectName} not found`); |
|
f7eb47b…
|
lmata
|
48 |
return project; |
|
f7eb47b…
|
lmata
|
49 |
} |
|
f7eb47b…
|
lmata
|
50 |
async function findSeedFile(project) { |
|
f7eb47b…
|
lmata
|
51 |
const files = await (0, import_projectUtils.collectFilesForProject)(project); |
|
f7eb47b…
|
lmata
|
52 |
return files.find((file) => import_path.default.basename(file).includes("seed")); |
|
f7eb47b…
|
lmata
|
53 |
} |
|
f7eb47b…
|
lmata
|
54 |
function defaultSeedFile(project) { |
|
f7eb47b…
|
lmata
|
55 |
const testDir = project.project.testDir; |
|
f7eb47b…
|
lmata
|
56 |
return import_path.default.resolve(testDir, "seed.spec.ts"); |
|
f7eb47b…
|
lmata
|
57 |
} |
|
f7eb47b…
|
lmata
|
58 |
async function ensureSeedFile(project) { |
|
f7eb47b…
|
lmata
|
59 |
const seedFile = await findSeedFile(project); |
|
f7eb47b…
|
lmata
|
60 |
if (seedFile) |
|
f7eb47b…
|
lmata
|
61 |
return seedFile; |
|
f7eb47b…
|
lmata
|
62 |
const seedFilePath = defaultSeedFile(project); |
|
f7eb47b…
|
lmata
|
63 |
await (0, import_utils.mkdirIfNeeded)(seedFilePath); |
|
f7eb47b…
|
lmata
|
64 |
await import_fs.default.promises.writeFile(seedFilePath, seedFileContent); |
|
f7eb47b…
|
lmata
|
65 |
return seedFilePath; |
|
f7eb47b…
|
lmata
|
66 |
} |
|
f7eb47b…
|
lmata
|
67 |
const seedFileContent = `import { test, expect } from '@playwright/test'; |
|
f7eb47b…
|
lmata
|
68 |
|
|
f7eb47b…
|
lmata
|
69 |
test.describe('Test group', () => { |
|
f7eb47b…
|
lmata
|
70 |
test('seed', async ({ page }) => { |
|
f7eb47b…
|
lmata
|
71 |
// generate code here. |
|
f7eb47b…
|
lmata
|
72 |
}); |
|
f7eb47b…
|
lmata
|
73 |
}); |
|
f7eb47b…
|
lmata
|
74 |
`; |
|
f7eb47b…
|
lmata
|
75 |
// Annotate the CommonJS export names for ESM import in node: |
|
f7eb47b…
|
lmata
|
76 |
0 && (module.exports = { |
|
f7eb47b…
|
lmata
|
77 |
defaultSeedFile, |
|
f7eb47b…
|
lmata
|
78 |
ensureSeedFile, |
|
f7eb47b…
|
lmata
|
79 |
findSeedFile, |
|
f7eb47b…
|
lmata
|
80 |
seedFileContent, |
|
f7eb47b…
|
lmata
|
81 |
seedProject |
|
f7eb47b…
|
lmata
|
82 |
}); |