Skip to content

Commit 747f183

Browse files
Merge remote-tracking branch 'origin/main' into sshin/3108
2 parents 0c413de + c489df8 commit 747f183

File tree

125 files changed

+1522
-850
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+1522
-850
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
24.12.2
1+
25.1.3

src/pages/AccountSettings/AccountSettings.test.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ describe('AccountSettings', () => {
168168
planValue === Plans.USERS_TEAMM ||
169169
planValue === Plans.USERS_TEAMY,
170170
isTrialPlan: false,
171+
isSentryPlan: false,
171172
},
172173
},
173174
},

src/pages/AccountSettings/AccountSettingsSideMenu.test.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ describe('AccountSettingsSideMenu', () => {
156156
planValue === Plans.USERS_TEAMM ||
157157
planValue === Plans.USERS_TEAMY,
158158
isTrialPlan: false,
159+
isSentryPlan: false,
159160
},
160161
},
161162
},

src/pages/AccountSettings/tabs/Admin/DetailsSection/DetailsSection.test.jsx

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ beforeEach(() => {
3333
server.resetHandlers()
3434
})
3535

36+
afterEach(() => {
37+
vi.clearAllMocks()
38+
})
39+
3640
afterAll(() => {
3741
server.close()
3842
})
@@ -43,7 +47,7 @@ describe('DetailsSection', () => {
4347
const mutate = vi.fn()
4448
const addNotification = vi.fn()
4549

46-
useAddNotification.mockReturnValue(addNotification)
50+
vi.mocked(useAddNotification).mockReturnValue(addNotification)
4751
server.use(
4852
graphql.mutation('UpdateProfile', (info) => {
4953
mutate(info.variables)
@@ -52,15 +56,23 @@ describe('DetailsSection', () => {
5256
data: {
5357
updateProfile: {
5458
me: {
55-
username: 'donald duck',
5659
email: info.variables.input.email
5760
? info.variables.input.email
5861
59-
name: info.variables.input.name
60-
? info.variables.input.name
61-
: 'donald duck',
62-
avatarUrl: 'http://127.0.0.1/avatar-url',
63-
onboardingCompleted: false,
62+
onboardingCompleted: true,
63+
privateAccess: null,
64+
businessEmail: null,
65+
user: {
66+
name: info.variables.input.name
67+
? info.variables.input.name
68+
: 'donald duck',
69+
username: 'donald duck',
70+
avatarUrl: 'http://127.0.0.1/avatar-url',
71+
avatar: 'http://127.0.0.1/avatar-url',
72+
student: false,
73+
studentCreatedAt: null,
74+
studentUpdatedAt: null,
75+
},
6476
},
6577
},
6678
},
@@ -218,10 +230,15 @@ describe('DetailsSection', () => {
218230
)
219231
})
220232
})
221-
222233
describe('when mutation is not successful', () => {
223234
it('adds an error notification', async () => {
224235
const { user, addNotification } = setup()
236+
server.use(
237+
graphql.mutation('UpdateProfile', () => {
238+
return HttpResponse.error()
239+
})
240+
)
241+
225242
render(<DetailsSection name="donald duck" email="[email protected]" />, {
226243
wrapper,
227244
})

src/pages/AccountSettings/tabs/OrgUploadToken/GenerateOrgUploadToken.jsx renamed to src/pages/AccountSettings/tabs/OrgUploadToken/GenerateOrgUploadToken.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@ import Icon from 'ui/Icon'
77

88
import useGenerateOrgUploadToken from './useGenerateOrgUploadToken'
99

10+
interface URLParams {
11+
owner: string
12+
}
13+
1014
function GenerateOrgUploadToken() {
11-
const { owner } = useParams()
15+
const { owner } = useParams<URLParams>()
1216
const { regenerateToken, isLoading } = useGenerateOrgUploadToken()
1317
const isAdmin = useIsCurrentUserAnAdmin({ owner })
1418

@@ -33,11 +37,12 @@ function GenerateOrgUploadToken() {
3337
</div>
3438
{!isAdmin && (
3539
<div className="flex gap-1">
36-
<Icon name="information-circle" size="sm" />
40+
<Icon name="informationCircle" size="sm" />
3741
Only organization admins can regenerate this token.
3842
</div>
3943
)}
4044
<div className="flex gap-1">
45+
{/* @ts-expect-error error until convert A to ts */}
4146
<A to={{ pageName: 'orgUploadTokenDoc' }}>Learn more</A>
4247
<p>how to generate and use the global upload token.</p>
4348
</div>

src/pages/AccountSettings/tabs/OrgUploadToken/OrgUploadToken.test.jsx renamed to src/pages/AccountSettings/tabs/OrgUploadToken/OrgUploadToken.test.tsx

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const queryClient = new QueryClient({
2929
},
3030
})
3131

32-
const wrapper = ({ children }) => (
32+
const wrapper: React.FC<React.PropsWithChildren> = ({ children }) => (
3333
<MemoryRouter initialEntries={['/account/gh/codecov/orgUploadToken']}>
3434
<QueryClientProvider client={queryClient}>
3535
<Route path="/account/:provider/:owner/orgUploadToken">
@@ -46,26 +46,31 @@ beforeAll(() => {
4646
afterEach(() => {
4747
queryClient.clear()
4848
server.resetHandlers()
49+
vi.clearAllMocks()
4950
})
5051

5152
afterAll(() => {
5253
server.close()
5354
})
5455

56+
type SetupOptions = {
57+
orgUploadToken?: string | null
58+
error?: string | null
59+
isAdmin?: boolean
60+
}
61+
5562
describe('OrgUploadToken', () => {
56-
function setup(
57-
{ orgUploadToken = null, error = null, isAdmin = true } = {
58-
orgUploadToken: null,
59-
error: null,
60-
isAdmin: true,
61-
}
62-
) {
63+
function setup({
64+
orgUploadToken = null,
65+
error = null,
66+
isAdmin = true,
67+
}: SetupOptions = {}) {
6368
const user = userEvent.setup()
6469
const mutate = vi.fn()
6570
const addNotification = vi.fn()
66-
useFlags.mockReturnValue({ tokenlessSection: true })
6771

68-
useAddNotification.mockReturnValue(addNotification)
72+
vi.mocked(useFlags).mockReturnValue({ tokenlessSection: true })
73+
vi.mocked(useAddNotification).mockReturnValue(addNotification)
6974

7075
server.use(
7176
graphql.query('DetailOwner', () => {
@@ -87,15 +92,17 @@ describe('OrgUploadToken', () => {
8792
},
8893
})
8994
}),
90-
graphql.mutation('regenerateOrgUploadToken', () => {
91-
mutate('regenerateOrgUploadToken')
95+
graphql.mutation('RegenerateOrgUploadToken', () => {
96+
mutate('RegenerateOrgUploadToken')
9297
return HttpResponse.json({
9398
data: {
9499
regenerateOrgUploadToken: {
95100
orgUploadToken,
96-
error: {
97-
__typename: error,
98-
},
101+
...(error && {
102+
error: {
103+
__typename: error,
104+
},
105+
}),
99106
},
100107
},
101108
})
@@ -163,7 +170,7 @@ describe('OrgUploadToken', () => {
163170

164171
describe('when user clicks on Generate button', () => {
165172
it('calls the mutation', async () => {
166-
const { mutate, user } = setup()
173+
const { mutate, user } = setup({ orgUploadToken: '' })
167174

168175
render(<OrgUploadToken />, { wrapper })
169176

@@ -177,7 +184,7 @@ describe('OrgUploadToken', () => {
177184
it('calls the mutation', async () => {
178185
const { user, mutate } = setup({
179186
orgUploadToken: '',
180-
error: 'Authentication Error',
187+
error: 'UnauthenticatedError',
181188
isAdmin: true,
182189
})
183190
render(<OrgUploadToken />, { wrapper })
@@ -193,7 +200,7 @@ describe('OrgUploadToken', () => {
193200
it('adds an error notification', async () => {
194201
const { addNotification, user } = setup({
195202
orgUploadToken: '',
196-
error: 'Authentication Error',
203+
error: 'UnauthenticatedError',
197204
isAdmin: true,
198205
})
199206
const { rerender } = render(<OrgUploadToken />, { wrapper })
@@ -203,12 +210,12 @@ describe('OrgUploadToken', () => {
203210

204211
await user.click(genBtn)
205212

206-
rerender()
213+
rerender(<OrgUploadToken />)
207214

208215
await waitFor(() =>
209216
expect(addNotification).toHaveBeenCalledWith({
210217
type: 'error',
211-
text: 'Authentication Error',
218+
text: 'UnauthenticatedError',
212219
})
213220
)
214221
})
@@ -299,7 +306,7 @@ describe('OrgUploadToken', () => {
299306

300307
const show = await screen.findAllByText('Show')
301308
expect(show[1]).toBeInTheDocument()
302-
await user.click(show[1])
309+
await user.click(show[1]!)
303310

304311
const token1 = await screen.findByText('CODECOV_TOKEN=token')
305312
expect(token1).toBeInTheDocument()

src/pages/AccountSettings/tabs/OrgUploadToken/OrgUploadToken.jsx renamed to src/pages/AccountSettings/tabs/OrgUploadToken/OrgUploadToken.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,13 @@ import RegenerateOrgUploadToken from './RegenerateOrgUploadToken'
1111

1212
const TokenlessSection = lazy(() => import('./TokenlessSection'))
1313

14+
interface URLParams {
15+
provider: string
16+
owner: string
17+
}
18+
1419
function OrgUploadToken() {
15-
const { provider, owner } = useParams()
20+
const { provider, owner } = useParams<URLParams>()
1621
const { data: orgUploadToken } = useOrgUploadToken({ provider, owner })
1722
const { tokenlessSection: tokenlessSectionFlag } = useFlags({
1823
tokenlessSection: false,
@@ -23,6 +28,7 @@ function OrgUploadToken() {
2328
<div className="flex gap-1">
2429
<h1 className="text-lg font-semibold">Global upload token</h1>
2530
<div className="mt-2 text-xs">
31+
{/* @ts-expect-error error until we can convert A component to ts */}
2632
<A to={{ pageName: 'orgUploadTokenDoc' }}>learn more</A>
2733
</div>
2834
</div>

src/pages/AccountSettings/tabs/OrgUploadToken/RegenerateOrgUploadToken.jsx renamed to src/pages/AccountSettings/tabs/OrgUploadToken/RegenerateOrgUploadToken.tsx

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import PropTypes from 'prop-types'
21
import { useState } from 'react'
32
import { useParams } from 'react-router-dom'
43

@@ -15,9 +14,11 @@ const TokenFormatEnum = Object.freeze({
1514
SECOND_FORMAT: 'CODECOV_TOKEN=',
1615
})
1716

18-
const UploadToken = ({ token, format }) => {
17+
const UploadToken = ({ token, format }: { token: string; format: string }) => {
1918
const [hideClipboard, setHideClipboard] = useState(true)
20-
const encodedToken = hideClipboard && format + token.replace(/[^w-]|/g, 'x')
19+
const encodedToken = hideClipboard
20+
? format + token.replace(/[^w-]|/g, 'x')
21+
: undefined
2122

2223
return (
2324
<div className="flex items-center gap-2">
@@ -28,7 +29,7 @@ const UploadToken = ({ token, format }) => {
2829
data-testid="hide-token"
2930
>
3031
<Icon
31-
name={hideClipboard ? 'eye' : 'eye-off'}
32+
name={hideClipboard ? 'eye' : 'eyeOff'}
3233
size="sm"
3334
variant="solid"
3435
/>
@@ -40,14 +41,18 @@ const UploadToken = ({ token, format }) => {
4041
)
4142
}
4243

43-
UploadToken.propTypes = {
44-
token: PropTypes.string.isRequired,
45-
format: PropTypes.string.isRequired,
44+
interface URLParams {
45+
provider: string
46+
owner: string
4647
}
4748

48-
function RegenerateOrgUploadToken({ orgUploadToken }) {
49-
const { owner } = useParams()
50-
const { regenerateToken, isLoading } = useGenerateOrgUploadToken()
49+
function RegenerateOrgUploadToken({
50+
orgUploadToken,
51+
}: {
52+
orgUploadToken: string
53+
}) {
54+
const { owner } = useParams<URLParams>()
55+
const { regenerateTokenAsync, isLoading } = useGenerateOrgUploadToken()
5156
const [showModal, setShowModal] = useState(false)
5257
const isAdmin = useIsCurrentUserAnAdmin({ owner })
5358

@@ -66,7 +71,7 @@ function RegenerateOrgUploadToken({ orgUploadToken }) {
6671
/>
6772
{!isAdmin && (
6873
<div className="flex gap-1">
69-
<Icon name="information-circle" size="sm" />
74+
<Icon name="informationCircle" size="sm" />
7075
Only organization admins can regenerate this token.
7176
</div>
7277
)}
@@ -82,7 +87,7 @@ function RegenerateOrgUploadToken({ orgUploadToken }) {
8287
{showModal && (
8388
<RegenerateTokenModal
8489
closeModal={() => setShowModal(false)}
85-
regenerateToken={regenerateToken}
90+
regenerateToken={regenerateTokenAsync}
8691
isLoading={isLoading}
8792
/>
8893
)}
@@ -91,8 +96,4 @@ function RegenerateOrgUploadToken({ orgUploadToken }) {
9196
)
9297
}
9398

94-
RegenerateOrgUploadToken.propTypes = {
95-
orgUploadToken: PropTypes.string.isRequired,
96-
}
97-
9899
export default RegenerateOrgUploadToken

src/pages/AccountSettings/tabs/OrgUploadToken/RegenrateTokenModal.jsx renamed to src/pages/AccountSettings/tabs/OrgUploadToken/RegenrateTokenModal.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
import PropTypes from 'prop-types'
2-
31
import Button from 'ui/Button'
42
import Modal from 'ui/Modal'
53

6-
const RegenerateTokenModal = ({ closeModal, regenerateToken, isLoading }) => (
4+
const RegenerateTokenModal = ({
5+
closeModal,
6+
regenerateToken,
7+
isLoading,
8+
}: {
9+
closeModal: () => void
10+
regenerateToken: () => Promise<unknown>
11+
isLoading: boolean
12+
}) => (
713
<Modal
814
isOpen={true}
915
onClose={closeModal}
@@ -45,10 +51,4 @@ const RegenerateTokenModal = ({ closeModal, regenerateToken, isLoading }) => (
4551
/>
4652
)
4753

48-
RegenerateTokenModal.propTypes = {
49-
closeModal: PropTypes.func.isRequired,
50-
regenerateToken: PropTypes.func.isRequired,
51-
isLoading: PropTypes.bool.isRequired,
52-
}
53-
5454
export default RegenerateTokenModal

0 commit comments

Comments
 (0)