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
|
@@ -129,7 +129,17 @@ var appwriteVerifyEmailActionSchema = z.object({
|
|
|
129
129
|
var debugActionSchema = z.object({
|
|
130
130
|
type: z.literal("debug")
|
|
131
131
|
}).describe("Pause execution and open Playwright Inspector for debugging");
|
|
132
|
-
var
|
|
132
|
+
var waitForSelectorActionSchema = z.object({
|
|
133
|
+
type: z.literal("waitForSelector"),
|
|
134
|
+
target: LocatorSchema,
|
|
135
|
+
state: z.enum(["enabled", "disabled", "visible", "hidden", "attached", "detached"]).describe("Element state to wait for"),
|
|
136
|
+
timeout: z.number().int().positive().optional().describe("Time to wait in milliseconds")
|
|
137
|
+
}).describe("Wait for an element to reach a specific state");
|
|
138
|
+
var failActionSchema = z.object({
|
|
139
|
+
type: z.literal("fail"),
|
|
140
|
+
message: nonEmptyString.describe("Error message to display when test fails")
|
|
141
|
+
}).describe("Explicitly fail the test with a custom message");
|
|
142
|
+
var BaseActionSchema = z.discriminatedUnion("type", [
|
|
133
143
|
navigateActionSchema,
|
|
134
144
|
tapActionSchema,
|
|
135
145
|
inputActionSchema,
|
|
@@ -150,8 +160,20 @@ var ActionSchema = z.discriminatedUnion("type", [
|
|
|
150
160
|
emailExtractLinkActionSchema,
|
|
151
161
|
emailClearActionSchema,
|
|
152
162
|
appwriteVerifyEmailActionSchema,
|
|
153
|
-
debugActionSchema
|
|
163
|
+
debugActionSchema,
|
|
164
|
+
waitForSelectorActionSchema,
|
|
165
|
+
failActionSchema
|
|
154
166
|
]);
|
|
167
|
+
var conditionalActionSchema = z.object({
|
|
168
|
+
type: z.literal("conditional"),
|
|
169
|
+
condition: z.object({
|
|
170
|
+
type: z.enum(["exists", "notExists", "visible", "hidden"]),
|
|
171
|
+
target: LocatorSchema
|
|
172
|
+
}).describe("Condition to check"),
|
|
173
|
+
then: z.array(BaseActionSchema).describe("Steps to execute if condition is true"),
|
|
174
|
+
else: z.array(BaseActionSchema).optional().describe("Steps to execute if condition is false")
|
|
175
|
+
}).describe("Execute steps conditionally based on element state");
|
|
176
|
+
var ActionSchema = z.union([BaseActionSchema, conditionalActionSchema]);
|
|
155
177
|
var defaultsSchema = z.object({
|
|
156
178
|
timeout: z.number().int().positive().optional().describe("Default timeout in milliseconds for all actions"),
|
|
157
179
|
screenshots: z.enum(["on-failure", "always", "never"]).optional().describe("When to capture screenshots during test execution")
|
|
@@ -1352,6 +1374,14 @@ var runWait = async (page, action) => {
|
|
|
1352
1374
|
}
|
|
1353
1375
|
await page.waitForTimeout(action.timeout ?? 1e3);
|
|
1354
1376
|
};
|
|
1377
|
+
var waitForCondition = async (checkFn, timeout, errorMessage) => {
|
|
1378
|
+
const start = Date.now();
|
|
1379
|
+
while (Date.now() - start < timeout) {
|
|
1380
|
+
if (await checkFn()) return;
|
|
1381
|
+
await new Promise((r) => setTimeout(r, 100));
|
|
1382
|
+
}
|
|
1383
|
+
throw new Error(errorMessage);
|
|
1384
|
+
};
|
|
1355
1385
|
var runScroll = async (page, action) => {
|
|
1356
1386
|
if (action.target) {
|
|
1357
1387
|
const handle = resolveLocator(page, action.target);
|
|
@@ -1787,6 +1817,91 @@ async function executeActionWithRetry(page, action, index, options) {
|
|
|
1787
1817
|
await page.pause();
|
|
1788
1818
|
break;
|
|
1789
1819
|
}
|
|
1820
|
+
case "waitForSelector": {
|
|
1821
|
+
const wsAction = action;
|
|
1822
|
+
const handle = resolveLocator(page, wsAction.target);
|
|
1823
|
+
const timeout = wsAction.timeout ?? 3e4;
|
|
1824
|
+
if (debugMode) {
|
|
1825
|
+
console.log(`[DEBUG] Waiting for element to be ${wsAction.state}:`, wsAction.target);
|
|
1826
|
+
}
|
|
1827
|
+
switch (wsAction.state) {
|
|
1828
|
+
case "visible":
|
|
1829
|
+
case "hidden":
|
|
1830
|
+
case "attached":
|
|
1831
|
+
case "detached":
|
|
1832
|
+
await handle.waitFor({ state: wsAction.state, timeout });
|
|
1833
|
+
break;
|
|
1834
|
+
case "enabled":
|
|
1835
|
+
await waitForCondition(
|
|
1836
|
+
() => handle.isEnabled(),
|
|
1837
|
+
timeout,
|
|
1838
|
+
`Element did not become enabled within ${timeout}ms`
|
|
1839
|
+
);
|
|
1840
|
+
break;
|
|
1841
|
+
case "disabled":
|
|
1842
|
+
await waitForCondition(
|
|
1843
|
+
() => handle.isDisabled(),
|
|
1844
|
+
timeout,
|
|
1845
|
+
`Element did not become disabled within ${timeout}ms`
|
|
1846
|
+
);
|
|
1847
|
+
break;
|
|
1848
|
+
}
|
|
1849
|
+
break;
|
|
1850
|
+
}
|
|
1851
|
+
case "conditional": {
|
|
1852
|
+
const condAction = action;
|
|
1853
|
+
const handle = resolveLocator(page, condAction.condition.target);
|
|
1854
|
+
let conditionMet = false;
|
|
1855
|
+
if (debugMode) {
|
|
1856
|
+
console.log(`[DEBUG] Checking condition ${condAction.condition.type}:`, condAction.condition.target);
|
|
1857
|
+
}
|
|
1858
|
+
try {
|
|
1859
|
+
switch (condAction.condition.type) {
|
|
1860
|
+
case "exists":
|
|
1861
|
+
await handle.waitFor({ state: "attached", timeout: 500 });
|
|
1862
|
+
conditionMet = true;
|
|
1863
|
+
break;
|
|
1864
|
+
case "notExists":
|
|
1865
|
+
try {
|
|
1866
|
+
await handle.waitFor({ state: "detached", timeout: 500 });
|
|
1867
|
+
conditionMet = true;
|
|
1868
|
+
} catch {
|
|
1869
|
+
conditionMet = false;
|
|
1870
|
+
}
|
|
1871
|
+
break;
|
|
1872
|
+
case "visible":
|
|
1873
|
+
conditionMet = await handle.isVisible();
|
|
1874
|
+
break;
|
|
1875
|
+
case "hidden":
|
|
1876
|
+
conditionMet = !await handle.isVisible();
|
|
1877
|
+
break;
|
|
1878
|
+
}
|
|
1879
|
+
} catch {
|
|
1880
|
+
conditionMet = condAction.condition.type === "notExists";
|
|
1881
|
+
}
|
|
1882
|
+
if (debugMode) {
|
|
1883
|
+
console.log(`[DEBUG] Condition result: ${conditionMet}`);
|
|
1884
|
+
}
|
|
1885
|
+
const stepsToRun = conditionMet ? condAction.then : condAction.else ?? [];
|
|
1886
|
+
for (const [nestedIdx, nestedAction] of stepsToRun.entries()) {
|
|
1887
|
+
if (debugMode) {
|
|
1888
|
+
console.log(`[DEBUG] Executing nested step ${nestedIdx + 1}: ${nestedAction.type}`);
|
|
1889
|
+
}
|
|
1890
|
+
await executeActionWithRetry(page, nestedAction, index, {
|
|
1891
|
+
baseUrl,
|
|
1892
|
+
context,
|
|
1893
|
+
screenshotDir,
|
|
1894
|
+
debugMode,
|
|
1895
|
+
interactive,
|
|
1896
|
+
aiConfig
|
|
1897
|
+
});
|
|
1898
|
+
}
|
|
1899
|
+
break;
|
|
1900
|
+
}
|
|
1901
|
+
case "fail": {
|
|
1902
|
+
const failAction = action;
|
|
1903
|
+
throw new Error(failAction.message);
|
|
1904
|
+
}
|
|
1790
1905
|
default:
|
|
1791
1906
|
throw new Error(`Unsupported action type: ${action.type}`);
|
|
1792
1907
|
}
|
|
@@ -2945,5 +3060,5 @@ Collected ${serverResources.length} server-tracked resources`);
|
|
|
2945
3060
|
}
|
|
2946
3061
|
|
|
2947
3062
|
export { ActionSchema, IntellitesterConfigSchema, LocatorSchema, TestConfigSchema, TestDefinitionSchema, cleanupConfigSchema, cleanupDiscoverSchema, collectMissingEnvVars, createAIProvider, createTestContext, generateFillerText, generateRandomEmail, generateRandomPhone, generateRandomPhoto, generateRandomUsername, interpolateVariables, isPipelineContent, isPipelineFile, isWorkflowContent, isWorkflowFile, killServer, loadIntellitesterConfig, loadPipelineDefinition, loadTestDefinition, loadWorkflowDefinition, parseIntellitesterConfig, parsePipelineDefinition, parseTestDefinition, parseWorkflowDefinition, previewConfigSchema, runWebTest, runWorkflow, runWorkflowWithContext, setupAppwriteTracking, startTrackingServer, startWebServer };
|
|
2948
|
-
//# sourceMappingURL=chunk-
|
|
2949
|
-
//# sourceMappingURL=chunk-
|
|
3063
|
+
//# sourceMappingURL=chunk-CKUSY4ZM.js.map
|
|
3064
|
+
//# sourceMappingURL=chunk-CKUSY4ZM.js.map
|