@@ -9,25 +9,34 @@ module("Integration | Component | work-item-button", function (hooks) {
9
9
setupRenderingTest ( hooks ) ;
10
10
setupMirage ( hooks ) ;
11
11
12
+ hooks . beforeEach ( function ( ) {
13
+ this . workItem = this . server . create ( "workItem" , { status : "READY" } ) ;
14
+ this . id = this . workItem . id ;
15
+ } ) ;
16
+
12
17
test ( "it renders default" , async function ( assert ) {
13
18
await render (
14
- hbs `<WorkItemButton @mutation="complete" @workItemId="test" />` ,
19
+ hbs `<WorkItemButton @mutation="complete" @workItemId={{this.id}} />` ,
15
20
) ;
16
21
17
22
assert . dom ( "button" ) . hasText ( "Complete" ) ;
18
23
} ) ;
19
24
20
25
test ( "it renders label" , async function ( assert ) {
21
26
await render (
22
- hbs `<WorkItemButton @mutation="complete" @workItemId="test" @label="Lorem Ipsum" />` ,
27
+ hbs `<WorkItemButton
28
+ @mutation="complete"
29
+ @workItemId={{this.id}}
30
+ @label="Lorem Ipsum"
31
+ />` ,
23
32
) ;
24
33
25
34
assert . dom ( "button" ) . hasText ( "Lorem Ipsum" ) ;
26
35
} ) ;
27
36
28
37
test ( "it renders block" , async function ( assert ) {
29
38
await render (
30
- hbs `<WorkItemButton @mutation="complete" @workItemId="test" >Lorem Ipsum</WorkItemButton>` ,
39
+ hbs `<WorkItemButton @mutation="complete" @workItemId={{this.id}} >Lorem Ipsum</WorkItemButton>` ,
31
40
) ;
32
41
33
42
assert . dom ( "button" ) . hasText ( "Lorem Ipsum" ) ;
@@ -39,6 +48,10 @@ module("Integration | Component | work-item-button", function (hooks) {
39
48
let mutation = "complete" ;
40
49
this . set ( "mutation" , mutation ) ;
41
50
51
+ await render (
52
+ hbs `<WorkItemButton @mutation={{this.mutation}} @workItemId={{this.id}} />` ,
53
+ ) ;
54
+
42
55
this . server . post (
43
56
"graphql" ,
44
57
( _ , request ) => {
@@ -53,10 +66,6 @@ module("Integration | Component | work-item-button", function (hooks) {
53
66
200 ,
54
67
) ;
55
68
56
- await render (
57
- hbs `<WorkItemButton @mutation={{this.mutation}} @workItemId="test" />` ,
58
- ) ;
59
-
60
69
await click ( "button" ) ;
61
70
62
71
mutation = "skip" ;
@@ -79,7 +88,7 @@ module("Integration | Component | work-item-button", function (hooks) {
79
88
await render (
80
89
hbs `<WorkItemButton
81
90
@mutation="complete"
82
- @workItemId="test"
91
+ @workItemId={{this.id}}
83
92
@beforeMutate={{this.beforeMutate}}
84
93
/>` ,
85
94
) ;
@@ -88,4 +97,23 @@ module("Integration | Component | work-item-button", function (hooks) {
88
97
89
98
assert . verifySteps ( [ "beforeMutate" ] ) ;
90
99
} ) ;
100
+
101
+ test ( "it renders as disabled if the required work item status is not given" , async function ( assert ) {
102
+ assert . expect ( 2 ) ;
103
+
104
+ await render (
105
+ hbs `<WorkItemButton @mutation="complete" @workItemId={{this.id}} />` ,
106
+ ) ;
107
+
108
+ assert . dom ( "button" ) . isNotDisabled ( ) ;
109
+
110
+ this . workItem . status = "COMPLETED" ;
111
+ this . workItem . save ( ) ;
112
+
113
+ await render (
114
+ hbs `<WorkItemButton @mutation="complete" @workItemId={{this.id}} />` ,
115
+ ) ;
116
+
117
+ assert . dom ( "button" ) . isDisabled ( ) ;
118
+ } ) ;
91
119
} ) ;
0 commit comments