@@ -131,6 +131,15 @@ describe("handleSystemRunInvoke mac app exec host routing", () => {
|
131 | 131 | ); |
132 | 132 | } |
133 | 133 | |
| 134 | +function requireFirstRunCommandArgs(runCommand: MockedRunCommand): string[] { |
| 135 | +const args = vi.mocked(runCommand).mock.calls[0]?.[0] as string[] | undefined; |
| 136 | +expect(args).toBeDefined(); |
| 137 | +if (!args) { |
| 138 | +throw new Error("expected runCommand args"); |
| 139 | +} |
| 140 | +return args; |
| 141 | +} |
| 142 | + |
134 | 143 | function expectApprovalRequiredDenied(params: { |
135 | 144 | sendNodeEvent: MockedSendNodeEvent; |
136 | 145 | sendInvokeResult: MockedSendInvokeResult; |
@@ -598,8 +607,12 @@ describe("handleSystemRunInvoke mac app exec host routing", () => {
|
598 | 607 | continue; |
599 | 608 | } |
600 | 609 | |
601 | | -const runArgs = vi.mocked(invoke.runCommand).mock.calls[0]?.[0] as string[] | undefined; |
602 | | -expect(runArgs).toEqual(["env", "sh", "-c", "echo SAFE"]); |
| 610 | +expect(requireFirstRunCommandArgs(invoke.runCommand)).toEqual([ |
| 611 | +"env", |
| 612 | +"sh", |
| 613 | +"-c", |
| 614 | +"echo SAFE", |
| 615 | +]); |
603 | 616 | expect(fs.existsSync(marker)).toBe(false); |
604 | 617 | expectInvokeOk(invoke.sendInvokeResult); |
605 | 618 | } |
@@ -621,10 +634,11 @@ describe("handleSystemRunInvoke mac app exec host routing", () => {
|
621 | 634 | expect(transparent.runCommand).not.toHaveBeenCalled(); |
622 | 635 | expectInvokeErrorMessage(transparent.sendInvokeResult, { message: "allowlist miss" }); |
623 | 636 | } else { |
624 | | -const runArgs = vi.mocked(transparent.runCommand).mock.calls[0]?.[0] as |
625 | | -| string[] |
626 | | -| undefined; |
627 | | -expect(runArgs).toEqual([expect.stringMatching(/(^|[/\\])tr$/), "a", "b"]); |
| 637 | +expect(requireFirstRunCommandArgs(transparent.runCommand)).toEqual([ |
| 638 | +expect.stringMatching(/(^|[/\\])tr$/), |
| 639 | +"a", |
| 640 | +"b", |
| 641 | +]); |
628 | 642 | expectInvokeOk(transparent.sendInvokeResult); |
629 | 643 | } |
630 | 644 | |
|