Skip to content

Commit 6d68c41

Browse files
authored
fix: resolve TypeScript errors in test files (#2654)
- Add missing isViewer property to UserAccessState mocks - Add required properties to CategorizedPlaybookRunAction test mocks - Add missing actions array to Playbook spec - Add missing name property to PlaybookAction
1 parent 71ad39f commit 6d68c41

File tree

4 files changed

+52
-5
lines changed

4 files changed

+52
-5
lines changed

src/components/Canary/CanaryPopup/__tests__/CheckRunNow.unit.test.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ describe("CheckRunNow", () => {
3737
value={{
3838
refresh: jest.fn(),
3939
isAdmin: true,
40+
isViewer: false,
4041
hasResourceAccess: jest.fn(),
4142
hasAnyResourceAccess: jest.fn(),
4243
roles: ["admin"]
@@ -77,6 +78,7 @@ describe("CheckRunNow", () => {
7778
value={{
7879
refresh: jest.fn(),
7980
isAdmin: true,
81+
isViewer: false,
8082
hasResourceAccess: jest.fn(),
8183
hasAnyResourceAccess: jest.fn(),
8284
roles: ["guest"]

src/components/Playbooks/Runs/Actions/__tests__/PlaybooksActionsResults.unit.test.tsx

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,55 @@ import PlaybooksRunActionsResults from "../PlaybooksActionsResults";
33

44
describe("PlaybooksRunActionsResults", () => {
55
it("renders 'No result' when result is falsy", () => {
6-
render(<PlaybooksRunActionsResults action={{}} />);
6+
render(
7+
<PlaybooksRunActionsResults
8+
action={{
9+
id: "1",
10+
name: "test",
11+
status: "completed",
12+
playbook_run_id: "1",
13+
start_time: "2024-01-01"
14+
}}
15+
/>
16+
);
717
expect(screen.getByText("No result")).toBeInTheDocument();
818
});
919

1020
it("renders stdout when result has stdout", () => {
11-
const action = { result: { stdout: "Hello, world!" } };
21+
const action = {
22+
id: "1",
23+
name: "test",
24+
status: "completed" as const,
25+
playbook_run_id: "1",
26+
start_time: "2024-01-01",
27+
result: { stdout: "Hello, world!" }
28+
};
1229
render(<PlaybooksRunActionsResults action={action} />);
1330
expect(screen.getByText("Hello, world!")).toBeInTheDocument();
1431
});
1532

1633
it("renders logs when result has logs", () => {
17-
const action = { result: { logs: "Hello, world!" } };
34+
const action = {
35+
id: "1",
36+
name: "test",
37+
status: "completed" as const,
38+
playbook_run_id: "1",
39+
start_time: "2024-01-01",
40+
result: { logs: "Hello, world!" }
41+
};
1842
render(<PlaybooksRunActionsResults action={action} />);
1943
expect(screen.getByText("Hello, world!")).toBeInTheDocument();
2044
});
2145

2246
it("renders JSON when result has neither stdout nor logs", () => {
23-
const action = { result: { foo: "bar" } };
47+
const action = {
48+
id: "1",
49+
name: "test",
50+
status: "completed" as const,
51+
playbook_run_id: "1",
52+
start_time: "2024-01-01",
53+
result: { foo: "bar" }
54+
};
2455
render(<PlaybooksRunActionsResults action={action} />);
2556
expect(
2657
screen.getByText("foo", {
@@ -31,14 +62,26 @@ describe("PlaybooksRunActionsResults", () => {
3162

3263
it("shows stdout as the first tab", () => {
3364
const action = {
65+
id: "1",
66+
name: "test",
67+
status: "completed" as const,
68+
playbook_run_id: "1",
69+
start_time: "2024-01-01",
3470
result: { stdout: "Hello, world!", stderr: "Goodbye, world!" }
3571
};
3672
render(<PlaybooksRunActionsResults action={action} />);
3773
expect(screen.getByText("Hello, world!")).toBeInTheDocument();
3874
});
3975

4076
it("renders error when action has error", () => {
41-
const action = { error: "Something went wrong" };
77+
const action = {
78+
id: "1",
79+
name: "test",
80+
status: "failed" as const,
81+
playbook_run_id: "1",
82+
start_time: "2024-01-01",
83+
error: "Something went wrong"
84+
};
4285
render(<PlaybooksRunActionsResults action={action} />);
4386
expect(
4487
screen.getByText("Something went wrong", {

src/components/Playbooks/Runs/Submit/__tests__/SubmitPlaybookRunForm.unit.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const playbook: RunnablePlaybook & {
2727
updated_at: "2021-09-01T00:00:00Z",
2828
spec: {
2929
icon: "playbook.svg",
30+
actions: [],
3031
components: [
3132
{
3233
types: ["kubernetes"]

src/components/Playbooks/Settings/__tests__/PlaybookSpecCard.unit.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const mockPlaybook: PlaybookSpec = {
1616
spec: {
1717
actions: [
1818
{
19+
name: "test-action",
1920
exec: {
2021
script: 'echo "{{.}}"'
2122
}

0 commit comments

Comments
 (0)