@iblai/iblai-js 1.0.20 → 1.0.22
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/README.md +148 -1
- package/dist/web-containers/source/index.esm.js +2 -1133
- package/package.json +6 -5
package/README.md
CHANGED
|
@@ -30,6 +30,8 @@ npm install react react-dom @reduxjs/toolkit react-redux @iblai/iblai-api
|
|
|
30
30
|
|
|
31
31
|
`next` (>= 15) is an **optional** peer dependency, required only when using `@iblai/iblai-js/web-containers/next`.
|
|
32
32
|
|
|
33
|
+
`@playwright/test` and `@axe-core/playwright` are **optional** peer dependencies, required only when using `@iblai/iblai-js/playwright`.
|
|
34
|
+
|
|
33
35
|
## Framework Configuration
|
|
34
36
|
|
|
35
37
|
### Next.js
|
|
@@ -381,6 +383,150 @@ import {
|
|
|
381
383
|
|
|
382
384
|
---
|
|
383
385
|
|
|
386
|
+
### `@iblai/iblai-js/playwright`
|
|
387
|
+
|
|
388
|
+
Shared Playwright test utilities for E2E testing across IBL.ai apps. Unlike the other subpaths, this is **not** a re-export — it contains original source code for test infrastructure shared between standalone app repos (mentorai, skillsai).
|
|
389
|
+
|
|
390
|
+
**Requires:** `@playwright/test` and `@axe-core/playwright` as dev dependencies.
|
|
391
|
+
|
|
392
|
+
```bash
|
|
393
|
+
pnpm add -D @playwright/test @axe-core/playwright dotenv cross-env
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
#### Config Generation
|
|
397
|
+
|
|
398
|
+
Generate a complete Playwright config with per-browser auth setup projects:
|
|
399
|
+
|
|
400
|
+
```typescript
|
|
401
|
+
// e2e/playwright.config.ts
|
|
402
|
+
import { createPlaywrightConfig } from '@iblai/iblai-js/playwright';
|
|
403
|
+
import dotenv from 'dotenv';
|
|
404
|
+
import path from 'path';
|
|
405
|
+
|
|
406
|
+
dotenv.config({ path: path.resolve(__dirname, '.env.development') });
|
|
407
|
+
|
|
408
|
+
export default createPlaywrightConfig({
|
|
409
|
+
platforms: [
|
|
410
|
+
{
|
|
411
|
+
name: 'skills',
|
|
412
|
+
dependencies: ['setup'],
|
|
413
|
+
otherTestMatch: ['**skills/*/*.spec.ts'],
|
|
414
|
+
},
|
|
415
|
+
],
|
|
416
|
+
});
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
`createPlaywrightConfig` generates browser-specific setup projects (Chrome, Firefox, Safari, Edge) that each run `auth.setup.ts`, then creates test projects for each platform/browser combination. The `devices` option defaults to `['Desktop Chrome', 'Desktop Firefox', 'Desktop Safari', 'Desktop Edge']`.
|
|
420
|
+
|
|
421
|
+
#### Auth Setup
|
|
422
|
+
|
|
423
|
+
Create an `auth.setup.ts` that authenticates once per browser and saves the storage state:
|
|
424
|
+
|
|
425
|
+
```typescript
|
|
426
|
+
// e2e/auth.setup.ts
|
|
427
|
+
import { test as setup, createAuthSetup } from '@iblai/iblai-js/playwright';
|
|
428
|
+
|
|
429
|
+
setup(
|
|
430
|
+
'authenticate',
|
|
431
|
+
createAuthSetup({
|
|
432
|
+
hostUrl: process.env.SKILLS_HOST || '',
|
|
433
|
+
authHost: process.env.AUTH_HOST || '',
|
|
434
|
+
appName: 'skills',
|
|
435
|
+
postLoginUrlMatcher: (url) =>
|
|
436
|
+
url.href.includes('/home') || url.href.includes('/start'),
|
|
437
|
+
})
|
|
438
|
+
);
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
`createAuthSetup` supports four auth flows via the `authFlow` option: `'username_password'` (default), `'magic_link'`, `'sso'`, and `'direct_sso'`. Credentials are read from `PLAYWRIGHT_USERNAME` and `PLAYWRIGHT_PASSWORD` env vars.
|
|
442
|
+
|
|
443
|
+
#### Custom Reporter
|
|
444
|
+
|
|
445
|
+
Re-export the SDK's custom reporter for Playwright:
|
|
446
|
+
|
|
447
|
+
```typescript
|
|
448
|
+
// e2e/custom-reporter.ts
|
|
449
|
+
export { CustomReporter as default } from '@iblai/iblai-js/playwright';
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
#### Test Helpers
|
|
453
|
+
|
|
454
|
+
```typescript
|
|
455
|
+
import {
|
|
456
|
+
// Extended test fixture with step support (optional — most tests use @playwright/test directly)
|
|
457
|
+
test,
|
|
458
|
+
expect,
|
|
459
|
+
|
|
460
|
+
// Navigation
|
|
461
|
+
safeWaitForURL,
|
|
462
|
+
waitForPageLoad,
|
|
463
|
+
isFirefox,
|
|
464
|
+
|
|
465
|
+
// Page interaction
|
|
466
|
+
waitForPageReady,
|
|
467
|
+
checkAdminStatus,
|
|
468
|
+
reliableClick,
|
|
469
|
+
reliableFill,
|
|
470
|
+
waitForDialogReady,
|
|
471
|
+
selectDateFromCalendar,
|
|
472
|
+
|
|
473
|
+
// Accessibility
|
|
474
|
+
expectNoAccessibilityViolations,
|
|
475
|
+
expectNoAccessibilityViolationsOnDialogs,
|
|
476
|
+
|
|
477
|
+
// Auth helpers
|
|
478
|
+
loginWithEmailAndPassword,
|
|
479
|
+
signUpWithEmailAndPassword,
|
|
480
|
+
loginWithMicrosoftIdp,
|
|
481
|
+
AuthFlowBuilder,
|
|
482
|
+
createAuthSetup,
|
|
483
|
+
|
|
484
|
+
// Logging
|
|
485
|
+
logger,
|
|
486
|
+
|
|
487
|
+
// Email testing
|
|
488
|
+
MailsacClient,
|
|
489
|
+
|
|
490
|
+
// Config generation
|
|
491
|
+
createPlaywrightConfig,
|
|
492
|
+
createEnvConfig,
|
|
493
|
+
CustomReporter,
|
|
494
|
+
} from '@iblai/iblai-js/playwright';
|
|
495
|
+
```
|
|
496
|
+
|
|
497
|
+
#### Environment Variables
|
|
498
|
+
|
|
499
|
+
Tests expect these env vars (set them in `.env.development` or CI):
|
|
500
|
+
|
|
501
|
+
| Variable | Description |
|
|
502
|
+
| --- | --- |
|
|
503
|
+
| `SKILLS_HOST` / `MENTOR_NEXTJS_HOST` | App host URL |
|
|
504
|
+
| `AUTH_HOST` | Auth service URL |
|
|
505
|
+
| `PLAYWRIGHT_USERNAME` | Login username |
|
|
506
|
+
| `PLAYWRIGHT_PASSWORD` | Login password |
|
|
507
|
+
| `AUTH_FLOW` | Auth flow type (`username_password`, `magic_link`, `sso`, `direct_sso`) |
|
|
508
|
+
| `AUTH_IDP` | SSO identity provider name (required for `sso`/`direct_sso` flows) |
|
|
509
|
+
|
|
510
|
+
#### Directory Structure
|
|
511
|
+
|
|
512
|
+
Both mentorai and skillsai follow this layout:
|
|
513
|
+
|
|
514
|
+
```
|
|
515
|
+
e2e/
|
|
516
|
+
├── playwright.config.ts # Uses createPlaywrightConfig()
|
|
517
|
+
├── auth.setup.ts # Uses createAuthSetup()
|
|
518
|
+
├── custom-reporter.ts # Re-exports CustomReporter
|
|
519
|
+
├── .env.development # Environment variables
|
|
520
|
+
├── tests/
|
|
521
|
+
│ ├── utils.ts # App-specific env var exports
|
|
522
|
+
│ ├── helpers.ts # App-specific auth/login helpers
|
|
523
|
+
│ ├── shared.ts # Shared test helper functions
|
|
524
|
+
│ └── <platform>/ # Test spec files by feature
|
|
525
|
+
└── utils/ # App-specific helper modules
|
|
526
|
+
```
|
|
527
|
+
|
|
528
|
+
---
|
|
529
|
+
|
|
384
530
|
## Relationship to Standalone Packages
|
|
385
531
|
|
|
386
532
|
`@iblai/iblai-js` is a convenience wrapper. Each subpath is a direct re-export from its standalone package:
|
|
@@ -392,8 +538,9 @@ import {
|
|
|
392
538
|
| `@iblai/iblai-js/web-containers/next` | `@iblai/web-containers/next`|
|
|
393
539
|
| `@iblai/iblai-js/web-containers/sso` | `@iblai/web-containers/sso` |
|
|
394
540
|
| `@iblai/iblai-js/web-utils` | `@iblai/web-utils` |
|
|
541
|
+
| `@iblai/iblai-js/playwright` | Original source (not a re-export) |
|
|
395
542
|
|
|
396
|
-
You can use the standalone packages directly if you only need one module. This unified package is useful when you need multiple IBL libraries and prefer a single dependency.
|
|
543
|
+
You can use the standalone packages directly if you only need one module. This unified package is useful when you need multiple IBL libraries and prefer a single dependency. The `playwright` subpath is unique — it contains original source code rather than re-exporting a standalone package.
|
|
397
544
|
|
|
398
545
|
## TypeScript
|
|
399
546
|
|