generator-jhipster-playwright 1.0.0
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/LICENSE +176 -0
- package/README.md +137 -0
- package/cli/cli.cjs +37 -0
- package/generators/cypress/command.js +5 -0
- package/generators/cypress/files.js +75 -0
- package/generators/cypress/generator.js +111 -0
- package/generators/cypress/index.js +2 -0
- package/generators/cypress/templates/playwright.config.ts.ejs +30 -0
- package/generators/cypress/templates/src/test/javascript/cypress/e2e/account/login-page.spec.ts.ejs +83 -0
- package/generators/cypress/templates/src/test/javascript/cypress/e2e/account/logout.spec.ts.ejs +39 -0
- package/generators/cypress/templates/src/test/javascript/cypress/e2e/account/password-page.spec.ts.ejs +88 -0
- package/generators/cypress/templates/src/test/javascript/cypress/e2e/account/register-page.spec.ts.ejs +124 -0
- package/generators/cypress/templates/src/test/javascript/cypress/e2e/account/reset-password-page.spec.ts.ejs +57 -0
- package/generators/cypress/templates/src/test/javascript/cypress/e2e/account/settings-page.spec.ts.ejs +85 -0
- package/generators/cypress/templates/src/test/javascript/cypress/e2e/administration/administration.spec.ts.ejs +73 -0
- package/generators/cypress/templates/src/test/javascript/cypress/e2e/entity/_entity_.spec.ts.ejs +378 -0
- package/generators/cypress/templates/src/test/javascript/cypress/fixtures/integration-test.png +0 -0
- package/generators/cypress/templates/src/test/javascript/cypress/support/account.ts.ejs +26 -0
- package/generators/cypress/templates/src/test/javascript/cypress/support/commands.ts.ejs +200 -0
- package/generators/cypress/templates/src/test/javascript/cypress/support/entity.ts.ejs +73 -0
- package/generators/cypress/templates/src/test/javascript/cypress/support/index.ts.ejs +3 -0
- package/generators/cypress/templates/src/test/javascript/cypress/support/management.ts.ejs +12 -0
- package/generators/cypress/templates/src/test/javascript/cypress/support/navbar.ts.ejs +54 -0
- package/generators/cypress/templates/src/test/javascript/cypress/support/oauth2.ts.ejs +64 -0
- package/generators/cypress/templates/src/test/javascript/cypress/tsconfig.json.ejs +14 -0
- package/package.json +45 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Playwright management helpers
|
|
3
|
+
* Translated from Cypress management.ts (v9)
|
|
4
|
+
*
|
|
5
|
+
* Source: ZERO EJS variables — pure static translation.
|
|
6
|
+
*/
|
|
7
|
+
import type { APIRequestContext } from '@playwright/test';
|
|
8
|
+
|
|
9
|
+
export async function getManagementInfo(request: APIRequestContext): Promise<any> {
|
|
10
|
+
const response = await request.get('/management/info');
|
|
11
|
+
return response.json();
|
|
12
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Playwright navbar helpers
|
|
3
|
+
* Translated from Cypress navbar.ts (v9)
|
|
4
|
+
*
|
|
5
|
+
* Source: ZERO EJS variables — pure static translation.
|
|
6
|
+
*/
|
|
7
|
+
import { expect, type Locator, type Page } from '@playwright/test';
|
|
8
|
+
import {
|
|
9
|
+
navbarSelector,
|
|
10
|
+
adminMenuSelector,
|
|
11
|
+
accountMenuSelector,
|
|
12
|
+
registerItemSelector,
|
|
13
|
+
loginItemSelector,
|
|
14
|
+
logoutItemSelector,
|
|
15
|
+
settingsItemSelector,
|
|
16
|
+
passwordItemSelector,
|
|
17
|
+
entityItemSelector,
|
|
18
|
+
} from './commands';
|
|
19
|
+
|
|
20
|
+
async function clickDropdownItem(menu: Locator, item: string): Promise<void> {
|
|
21
|
+
await expect(menu).toBeVisible();
|
|
22
|
+
await menu.click();
|
|
23
|
+
const itemLocator = menu.locator(item);
|
|
24
|
+
await expect(itemLocator).toBeVisible();
|
|
25
|
+
await itemLocator.click();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export async function clickOnLoginItem(page: Page): Promise<void> {
|
|
29
|
+
await clickDropdownItem(page.locator(navbarSelector).locator(accountMenuSelector), loginItemSelector);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export async function clickOnLogoutItem(page: Page): Promise<void> {
|
|
33
|
+
await clickDropdownItem(page.locator(navbarSelector).locator(accountMenuSelector), logoutItemSelector);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export async function clickOnRegisterItem(page: Page): Promise<void> {
|
|
37
|
+
await clickDropdownItem(page.locator(navbarSelector).locator(accountMenuSelector), registerItemSelector);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export async function clickOnSettingsItem(page: Page): Promise<void> {
|
|
41
|
+
await clickDropdownItem(page.locator(navbarSelector).locator(accountMenuSelector), settingsItemSelector);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export async function clickOnPasswordItem(page: Page): Promise<void> {
|
|
45
|
+
await clickDropdownItem(page.locator(navbarSelector).locator(accountMenuSelector), passwordItemSelector);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export async function clickOnAdminMenuItem(page: Page, item: string): Promise<void> {
|
|
49
|
+
await clickDropdownItem(page.locator(navbarSelector).locator(adminMenuSelector), `.dropdown-item[href="/${item}"]`);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export async function clickOnEntityMenuItem(page: Page, entityName: string): Promise<void> {
|
|
53
|
+
await clickDropdownItem(page.locator(navbarSelector).locator(entityItemSelector), `.dropdown-item[href="/${entityName}"]`);
|
|
54
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Playwright OAuth2 support helpers
|
|
3
|
+
* Translated from Cypress oauth2.ts
|
|
4
|
+
*
|
|
5
|
+
* This module handles OAuth2/Keycloak authentication flows.
|
|
6
|
+
*/
|
|
7
|
+
import type { Page, APIRequestContext } from '@playwright/test';
|
|
8
|
+
|
|
9
|
+
export interface OAuth2Data {
|
|
10
|
+
accessToken: string;
|
|
11
|
+
idToken: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Initiate OAuth2 login flow and return tokens.
|
|
16
|
+
* Translates the Cypress OAuth2 command chain:
|
|
17
|
+
* 1. GET /oauth2/authorization/oidc (follow redirects to Keycloak)
|
|
18
|
+
* 2. Parse the Keycloak login form
|
|
19
|
+
* 3. POST credentials to Keycloak
|
|
20
|
+
* 4. Follow redirects back to the app
|
|
21
|
+
*/
|
|
22
|
+
export async function oauth2Login(
|
|
23
|
+
page: Page,
|
|
24
|
+
username: string,
|
|
25
|
+
password: string,
|
|
26
|
+
): Promise<void> {
|
|
27
|
+
// Navigate to the OAuth2 login endpoint
|
|
28
|
+
await page.goto('/oauth2/authorization/oidc');
|
|
29
|
+
|
|
30
|
+
// Wait for Keycloak login form
|
|
31
|
+
await page.waitForSelector('#kc-form-login', { timeout: 15000 });
|
|
32
|
+
|
|
33
|
+
// Fill in credentials
|
|
34
|
+
await page.locator('#username').fill(username);
|
|
35
|
+
await page.locator('#password').fill(password);
|
|
36
|
+
|
|
37
|
+
// Submit the form
|
|
38
|
+
await page.locator('#kc-login').click();
|
|
39
|
+
|
|
40
|
+
// Wait for redirect back to the app
|
|
41
|
+
await page.waitForURL('**/', { timeout: 15000 });
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Get OAuth2 tokens from the current session.
|
|
46
|
+
*/
|
|
47
|
+
export async function getOAuth2Data(request: APIRequestContext): Promise<OAuth2Data | null> {
|
|
48
|
+
const response = await request.get('/api/account', { failOnStatusCode: false });
|
|
49
|
+
if (response.ok()) {
|
|
50
|
+
return {
|
|
51
|
+
accessToken: '',
|
|
52
|
+
idToken: '',
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Logout from OAuth2/Keycloak session.
|
|
60
|
+
*/
|
|
61
|
+
export async function oauth2Logout(page: Page): Promise<void> {
|
|
62
|
+
await page.goto('/api/logout');
|
|
63
|
+
await page.waitForURL('**/', { timeout: 15000 });
|
|
64
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ESNext",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"strict": true,
|
|
7
|
+
"esModuleInterop": true,
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
"forceConsistentCasingInFileNames": true,
|
|
10
|
+
"resolveJsonModule": true,
|
|
11
|
+
"types": ["node"]
|
|
12
|
+
},
|
|
13
|
+
"include": ["**/*.ts"]
|
|
14
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "generator-jhipster-playwright",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "JHipster Playwright E2E blueprint - replaces Cypress with Playwright for end-to-end testing",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"yeoman-generator",
|
|
7
|
+
"jhipster-blueprint",
|
|
8
|
+
"jhipster-9"
|
|
9
|
+
],
|
|
10
|
+
"homepage": "https://github.com/sreeshanth-soma/generator-jhipster-playwright",
|
|
11
|
+
"bugs": "https://github.com/sreeshanth-soma/generator-jhipster-playwright/issues",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git://github.com/sreeshanth-soma/generator-jhipster-playwright.git"
|
|
15
|
+
},
|
|
16
|
+
"license": "Apache-2.0",
|
|
17
|
+
"type": "module",
|
|
18
|
+
"bin": {
|
|
19
|
+
"jhipster-playwright": "cli/cli.cjs"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"cli",
|
|
23
|
+
"generators",
|
|
24
|
+
"!**/__*",
|
|
25
|
+
"!**/*.snap",
|
|
26
|
+
"!**/*.spec.?(c|m)js"
|
|
27
|
+
],
|
|
28
|
+
"scripts": {
|
|
29
|
+
"lint": "eslint .",
|
|
30
|
+
"smoke": "node --check cli/cli.cjs && node --check generators/cypress/command.js && node --check generators/cypress/files.js && node --check generators/cypress/generator.js && node --check generators/cypress/index.js && node --input-type=module -e \"await import('./generators/cypress/index.js'); await import('./generators/cypress/generator.js'); await import('./generators/cypress/files.js'); await import('./generators/cypress/command.js');\"",
|
|
31
|
+
"test": "npm run lint && npm run smoke"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"generator-jhipster": "9.0.0"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@playwright/test": "^1.58.2",
|
|
38
|
+
"eslint": "9.39.2",
|
|
39
|
+
"yeoman-test": ">=8.2.0"
|
|
40
|
+
},
|
|
41
|
+
"engines": {
|
|
42
|
+
"generator-jhipster": "9.0.0",
|
|
43
|
+
"node": ">= 22"
|
|
44
|
+
}
|
|
45
|
+
}
|