@@ -3,24 +3,55 @@ import PlaybooksRunActionsResults from "../PlaybooksActionsResults";
3
3
4
4
describe ( "PlaybooksRunActionsResults" , ( ) => {
5
5
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
+ ) ;
7
17
expect ( screen . getByText ( "No result" ) ) . toBeInTheDocument ( ) ;
8
18
} ) ;
9
19
10
20
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
+ } ;
12
29
render ( < PlaybooksRunActionsResults action = { action } /> ) ;
13
30
expect ( screen . getByText ( "Hello, world!" ) ) . toBeInTheDocument ( ) ;
14
31
} ) ;
15
32
16
33
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
+ } ;
18
42
render ( < PlaybooksRunActionsResults action = { action } /> ) ;
19
43
expect ( screen . getByText ( "Hello, world!" ) ) . toBeInTheDocument ( ) ;
20
44
} ) ;
21
45
22
46
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
+ } ;
24
55
render ( < PlaybooksRunActionsResults action = { action } /> ) ;
25
56
expect (
26
57
screen . getByText ( "foo" , {
@@ -31,14 +62,26 @@ describe("PlaybooksRunActionsResults", () => {
31
62
32
63
it ( "shows stdout as the first tab" , ( ) => {
33
64
const action = {
65
+ id : "1" ,
66
+ name : "test" ,
67
+ status : "completed" as const ,
68
+ playbook_run_id : "1" ,
69
+ start_time : "2024-01-01" ,
34
70
result : { stdout : "Hello, world!" , stderr : "Goodbye, world!" }
35
71
} ;
36
72
render ( < PlaybooksRunActionsResults action = { action } /> ) ;
37
73
expect ( screen . getByText ( "Hello, world!" ) ) . toBeInTheDocument ( ) ;
38
74
} ) ;
39
75
40
76
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
+ } ;
42
85
render ( < PlaybooksRunActionsResults action = { action } /> ) ;
43
86
expect (
44
87
screen . getByText ( "Something went wrong" , {
0 commit comments