refactor(tools): return complete analysis results inline
This commit is contained in:
@@ -61,23 +61,46 @@ it("rejects non-absolute deep-link values", () => {
|
||||
expect(result.success).toBe(false);
|
||||
});
|
||||
|
||||
it("accepts any argument count while validating each argument", () => {
|
||||
it("keeps long Electron arguments and deep-link URLs intact", () => {
|
||||
const longArgument = "x".repeat(5_000);
|
||||
const longUrl = `rea-fixture://open/${"item".repeat(2_000)}`;
|
||||
const longStepId = "step".repeat(100);
|
||||
const input = electronActiveObservationInputSchema.parse({
|
||||
executable_path: "/opt/electron",
|
||||
application_path: "/opt/app/main.js",
|
||||
application_root: "/opt/app",
|
||||
args: Array.from({ length: 40 }, (_, index) => `--flag-${index}`),
|
||||
args: [longArgument],
|
||||
actions: [
|
||||
{
|
||||
step_id: longStepId,
|
||||
kind: "deep-link",
|
||||
delivery: "open-url",
|
||||
url: longUrl,
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
expect(input.args).toHaveLength(40);
|
||||
expect(input.args).toEqual([longArgument]);
|
||||
expect(input.actions[0]).toMatchObject({
|
||||
step_id: longStepId,
|
||||
url: longUrl,
|
||||
});
|
||||
expect(
|
||||
electronActiveObservationInputSchema.safeParse({
|
||||
executable_path: "/opt/electron",
|
||||
application_path: "/opt/app/main.js",
|
||||
application_root: "/opt/app",
|
||||
args: ["x".repeat(4_097)],
|
||||
}).success,
|
||||
).toBe(false);
|
||||
electronActiveObservationResultSchema.parse({
|
||||
...createElectronActiveObservationFixtureResult("/opt/app"),
|
||||
actions: [
|
||||
{
|
||||
step_id: longStepId,
|
||||
kind: "deep-link",
|
||||
window_index: null,
|
||||
target: null,
|
||||
status: "completed",
|
||||
elapsed_ms: 0,
|
||||
error: null,
|
||||
},
|
||||
],
|
||||
}).actions[0]?.step_id,
|
||||
).toBe(longStepId);
|
||||
});
|
||||
|
||||
it("redacts action inputs from Playwright failures", async () => {
|
||||
@@ -114,6 +137,131 @@ it("redacts action inputs from Playwright failures", async () => {
|
||||
expect(result[0]?.error).not.toContain("raw-secret");
|
||||
});
|
||||
|
||||
it("retains complete action errors and Electron window text", async () => {
|
||||
const longError = `locator failed ${"detail ".repeat(300)}`;
|
||||
const input = electronActiveObservationInputSchema.parse({
|
||||
executable_path: "/opt/electron",
|
||||
application_path: "/opt/app/main.js",
|
||||
application_root: "/opt/app",
|
||||
actions: [{ step_id: "click-step", kind: "click", selector: "#run" }],
|
||||
});
|
||||
const page = {
|
||||
locator: () => ({
|
||||
click: async () => Promise.reject(new Error(longError)),
|
||||
}),
|
||||
};
|
||||
const actions = await runElectronActions(
|
||||
{ windows: () => [page] } as never,
|
||||
input,
|
||||
{},
|
||||
Date.now() + 1_000,
|
||||
);
|
||||
const result = createElectronActiveObservationFixtureResult("/opt/app");
|
||||
const longUrl = `file://${"/segment".repeat(10_000)}`;
|
||||
const longTitle = "title".repeat(4_000);
|
||||
|
||||
expect(actions[0]?.error).toBe(longError);
|
||||
expect(
|
||||
electronActiveObservationResultSchema.parse({
|
||||
...result,
|
||||
windows: [{ ...result.windows[0], url: longUrl, title: longTitle }],
|
||||
actions: [
|
||||
{
|
||||
step_id: "click-step",
|
||||
kind: "click",
|
||||
window_index: 0,
|
||||
target: "window:0",
|
||||
status: "failed",
|
||||
elapsed_ms: 1,
|
||||
error: longError,
|
||||
},
|
||||
],
|
||||
}).windows[0],
|
||||
).toMatchObject({ url: longUrl, title: longTitle });
|
||||
});
|
||||
|
||||
it("accepts complete Electron input and observation strings", () => {
|
||||
const longText = "evidence-".repeat(3_000);
|
||||
const longPath = `/opt/${"directory/".repeat(2_000)}app`;
|
||||
const input = electronActiveObservationInputSchema.parse({
|
||||
executable_path: longPath,
|
||||
application_path: `${longPath}/main.js`,
|
||||
application_root: longPath,
|
||||
actions: [
|
||||
{ step_id: longText, kind: "click", selector: longText },
|
||||
{
|
||||
step_id: longText,
|
||||
kind: "deep-link",
|
||||
delivery: "open-url",
|
||||
url: `custom://${longText}`,
|
||||
},
|
||||
],
|
||||
});
|
||||
const fixture = createElectronActiveObservationFixtureResult("/opt/app");
|
||||
const event = {
|
||||
...fixture.ipc.events[0],
|
||||
correlation_id: longText,
|
||||
event: longText,
|
||||
channel: longText,
|
||||
sender: longText,
|
||||
receiver: longText,
|
||||
frame: longText,
|
||||
target: longText,
|
||||
result_shape: longText,
|
||||
process_type: longText,
|
||||
source: longText,
|
||||
artifact_path: longPath,
|
||||
};
|
||||
const result = electronActiveObservationResultSchema.parse({
|
||||
...fixture,
|
||||
application: {
|
||||
...fixture.application,
|
||||
application_path: longPath,
|
||||
electron_version: longText,
|
||||
},
|
||||
actions: [
|
||||
{
|
||||
...fixture.actions[0],
|
||||
step_id: longText,
|
||||
target: longText,
|
||||
error: longText,
|
||||
status: "failed",
|
||||
},
|
||||
],
|
||||
windows: [
|
||||
{
|
||||
...fixture.windows[0],
|
||||
window_id: longText,
|
||||
web_contents_id: longText,
|
||||
url: longText,
|
||||
title: longText,
|
||||
},
|
||||
],
|
||||
ipc: { events: [event], observed: 1 },
|
||||
timeline: {
|
||||
events: [
|
||||
{
|
||||
...event,
|
||||
kind: "navigation",
|
||||
phase: "observed",
|
||||
direction: null,
|
||||
capture_method: "event-emitter",
|
||||
},
|
||||
],
|
||||
observed: 1,
|
||||
},
|
||||
limitations: [longText],
|
||||
});
|
||||
|
||||
expect(input.actions[0]?.step_id).toBe(longText);
|
||||
expect(input.actions[0]?.kind === "click" && input.actions[0].selector).toBe(
|
||||
longText,
|
||||
);
|
||||
expect(result.ipc.events[0]?.channel).toBe(longText);
|
||||
expect(result.windows[0]?.title).toBe(longText);
|
||||
expect(result.limitations[0]).toBe(longText);
|
||||
});
|
||||
|
||||
it("runs an untargeted deep-link without requiring a BrowserWindow", async () => {
|
||||
const input = electronActiveObservationInputSchema.parse({
|
||||
executable_path: "/opt/electron",
|
||||
|
||||
Reference in New Issue
Block a user