intellitester 0.2.20 → 0.2.21
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/{chunk-ICJK4WBA.js → chunk-CKUSY4ZM.js} +119 -4
- package/dist/chunk-CKUSY4ZM.js.map +1 -0
- package/dist/{chunk-JIVORCLQ.cjs → chunk-PP666GZQ.cjs} +119 -4
- package/dist/chunk-PP666GZQ.cjs.map +1 -0
- package/dist/cli/index.cjs +35 -35
- package/dist/cli/index.js +1 -1
- package/dist/index.cjs +34 -34
- package/dist/index.d.cts +903 -7
- package/dist/index.d.ts +903 -7
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-ICJK4WBA.js.map +0 -1
- package/dist/chunk-JIVORCLQ.cjs.map +0 -1
|
@@ -138,7 +138,17 @@ var appwriteVerifyEmailActionSchema = zod.z.object({
|
|
|
138
138
|
var debugActionSchema = zod.z.object({
|
|
139
139
|
type: zod.z.literal("debug")
|
|
140
140
|
}).describe("Pause execution and open Playwright Inspector for debugging");
|
|
141
|
-
var
|
|
141
|
+
var waitForSelectorActionSchema = zod.z.object({
|
|
142
|
+
type: zod.z.literal("waitForSelector"),
|
|
143
|
+
target: LocatorSchema,
|
|
144
|
+
state: zod.z.enum(["enabled", "disabled", "visible", "hidden", "attached", "detached"]).describe("Element state to wait for"),
|
|
145
|
+
timeout: zod.z.number().int().positive().optional().describe("Time to wait in milliseconds")
|
|
146
|
+
}).describe("Wait for an element to reach a specific state");
|
|
147
|
+
var failActionSchema = zod.z.object({
|
|
148
|
+
type: zod.z.literal("fail"),
|
|
149
|
+
message: nonEmptyString.describe("Error message to display when test fails")
|
|
150
|
+
}).describe("Explicitly fail the test with a custom message");
|
|
151
|
+
var BaseActionSchema = zod.z.discriminatedUnion("type", [
|
|
142
152
|
navigateActionSchema,
|
|
143
153
|
tapActionSchema,
|
|
144
154
|
inputActionSchema,
|
|
@@ -159,8 +169,20 @@ var ActionSchema = zod.z.discriminatedUnion("type", [
|
|
|
159
169
|
emailExtractLinkActionSchema,
|
|
160
170
|
emailClearActionSchema,
|
|
161
171
|
appwriteVerifyEmailActionSchema,
|
|
162
|
-
debugActionSchema
|
|
172
|
+
debugActionSchema,
|
|
173
|
+
waitForSelectorActionSchema,
|
|
174
|
+
failActionSchema
|
|
163
175
|
]);
|
|
176
|
+
var conditionalActionSchema = zod.z.object({
|
|
177
|
+
type: zod.z.literal("conditional"),
|
|
178
|
+
condition: zod.z.object({
|
|
179
|
+
type: zod.z.enum(["exists", "notExists", "visible", "hidden"]),
|
|
180
|
+
target: LocatorSchema
|
|
181
|
+
}).describe("Condition to check"),
|
|
182
|
+
then: zod.z.array(BaseActionSchema).describe("Steps to execute if condition is true"),
|
|
183
|
+
else: zod.z.array(BaseActionSchema).optional().describe("Steps to execute if condition is false")
|
|
184
|
+
}).describe("Execute steps conditionally based on element state");
|
|
185
|
+
var ActionSchema = zod.z.union([BaseActionSchema, conditionalActionSchema]);
|
|
164
186
|
var defaultsSchema = zod.z.object({
|
|
165
187
|
timeout: zod.z.number().int().positive().optional().describe("Default timeout in milliseconds for all actions"),
|
|
166
188
|
screenshots: zod.z.enum(["on-failure", "always", "never"]).optional().describe("When to capture screenshots during test execution")
|
|
@@ -1361,6 +1383,14 @@ var runWait = async (page, action) => {
|
|
|
1361
1383
|
}
|
|
1362
1384
|
await page.waitForTimeout(action.timeout ?? 1e3);
|
|
1363
1385
|
};
|
|
1386
|
+
var waitForCondition = async (checkFn, timeout, errorMessage) => {
|
|
1387
|
+
const start = Date.now();
|
|
1388
|
+
while (Date.now() - start < timeout) {
|
|
1389
|
+
if (await checkFn()) return;
|
|
1390
|
+
await new Promise((r) => setTimeout(r, 100));
|
|
1391
|
+
}
|
|
1392
|
+
throw new Error(errorMessage);
|
|
1393
|
+
};
|
|
1364
1394
|
var runScroll = async (page, action) => {
|
|
1365
1395
|
if (action.target) {
|
|
1366
1396
|
const handle = resolveLocator(page, action.target);
|
|
@@ -1796,6 +1826,91 @@ async function executeActionWithRetry(page, action, index, options) {
|
|
|
1796
1826
|
await page.pause();
|
|
1797
1827
|
break;
|
|
1798
1828
|
}
|
|
1829
|
+
case "waitForSelector": {
|
|
1830
|
+
const wsAction = action;
|
|
1831
|
+
const handle = resolveLocator(page, wsAction.target);
|
|
1832
|
+
const timeout = wsAction.timeout ?? 3e4;
|
|
1833
|
+
if (debugMode) {
|
|
1834
|
+
console.log(`[DEBUG] Waiting for element to be ${wsAction.state}:`, wsAction.target);
|
|
1835
|
+
}
|
|
1836
|
+
switch (wsAction.state) {
|
|
1837
|
+
case "visible":
|
|
1838
|
+
case "hidden":
|
|
1839
|
+
case "attached":
|
|
1840
|
+
case "detached":
|
|
1841
|
+
await handle.waitFor({ state: wsAction.state, timeout });
|
|
1842
|
+
break;
|
|
1843
|
+
case "enabled":
|
|
1844
|
+
await waitForCondition(
|
|
1845
|
+
() => handle.isEnabled(),
|
|
1846
|
+
timeout,
|
|
1847
|
+
`Element did not become enabled within ${timeout}ms`
|
|
1848
|
+
);
|
|
1849
|
+
break;
|
|
1850
|
+
case "disabled":
|
|
1851
|
+
await waitForCondition(
|
|
1852
|
+
() => handle.isDisabled(),
|
|
1853
|
+
timeout,
|
|
1854
|
+
`Element did not become disabled within ${timeout}ms`
|
|
1855
|
+
);
|
|
1856
|
+
break;
|
|
1857
|
+
}
|
|
1858
|
+
break;
|
|
1859
|
+
}
|
|
1860
|
+
case "conditional": {
|
|
1861
|
+
const condAction = action;
|
|
1862
|
+
const handle = resolveLocator(page, condAction.condition.target);
|
|
1863
|
+
let conditionMet = false;
|
|
1864
|
+
if (debugMode) {
|
|
1865
|
+
console.log(`[DEBUG] Checking condition ${condAction.condition.type}:`, condAction.condition.target);
|
|
1866
|
+
}
|
|
1867
|
+
try {
|
|
1868
|
+
switch (condAction.condition.type) {
|
|
1869
|
+
case "exists":
|
|
1870
|
+
await handle.waitFor({ state: "attached", timeout: 500 });
|
|
1871
|
+
conditionMet = true;
|
|
1872
|
+
break;
|
|
1873
|
+
case "notExists":
|
|
1874
|
+
try {
|
|
1875
|
+
await handle.waitFor({ state: "detached", timeout: 500 });
|
|
1876
|
+
conditionMet = true;
|
|
1877
|
+
} catch {
|
|
1878
|
+
conditionMet = false;
|
|
1879
|
+
}
|
|
1880
|
+
break;
|
|
1881
|
+
case "visible":
|
|
1882
|
+
conditionMet = await handle.isVisible();
|
|
1883
|
+
break;
|
|
1884
|
+
case "hidden":
|
|
1885
|
+
conditionMet = !await handle.isVisible();
|
|
1886
|
+
break;
|
|
1887
|
+
}
|
|
1888
|
+
} catch {
|
|
1889
|
+
conditionMet = condAction.condition.type === "notExists";
|
|
1890
|
+
}
|
|
1891
|
+
if (debugMode) {
|
|
1892
|
+
console.log(`[DEBUG] Condition result: ${conditionMet}`);
|
|
1893
|
+
}
|
|
1894
|
+
const stepsToRun = conditionMet ? condAction.then : condAction.else ?? [];
|
|
1895
|
+
for (const [nestedIdx, nestedAction] of stepsToRun.entries()) {
|
|
1896
|
+
if (debugMode) {
|
|
1897
|
+
console.log(`[DEBUG] Executing nested step ${nestedIdx + 1}: ${nestedAction.type}`);
|
|
1898
|
+
}
|
|
1899
|
+
await executeActionWithRetry(page, nestedAction, index, {
|
|
1900
|
+
baseUrl,
|
|
1901
|
+
context,
|
|
1902
|
+
screenshotDir,
|
|
1903
|
+
debugMode,
|
|
1904
|
+
interactive,
|
|
1905
|
+
aiConfig
|
|
1906
|
+
});
|
|
1907
|
+
}
|
|
1908
|
+
break;
|
|
1909
|
+
}
|
|
1910
|
+
case "fail": {
|
|
1911
|
+
const failAction = action;
|
|
1912
|
+
throw new Error(failAction.message);
|
|
1913
|
+
}
|
|
1799
1914
|
default:
|
|
1800
1915
|
throw new Error(`Unsupported action type: ${action.type}`);
|
|
1801
1916
|
}
|
|
@@ -2989,5 +3104,5 @@ exports.runWorkflowWithContext = runWorkflowWithContext;
|
|
|
2989
3104
|
exports.setupAppwriteTracking = setupAppwriteTracking;
|
|
2990
3105
|
exports.startTrackingServer = startTrackingServer;
|
|
2991
3106
|
exports.startWebServer = startWebServer;
|
|
2992
|
-
//# sourceMappingURL=chunk-
|
|
2993
|
-
//# sourceMappingURL=chunk-
|
|
3107
|
+
//# sourceMappingURL=chunk-PP666GZQ.cjs.map
|
|
3108
|
+
//# sourceMappingURL=chunk-PP666GZQ.cjs.map
|