simple-playwright-framework 0.0.10 → 0.0.11
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 +1 -1
- package/scripts/init-demo-project.js +55 -3
package/package.json
CHANGED
|
@@ -168,6 +168,19 @@ writeFileSafe(path.join(demoDir, "storage/authStorage.json"),
|
|
|
168
168
|
);
|
|
169
169
|
|
|
170
170
|
// -------------------- Tests --------------------
|
|
171
|
+
// Login basic test
|
|
172
|
+
writeFileSafe(path.join(demoDir, "tests/login/login.test.ts"),
|
|
173
|
+
`import { test, expect } from 'simple-playwright-framework';
|
|
174
|
+
test('login with Admin user @smoke', async ({ page, envConfig, td }) => {
|
|
175
|
+
await page.goto(envConfig.baseUrl);
|
|
176
|
+
await page.fill('input[name="username"]', td.users.admin.username);
|
|
177
|
+
await page.fill('input[name="password"]', td.users.admin.password);
|
|
178
|
+
await page.click('button[type="submit"]');
|
|
179
|
+
await expect(page).toHaveURL(/dashboard/);
|
|
180
|
+
});
|
|
181
|
+
`);
|
|
182
|
+
|
|
183
|
+
// Login scenarios
|
|
171
184
|
writeFileSafe(path.join(demoDir, "tests/login/login.scenarios.spec.ts"),
|
|
172
185
|
`import { test, expect, scenarioLoader, initAuthSession } from 'simple-playwright-framework';
|
|
173
186
|
import { providerRegistry } from '@demo-project/auth';
|
|
@@ -187,6 +200,36 @@ test.describe.parallel("Login scenarios", () => {
|
|
|
187
200
|
});
|
|
188
201
|
`);
|
|
189
202
|
|
|
203
|
+
// Login with auth storage
|
|
204
|
+
writeFileSafe(path.join(demoDir, "tests/login/loginwithauthstorage.spec.ts"),
|
|
205
|
+
`import { test, expect, initAuthSession } from 'simple-playwright-framework';
|
|
206
|
+
import { providerRegistry } from '@demo-project/auth';
|
|
207
|
+
test('login with Admin user using Auth Storage', async ({ page, envConfig, td }) => {
|
|
208
|
+
await page.goto(envConfig.baseUrl);
|
|
209
|
+
await initAuthSession(page, envConfig.authStorage!, { username: td.users.admin.username, password: td.users.admin.password }, providerRegistry);
|
|
210
|
+
await expect(page).toHaveURL(/dashboard/);
|
|
211
|
+
});
|
|
212
|
+
`);
|
|
213
|
+
|
|
214
|
+
// Login with TestRail reporting
|
|
215
|
+
writeFileSafe(path.join(demoDir, "tests/login/login.testrail.spec.ts"),
|
|
216
|
+
`import { test, expect } from 'simple-playwright-framework';
|
|
217
|
+
test('Login linked to TestRail case C1234', async ({ page, envConfig, testrail }) => {
|
|
218
|
+
await page.goto(envConfig.baseUrl);
|
|
219
|
+
await page.fill('input[name="username"]', 'Admin');
|
|
220
|
+
await page.fill('input[name="password"]', 'admin123');
|
|
221
|
+
await page.click('button[type="submit"]');
|
|
222
|
+
try {
|
|
223
|
+
await expect(page).toHaveURL(/dashboard/);
|
|
224
|
+
await testrail.addResult(1234, 1, "Login passed ✅");
|
|
225
|
+
} catch (err) {
|
|
226
|
+
await testrail.addResult(1234, 5, "Login failed ❌");
|
|
227
|
+
throw err;
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
`);
|
|
231
|
+
|
|
232
|
+
// File handling test
|
|
190
233
|
writeFileSafe(path.join(demoDir, "tests/filehandling/filehandling.spec.ts"),
|
|
191
234
|
`import { test, expect } from 'simple-playwright-framework';
|
|
192
235
|
|
|
@@ -204,6 +247,7 @@ test("upload and download demo", async ({ page, fileUtils }) => {
|
|
|
204
247
|
});
|
|
205
248
|
`);
|
|
206
249
|
|
|
250
|
+
// API test
|
|
207
251
|
writeFileSafe(path.join(demoDir, "tests/api/api.test.ts"),
|
|
208
252
|
`import { test, expect } from 'simple-playwright-framework';
|
|
209
253
|
test('sample API call', async ({ request, envConfig }) => {
|
|
@@ -213,7 +257,15 @@ test('sample API call', async ({ request, envConfig }) => {
|
|
|
213
257
|
});
|
|
214
258
|
`);
|
|
215
259
|
|
|
216
|
-
//
|
|
260
|
+
// Reporting example
|
|
261
|
+
writeFileSafe(path.join(demoDir, "tests/reporting/testrail.test.ts"),
|
|
262
|
+
`import { test } from 'simple-playwright-framework';
|
|
263
|
+
test('reporting example', async ({ testrail }) => {
|
|
264
|
+
await testrail.addResult(5678, 1, "Reporting fixture works ✅");
|
|
265
|
+
});
|
|
266
|
+
`);
|
|
267
|
+
|
|
268
|
+
// README
|
|
217
269
|
writeFileSafe(path.join(demoDir, "README.md"),
|
|
218
270
|
`# Demo Project
|
|
219
271
|
|
|
@@ -224,6 +276,7 @@ This is a scaffolded Playwright demo project using **simple-playwright-framework
|
|
|
224
276
|
- ✅ API test using jsonplaceholder
|
|
225
277
|
- ✅ File upload & download test with FileUtils
|
|
226
278
|
- ✅ Auth storage example
|
|
279
|
+
- ✅ TestRail reporting example
|
|
227
280
|
|
|
228
281
|
## Usage
|
|
229
282
|
- Run \`npm run init\` to scaffold the project
|
|
@@ -231,7 +284,7 @@ This is a scaffolded Playwright demo project using **simple-playwright-framework
|
|
|
231
284
|
- Run \`npm run build\` to compile TypeScript
|
|
232
285
|
`);
|
|
233
286
|
|
|
234
|
-
//
|
|
287
|
+
// Final step: install deps + build
|
|
235
288
|
try {
|
|
236
289
|
console.log("🚀 Installing dependencies and building demo-project...");
|
|
237
290
|
run("npm install", demoDir);
|
|
@@ -241,4 +294,3 @@ try {
|
|
|
241
294
|
console.error("❌ Init failed:", err.message);
|
|
242
295
|
process.exit(1);
|
|
243
296
|
}
|
|
244
|
-
|