@sridharkikkeri/playwright-common 1.0.18 → 1.0.19

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.
@@ -56,7 +56,7 @@ const packageJson = {
56
56
  'lint:fix': 'eslint . --fix'
57
57
  },
58
58
  dependencies: {
59
- '@sridharkikkeri/playwright-common': '^1.0.18',
59
+ '@sridharkikkeri/playwright-common': '^1.0.19',
60
60
  '@playwright/test': '^1.42.0',
61
61
  'allure-playwright': '^3.4.5'
62
62
  },
@@ -76,8 +76,6 @@ const apiClientTs = `import { ApiClient as CommonApiClient } from '@sridharkikke
76
76
 
77
77
  /**
78
78
  * Enterprise API Client.
79
- * Use this class to add project-specific headers,
80
- * authentication tokens, or shared response validation.
81
79
  */
82
80
  export class ApiClient extends CommonApiClient {
83
81
  constructor(baseUrl: string) {
@@ -85,7 +83,7 @@ export class ApiClient extends CommonApiClient {
85
83
  }
86
84
 
87
85
  async getWithAuth(endpoint: string) {
88
- const token = 'YOUR_AUTH_TOKEN'; // Replace with real auth logic
86
+ const token = 'YOUR_AUTH_TOKEN';
89
87
  return this.get(endpoint, {
90
88
  headers: { 'Authorization': \`Bearer \${token}\` }
91
89
  });
@@ -102,7 +100,6 @@ const authStrategyTs = `import { CookieAuth, AuthStrategy as CommonAuthStrategy
102
100
 
103
101
  export class AuthStrategy extends CommonAuthStrategy {
104
102
  async login(credentials: any): Promise<void> {
105
- // Implement project-specific login logic here
106
103
  await this.page.goto('/login');
107
104
  await this.page.fill('#username', credentials.username);
108
105
  await this.page.fill('#password', credentials.password);
@@ -167,7 +164,6 @@ fs.writeFileSync(path.join(projectPath, 'src/core/reporting/AllureUtil.ts'), all
167
164
  const locatorHealingTs = `import { LocatorHealing as CommonLocatorHealing } from '@sridharkikkeri/playwright-common';
168
165
 
169
166
  export class LocatorHealing extends CommonLocatorHealing {
170
- // Add project-specific healing logic or custom heuristics here
171
167
  }
172
168
  `;
173
169
  fs.writeFileSync(path.join(projectPath, 'src/core/selfhealing/LocatorHealing.ts'), locatorHealingTs);
@@ -175,7 +171,6 @@ fs.writeFileSync(path.join(projectPath, 'src/core/selfhealing/LocatorHealing.ts'
175
171
  const actionOrchestratorTs = `import { ActionOrchestrator as CommonActionOrchestrator } from '@sridharkikkeri/playwright-common';
176
172
 
177
173
  export class ActionOrchestrator extends CommonActionOrchestrator {
178
- // Extend orchestration logic here
179
174
  }
180
175
  `;
181
176
  fs.writeFileSync(path.join(projectPath, 'src/core/selfhealing/ActionOrchestrator.ts'), actionOrchestratorTs);
@@ -183,9 +178,6 @@ fs.writeFileSync(path.join(projectPath, 'src/core/selfhealing/ActionOrchestrator
183
178
  const visualTestingTs = `import { VisualTesting as CommonVisualTesting } from '@sridharkikkeri/playwright-common';
184
179
 
185
180
  export class VisualTesting extends CommonVisualTesting {
186
- static async verifyFullPage(name: string) {
187
- // Custom full page screenshot logic
188
- }
189
181
  }
190
182
  `;
191
183
  fs.writeFileSync(path.join(projectPath, 'src/core/visual/VisualTesting.ts'), visualTestingTs);
@@ -194,17 +186,12 @@ const elementWrapperTs = `import { ElementWrapper as CommonElementWrapper } from
194
186
 
195
187
  /**
196
188
  * Enterprise Element Wrapper.
197
- * Extend this class to add project-specific element interactions.
198
189
  */
199
190
  export class ElementWrapper extends CommonElementWrapper {
200
191
  async clickAndLog(stepDescription?: string): Promise<void> {
201
192
  console.log(\`[AUTO-LOG] Clicking element: \${stepDescription || 'unknown'}\`);
202
193
  await this.click(stepDescription);
203
194
  }
204
-
205
- async forceFill(value: string, stepDescription?: string): Promise<void> {
206
- await this.locator.fill(value, { force: true });
207
- }
208
195
  }
209
196
  `;
210
197
  fs.writeFileSync(path.join(projectPath, 'src/core/wrappers/ElementWrapper.ts'), elementWrapperTs);
@@ -212,9 +199,6 @@ fs.writeFileSync(path.join(projectPath, 'src/core/wrappers/ElementWrapper.ts'),
212
199
  const loggerTs = `import { Logger as CommonLogger } from '@sridharkikkeri/playwright-common';
213
200
 
214
201
  export class Logger extends CommonLogger {
215
- static info(message: string) {
216
- console.log(\`[INFO] \${message}\`);
217
- }
218
202
  }
219
203
  `;
220
204
  fs.writeFileSync(path.join(projectPath, 'src/core/utils/Logger.ts'), loggerTs);
@@ -222,7 +206,6 @@ fs.writeFileSync(path.join(projectPath, 'src/core/utils/Logger.ts'), loggerTs);
222
206
  const errorUtilsTs = `import { ErrorUtils as CommonErrorUtils } from '@sridharkikkeri/playwright-common';
223
207
 
224
208
  export class ErrorUtils extends CommonErrorUtils {
225
- // Project-specific error handling
226
209
  }
227
210
  `;
228
211
  fs.writeFileSync(path.join(projectPath, 'src/core/utils/ErrorUtils.ts'), errorUtilsTs);
@@ -230,13 +213,11 @@ fs.writeFileSync(path.join(projectPath, 'src/core/utils/ErrorUtils.ts'), errorUt
230
213
  // --- UTILS & I18N POPULATION ---
231
214
  const stringUtilsTs = `export class StringUtils {
232
215
  static capitalize(str: string) { return str.charAt(0).toUpperCase() + str.slice(1); }
233
- static mask(str: string) { return str.replace(/./g, '*'); }
234
216
  }`;
235
217
  fs.writeFileSync(path.join(projectPath, 'src/utils/StringUtils.ts'), stringUtilsTs);
236
218
 
237
219
  const dateUtilsTs = `export class DateUtils {
238
220
  static now() { return new Date().toISOString(); }
239
- static format(date: Date) { return date.toLocaleDateString(); }
240
221
  }`;
241
222
  fs.writeFileSync(path.join(projectPath, 'src/utils/DateUtils.ts'), dateUtilsTs);
242
223
 
@@ -244,47 +225,43 @@ fs.writeFileSync(path.join(projectPath, 'src/i18n/en.json'), JSON.stringify({ "w
244
225
  fs.writeFileSync(path.join(projectPath, 'src/i18n/fr.json'), JSON.stringify({ "welcome": "Bienvenue chez HealthEdge" }, null, 2));
245
226
 
246
227
  // --- DOCUMENTATION ---
247
- fs.writeFileSync(path.join(projectPath, 'api-docs/assets/style.css'), 'body { font-family: sans-serif; padding: 20px; line-height: 1.6; }');
248
- fs.writeFileSync(path.join(projectPath, 'api-docs/index.html'), \`
228
+ fs.writeFileSync(path.join(projectPath, 'api-docs/assets/style.css'), 'body { font-family: sans-serif; padding: 20px; }');
229
+ const indexHtmlContent = `
249
230
  <html>
250
231
  <head>
251
- <title>\${projectName} API Docs</title>
232
+ <title>${projectName} API Docs</title>
252
233
  <link rel="stylesheet" href="assets/style.css">
253
234
  </head>
254
235
  <body>
255
- <h1>\${projectName} - Enterprise API Documentation</h1>
256
- <p>Welcome to the central documentation hub for your Playwright testing project.</p>
257
- <ul>
258
- <li><a href="classes/README.md">Class References</a></li>
259
- <li><a href="interfaces/README.md">Interfaces</a></li>
260
- </ul>
236
+ <h1>${projectName} - Enterprise API Documentation</h1>
237
+ <p>Welcome to the central documentation hub.</p>
261
238
  </body>
262
- </html>\`);
239
+ </html>`;
240
+ fs.writeFileSync(path.join(projectPath, 'api-docs/index.html'), indexHtmlContent);
263
241
 
264
242
  ['classes', 'interfaces', 'types', 'variables'].forEach(fold => {
265
- fs.writeFileSync(path.join(projectPath, \`api-docs/\${fold}/README.md\`), \`# \${fold.toUpperCase()}\\nDetailed documentation for \${fold} in project \${projectName}.\`);
243
+ fs.writeFileSync(path.join(projectPath, `api-docs/${fold}/README.md`), `# ${fold.toUpperCase()}\nDocumentation for ${fold} in ${projectName}.`);
266
244
  });
267
245
 
268
246
  // --- STANDARD CONFIG & EXAMPLES ---
269
247
  const baseConfig = { healingEnabled: true, environment: 'dev', baseUrl: 'https://example.com', apiUrl: 'https://api.example.com', timeout: 30000, retries: 2 };
270
248
  const environments = ['dev', 'qa', 'auto', 'staging', 'prod'];
271
249
  environments.forEach(env => {
272
- const config = { ...baseConfig, environment: env, baseUrl: \`https://\${env}.example.com\`, apiUrl: \`https://api-\${env}.example.com\` };
273
- fs.writeFileSync(path.join(projectPath, \`framework.config.\${env}.json\`), JSON.stringify(config, null, 2));
250
+ const config = { ...baseConfig, environment: env, baseUrl: `https://${env}.example.com`, apiUrl: `https://api-${env}.example.com` };
251
+ fs.writeFileSync(path.join(projectPath, `framework.config.${env}.json`), JSON.stringify(config, null, 2));
274
252
  });
275
253
  fs.writeFileSync(path.join(projectPath, 'framework.config.json'), JSON.stringify(baseConfig, null, 2));
276
254
 
277
- const playwrightConfig = \`import { defineConfig } from '@playwright/test';
255
+ const playwrightConfig = `import { defineConfig } from '@playwright/test';
278
256
  export default defineConfig({
279
257
  testDir: './src/tests',
280
258
  timeout: 30000,
281
- retries: process.env.CI ? 2 : 0,
282
259
  reporter: [['html'], ['allure-playwright', { outputFolder: 'allure-results' }]],
283
260
  use: { trace: 'on-first-retry', screenshot: 'only-on-failure' }
284
- });\`;
261
+ });`;
285
262
  fs.writeFileSync(path.join(projectPath, 'playwright.config.ts'), playwrightConfig);
286
263
 
287
- const fixturesTs = \`import { test as base } from '@sridharkikkeri/playwright-common';
264
+ const fixturesTs = `import { test as base } from '@sridharkikkeri/playwright-common';
288
265
  import { HomePage } from '../pages/HomePage';
289
266
  import { LoginPage } from '../pages/LoginPage';
290
267
 
@@ -293,10 +270,10 @@ export const test = base.extend<{ homePage: HomePage; loginPage: LoginPage }>({
293
270
  loginPage: async ({ page, orchestrator }, use) => { await use(new LoginPage(page, orchestrator)); },
294
271
  });
295
272
 
296
- export { expect } from '@playwright/test';\`;
273
+ export { expect } from '@playwright/test';`;
297
274
  fs.writeFileSync(path.join(projectPath, 'src/fixtures/fixtures.ts'), fixturesTs);
298
275
 
299
- const homePageTs = \`import { Page } from '@playwright/test';
276
+ const homePageTs = `import { Page } from '@playwright/test';
300
277
  import { BasePage } from '../core/pages/BasePage';
301
278
  import { ActionOrchestrator } from '../core/selfhealing/ActionOrchestrator';
302
279
 
@@ -307,10 +284,10 @@ export class HomePage extends BasePage {
307
284
  private readonly searchBtn = this.element('button[type="submit"]');
308
285
  async clickSearch() { await this.searchBtn.click('Click Search Button'); }
309
286
  }
310
- \`;
287
+ `;
311
288
  fs.writeFileSync(path.join(projectPath, 'src/pages/HomePage.ts'), homePageTs);
312
289
 
313
- const loginPageTs = \`import { Page } from '@playwright/test';
290
+ const loginPageTs = `import { Page } from '@playwright/test';
314
291
  import { BasePage } from '../core/pages/BasePage';
315
292
  import { ActionOrchestrator } from '../core/selfhealing/ActionOrchestrator';
316
293
 
@@ -318,20 +295,11 @@ export class LoginPage extends BasePage {
318
295
  constructor(page: Page, orchestrator?: ActionOrchestrator) {
319
296
  super(page, { pageName: 'LoginPage', orchestrator });
320
297
  }
321
- private readonly userField = this.element('#user');
322
- private readonly passField = this.element('#pass');
323
- private readonly loginBtn = this.element('#login');
324
-
325
- async login(u: string, p: string) {
326
- await this.userField.fill(u, 'Enter username');
327
- await this.passField.fill(p, 'Enter password');
328
- await this.loginBtn.click('Click Login');
329
- }
330
298
  }
331
- \`;
299
+ `;
332
300
  fs.writeFileSync(path.join(projectPath, 'src/pages/LoginPage.ts'), loginPageTs);
333
301
 
334
- const visualTest = \`import { test, expect } from '../fixtures/fixtures';
302
+ const visualTest = `import { test, expect } from '../fixtures/fixtures';
335
303
 
336
304
  test.describe('Enterprise Visual Regression', () => {
337
305
  test('HP Visual Verification', async ({ page }) => {
@@ -341,27 +309,27 @@ test.describe('Enterprise Visual Regression', () => {
341
309
  threshold: 0.1
342
310
  });
343
311
  });
344
- });\`;
312
+ });`;
345
313
  fs.writeFileSync(path.join(projectPath, 'src/tests/visual.spec.ts'), visualTest);
346
314
 
347
- const sampleTest = \`import { test, expect } from '../fixtures/fixtures';
315
+ const sampleTest = `import { test, expect } from '../fixtures/fixtures';
348
316
 
349
- test('Standard Smoke Test', async ({ page, loginPage }) => {
317
+ test('Standard Smoke Test', async ({ page }) => {
350
318
  await page.goto('https://playwright.dev');
351
319
  await expect(page).toHaveTitle(/Playwright/);
352
- });\`;
320
+ });`;
353
321
  fs.writeFileSync(path.join(projectPath, 'src/tests/sample.spec.ts'), sampleTest);
354
322
 
355
- const tsConfig = {
356
- compilerOptions: {
357
- target: 'ES2020', module: 'commonjs', lib: ['ES2020', 'DOM'],
358
- strict: true, esModuleInterop: true, skipLibCheck: true, resolveJsonModule: true
359
- },
360
- include: ['src/**/*']
323
+ const tsConfig = {
324
+ compilerOptions: {
325
+ target: 'ES2020', module: 'commonjs', lib: ['ES2020', 'DOM'],
326
+ strict: true, esModuleInterop: true, skipLibCheck: true, resolveJsonModule: true
327
+ },
328
+ include: ['src/**/*']
361
329
  };
362
330
  fs.writeFileSync(path.join(projectPath, 'tsconfig.json'), JSON.stringify(tsConfig, null, 2));
363
331
 
364
- const gitignore = \`node_modules/
332
+ const gitignore = `node_modules/
365
333
  allure-results/
366
334
  allure-report/
367
335
  test-results/
@@ -369,35 +337,27 @@ playwright-report/
369
337
  .env
370
338
  *.log
371
339
  dist/
372
- \`;
340
+ `;
373
341
  fs.writeFileSync(path.join(projectPath, '.gitignore'), gitignore);
374
342
 
375
- const readme = \`# \${projectName}
376
-
377
- ## Overview
378
- Enterprise automation test project powered by **@sridharkikkeri/playwright-common**.
343
+ const readme = `# ${projectName}
379
344
 
380
345
  ## Getting Started
381
- \\\`\\\`\\\`bash
346
+ \`\`\`bash
382
347
  npm install
383
348
  npm run test:dev
384
- \\\`\\\`\\\`
385
-
386
- ## Features
387
- - **Self-Healing**: Powered by AI Action Orchestrator
388
- - **Visual Regression**: Built-in screenshot comparison
389
- - **Enterprise Reporting**: Allure reporting with custom steps
390
- \`;
349
+ \`\`\`
350
+ `;
391
351
  fs.writeFileSync(path.join(projectPath, 'README.md'), readme);
392
352
 
393
353
  console.log('āœ… Comprehensive Project Structure Created');
394
- console.log('\\nšŸ“¦ Installing dependencies...\\n');
354
+ console.log('\nšŸ“¦ Installing dependencies...\n');
395
355
 
396
356
  try {
397
357
  execSync('npm install', { cwd: projectPath, stdio: 'inherit' });
398
- console.log('\\nāœ… Dependencies installed');
358
+ console.log('\nāœ… Dependencies installed');
399
359
  } catch (error) {
400
- console.log('\\nāš ļø npm install failed. Please run manually.');
360
+ console.log('\nāš ļø npm install failed. Please run manually.');
401
361
  }
402
362
 
403
- console.log(\`\\nšŸŽ‰ Project ready! cd \${projectName} and try: npm run test:dev\\n\`);
363
+ console.log(`\nšŸŽ‰ Project ready! cd ${projectName} and try: npm run test:dev\n`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sridharkikkeri/playwright-common",
3
- "version": "1.0.18",
3
+ "version": "1.0.19",
4
4
  "description": "Production-grade Playwright framework with AI-powered self-healing, visual regression, and enterprise features",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",