@sridharkikkeri/playwright-common 1.0.17 → 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.17',
59
+ '@sridharkikkeri/playwright-common': '^1.0.19',
60
60
  '@playwright/test': '^1.42.0',
61
61
  'allure-playwright': '^3.4.5'
62
62
  },
@@ -70,95 +70,145 @@ const packageJson = {
70
70
 
71
71
  fs.writeFileSync(path.join(projectPath, 'package.json'), JSON.stringify(packageJson, null, 2));
72
72
 
73
- // --- CORE EXTENSION BOILERPLATE ---
73
+ // --- ENHANCED CORE EXTENSION BOILERPLATE ---
74
74
 
75
- const baseApiClientTs = `import { ApiClient } from '@sridharkikkeri/playwright-common';
75
+ const apiClientTs = `import { ApiClient as CommonApiClient } from '@sridharkikkeri/playwright-common';
76
76
 
77
- export class BaseApiClient extends ApiClient {
77
+ /**
78
+ * Enterprise API Client.
79
+ */
80
+ export class ApiClient extends CommonApiClient {
78
81
  constructor(baseUrl: string) {
79
82
  super(baseUrl);
80
83
  }
81
- // Add shared project-specific headers or logic here
84
+
85
+ async getWithAuth(endpoint: string) {
86
+ const token = 'YOUR_AUTH_TOKEN';
87
+ return this.get(endpoint, {
88
+ headers: { 'Authorization': \`Bearer \${token}\` }
89
+ });
90
+ }
91
+
92
+ async postData(endpoint: string, data: any) {
93
+ return this.post(endpoint, data);
94
+ }
82
95
  }
83
96
  `;
84
- fs.writeFileSync(path.join(projectPath, 'src/core/api/BaseApiClient.ts'), baseApiClientTs);
97
+ fs.writeFileSync(path.join(projectPath, 'src/core/api/ApiClient.ts'), apiClientTs);
85
98
 
86
- const projectAuthTs = `import { CookieAuth, AuthStrategy } from '@sridharkikkeri/playwright-common';
99
+ const authStrategyTs = `import { CookieAuth, AuthStrategy as CommonAuthStrategy } from '@sridharkikkeri/playwright-common';
87
100
 
88
- export class ProjectAuth {
89
- static async setupSession(auth: AuthStrategy) {
90
- // Implement custom complex auth setup if needed
101
+ export class AuthStrategy extends CommonAuthStrategy {
102
+ async login(credentials: any): Promise<void> {
103
+ await this.page.goto('/login');
104
+ await this.page.fill('#username', credentials.username);
105
+ await this.page.fill('#password', credentials.password);
106
+ await this.page.click('#login-btn');
91
107
  }
92
108
  }
93
109
  `;
94
- fs.writeFileSync(path.join(projectPath, 'src/core/api/auth/ProjectAuth.ts'), projectAuthTs);
110
+ fs.writeFileSync(path.join(projectPath, 'src/core/api/auth/AuthStrategy.ts'), authStrategyTs);
95
111
 
96
- const envConfigTs = `import { ConfigManager } from '@sridharkikkeri/playwright-common';
112
+ const configManagerTs = `import { ConfigManager as CommonConfigManager } from '@sridharkikkeri/playwright-common';
97
113
 
98
- export class ProjectConfig extends ConfigManager {
99
- static getClientName() { return 'HealthEdge'; }
114
+ export class ConfigManager extends CommonConfigManager {
115
+ static getEnvironmentConfig() {
116
+ return this.getConfig();
117
+ }
118
+
119
+ static isSelfHealingEnabled() {
120
+ return this.getConfig().healingEnabled ?? true;
121
+ }
100
122
  }
101
123
  `;
102
- fs.writeFileSync(path.join(projectPath, 'src/core/config/ProjectConfig.ts'), envConfigTs);
124
+ fs.writeFileSync(path.join(projectPath, 'src/core/config/ConfigManager.ts'), configManagerTs);
103
125
 
104
- const localizationTs = `import { Localization } from '@sridharkikkeri/playwright-common';
126
+ const localizationTs = `import { Localization as CommonLocalization } from '@sridharkikkeri/playwright-common';
105
127
 
106
- export class ProjectLocalization extends Localization {
107
- static getAvailableLocales() { return ['en', 'fr']; }
128
+ export class Localization extends CommonLocalization {
129
+ static getTranslate(key: string) {
130
+ return this.t(key);
131
+ }
108
132
  }
109
133
  `;
110
- fs.writeFileSync(path.join(projectPath, 'src/core/i18n/ProjectLocalization.ts'), localizationTs);
134
+ fs.writeFileSync(path.join(projectPath, 'src/core/i18n/Localization.ts'), localizationTs);
111
135
 
112
- const baseComponentTs = `import { Page } from '@playwright/test';
113
- import { BasePage, ActionOrchestrator } from '@sridharkikkeri/playwright-common';
136
+ const basePageTs = `import { Page } from '@playwright/test';
137
+ import { BasePage as CommonBasePage, ActionOrchestrator } from '@sridharkikkeri/playwright-common';
114
138
 
115
- export abstract class BaseComponent extends BasePage {
116
- constructor(page: Page, orchestrator?: ActionOrchestrator) {
117
- super(page, { pageName: 'BaseComponent', orchestrator });
139
+ /**
140
+ * Global Base Page for all project Page Objects.
141
+ */
142
+ export abstract class BasePage extends CommonBasePage {
143
+ constructor(page: Page, options?: { pageName: string; orchestrator?: ActionOrchestrator }) {
144
+ super(page, options);
145
+ }
146
+
147
+ async waitForLoadingFinished() {
148
+ await this.page.waitForSelector('.loading-spinner', { state: 'hidden' });
118
149
  }
119
150
  }
120
151
  `;
121
- fs.writeFileSync(path.join(projectPath, 'src/core/pages/BaseComponent.ts'), baseComponentTs);
152
+ fs.writeFileSync(path.join(projectPath, 'src/core/pages/BasePage.ts'), basePageTs);
122
153
 
123
- const reporterTs = `import { AllureUtil } from '@sridharkikkeri/playwright-common';
154
+ const allureUtilTs = `import { AllureUtil as CommonAllureUtil } from '@sridharkikkeri/playwright-common';
124
155
 
125
- export class ProjectReporter {
126
- static async logEnterpriseStep(name: string) {
127
- console.log(\`[ENTERPRISE] \${name}\`);
156
+ export class AllureUtil extends CommonAllureUtil {
157
+ static async captureStep(name: string, body: () => Promise<void>) {
158
+ await this.step(name, body);
128
159
  }
129
160
  }
130
161
  `;
131
- fs.writeFileSync(path.join(projectPath, 'src/core/reporting/ProjectReporter.ts'), reporterTs);
162
+ fs.writeFileSync(path.join(projectPath, 'src/core/reporting/AllureUtil.ts'), allureUtilTs);
163
+
164
+ const locatorHealingTs = `import { LocatorHealing as CommonLocatorHealing } from '@sridharkikkeri/playwright-common';
165
+
166
+ export class LocatorHealing extends CommonLocatorHealing {
167
+ }
168
+ `;
169
+ fs.writeFileSync(path.join(projectPath, 'src/core/selfhealing/LocatorHealing.ts'), locatorHealingTs);
170
+
171
+ const actionOrchestratorTs = `import { ActionOrchestrator as CommonActionOrchestrator } from '@sridharkikkeri/playwright-common';
172
+
173
+ export class ActionOrchestrator extends CommonActionOrchestrator {
174
+ }
175
+ `;
176
+ fs.writeFileSync(path.join(projectPath, 'src/core/selfhealing/ActionOrchestrator.ts'), actionOrchestratorTs);
132
177
 
133
- const healingTs = `import { LocatorHealing } from '@sridharkikkeri/playwright-common';
178
+ const visualTestingTs = `import { VisualTesting as CommonVisualTesting } from '@sridharkikkeri/playwright-common';
134
179
 
135
- export class ProjectHealer extends LocatorHealing {
136
- // Override framework healing logic here
180
+ export class VisualTesting extends CommonVisualTesting {
137
181
  }
138
182
  `;
139
- fs.writeFileSync(path.join(projectPath, 'src/core/selfhealing/ProjectHealer.ts'), healingTs);
183
+ fs.writeFileSync(path.join(projectPath, 'src/core/visual/VisualTesting.ts'), visualTestingTs);
140
184
 
141
- const visualTs = `import { VisualTesting } from '@sridharkikkeri/playwright-common';
185
+ const elementWrapperTs = `import { ElementWrapper as CommonElementWrapper } from '@sridharkikkeri/playwright-common';
142
186
 
143
- export class ProjectVisuals extends VisualTesting {
144
- // Custom exclusions or thresholds
187
+ /**
188
+ * Enterprise Element Wrapper.
189
+ */
190
+ export class ElementWrapper extends CommonElementWrapper {
191
+ async clickAndLog(stepDescription?: string): Promise<void> {
192
+ console.log(\`[AUTO-LOG] Clicking element: \${stepDescription || 'unknown'}\`);
193
+ await this.click(stepDescription);
194
+ }
145
195
  }
146
196
  `;
147
- fs.writeFileSync(path.join(projectPath, 'src/core/visual/ProjectVisuals.ts'), visualTs);
197
+ fs.writeFileSync(path.join(projectPath, 'src/core/wrappers/ElementWrapper.ts'), elementWrapperTs);
148
198
 
149
- const wrapperTs = `import { ElementWrapper } from '@sridharkikkeri/playwright-common';
199
+ const loggerTs = `import { Logger as CommonLogger } from '@sridharkikkeri/playwright-common';
150
200
 
151
- export class ProjectElement extends ElementWrapper {
152
- // Extend element behaviors (e.g., custom scrolls)
201
+ export class Logger extends CommonLogger {
153
202
  }
154
203
  `;
155
- fs.writeFileSync(path.join(projectPath, 'src/core/wrappers/ProjectElement.ts'), wrapperTs);
204
+ fs.writeFileSync(path.join(projectPath, 'src/core/utils/Logger.ts'), loggerTs);
156
205
 
157
- const projectUtilsTs = `export class ProjectUtils {
158
- static generateRandomID() { return Math.random().toString(36).substring(7); }
206
+ const errorUtilsTs = `import { ErrorUtils as CommonErrorUtils } from '@sridharkikkeri/playwright-common';
207
+
208
+ export class ErrorUtils extends CommonErrorUtils {
159
209
  }
160
210
  `;
161
- fs.writeFileSync(path.join(projectPath, 'src/core/utils/ProjectUtils.ts'), projectUtilsTs);
211
+ fs.writeFileSync(path.join(projectPath, 'src/core/utils/ErrorUtils.ts'), errorUtilsTs);
162
212
 
163
213
  // --- UTILS & I18N POPULATION ---
164
214
  const stringUtilsTs = `export class StringUtils {
@@ -176,16 +226,21 @@ fs.writeFileSync(path.join(projectPath, 'src/i18n/fr.json'), JSON.stringify({ "w
176
226
 
177
227
  // --- DOCUMENTATION ---
178
228
  fs.writeFileSync(path.join(projectPath, 'api-docs/assets/style.css'), 'body { font-family: sans-serif; padding: 20px; }');
179
- fs.writeFileSync(path.join(projectPath, 'api-docs/index.html'), `
229
+ const indexHtmlContent = `
180
230
  <html>
181
- <head><link rel="stylesheet" href="assets/style.css"></head>
231
+ <head>
232
+ <title>${projectName} API Docs</title>
233
+ <link rel="stylesheet" href="assets/style.css">
234
+ </head>
182
235
  <body>
183
- <h1>${projectName} - API Documentation</h1>
184
- <p>This folder is ready to host your TypeDoc or custom API documentation.</p>
236
+ <h1>${projectName} - Enterprise API Documentation</h1>
237
+ <p>Welcome to the central documentation hub.</p>
185
238
  </body>
186
- </html>`);
239
+ </html>`;
240
+ fs.writeFileSync(path.join(projectPath, 'api-docs/index.html'), indexHtmlContent);
241
+
187
242
  ['classes', 'interfaces', 'types', 'variables'].forEach(fold => {
188
- fs.writeFileSync(path.join(projectPath, `api-docs/${fold}/README.md`), `# ${fold}\nDocumentation for your project ${fold} goes here.`);
243
+ fs.writeFileSync(path.join(projectPath, `api-docs/${fold}/README.md`), `# ${fold.toUpperCase()}\nDocumentation for ${fold} in ${projectName}.`);
189
244
  });
190
245
 
191
246
  // --- STANDARD CONFIG & EXAMPLES ---
@@ -208,18 +263,19 @@ fs.writeFileSync(path.join(projectPath, 'playwright.config.ts'), playwrightConfi
208
263
 
209
264
  const fixturesTs = `import { test as base } from '@sridharkikkeri/playwright-common';
210
265
  import { HomePage } from '../pages/HomePage';
266
+ import { LoginPage } from '../pages/LoginPage';
211
267
 
212
- export const test = base.extend<{ homePage: HomePage }>({
213
- homePage: async ({ page, orchestrator }, use) => {
214
- await use(new HomePage(page, orchestrator));
215
- },
268
+ export const test = base.extend<{ homePage: HomePage; loginPage: LoginPage }>({
269
+ homePage: async ({ page, orchestrator }, use) => { await use(new HomePage(page, orchestrator)); },
270
+ loginPage: async ({ page, orchestrator }, use) => { await use(new LoginPage(page, orchestrator)); },
216
271
  });
217
272
 
218
273
  export { expect } from '@playwright/test';`;
219
274
  fs.writeFileSync(path.join(projectPath, 'src/fixtures/fixtures.ts'), fixturesTs);
220
275
 
221
- const samplePage = `import { Page } from '@playwright/test';
222
- import { BasePage, ActionOrchestrator } from '@sridharkikkeri/playwright-common';
276
+ const homePageTs = `import { Page } from '@playwright/test';
277
+ import { BasePage } from '../core/pages/BasePage';
278
+ import { ActionOrchestrator } from '../core/selfhealing/ActionOrchestrator';
223
279
 
224
280
  export class HomePage extends BasePage {
225
281
  constructor(page: Page, orchestrator?: ActionOrchestrator) {
@@ -229,7 +285,19 @@ export class HomePage extends BasePage {
229
285
  async clickSearch() { await this.searchBtn.click('Click Search Button'); }
230
286
  }
231
287
  `;
232
- fs.writeFileSync(path.join(projectPath, 'src/pages/HomePage.ts'), samplePage);
288
+ fs.writeFileSync(path.join(projectPath, 'src/pages/HomePage.ts'), homePageTs);
289
+
290
+ const loginPageTs = `import { Page } from '@playwright/test';
291
+ import { BasePage } from '../core/pages/BasePage';
292
+ import { ActionOrchestrator } from '../core/selfhealing/ActionOrchestrator';
293
+
294
+ export class LoginPage extends BasePage {
295
+ constructor(page: Page, orchestrator?: ActionOrchestrator) {
296
+ super(page, { pageName: 'LoginPage', orchestrator });
297
+ }
298
+ }
299
+ `;
300
+ fs.writeFileSync(path.join(projectPath, 'src/pages/LoginPage.ts'), loginPageTs);
233
301
 
234
302
  const visualTest = `import { test, expect } from '../fixtures/fixtures';
235
303
 
@@ -254,13 +322,8 @@ fs.writeFileSync(path.join(projectPath, 'src/tests/sample.spec.ts'), sampleTest)
254
322
 
255
323
  const tsConfig = {
256
324
  compilerOptions: {
257
- target: 'ES2020',
258
- module: 'commonjs',
259
- lib: ['ES2020'],
260
- strict: true,
261
- esModuleInterop: true,
262
- skipLibCheck: true,
263
- resolveJsonModule: true
325
+ target: 'ES2020', module: 'commonjs', lib: ['ES2020', 'DOM'],
326
+ strict: true, esModuleInterop: true, skipLibCheck: true, resolveJsonModule: true
264
327
  },
265
328
  include: ['src/**/*']
266
329
  };
@@ -279,19 +342,11 @@ fs.writeFileSync(path.join(projectPath, '.gitignore'), gitignore);
279
342
 
280
343
  const readme = `# ${projectName}
281
344
 
282
- ## Overview
283
- Enterprise automation test project powered by **@sridharkikkeri/playwright-common**.
284
-
285
345
  ## Getting Started
286
346
  \`\`\`bash
287
347
  npm install
288
348
  npm run test:dev
289
349
  \`\`\`
290
-
291
- ## Features
292
- - **Self-Healing**: Enabled by default
293
- - **Visual Regression**: \`npm run test:visual\`
294
- - **Enterprise Reporting**: Allure integration
295
350
  `;
296
351
  fs.writeFileSync(path.join(projectPath, 'README.md'), readme);
297
352
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sridharkikkeri/playwright-common",
3
- "version": "1.0.17",
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",