simple-playwright-framework 0.0.5 ā 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/scripts/init-demo-project.js +99 -66
- package/scripts/init-framework-project.js +136 -60
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "simple-playwright-framework",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "A modular Playwright framework with fixtures, loaders, and demo scaffolding.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"report": "playwright show-report"
|
|
14
14
|
},
|
|
15
15
|
"bin": {
|
|
16
|
-
"init-framework-project": "
|
|
17
|
-
"init-demo-project": "
|
|
16
|
+
"init-framework-project": "scripts/init-framework-project.js",
|
|
17
|
+
"init-demo-project": "scripts/init-demo-project.js"
|
|
18
18
|
},
|
|
19
19
|
"files": [
|
|
20
20
|
"dist/**/*",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
1
|
+
#!/usr/bin/env node
|
|
2
2
|
const fs = require("fs");
|
|
3
3
|
const path = require("path");
|
|
4
4
|
|
|
@@ -6,62 +6,82 @@ const cwd = process.cwd();
|
|
|
6
6
|
const demoDir = path.join(cwd, "demo-project");
|
|
7
7
|
fs.mkdirSync(demoDir, { recursive: true });
|
|
8
8
|
|
|
9
|
+
function writeFileSafe(filePath, content) {
|
|
10
|
+
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
11
|
+
fs.writeFileSync(filePath, content);
|
|
12
|
+
console.log(`š Created: ${filePath}`);
|
|
13
|
+
}
|
|
14
|
+
|
|
9
15
|
// package.json
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
16
|
+
writeFileSafe(path.join(demoDir, "package.json"),
|
|
17
|
+
JSON.stringify({
|
|
18
|
+
name: "demo-project",
|
|
19
|
+
version: "1.0.0",
|
|
20
|
+
private: true,
|
|
21
|
+
scripts: { test: "playwright test" },
|
|
22
|
+
devDependencies: {
|
|
23
|
+
"@playwright/test": "^1.58.2",
|
|
24
|
+
"simple-playwright-framework": "latest"
|
|
25
|
+
}
|
|
26
|
+
}, null, 2)
|
|
27
|
+
);
|
|
20
28
|
|
|
21
29
|
// playwright.config.ts
|
|
22
|
-
|
|
23
|
-
export default defineConfig({
|
|
24
|
-
testDir: './tests',
|
|
25
|
-
reporter: [['html']],
|
|
26
|
-
});
|
|
30
|
+
writeFileSafe(path.join(demoDir, "playwright.config.ts"), `import { defineConfig } from '@playwright/test';
|
|
31
|
+
export default defineConfig({ testDir: './tests', reporter: [['html']] });
|
|
27
32
|
`);
|
|
28
33
|
|
|
29
34
|
// config
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
// data
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
35
|
+
writeFileSafe(path.join(demoDir, "config/environments.json"),
|
|
36
|
+
JSON.stringify({
|
|
37
|
+
defaults: { timeout: 30000, retries: 1, autoLaunch: false },
|
|
38
|
+
dev: { baseUrl: "https://dev.orangehrm.example.com", authStorage: { enabled: true, provider: "OrangeHRMLogin" } },
|
|
39
|
+
qa: { baseUrl: "https://qa.orangehrm.example.com", authStorage: { enabled: true, provider: "OrangeHRMLogin" } },
|
|
40
|
+
prod: { baseUrl: "https://opensource-demo.orangehrmlive.com/", authStorage: { enabled: true, provider: "OrangeHRMLogin" } }
|
|
41
|
+
}, null, 2)
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
// data/login
|
|
45
|
+
writeFileSafe(path.join(demoDir, "data/login/login.json"),
|
|
46
|
+
JSON.stringify({
|
|
47
|
+
prod: {
|
|
48
|
+
users: {
|
|
49
|
+
admin: { username: "Admin", password: "admin123" },
|
|
50
|
+
employee: { username: "Emp", password: "emp123" },
|
|
51
|
+
locked: { username: "LockedUser", password: "locked123" },
|
|
52
|
+
problem: { username: "ProblemUser", password: "problem123" }
|
|
53
|
+
}
|
|
48
54
|
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
}, null, 2)
|
|
56
|
+
);
|
|
57
|
+
writeFileSafe(path.join(demoDir, "data/login/login.scenarios.json"),
|
|
58
|
+
JSON.stringify({
|
|
59
|
+
prod: [
|
|
60
|
+
{ name: "Valid login", url: "https://opensource-demo.orangehrmlive.com/", username: "Admin", password: "admin123", expected: "success", tags: ["smoke"] },
|
|
61
|
+
{ name: "Invalid login", url: "https://opensource-demo.orangehrmlive.com/", username: "WrongUser", password: "WrongPass", expected: "failure", tags: ["negative"] },
|
|
62
|
+
{ name: "Valid login Two", url: "https://opensource-demo.orangehrmlive.com/", username: "akshay.emp.61499", password: "October@2020", expected: "success", tags: ["regression","positive"] }
|
|
63
|
+
]
|
|
64
|
+
}, null, 2)
|
|
65
|
+
);
|
|
66
|
+
writeFileSafe(path.join(demoDir, "data/login/loginwithauthstorage.json"),
|
|
67
|
+
JSON.stringify({ prod: { users: { admin: { username: "Admin", password: "admin123" } } } }, null, 2)
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
// data/api
|
|
71
|
+
writeFileSafe(path.join(demoDir, "data/api/payload.json"),
|
|
72
|
+
JSON.stringify({ createUser: { username: "demoUser", password: "demoPass" } }, null, 2)
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
// data/ui
|
|
76
|
+
writeFileSafe(path.join(demoDir, "data/ui/sample.txt"), "This is a sample file used for upload tests.\n");
|
|
77
|
+
|
|
78
|
+
// storage
|
|
79
|
+
writeFileSafe(path.join(demoDir, "storage/authStorage.json"),
|
|
80
|
+
JSON.stringify({ session: { validityMinutes: 30, provider: "OrangeHRMLogin" } }, null, 2)
|
|
81
|
+
);
|
|
60
82
|
|
|
61
83
|
// auth
|
|
62
|
-
|
|
63
|
-
fs.mkdirSync(authDir, { recursive: true });
|
|
64
|
-
fs.writeFileSync(path.join(authDir, "orangehrm.login.ts"), `import { Page } from '@playwright/test';
|
|
84
|
+
writeFileSafe(path.join(demoDir, "auth/orangehrm.login.ts"), `import { Page } from '@playwright/test';
|
|
65
85
|
import { AuthProvider } from 'simple-playwright-framework/fixtures/src/types/auth';
|
|
66
86
|
export class OrangeHRMLogin implements AuthProvider {
|
|
67
87
|
constructor(private creds: { username: string; password: string }) {}
|
|
@@ -74,19 +94,8 @@ export class OrangeHRMLogin implements AuthProvider {
|
|
|
74
94
|
}
|
|
75
95
|
`);
|
|
76
96
|
|
|
77
|
-
//
|
|
78
|
-
|
|
79
|
-
fs.mkdirSync(storageDir, { recursive: true });
|
|
80
|
-
fs.writeFileSync(path.join(storageDir, "authStorage.json"), JSON.stringify({
|
|
81
|
-
session: { validityMinutes: 30, provider: "OrangeHRMLogin" }
|
|
82
|
-
}, null, 2));
|
|
83
|
-
|
|
84
|
-
// tests
|
|
85
|
-
const testsDir = path.join(demoDir, "tests");
|
|
86
|
-
fs.mkdirSync(path.join(testsDir, "login"), { recursive: true });
|
|
87
|
-
fs.mkdirSync(path.join(testsDir, "filehandling"), { recursive: true });
|
|
88
|
-
|
|
89
|
-
fs.writeFileSync(path.join(testsDir, "login/login.test.ts"), `import { test, expect } from 'simple-playwright-framework';
|
|
97
|
+
// tests/login
|
|
98
|
+
writeFileSafe(path.join(demoDir, "tests/login/login.test.ts"), `import { test, expect } from 'simple-playwright-framework';
|
|
90
99
|
test('login with Admin user @smoke', async ({ page, envConfig, td }) => {
|
|
91
100
|
await page.goto(envConfig.baseUrl);
|
|
92
101
|
await page.fill('input[name="username"]', td.users.admin.username);
|
|
@@ -96,7 +105,7 @@ test('login with Admin user @smoke', async ({ page, envConfig, td }) => {
|
|
|
96
105
|
});
|
|
97
106
|
`);
|
|
98
107
|
|
|
99
|
-
|
|
108
|
+
writeFileSafe(path.join(demoDir, "tests/login/login.scenarios.spec.ts"), `import { test, expect, scenarioLoader, initAuthSession } from 'simple-playwright-framework';
|
|
100
109
|
import { providerRegistry } from '@project/auth';
|
|
101
110
|
const scenarios = scenarioLoader(__filename);
|
|
102
111
|
test.describe.parallel("Login scenarios", () => {
|
|
@@ -114,7 +123,7 @@ test.describe.parallel("Login scenarios", () => {
|
|
|
114
123
|
});
|
|
115
124
|
`);
|
|
116
125
|
|
|
117
|
-
|
|
126
|
+
writeFileSafe(path.join(demoDir, "tests/login/loginwithauthstorage.spec.ts"), `import { test, expect, initAuthSession } from 'simple-playwright-framework';
|
|
118
127
|
import { providerRegistry } from '@project/auth';
|
|
119
128
|
test('login with Admin user using Auth Storage', async ({ page, envConfig, td }) => {
|
|
120
129
|
await page.goto(envConfig.baseUrl);
|
|
@@ -123,7 +132,7 @@ test('login with Admin user using Auth Storage', async ({ page, envConfig, td })
|
|
|
123
132
|
});
|
|
124
133
|
`);
|
|
125
134
|
|
|
126
|
-
|
|
135
|
+
writeFileSafe(path.join(demoDir, "tests/login/login.testrail.spec.ts"), `import { test, expect } from 'simple-playwright-framework';
|
|
127
136
|
test('Login linked to TestRail case C1234', async ({ page, envConfig, testrail }) => {
|
|
128
137
|
await page.goto(envConfig.baseUrl);
|
|
129
138
|
await page.fill('input[name="username"]', 'Admin');
|
|
@@ -139,7 +148,8 @@ test('Login linked to TestRail case C1234', async ({ page, envConfig, testrail }
|
|
|
139
148
|
});
|
|
140
149
|
`);
|
|
141
150
|
|
|
142
|
-
|
|
151
|
+
// tests/filehandling
|
|
152
|
+
writeFileSafe(path.join(demoDir, "tests/filehandling/filehandling.spec.ts"), `import { test } from 'simple-playwright-framework/fixtures';
|
|
143
153
|
test("upload and download demo", async ({ page, fileUtils }) => {
|
|
144
154
|
await page.goto("https://the-internet.herokuapp.com/upload");
|
|
145
155
|
await fileUtils.uploadFile("#file-upload", "data/ui/sample.txt");
|
|
@@ -150,4 +160,27 @@ test("upload and download demo", async ({ page, fileUtils }) => {
|
|
|
150
160
|
});
|
|
151
161
|
`);
|
|
152
162
|
|
|
153
|
-
|
|
163
|
+
// tests/api
|
|
164
|
+
writeFileSafe(path.join(demoDir, "tests/api/api.test.ts"), `import { test, expect } from 'simple-playwright-framework';
|
|
165
|
+
test('sample API call', async ({ request, envConfig }) => {
|
|
166
|
+
const response = await request.get(\`\${envConfig.baseUrl}/api/health\`);
|
|
167
|
+
expect(response.status()).toBe(200);
|
|
168
|
+
});
|
|
169
|
+
`);
|
|
170
|
+
|
|
171
|
+
// tests/utils
|
|
172
|
+
writeFileSafe(path.join(demoDir, "tests/utils/fileutils.test.ts"), `import { test } from 'simple-playwright-framework/fixtures';
|
|
173
|
+
test('use fileUtils directly', async ({ fileUtils }) => {
|
|
174
|
+
const path = await fileUtils.downloadFile("https://example.com/file.txt");
|
|
175
|
+
console.log("Downloaded:", path);
|
|
176
|
+
});
|
|
177
|
+
`);
|
|
178
|
+
|
|
179
|
+
// tests/reporting
|
|
180
|
+
writeFileSafe(path.join(demoDir, "tests/reporting/testrail.test.ts"), `import { test } from 'simple-playwright-framework';
|
|
181
|
+
test('reporting example', async ({ testrail }) => {
|
|
182
|
+
await testrail.addResult(5678, 1, "Reporting fixture works ā
");
|
|
183
|
+
});
|
|
184
|
+
`);
|
|
185
|
+
|
|
186
|
+
// README
|
|
@@ -1,52 +1,75 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
1
|
+
#!/usr/bin/env node
|
|
2
2
|
const fs = require("fs");
|
|
3
3
|
const path = require("path");
|
|
4
|
+
const readline = require("readline");
|
|
4
5
|
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
6
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
7
|
+
const ask = (q) => new Promise(res => rl.question(q, ans => res(ans.trim())));
|
|
8
|
+
|
|
9
|
+
async function scaffoldFile(filePath, content) {
|
|
10
|
+
if (fs.existsSync(filePath)) {
|
|
11
|
+
console.log(`ā ļø ALERT: ${filePath} already exists.`);
|
|
12
|
+
const ans = await ask(`Do you want to overwrite ${filePath}? (y/N): `);
|
|
13
|
+
if (ans.toLowerCase() !== "y") {
|
|
14
|
+
console.log(`ā Skipped ${filePath}`);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
console.log(`ā
Approved overwrite for ${filePath}`);
|
|
18
|
+
} else {
|
|
19
|
+
const ans = await ask(`Create new file ${filePath}? (y/N): `);
|
|
20
|
+
if (ans.toLowerCase() !== "y") {
|
|
21
|
+
console.log(`ā Skipped ${filePath}`);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
console.log(`ā
Approved creation of ${filePath}`);
|
|
18
25
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
{
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
26
|
+
|
|
27
|
+
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
28
|
+
fs.writeFileSync(filePath, content);
|
|
29
|
+
console.log(`š File created/updated: ${filePath}`);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
(async () => {
|
|
33
|
+
const cwd = process.cwd();
|
|
34
|
+
console.log("š Starting framework integration with confirmations...");
|
|
35
|
+
|
|
36
|
+
// config
|
|
37
|
+
await scaffoldFile(path.join(cwd, "config/environments.json"),
|
|
38
|
+
JSON.stringify({
|
|
39
|
+
defaults: { timeout: 30000, retries: 1, autoLaunch: false },
|
|
40
|
+
qa: { baseUrl: "http://localhost:3000", authStorage: { enabled: true, provider: "OrangeHRMLogin" } }
|
|
41
|
+
}, null, 2)
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
// data/login
|
|
45
|
+
await scaffoldFile(path.join(cwd, "data/login/login.json"),
|
|
46
|
+
JSON.stringify({ qa: { users: { admin: { username: "Admin", password: "admin123" } } } }, null, 2)
|
|
47
|
+
);
|
|
48
|
+
await scaffoldFile(path.join(cwd, "data/login/login.scenarios.json"),
|
|
49
|
+
JSON.stringify({ qa: [
|
|
50
|
+
{ name: "Valid login", username: "Admin", password: "admin123", expected: "success" },
|
|
51
|
+
{ name: "Invalid login", username: "WrongUser", password: "WrongPass", expected: "failure" }
|
|
52
|
+
] }, null, 2)
|
|
53
|
+
);
|
|
54
|
+
await scaffoldFile(path.join(cwd, "data/login/loginwithauthstorage.json"),
|
|
55
|
+
JSON.stringify({ qa: { users: { admin: { username: "Admin", password: "admin123" } } } }, null, 2)
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
// data/api
|
|
59
|
+
await scaffoldFile(path.join(cwd, "data/api/payload.json"),
|
|
60
|
+
JSON.stringify({ createUser: { username: "demoUser", password: "demoPass" } }, null, 2)
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
// data/ui
|
|
64
|
+
await scaffoldFile(path.join(cwd, "data/ui/sample.txt"), "This is a sample file used for upload tests.\n");
|
|
65
|
+
|
|
66
|
+
// storage
|
|
67
|
+
await scaffoldFile(path.join(cwd, "storage/authStorage.json"),
|
|
68
|
+
JSON.stringify({ session: { validityMinutes: 30, provider: "OrangeHRMLogin" } }, null, 2)
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
// auth
|
|
72
|
+
await scaffoldFile(path.join(cwd, "auth/orangehrm.login.ts"), `import { Page } from '@playwright/test';
|
|
50
73
|
import { AuthProvider } from 'simple-playwright-framework/fixtures/src/types/auth';
|
|
51
74
|
export class OrangeHRMLogin implements AuthProvider {
|
|
52
75
|
constructor(private creds: { username: string; password: string }) {}
|
|
@@ -59,19 +82,8 @@ export class OrangeHRMLogin implements AuthProvider {
|
|
|
59
82
|
}
|
|
60
83
|
`);
|
|
61
84
|
|
|
62
|
-
//
|
|
63
|
-
|
|
64
|
-
fs.mkdirSync(storageDir, { recursive: true });
|
|
65
|
-
fs.writeFileSync(path.join(storageDir, "authStorage.json"), JSON.stringify({
|
|
66
|
-
session: { validityMinutes: 30, provider: "OrangeHRMLogin" }
|
|
67
|
-
}, null, 2));
|
|
68
|
-
|
|
69
|
-
// tests
|
|
70
|
-
const testsDir = path.join(demoDir, "tests");
|
|
71
|
-
fs.mkdirSync(path.join(testsDir, "login"), { recursive: true });
|
|
72
|
-
fs.mkdirSync(path.join(testsDir, "filehandling"), { recursive: true });
|
|
73
|
-
|
|
74
|
-
fs.writeFileSync(path.join(testsDir, "login/login.test.ts"), `import { test, expect } from 'simple-playwright-framework';
|
|
85
|
+
// tests/login
|
|
86
|
+
await scaffoldFile(path.join(cwd, "tests/login/login.test.ts"), `import { test, expect } from 'simple-playwright-framework';
|
|
75
87
|
test('login with Admin user @smoke', async ({ page, envConfig, td }) => {
|
|
76
88
|
await page.goto(envConfig.baseUrl);
|
|
77
89
|
await page.fill('input[name="username"]', td.users.admin.username);
|
|
@@ -81,7 +93,7 @@ test('login with Admin user @smoke', async ({ page, envConfig, td }) => {
|
|
|
81
93
|
});
|
|
82
94
|
`);
|
|
83
95
|
|
|
84
|
-
|
|
96
|
+
await scaffoldFile(path.join(cwd, "tests/login/login.scenarios.spec.ts"), `import { test, expect, scenarioLoader, initAuthSession } from 'simple-playwright-framework';
|
|
85
97
|
import { providerRegistry } from '@project/auth';
|
|
86
98
|
const scenarios = scenarioLoader(__filename);
|
|
87
99
|
test.describe.parallel("Login scenarios", () => {
|
|
@@ -99,4 +111,68 @@ test.describe.parallel("Login scenarios", () => {
|
|
|
99
111
|
});
|
|
100
112
|
`);
|
|
101
113
|
|
|
102
|
-
|
|
114
|
+
await scaffoldFile(path.join(cwd, "tests/login/loginwithauthstorage.spec.ts"), `import { test, expect, initAuthSession } from 'simple-playwright-framework';
|
|
115
|
+
import { providerRegistry } from '@project/auth';
|
|
116
|
+
test('login with Admin user using Auth Storage', async ({ page, envConfig, td }) => {
|
|
117
|
+
await page.goto(envConfig.baseUrl);
|
|
118
|
+
await initAuthSession(page, envConfig.authStorage!, { username: td.users.admin.username, password: td.users.admin.password }, providerRegistry);
|
|
119
|
+
await expect(page).toHaveURL(/dashboard/);
|
|
120
|
+
});
|
|
121
|
+
`);
|
|
122
|
+
|
|
123
|
+
await scaffoldFile(path.join(cwd, "tests/login/login.testrail.spec.ts"), `import { test, expect } from 'simple-playwright-framework';
|
|
124
|
+
test('Login linked to TestRail case C1234', async ({ page, envConfig, testrail }) => {
|
|
125
|
+
await page.goto(envConfig.baseUrl);
|
|
126
|
+
await page.fill('input[name="username"]', 'Admin');
|
|
127
|
+
await page.fill('input[name="password"]', 'admin123');
|
|
128
|
+
await page.click('button[type="submit"]');
|
|
129
|
+
try {
|
|
130
|
+
await expect(page).toHaveURL(/dashboard/);
|
|
131
|
+
await testrail.addResult(1234, 1, "Login passed ā
");
|
|
132
|
+
} catch (err) {
|
|
133
|
+
await testrail.addResult(1234, 5, "Login failed ā");
|
|
134
|
+
throw err;
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
`);
|
|
138
|
+
|
|
139
|
+
// tests/filehandling
|
|
140
|
+
await scaffoldFile(path.join(cwd, "tests/filehandling/filehandling.spec.ts"), `import { test } from 'simple-playwright-framework/fixtures';
|
|
141
|
+
test("upload and download demo", async ({ page, fileUtils }) => {
|
|
142
|
+
await page.goto("https://the-internet.herokuapp.com/upload");
|
|
143
|
+
await fileUtils.uploadFile("#file-upload", "data/ui/sample.txt");
|
|
144
|
+
await page.click("#file-submit");
|
|
145
|
+
await page.goto("https://the-internet.herokuapp.com/download");
|
|
146
|
+
const downloadedPath = await fileUtils.downloadFile("a[href*='some-file.txt']");
|
|
147
|
+
console.log("Downloaded file path:", downloadedPath);
|
|
148
|
+
});
|
|
149
|
+
`);
|
|
150
|
+
|
|
151
|
+
// tests/api
|
|
152
|
+
await scaffoldFile(path.join(cwd, "tests/api/api.test.ts"), `import { test, expect } from 'simple-playwright-framework';
|
|
153
|
+
test('sample API call', async ({ request, envConfig }) => {
|
|
154
|
+
const response = await request.get(\`\${envConfig.baseUrl}/api/health\`);
|
|
155
|
+
expect(response.status()).toBe(200);
|
|
156
|
+
});
|
|
157
|
+
`);
|
|
158
|
+
|
|
159
|
+
// tests/utils
|
|
160
|
+
await scaffoldFile(path.join(cwd, "tests/utils/fileutils.test.ts"), `import { test } from 'simple-playwright-framework/fixtures';
|
|
161
|
+
test('use fileUtils directly', async ({ fileUtils }) => {
|
|
162
|
+
const path = await fileUtils.downloadFile("https://example.com/file.txt");
|
|
163
|
+
console.log("Downloaded:", path);
|
|
164
|
+
});
|
|
165
|
+
`);
|
|
166
|
+
|
|
167
|
+
// tests/reporting
|
|
168
|
+
await scaffoldFile(path.join(cwd, "tests/reporting/testrail.test.ts"), `import { test } from 'simple-playwright-framework';
|
|
169
|
+
test('reporting example', async ({ testrail }) => {
|
|
170
|
+
await testrail.addResult(5678, 1, "Reporting fixture works ā
");
|
|
171
|
+
});
|
|
172
|
+
`);
|
|
173
|
+
|
|
174
|
+
rl.close();
|
|
175
|
+
console.log("\nš Framework integration complete with confirmations.");
|
|
176
|
+
console.log("š Next step: commit and push these changes to GitHub:");
|
|
177
|
+
console.log(" git add . && git commit -m \"Integrate Playwright framework\" && git push");
|
|
178
|
+
})();
|