@@ -6,7 +6,7 @@ import { delay, graphql, HttpResponse } from 'msw'
6
6
import { setupServer } from 'msw/node'
7
7
import { MemoryRouter , Route } from 'react-router-dom'
8
8
9
- import EraseRepoContent from './EraseRepoContent '
9
+ import EraseRepo from './EraseRepo '
10
10
11
11
const mocks = vi . hoisted ( ( ) => ( {
12
12
useAddNotification : vi . fn ( ) ,
@@ -70,7 +70,7 @@ const mockResponse = {
70
70
} ,
71
71
}
72
72
73
- describe ( 'EraseRepoContent ' , ( ) => {
73
+ describe ( 'EraseRepository ' , ( ) => {
74
74
function setup (
75
75
{ failedMutation = false , isLoading = false , unauthorized = false } = {
76
76
failedMutation : false ,
@@ -103,45 +103,45 @@ describe('EraseRepoContent', () => {
103
103
return { user, mutate, addNotification }
104
104
}
105
105
106
- describe ( 'renders EraseRepoContent component' , ( ) => {
106
+ describe ( 'renders EraseRepo component' , ( ) => {
107
107
beforeEach ( ( ) => setup ( ) )
108
108
109
109
it ( 'renders title' , async ( ) => {
110
- render ( < EraseRepoContent /> , { wrapper } )
110
+ render ( < EraseRepo /> , { wrapper } )
111
111
112
- const title = await screen . findByText ( / E r a s e r e p o c o v e r a g e c o n t e n t / )
112
+ const title = await screen . findByText ( / E r a s e r e p o s i t o r y / )
113
113
expect ( title ) . toBeInTheDocument ( )
114
114
} )
115
115
116
116
it ( 'renders body' , async ( ) => {
117
- render ( < EraseRepoContent /> , { wrapper } )
117
+ render ( < EraseRepo /> , { wrapper } )
118
118
119
119
const firstBlock = await screen . findByText (
120
- / T h i s w i l l r e m o v e a l l c o v e r a g e r e p o r t i n g f r o m t h e r e p o ./
120
+ / T h i s w i l l e r a s e t h e r e p o s i t o r y , i n c l u d i n g a l l o f i t s c o n t e n t s ./
121
121
)
122
122
expect ( firstBlock ) . toBeInTheDocument ( )
123
123
} )
124
124
125
125
it ( 'renders erase button' , async ( ) => {
126
- render ( < EraseRepoContent /> , { wrapper } )
126
+ render ( < EraseRepo /> , { wrapper } )
127
127
128
128
const eraseButton = await screen . findByRole ( 'button' , {
129
- name : / E r a s e C o n t e n t / ,
129
+ name : / E r a s e R e p o s i t o r y / ,
130
130
} )
131
131
expect ( eraseButton ) . toBeInTheDocument ( )
132
132
} )
133
133
134
134
it ( 'renders processing copy when isLoading is true' , async ( ) => {
135
135
const { user } = setup ( { isLoading : true } )
136
- render ( < EraseRepoContent /> , { wrapper } )
136
+ render ( < EraseRepo /> , { wrapper } )
137
137
138
138
const eraseButton = await screen . findByRole ( 'button' , {
139
- name : / E r a s e C o n t e n t / ,
139
+ name : / E r a s e R e p o s i t o r y / ,
140
140
} )
141
141
await user . click ( eraseButton )
142
142
143
143
const modalCancelButton = await screen . findByRole ( 'button' , {
144
- name : / E r a s e C o n t e n t / ,
144
+ name : / E r a s e R e p o s i t o r y / ,
145
145
} )
146
146
await user . click ( modalCancelButton )
147
147
@@ -152,56 +152,56 @@ describe('EraseRepoContent', () => {
152
152
} )
153
153
} )
154
154
155
- describe ( 'when the user clicks on erase content button' , ( ) => {
156
- describe ( 'displays Erase Content Modal' , ( ) => {
155
+ describe ( 'when the user clicks on erase repository button' , ( ) => {
156
+ describe ( 'displays Erase Repository Modal' , ( ) => {
157
157
beforeEach ( ( ) => setup ( ) )
158
158
159
- it ( 'displays erase content button' , async ( ) => {
159
+ it ( 'displays erase repository button' , async ( ) => {
160
160
const { user } = setup ( )
161
- render ( < EraseRepoContent /> , { wrapper } )
161
+ render ( < EraseRepo /> , { wrapper } )
162
162
163
163
const eraseButton = await screen . findByRole ( 'button' , {
164
- name : / E r a s e C o n t e n t / ,
164
+ name : / E r a s e R e p o s i t o r y / ,
165
165
} )
166
166
user . click ( eraseButton )
167
167
168
168
const modalEraseButton = await screen . findByRole ( 'button' , {
169
- name : / E r a s e C o n t e n t / ,
169
+ name : / E r a s e R e p o s i t o r y / ,
170
170
} )
171
171
expect ( modalEraseButton ) . toBeInTheDocument ( )
172
172
} )
173
173
174
174
it ( 'displays modal body' , async ( ) => {
175
175
const { user } = setup ( )
176
- render ( < EraseRepoContent /> , { wrapper } )
176
+ render ( < EraseRepo /> , { wrapper } )
177
177
178
178
const eraseButton = await screen . findByRole ( 'button' , {
179
- name : / E r a s e C o n t e n t / ,
179
+ name : / E r a s e R e p o s i t o r y / ,
180
180
} )
181
181
user . click ( eraseButton )
182
182
183
183
const p1 = await screen . findByText (
184
- / A r e y o u s u r e y o u w a n t t o e r a s e t h e r e p o c o v e r a g e c o n t e n t ? /
184
+ / A r e y o u s u r e y o u w a n t t o e r a s e t h e r e p o s i t o r y ? /
185
185
)
186
186
expect ( p1 ) . toBeInTheDocument ( )
187
187
188
188
const p2 = await screen . findByText (
189
- / T h i s w i l l e r a s e r e p o c o v e r a g e c o n t e n t s h o u l d e r a s e a l l c o v e r a g e d a t a c o n t a i n e d i n t h e r e p o . T h i s a c t i o n i s i r r e v e r s i b l e a n d i f y o u p r o c e e d , y o u w i l l p e r m a n e n t l y e r a s e a n y h i s t o r i c a l c o d e c o v e r a g e i n C o d e c o v f o r t h i s r e p o s i t o r y . /
189
+ / T h i s w i l l e r a s e t h e r e p o s i t o r y , i n c l u d i n g a l l o f i t s c o n t e n t s . T h i s a c t i o n i s i r r e v e r s i b l e /
190
190
)
191
191
expect ( p2 ) . toBeInTheDocument ( )
192
192
} )
193
193
194
194
it ( 'displays modal buttons' , async ( ) => {
195
195
const { user } = setup ( )
196
- render ( < EraseRepoContent /> , { wrapper } )
196
+ render ( < EraseRepo /> , { wrapper } )
197
197
198
198
const eraseButton = await screen . findByRole ( 'button' , {
199
- name : / E r a s e C o n t e n t / ,
199
+ name : / E r a s e R e p o s i t o r y / ,
200
200
} )
201
201
user . click ( eraseButton )
202
202
203
203
const modalEraseButton = await screen . findByRole ( 'button' , {
204
- name : / E r a s e C o n t e n t / ,
204
+ name : / E r a s e R e p o s i t o r y / ,
205
205
} )
206
206
expect ( modalEraseButton ) . toBeInTheDocument ( )
207
207
@@ -215,10 +215,10 @@ describe('EraseRepoContent', () => {
215
215
describe ( 'when user clicks on Cancel button' , ( ) => {
216
216
it ( 'does not call the mutation' , async ( ) => {
217
217
const { user, mutate } = setup ( )
218
- render ( < EraseRepoContent /> , { wrapper } )
218
+ render ( < EraseRepo /> , { wrapper } )
219
219
220
220
const eraseButton = await screen . findByRole ( 'button' , {
221
- name : / E r a s e C o n t e n t / ,
221
+ name : / E r a s e R e p o s i t o r y / ,
222
222
} )
223
223
await user . click ( eraseButton )
224
224
@@ -232,18 +232,18 @@ describe('EraseRepoContent', () => {
232
232
} )
233
233
} )
234
234
235
- describe ( 'when user clicks on Erase Content button' , ( ) => {
235
+ describe ( 'when user clicks on Erase Repository button' , ( ) => {
236
236
it ( 'calls the mutation' , async ( ) => {
237
237
const { user, mutate } = setup ( )
238
- render ( < EraseRepoContent /> , { wrapper } )
238
+ render ( < EraseRepo /> , { wrapper } )
239
239
240
240
const eraseButton = await screen . findByRole ( 'button' , {
241
- name : / E r a s e C o n t e n t / ,
241
+ name : / E r a s e R e p o s i t o r y / ,
242
242
} )
243
243
await user . click ( eraseButton )
244
244
245
245
const modalEraseButton = await screen . findByRole ( 'button' , {
246
- name : / E r a s e C o n t e n t / ,
246
+ name : / E r a s e R e p o s i t o r y / ,
247
247
} )
248
248
await user . click ( modalEraseButton )
249
249
@@ -254,23 +254,23 @@ describe('EraseRepoContent', () => {
254
254
describe ( 'when mutation is successful' , ( ) => {
255
255
it ( 'adds a success notification' , async ( ) => {
256
256
const { user, mutate, addNotification } = setup ( )
257
- render ( < EraseRepoContent /> , { wrapper } )
257
+ render ( < EraseRepo /> , { wrapper } )
258
258
259
259
const eraseButton = await screen . findByRole ( 'button' , {
260
- name : / E r a s e C o n t e n t / ,
260
+ name : / E r a s e R e p o s i t o r y / ,
261
261
} )
262
262
await user . click ( eraseButton )
263
263
264
264
const modalEraseButton = await screen . findByRole ( 'button' , {
265
- name : / E r a s e C o n t e n t / ,
265
+ name : / E r a s e R e p o s i t o r y / ,
266
266
} )
267
267
await user . click ( modalEraseButton )
268
268
269
269
await waitFor ( ( ) => expect ( mutate ) . toHaveBeenCalled ( ) )
270
270
await waitFor ( ( ) =>
271
271
expect ( addNotification ) . toHaveBeenCalledWith ( {
272
272
type : 'success' ,
273
- text : 'Repo coverage content erased successfully' ,
273
+ text : 'Repository erased successfully' ,
274
274
} )
275
275
)
276
276
} )
@@ -279,23 +279,23 @@ describe('EraseRepoContent', () => {
279
279
describe ( 'when mutation is not successful' , ( ) => {
280
280
it ( 'adds an error notification' , async ( ) => {
281
281
const { user, mutate, addNotification } = setup ( { failedMutation : true } )
282
- render ( < EraseRepoContent /> , { wrapper } )
282
+ render ( < EraseRepo /> , { wrapper } )
283
283
284
284
const eraseButton = await screen . findByRole ( 'button' , {
285
- name : / E r a s e C o n t e n t / ,
285
+ name : / E r a s e R e p o s i t o r y / ,
286
286
} )
287
287
await user . click ( eraseButton )
288
288
289
289
const modalEraseButton = await screen . findByRole ( 'button' , {
290
- name : / E r a s e C o n t e n t / ,
290
+ name : / E r a s e R e p o s i t o r y / ,
291
291
} )
292
292
await user . click ( modalEraseButton )
293
293
294
294
await waitFor ( ( ) => expect ( mutate ) . toHaveBeenCalled ( ) )
295
295
await waitFor ( ( ) =>
296
296
expect ( addNotification ) . toHaveBeenCalledWith ( {
297
297
type : 'error' ,
298
- text : " We were unable to erase this repo's content" ,
298
+ text : ' We were unable to erase this repository' ,
299
299
} )
300
300
)
301
301
} )
@@ -304,23 +304,23 @@ describe('EraseRepoContent', () => {
304
304
describe ( 'when user is unauthorized' , ( ) => {
305
305
it ( 'adds an error notification' , async ( ) => {
306
306
const { user, mutate, addNotification } = setup ( { unauthorized : true } )
307
- render ( < EraseRepoContent /> , { wrapper } )
307
+ render ( < EraseRepo /> , { wrapper } )
308
308
309
309
const eraseButton = await screen . findByRole ( 'button' , {
310
- name : / E r a s e C o n t e n t / ,
310
+ name : / E r a s e R e p o s i t o r y / ,
311
311
} )
312
312
await user . click ( eraseButton )
313
313
314
314
const modalEraseButton = await screen . findByRole ( 'button' , {
315
- name : / E r a s e C o n t e n t / ,
315
+ name : / E r a s e R e p o s i t o r y / ,
316
316
} )
317
317
await user . click ( modalEraseButton )
318
318
319
319
await waitFor ( ( ) => expect ( mutate ) . toHaveBeenCalled ( ) )
320
320
await waitFor ( ( ) =>
321
321
expect ( addNotification ) . toHaveBeenCalledWith ( {
322
322
type : 'error' ,
323
- text : " We were unable to erase this repo's content" ,
323
+ text : ' We were unable to erase this repository' ,
324
324
} )
325
325
)
326
326
} )
0 commit comments