Skip to content

Commit a3390e6

Browse files
authored
Reword the "Erase Repo" action (#3670)
1 parent 02d5b6b commit a3390e6

File tree

8 files changed

+77
-81
lines changed

8 files changed

+77
-81
lines changed

src/pages/RepoPage/ConfigTab/tabs/GeneralTab/DangerZone/DangerZone.jsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import SettingsDescriptor from 'ui/SettingsDescriptor'
22

3-
import EraseRepoContent from './EraseRepoContent'
3+
import EraseRepo from './EraseRepo'
44
import RepoState from './RepoState'
55

66
function DangerZone() {
77
return (
88
<SettingsDescriptor
99
title="Danger Zone"
10-
description="Erase repo coverage data and pause upload ability"
10+
description="Erase repository or pause upload ability"
1111
content={
1212
<>
13-
<EraseRepoContent />
13+
<EraseRepo />
1414
<RepoState />
1515
</>
1616
}
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import PropTypes from 'prop-types'
22
import { useState } from 'react'
33

4-
import { useEraseRepoContent } from 'services/repo'
4+
import { useEraseRepo } from 'services/repo'
55
import Button from 'ui/Button'
66

7-
import EraseRepoContentModal from './EraseRepoContentModal'
7+
import EraseRepoModal from './EraseRepoModal'
88

99
function EraseRepoButton({ isLoading, setShowModal }) {
1010
if (isLoading) {
@@ -21,7 +21,7 @@ function EraseRepoButton({ isLoading, setShowModal }) {
2121
hook="show-modal"
2222
onClick={() => setShowModal(true)}
2323
>
24-
Erase Content
24+
Erase Repository
2525
</Button>
2626
)
2727
}
@@ -31,31 +31,31 @@ EraseRepoButton.propTypes = {
3131
isLoading: PropTypes.bool.isRequired,
3232
}
3333

34-
function EraseRepoContent() {
34+
function EraseRepo() {
3535
const [showModal, setShowModal] = useState(false)
36-
const { mutate: eraseRepoContent, isLoading } = useEraseRepoContent()
36+
const { mutate: eraseRepo, isLoading } = useEraseRepo()
3737

3838
return (
3939
<div className="flex flex-col sm:flex-row">
4040
<div className="flex flex-1 flex-col gap-1">
41-
<h2 className="font-semibold">Erase repo coverage content</h2>
41+
<h2 className="font-semibold">Erase repository</h2>
4242
<p className="max-w-md">
43-
This will remove all coverage reporting from the repo. For larger
44-
repositories, this process may not be able to complete automatically.
45-
In that case, please reach out to support for help.
43+
This will erase the repository, including all of its contents. The
44+
repository itself will be re-created when resync-ing the organization
45+
contents.
4646
</p>
4747
</div>
4848
<div>
4949
<EraseRepoButton isLoading={isLoading} setShowModal={setShowModal} />
50-
<EraseRepoContentModal
50+
<EraseRepoModal
5151
showModal={showModal}
5252
closeModal={() => setShowModal(false)}
53-
eraseRepoContent={eraseRepoContent}
53+
eraseRepo={eraseRepo}
5454
isLoading={isLoading}
5555
/>
5656
</div>
5757
</div>
5858
)
5959
}
6060

61-
export default EraseRepoContent
61+
export default EraseRepo

src/pages/RepoPage/ConfigTab/tabs/GeneralTab/DangerZone/EraseRepoContent/EraseRepoContent.test.jsx src/pages/RepoPage/ConfigTab/tabs/GeneralTab/DangerZone/EraseRepo/EraseRepo.test.jsx

+43-43
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { delay, graphql, HttpResponse } from 'msw'
66
import { setupServer } from 'msw/node'
77
import { MemoryRouter, Route } from 'react-router-dom'
88

9-
import EraseRepoContent from './EraseRepoContent'
9+
import EraseRepo from './EraseRepo'
1010

1111
const mocks = vi.hoisted(() => ({
1212
useAddNotification: vi.fn(),
@@ -70,7 +70,7 @@ const mockResponse = {
7070
},
7171
}
7272

73-
describe('EraseRepoContent', () => {
73+
describe('EraseRepository', () => {
7474
function setup(
7575
{ failedMutation = false, isLoading = false, unauthorized = false } = {
7676
failedMutation: false,
@@ -103,45 +103,45 @@ describe('EraseRepoContent', () => {
103103
return { user, mutate, addNotification }
104104
}
105105

106-
describe('renders EraseRepoContent component', () => {
106+
describe('renders EraseRepo component', () => {
107107
beforeEach(() => setup())
108108

109109
it('renders title', async () => {
110-
render(<EraseRepoContent />, { wrapper })
110+
render(<EraseRepo />, { wrapper })
111111

112-
const title = await screen.findByText(/Erase repo coverage content/)
112+
const title = await screen.findByText(/Erase repository/)
113113
expect(title).toBeInTheDocument()
114114
})
115115

116116
it('renders body', async () => {
117-
render(<EraseRepoContent />, { wrapper })
117+
render(<EraseRepo />, { wrapper })
118118

119119
const firstBlock = await screen.findByText(
120-
/This will remove all coverage reporting from the repo./
120+
/This will erase the repository, including all of its contents./
121121
)
122122
expect(firstBlock).toBeInTheDocument()
123123
})
124124

125125
it('renders erase button', async () => {
126-
render(<EraseRepoContent />, { wrapper })
126+
render(<EraseRepo />, { wrapper })
127127

128128
const eraseButton = await screen.findByRole('button', {
129-
name: /Erase Content/,
129+
name: /Erase Repository/,
130130
})
131131
expect(eraseButton).toBeInTheDocument()
132132
})
133133

134134
it('renders processing copy when isLoading is true', async () => {
135135
const { user } = setup({ isLoading: true })
136-
render(<EraseRepoContent />, { wrapper })
136+
render(<EraseRepo />, { wrapper })
137137

138138
const eraseButton = await screen.findByRole('button', {
139-
name: /Erase Content/,
139+
name: /Erase Repository/,
140140
})
141141
await user.click(eraseButton)
142142

143143
const modalCancelButton = await screen.findByRole('button', {
144-
name: /Erase Content/,
144+
name: /Erase Repository/,
145145
})
146146
await user.click(modalCancelButton)
147147

@@ -152,56 +152,56 @@ describe('EraseRepoContent', () => {
152152
})
153153
})
154154

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', () => {
157157
beforeEach(() => setup())
158158

159-
it('displays erase content button', async () => {
159+
it('displays erase repository button', async () => {
160160
const { user } = setup()
161-
render(<EraseRepoContent />, { wrapper })
161+
render(<EraseRepo />, { wrapper })
162162

163163
const eraseButton = await screen.findByRole('button', {
164-
name: /Erase Content/,
164+
name: /Erase Repository/,
165165
})
166166
user.click(eraseButton)
167167

168168
const modalEraseButton = await screen.findByRole('button', {
169-
name: /Erase Content/,
169+
name: /Erase Repository/,
170170
})
171171
expect(modalEraseButton).toBeInTheDocument()
172172
})
173173

174174
it('displays modal body', async () => {
175175
const { user } = setup()
176-
render(<EraseRepoContent />, { wrapper })
176+
render(<EraseRepo />, { wrapper })
177177

178178
const eraseButton = await screen.findByRole('button', {
179-
name: /Erase Content/,
179+
name: /Erase Repository/,
180180
})
181181
user.click(eraseButton)
182182

183183
const p1 = await screen.findByText(
184-
/Are you sure you want to erase the repo coverage content?/
184+
/Are you sure you want to erase the repository?/
185185
)
186186
expect(p1).toBeInTheDocument()
187187

188188
const p2 = await screen.findByText(
189-
/This will erase repo coverage content should erase all coverage data contained in the repo. This action is irreversible and if you proceed, you will permanently erase any historical code coverage in Codecov for this repository./
189+
/This will erase the repository, including all of its contents. This action is irreversible/
190190
)
191191
expect(p2).toBeInTheDocument()
192192
})
193193

194194
it('displays modal buttons', async () => {
195195
const { user } = setup()
196-
render(<EraseRepoContent />, { wrapper })
196+
render(<EraseRepo />, { wrapper })
197197

198198
const eraseButton = await screen.findByRole('button', {
199-
name: /Erase Content/,
199+
name: /Erase Repository/,
200200
})
201201
user.click(eraseButton)
202202

203203
const modalEraseButton = await screen.findByRole('button', {
204-
name: /Erase Content/,
204+
name: /Erase Repository/,
205205
})
206206
expect(modalEraseButton).toBeInTheDocument()
207207

@@ -215,10 +215,10 @@ describe('EraseRepoContent', () => {
215215
describe('when user clicks on Cancel button', () => {
216216
it('does not call the mutation', async () => {
217217
const { user, mutate } = setup()
218-
render(<EraseRepoContent />, { wrapper })
218+
render(<EraseRepo />, { wrapper })
219219

220220
const eraseButton = await screen.findByRole('button', {
221-
name: /Erase Content/,
221+
name: /Erase Repository/,
222222
})
223223
await user.click(eraseButton)
224224

@@ -232,18 +232,18 @@ describe('EraseRepoContent', () => {
232232
})
233233
})
234234

235-
describe('when user clicks on Erase Content button', () => {
235+
describe('when user clicks on Erase Repository button', () => {
236236
it('calls the mutation', async () => {
237237
const { user, mutate } = setup()
238-
render(<EraseRepoContent />, { wrapper })
238+
render(<EraseRepo />, { wrapper })
239239

240240
const eraseButton = await screen.findByRole('button', {
241-
name: /Erase Content/,
241+
name: /Erase Repository/,
242242
})
243243
await user.click(eraseButton)
244244

245245
const modalEraseButton = await screen.findByRole('button', {
246-
name: /Erase Content/,
246+
name: /Erase Repository/,
247247
})
248248
await user.click(modalEraseButton)
249249

@@ -254,23 +254,23 @@ describe('EraseRepoContent', () => {
254254
describe('when mutation is successful', () => {
255255
it('adds a success notification', async () => {
256256
const { user, mutate, addNotification } = setup()
257-
render(<EraseRepoContent />, { wrapper })
257+
render(<EraseRepo />, { wrapper })
258258

259259
const eraseButton = await screen.findByRole('button', {
260-
name: /Erase Content/,
260+
name: /Erase Repository/,
261261
})
262262
await user.click(eraseButton)
263263

264264
const modalEraseButton = await screen.findByRole('button', {
265-
name: /Erase Content/,
265+
name: /Erase Repository/,
266266
})
267267
await user.click(modalEraseButton)
268268

269269
await waitFor(() => expect(mutate).toHaveBeenCalled())
270270
await waitFor(() =>
271271
expect(addNotification).toHaveBeenCalledWith({
272272
type: 'success',
273-
text: 'Repo coverage content erased successfully',
273+
text: 'Repository erased successfully',
274274
})
275275
)
276276
})
@@ -279,23 +279,23 @@ describe('EraseRepoContent', () => {
279279
describe('when mutation is not successful', () => {
280280
it('adds an error notification', async () => {
281281
const { user, mutate, addNotification } = setup({ failedMutation: true })
282-
render(<EraseRepoContent />, { wrapper })
282+
render(<EraseRepo />, { wrapper })
283283

284284
const eraseButton = await screen.findByRole('button', {
285-
name: /Erase Content/,
285+
name: /Erase Repository/,
286286
})
287287
await user.click(eraseButton)
288288

289289
const modalEraseButton = await screen.findByRole('button', {
290-
name: /Erase Content/,
290+
name: /Erase Repository/,
291291
})
292292
await user.click(modalEraseButton)
293293

294294
await waitFor(() => expect(mutate).toHaveBeenCalled())
295295
await waitFor(() =>
296296
expect(addNotification).toHaveBeenCalledWith({
297297
type: 'error',
298-
text: "We were unable to erase this repo's content",
298+
text: 'We were unable to erase this repository',
299299
})
300300
)
301301
})
@@ -304,23 +304,23 @@ describe('EraseRepoContent', () => {
304304
describe('when user is unauthorized', () => {
305305
it('adds an error notification', async () => {
306306
const { user, mutate, addNotification } = setup({ unauthorized: true })
307-
render(<EraseRepoContent />, { wrapper })
307+
render(<EraseRepo />, { wrapper })
308308

309309
const eraseButton = await screen.findByRole('button', {
310-
name: /Erase Content/,
310+
name: /Erase Repository/,
311311
})
312312
await user.click(eraseButton)
313313

314314
const modalEraseButton = await screen.findByRole('button', {
315-
name: /Erase Content/,
315+
name: /Erase Repository/,
316316
})
317317
await user.click(modalEraseButton)
318318

319319
await waitFor(() => expect(mutate).toHaveBeenCalled())
320320
await waitFor(() =>
321321
expect(addNotification).toHaveBeenCalledWith({
322322
type: 'error',
323-
text: "We were unable to erase this repo's content",
323+
text: 'We were unable to erase this repository',
324324
})
325325
)
326326
})

0 commit comments

Comments
 (0)