@lowdefy/e2e-utils 4.7.0 → 4.7.2
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/dist/core/navigation.js
CHANGED
|
@@ -24,14 +24,21 @@ async function waitForReady(page) {
|
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
async function goto(page, path) {
|
|
27
|
-
|
|
27
|
+
// domcontentloaded is sufficient — waitForReady gates on the Lowdefy client
|
|
28
|
+
// context, which is a stronger readiness signal than the browser 'load' event.
|
|
29
|
+
// Using 'load' can hang when pages have WebSocket connections or slow resources.
|
|
30
|
+
await page.goto(path, {
|
|
31
|
+
waitUntil: 'domcontentloaded'
|
|
32
|
+
});
|
|
28
33
|
await waitForReady(page);
|
|
29
34
|
}
|
|
30
35
|
async function expectNavigation(page, urlPattern) {
|
|
31
36
|
await expect(page).toHaveURL(urlPattern);
|
|
32
37
|
}
|
|
33
38
|
async function waitForPage(page, path) {
|
|
34
|
-
await page.waitForURL(path
|
|
39
|
+
await page.waitForURL(path, {
|
|
40
|
+
waitUntil: 'domcontentloaded'
|
|
41
|
+
});
|
|
35
42
|
await waitForReady(page);
|
|
36
43
|
}
|
|
37
44
|
export { goto, waitForReady, expectNavigation, waitForPage };
|
package/dist/init/index.js
CHANGED
|
@@ -13,12 +13,22 @@
|
|
|
13
13
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
14
|
See the License for the specific language governing permissions and
|
|
15
15
|
limitations under the License.
|
|
16
|
-
*/ /* eslint-disable no-console */ import
|
|
16
|
+
*/ /* eslint-disable no-console */ import fs from 'fs';
|
|
17
|
+
import path from 'path';
|
|
17
18
|
import prompts from 'prompts';
|
|
18
19
|
import detectApps from './detectApps.js';
|
|
19
20
|
import generateFiles from './generateFiles.js';
|
|
20
|
-
import installDeps, { detectPackageManager } from './installDeps.js';
|
|
21
21
|
import updateGitignore from './updateGitignore.js';
|
|
22
|
+
function detectPackageManager(cwd) {
|
|
23
|
+
let dir = cwd;
|
|
24
|
+
while(dir !== path.dirname(dir)){
|
|
25
|
+
if (fs.existsSync(path.join(dir, 'pnpm-lock.yaml'))) return 'pnpm';
|
|
26
|
+
if (fs.existsSync(path.join(dir, 'yarn.lock'))) return 'yarn';
|
|
27
|
+
if (fs.existsSync(path.join(dir, 'package-lock.json'))) return 'npm';
|
|
28
|
+
dir = path.dirname(dir);
|
|
29
|
+
}
|
|
30
|
+
return 'npm';
|
|
31
|
+
}
|
|
22
32
|
async function init() {
|
|
23
33
|
const cwd = process.cwd();
|
|
24
34
|
console.log('Setting up Lowdefy e2e testing...\n');
|
|
@@ -106,59 +116,40 @@ async function init() {
|
|
|
106
116
|
}
|
|
107
117
|
// Step 6: Update .gitignore
|
|
108
118
|
updateGitignore(cwd);
|
|
109
|
-
// Step 7:
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
console.log('\nSetup cancelled.');
|
|
119
|
-
process.exit(0);
|
|
119
|
+
// Step 7: Print completion summary and next steps
|
|
120
|
+
console.log('\n✓ E2E testing setup complete!\n');
|
|
121
|
+
console.log('Next steps:\n');
|
|
122
|
+
let step = 1;
|
|
123
|
+
// Install instructions
|
|
124
|
+
const packageManager = detectPackageManager(cwd);
|
|
125
|
+
console.log(` ${step}. Install dependencies:`);
|
|
126
|
+
if (selectedApps.length === 1) {
|
|
127
|
+
console.log(` cd ${selectedApps[0].path}`);
|
|
120
128
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
for (const app of selectedApps){
|
|
132
|
-
const packageManager = detectPackageManager(path.join(cwd, app.path));
|
|
133
|
-
console.log(`\nTo install dependencies manually in ${app.path}:`);
|
|
134
|
-
console.log(` cd ${app.path}`);
|
|
135
|
-
console.log(` ${packageManager} install`);
|
|
136
|
-
console.log(' npx playwright install chromium');
|
|
137
|
-
}
|
|
129
|
+
console.log(` ${packageManager} install`);
|
|
130
|
+
console.log(' npx playwright install chromium');
|
|
131
|
+
step += 1;
|
|
132
|
+
// MongoDB setup
|
|
133
|
+
if (useMongoDB) {
|
|
134
|
+
console.log(`\n ${step}. Configure MongoDB testing:`);
|
|
135
|
+
console.log(' Copy .env.e2e to .env.e2e.local');
|
|
136
|
+
console.log(' Set LOWDEFY_E2E_MONGODB_URI to your test database');
|
|
137
|
+
console.log(' See mongodb.spec.js for example tests');
|
|
138
|
+
step += 1;
|
|
138
139
|
}
|
|
139
|
-
//
|
|
140
|
-
console.log(
|
|
140
|
+
// Run tests
|
|
141
|
+
console.log(`\n ${step}. Run tests:`);
|
|
141
142
|
if (selectedApps.length === 1) {
|
|
142
|
-
|
|
143
|
-
console.log(
|
|
144
|
-
console.log(
|
|
145
|
-
console.log('
|
|
146
|
-
console.log('
|
|
147
|
-
console.log(' pnpm e2e:ui # Playwright UI mode');
|
|
148
|
-
console.log(' pnpm e2e:server # Start server for reuse');
|
|
143
|
+
console.log(` cd ${selectedApps[0].path}`);
|
|
144
|
+
console.log(' pnpm e2e # Run all tests');
|
|
145
|
+
console.log(' pnpm e2e:headed # Run with visible browser');
|
|
146
|
+
console.log(' pnpm e2e:ui # Playwright UI mode');
|
|
147
|
+
console.log(' pnpm e2e:server # Start server for reuse');
|
|
149
148
|
} else {
|
|
150
|
-
console.log('Run tests from each app directory:');
|
|
151
149
|
for (const app of selectedApps){
|
|
152
|
-
console.log(
|
|
153
|
-
console.log(` cd ${app.path} && pnpm e2e`);
|
|
150
|
+
console.log(` cd ${app.path} && pnpm e2e`);
|
|
154
151
|
}
|
|
155
152
|
}
|
|
156
|
-
if (useMongoDB) {
|
|
157
|
-
console.log('\nMongoDB testing setup:');
|
|
158
|
-
console.log(' 1. Copy .env.e2e to .env.e2e.local');
|
|
159
|
-
console.log(' 2. Set MDB_E2E_URI to your test database');
|
|
160
|
-
console.log(' 3. See mongodb.spec.js for example tests');
|
|
161
|
-
}
|
|
162
153
|
}
|
|
163
154
|
init().catch((err)=>{
|
|
164
155
|
console.error('Error:', err.message);
|
|
@@ -324,7 +324,7 @@ Copy `.env.e2e` to `.env.e2e.local` and set your values:
|
|
|
324
324
|
cp e2e/.env.e2e e2e/.env.e2e.local
|
|
325
325
|
```
|
|
326
326
|
|
|
327
|
-
For MongoDB testing, set `
|
|
327
|
+
For MongoDB testing, set `LOWDEFY_E2E_MONGODB_URI` to a dedicated test database (data will be cleared during tests). If using `@lowdefy/community-plugin-e2e-mdb` with `configureMdb()`, the URI is set automatically.
|
|
328
328
|
|
|
329
329
|
## More Information
|
|
330
330
|
|
|
@@ -14,6 +14,13 @@
|
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import { expect } from '@playwright/test';
|
|
16
16
|
import { expectValidationError, expectValidationWarning, expectValidationSuccess } from '../core/validation.js';
|
|
17
|
+
// Each block's e2e helper defines a `locator` function that targets the block element on the page.
|
|
18
|
+
// Two locator patterns exist:
|
|
19
|
+
// - `#${escapeId(blockId)}` — for blocks that render `id={blockId}` on their root DOM element
|
|
20
|
+
// (e.g. AgGrid variants, ProgressBar, Markdown variants, QRScanner).
|
|
21
|
+
// - `#bl-${escapeId(blockId)}` — for blocks whose root element does not carry the blockId;
|
|
22
|
+
// targets the Lowdefy layout wrapper div instead
|
|
23
|
+
// (e.g. Skeleton variants, Spinner, EChart, DocSearch, ColorSelector, GoogleMaps variants).
|
|
17
24
|
function createBlockHelper({ locator, do: doMethods, get: getMethods, expect: expectOverrides }) {
|
|
18
25
|
const commonExpect = {
|
|
19
26
|
visible: (page, blockId)=>expect(locator(page, blockId)).toBeVisible(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/e2e-utils",
|
|
3
|
-
"version": "4.7.
|
|
3
|
+
"version": "4.7.2",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Lowdefy E2E Testing Utilities for Playwright",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"dist/*"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@lowdefy/helpers": "4.7.
|
|
39
|
+
"@lowdefy/helpers": "4.7.2",
|
|
40
40
|
"js-yaml": "4.1.0",
|
|
41
41
|
"prompts": "2.4.2"
|
|
42
42
|
},
|
package/dist/init/installDeps.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2026 Lowdefy, Inc
|
|
3
|
-
|
|
4
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
you may not use this file except in compliance with the License.
|
|
6
|
-
You may obtain a copy of the License at
|
|
7
|
-
|
|
8
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
|
|
10
|
-
Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
See the License for the specific language governing permissions and
|
|
14
|
-
limitations under the License.
|
|
15
|
-
*/ /* eslint-disable no-console */ import fs from 'fs';
|
|
16
|
-
import path from 'path';
|
|
17
|
-
import { execSync } from 'child_process';
|
|
18
|
-
function detectPackageManager(cwd) {
|
|
19
|
-
// Walk up from cwd to find the lock file
|
|
20
|
-
let dir = cwd;
|
|
21
|
-
while(dir !== path.dirname(dir)){
|
|
22
|
-
if (fs.existsSync(path.join(dir, 'pnpm-lock.yaml'))) return 'pnpm';
|
|
23
|
-
if (fs.existsSync(path.join(dir, 'yarn.lock'))) return 'yarn';
|
|
24
|
-
if (fs.existsSync(path.join(dir, 'package-lock.json'))) return 'npm';
|
|
25
|
-
dir = path.dirname(dir);
|
|
26
|
-
}
|
|
27
|
-
return 'npm';
|
|
28
|
-
}
|
|
29
|
-
function installDeps({ appDir }) {
|
|
30
|
-
const packageManager = detectPackageManager(appDir);
|
|
31
|
-
const installCmd = `${packageManager} install`;
|
|
32
|
-
console.log(`\nInstalling dependencies in ${appDir}...`);
|
|
33
|
-
console.log(` $ ${installCmd}\n`);
|
|
34
|
-
try {
|
|
35
|
-
execSync(installCmd, {
|
|
36
|
-
cwd: appDir,
|
|
37
|
-
stdio: 'inherit'
|
|
38
|
-
});
|
|
39
|
-
console.log('\n✓ Dependencies installed successfully');
|
|
40
|
-
} catch {
|
|
41
|
-
console.error('\n✗ Failed to install dependencies automatically');
|
|
42
|
-
console.log(`\nInstall manually from ${appDir}:`);
|
|
43
|
-
console.log(` ${installCmd}`);
|
|
44
|
-
console.log(' npx playwright install chromium');
|
|
45
|
-
return false;
|
|
46
|
-
}
|
|
47
|
-
console.log('\nInstalling Playwright browsers...');
|
|
48
|
-
console.log(' $ npx playwright install chromium\n');
|
|
49
|
-
try {
|
|
50
|
-
execSync('npx playwright install chromium', {
|
|
51
|
-
cwd: appDir,
|
|
52
|
-
stdio: 'inherit'
|
|
53
|
-
});
|
|
54
|
-
console.log('\n✓ Playwright browsers installed');
|
|
55
|
-
} catch {
|
|
56
|
-
console.error('\n✗ Failed to install Playwright browsers');
|
|
57
|
-
console.error(' Run manually: npx playwright install chromium');
|
|
58
|
-
}
|
|
59
|
-
return true;
|
|
60
|
-
}
|
|
61
|
-
export { detectPackageManager };
|
|
62
|
-
export default installDeps;
|