From 06acd57428566f2dc9d2a5a1c2f8dc8b3838e63f Mon Sep 17 00:00:00 2001 From: Rola Date: Mon, 26 Aug 2024 17:48:14 +0200 Subject: [PATCH] Update to reflect is current user part of org --- .../CommitCoverage/CommitCoverage.spec.jsx | 2 +- .../CommitCoverageTabs.spec.jsx | 2 +- .../FilesChangedTab/FilesChangedTab.spec.tsx | 2 +- .../CommitDetailPage/Header/Header.spec.tsx | 2 +- .../PullRequestPage/Header/Header.spec.tsx | 2 +- .../PullCoverage/Summary/Summary.spec.tsx | 2 +- .../routes/FileExplorer/FileExplorer.spec.tsx | 2 +- .../FilesChangedTab/FilesChangedTab.spec.tsx | 2 +- .../RepoPage/CommitsTab/CommitsTab.spec.jsx | 2 +- .../Tokens/TokensTeam/TokensTeam.spec.js | 2 +- .../ComponentsTab/ComponentsTab.spec.tsx | 18 ++++++++++-------- .../ComponentsTab/ComponentsTab.tsx | 4 ++-- .../RepoPage/CoverageTab/CoverageTab.spec.tsx | 2 +- .../RepoPage/CoverageTab/FlagsTab/FlagsTab.jsx | 4 ++-- .../CoverageTab/FlagsTab/FlagsTab.spec.jsx | 14 +++++++------- .../OverviewTab/OverviewTab.spec.tsx | 2 +- .../FileExplorer/FlagMultiSelect.spec.jsx | 2 +- .../subroute/Fileviewer/Fileviewer.spec.jsx | 2 +- src/services/repo/useRepoSettingsTeam.spec.tsx | 8 ++++---- src/services/repo/useRepoSettingsTeam.tsx | 6 +++--- 20 files changed, 42 insertions(+), 40 deletions(-) diff --git a/src/pages/CommitDetailPage/CommitCoverage/CommitCoverage.spec.jsx b/src/pages/CommitDetailPage/CommitCoverage/CommitCoverage.spec.jsx index 8c4e160380..7f2057242f 100644 --- a/src/pages/CommitDetailPage/CommitCoverage/CommitCoverage.spec.jsx +++ b/src/pages/CommitDetailPage/CommitCoverage/CommitCoverage.spec.jsx @@ -165,7 +165,7 @@ const mockErroredUploads = { const mockRepoSettingsTeamData = (isPrivate = false) => ({ owner: { - isCurrentUserActivated: null, + isCurrentUserPartOfOrg: null, repository: { __typename: 'Repository', defaultBranch: 'master', diff --git a/src/pages/CommitDetailPage/CommitCoverage/CommitCoverageTabs/CommitCoverageTabs.spec.jsx b/src/pages/CommitDetailPage/CommitCoverage/CommitCoverageTabs/CommitCoverageTabs.spec.jsx index 878e4d746c..1c6800aedc 100644 --- a/src/pages/CommitDetailPage/CommitCoverage/CommitCoverageTabs/CommitCoverageTabs.spec.jsx +++ b/src/pages/CommitDetailPage/CommitCoverage/CommitCoverageTabs/CommitCoverageTabs.spec.jsx @@ -12,7 +12,7 @@ import CommitCoverageTabs from './CommitCoverageTabs' const mockRepoSettings = (isPrivate) => ({ owner: { - isCurrentUserActivated: true, + isCurrentUserPartOfOrg: true, repository: { __typename: 'Repository', defaultBranch: 'main', diff --git a/src/pages/CommitDetailPage/CommitCoverage/routes/FilesChangedTab/FilesChangedTab.spec.tsx b/src/pages/CommitDetailPage/CommitCoverage/routes/FilesChangedTab/FilesChangedTab.spec.tsx index a21adec0f5..9dd224f159 100644 --- a/src/pages/CommitDetailPage/CommitCoverage/routes/FilesChangedTab/FilesChangedTab.spec.tsx +++ b/src/pages/CommitDetailPage/CommitCoverage/routes/FilesChangedTab/FilesChangedTab.spec.tsx @@ -33,7 +33,7 @@ const mockProTier = { const mockRepoSettings = (isPrivate: boolean) => ({ owner: { - isCurrentUserActivated: true, + isCurrentUserPartOfOrg: true, repository: { __typename: 'Repository', defaultBranch: 'master', diff --git a/src/pages/CommitDetailPage/Header/Header.spec.tsx b/src/pages/CommitDetailPage/Header/Header.spec.tsx index 8a73acbbc2..3270330ed3 100644 --- a/src/pages/CommitDetailPage/Header/Header.spec.tsx +++ b/src/pages/CommitDetailPage/Header/Header.spec.tsx @@ -17,7 +17,7 @@ const mockedUseFlags = useFlags as jest.Mock<{ multipleTiers: boolean }> const mockRepoSettings = (isPrivate = false) => ({ owner: { - isCurrentUserActivated: true, + isCurrentUserPartOfOrg: true, repository: { __typename: 'Repository', defaultBranch: 'master', diff --git a/src/pages/PullRequestPage/Header/Header.spec.tsx b/src/pages/PullRequestPage/Header/Header.spec.tsx index 8a73acbbc2..3270330ed3 100644 --- a/src/pages/PullRequestPage/Header/Header.spec.tsx +++ b/src/pages/PullRequestPage/Header/Header.spec.tsx @@ -17,7 +17,7 @@ const mockedUseFlags = useFlags as jest.Mock<{ multipleTiers: boolean }> const mockRepoSettings = (isPrivate = false) => ({ owner: { - isCurrentUserActivated: true, + isCurrentUserPartOfOrg: true, repository: { __typename: 'Repository', defaultBranch: 'master', diff --git a/src/pages/PullRequestPage/PullCoverage/Summary/Summary.spec.tsx b/src/pages/PullRequestPage/PullCoverage/Summary/Summary.spec.tsx index bcde39290c..83b604c1b9 100644 --- a/src/pages/PullRequestPage/PullCoverage/Summary/Summary.spec.tsx +++ b/src/pages/PullRequestPage/PullCoverage/Summary/Summary.spec.tsx @@ -81,7 +81,7 @@ describe('Summary', () => { ctx.status(200), ctx.data({ owner: { - isCurrentUserActivated: true, + isCurrentUserPartOfOrg: true, repository: { __typename: 'Repository', defaultBranch: 'master', diff --git a/src/pages/PullRequestPage/PullCoverage/routes/FileExplorer/FileExplorer.spec.tsx b/src/pages/PullRequestPage/PullCoverage/routes/FileExplorer/FileExplorer.spec.tsx index 4a1782e5f9..35106f57a9 100644 --- a/src/pages/PullRequestPage/PullCoverage/routes/FileExplorer/FileExplorer.spec.tsx +++ b/src/pages/PullRequestPage/PullCoverage/routes/FileExplorer/FileExplorer.spec.tsx @@ -159,7 +159,7 @@ const mockTreeData = { const mockRepoSettings = { owner: { - isCurrentUserActivated: true, + isCurrentUserPartOfOrg: true, repository: { __typename: 'Repository', activated: true, diff --git a/src/pages/PullRequestPage/PullCoverage/routes/FilesChangedTab/FilesChangedTab.spec.tsx b/src/pages/PullRequestPage/PullCoverage/routes/FilesChangedTab/FilesChangedTab.spec.tsx index 3679aeb726..d1cb2f86d1 100644 --- a/src/pages/PullRequestPage/PullCoverage/routes/FilesChangedTab/FilesChangedTab.spec.tsx +++ b/src/pages/PullRequestPage/PullCoverage/routes/FilesChangedTab/FilesChangedTab.spec.tsx @@ -128,7 +128,7 @@ describe('FilesChangedTab', () => { ctx.status(200), ctx.data({ owner: { - isCurrentUserActivated: true, + isCurrentUserPartOfOrg: true, repository: { __typename: 'Repository', activated: true, diff --git a/src/pages/RepoPage/CommitsTab/CommitsTab.spec.jsx b/src/pages/RepoPage/CommitsTab/CommitsTab.spec.jsx index 2beb22e090..e48ef5be67 100644 --- a/src/pages/RepoPage/CommitsTab/CommitsTab.spec.jsx +++ b/src/pages/RepoPage/CommitsTab/CommitsTab.spec.jsx @@ -137,7 +137,7 @@ const mockBranch = (branchName) => ({ const mockRepoSettings = (isPrivate = false) => ({ owner: { - isCurrentUserActivated: true, + isCurrentUserPartOfOrg: true, repository: { __typename: 'Repository', activated: true, diff --git a/src/pages/RepoPage/ConfigTab/tabs/GeneralTab/Tokens/TokensTeam/TokensTeam.spec.js b/src/pages/RepoPage/ConfigTab/tabs/GeneralTab/Tokens/TokensTeam/TokensTeam.spec.js index 9797521cf1..d4d1f937c0 100644 --- a/src/pages/RepoPage/ConfigTab/tabs/GeneralTab/Tokens/TokensTeam/TokensTeam.spec.js +++ b/src/pages/RepoPage/ConfigTab/tabs/GeneralTab/Tokens/TokensTeam/TokensTeam.spec.js @@ -37,7 +37,7 @@ describe('TokensTeam', () => { ctx.status(200), ctx.data({ owner: { - isCurrentUserActivated: true, + isCurrentUserPartOfOrg: true, repository: { __typename: 'Repository', activated: true, diff --git a/src/pages/RepoPage/CoverageTab/ComponentsTab/ComponentsTab.spec.tsx b/src/pages/RepoPage/CoverageTab/ComponentsTab/ComponentsTab.spec.tsx index 4cc1756e6a..1b4071caa5 100644 --- a/src/pages/RepoPage/CoverageTab/ComponentsTab/ComponentsTab.spec.tsx +++ b/src/pages/RepoPage/CoverageTab/ComponentsTab/ComponentsTab.spec.tsx @@ -30,10 +30,10 @@ jest.mock('./Header', () => ({ children }: { children: React.ReactNode }) => ( const mockRepoSettings = ( isPrivate = false, - isCurrentUserActivated = true + isCurrentUserPartOfOrg = true ) => ({ owner: { - isCurrentUserActivated, + isCurrentUserPartOfOrg, repository: { __typename: 'Repository', activated: true, @@ -158,13 +158,13 @@ describe('Components Tab', () => { flags = [nextPageFlagData, initialFlagData], tierValue = TierNames.PRO, isPrivate = false, - isCurrentUserActivated = true, + isCurrentUserPartOfOrg = true, }: { data?: object flags?: any[] tierValue?: TTierNames isPrivate?: boolean - isCurrentUserActivated?: boolean + isCurrentUserPartOfOrg?: boolean }) { server.use( graphql.query('OwnerTier', (req, res, ctx) => { @@ -182,7 +182,7 @@ describe('Components Tab', () => { graphql.query('GetRepoSettingsTeam', (req, res, ctx) => { return res( ctx.status(200), - ctx.data(mockRepoSettings(isPrivate, isCurrentUserActivated)) + ctx.data(mockRepoSettings(isPrivate, isCurrentUserPartOfOrg)) ) }), graphql.query('BackfillComponentMemberships', (req, res, ctx) => @@ -338,7 +338,7 @@ describe('Components Tab', () => { }) }) - describe('when current user is not activated and data is not enabled', () => { + describe('when current user is not part of org and data is not enabled', () => { beforeEach(() => { setup({ data: { @@ -353,13 +353,15 @@ describe('Components Tab', () => { }, }, }, - isCurrentUserActivated: false, + isCurrentUserPartOfOrg: false, }) }) it('renders empty state message', async () => { render(, { wrapper }) - const componentsText = await screen.findByText(/No data to display/) + const componentsText = await screen.findByText( + /Component analytics is disabled./ + ) expect(componentsText).toBeInTheDocument() }) }) diff --git a/src/pages/RepoPage/CoverageTab/ComponentsTab/ComponentsTab.tsx b/src/pages/RepoPage/CoverageTab/ComponentsTab/ComponentsTab.tsx index 543f2249bd..25780a3a43 100644 --- a/src/pages/RepoPage/CoverageTab/ComponentsTab/ComponentsTab.tsx +++ b/src/pages/RepoPage/CoverageTab/ComponentsTab/ComponentsTab.tsx @@ -66,12 +66,12 @@ function ComponentsTab() { }) } > - {repoSettings?.isCurrentUserActivated ? ( + {repoSettings?.isCurrentUserPartOfOrg ? ( ) : (

-

No data to display

+

Component analytics is disabled.

)} diff --git a/src/pages/RepoPage/CoverageTab/CoverageTab.spec.tsx b/src/pages/RepoPage/CoverageTab/CoverageTab.spec.tsx index 2a953622dd..68228d31fc 100644 --- a/src/pages/RepoPage/CoverageTab/CoverageTab.spec.tsx +++ b/src/pages/RepoPage/CoverageTab/CoverageTab.spec.tsx @@ -12,7 +12,7 @@ import CoverageTab from './CoverageTab' const mockRepoSettingsTeam = { owner: { - isCurrentUserActivated: true, + isCurrentUserPartOfOrg: true, repository: { __typename: 'Repository', defaultBranch: 'master', diff --git a/src/pages/RepoPage/CoverageTab/FlagsTab/FlagsTab.jsx b/src/pages/RepoPage/CoverageTab/FlagsTab/FlagsTab.jsx index 40e07f8878..3f436ca64b 100644 --- a/src/pages/RepoPage/CoverageTab/FlagsTab/FlagsTab.jsx +++ b/src/pages/RepoPage/CoverageTab/FlagsTab/FlagsTab.jsx @@ -61,12 +61,12 @@ function FlagsTab() { isRepoBackfilling, })} > - {repoSettings?.isCurrentUserActivated ? ( + {repoSettings?.isCurrentUserPartOfOrg ? ( ) : (

-

No data to display

+

Flag analytics is disabled.

)} diff --git a/src/pages/RepoPage/CoverageTab/FlagsTab/FlagsTab.spec.jsx b/src/pages/RepoPage/CoverageTab/FlagsTab/FlagsTab.spec.jsx index 9debddebb1..672941a20d 100644 --- a/src/pages/RepoPage/CoverageTab/FlagsTab/FlagsTab.spec.jsx +++ b/src/pages/RepoPage/CoverageTab/FlagsTab/FlagsTab.spec.jsx @@ -38,10 +38,10 @@ const flagsData = [ const mockRepoSettings = ( isPrivate = false, - isCurrentUserActivated = true + isCurrentUserPartOfOrg = true ) => ({ owner: { - isCurrentUserActivated, + isCurrentUserPartOfOrg, repository: { __typename: 'Repository', activated: true, @@ -98,7 +98,7 @@ describe('Flags Tab', () => { flags = flagsData, tierValue = TierNames.PRO, isPrivate = false, - isCurrentUserActivated = true, + isCurrentUserPartOfOrg = true, }) { useRepoFlagsSelect.mockReturnValue({ data: flags }) useRepoBackfilled.mockReturnValue(data) @@ -119,7 +119,7 @@ describe('Flags Tab', () => { graphql.query('GetRepoSettingsTeam', (req, res, ctx) => { return res( ctx.status(200), - ctx.data(mockRepoSettings(isPrivate, isCurrentUserActivated)) + ctx.data(mockRepoSettings(isPrivate, isCurrentUserPartOfOrg)) ) }) ) @@ -330,7 +330,7 @@ describe('Flags Tab', () => { }) }) - describe('when current user is not activated and data is not enabled', () => { + describe('when current user is not part of org and data is not enabled', () => { beforeEach(() => { setup({ data: { @@ -348,13 +348,13 @@ describe('Flags Tab', () => { name: 'flag2', }, ], - isCurrentUserActivated: false, + isCurrentUserPartOfOrg: false, }) }) it('renders empty state message', async () => { render(, { wrapper }) - const flagsText = await screen.findByText(/No data to display/) + const flagsText = await screen.findByText(/Flag analytics is disabled./) expect(flagsText).toBeInTheDocument() }) }) diff --git a/src/pages/RepoPage/CoverageTab/OverviewTab/OverviewTab.spec.tsx b/src/pages/RepoPage/CoverageTab/OverviewTab/OverviewTab.spec.tsx index c3fe9dc7eb..2309afb86e 100644 --- a/src/pages/RepoPage/CoverageTab/OverviewTab/OverviewTab.spec.tsx +++ b/src/pages/RepoPage/CoverageTab/OverviewTab/OverviewTab.spec.tsx @@ -19,7 +19,7 @@ jest.mock('./subroute/Fileviewer', () => () => 'FileViewer') const mockRepoSettings = (isPrivate = false) => ({ owner: { - isCurrentUserActivated: true, + isCurrentUserPartOfOrg: true, repository: { defaultBranch: 'master', private: isPrivate, diff --git a/src/pages/RepoPage/CoverageTab/OverviewTab/subroute/FileExplorer/FlagMultiSelect.spec.jsx b/src/pages/RepoPage/CoverageTab/OverviewTab/subroute/FileExplorer/FlagMultiSelect.spec.jsx index 16c49eed32..f88d133fce 100644 --- a/src/pages/RepoPage/CoverageTab/OverviewTab/subroute/FileExplorer/FlagMultiSelect.spec.jsx +++ b/src/pages/RepoPage/CoverageTab/OverviewTab/subroute/FileExplorer/FlagMultiSelect.spec.jsx @@ -14,7 +14,7 @@ jest.mock('react-use/lib/useIntersection') const mockRepoSettings = (isPrivate) => ({ owner: { - isCurrentUserActivated: true, + isCurrentUserPartOfOrg: true, repository: { __typename: 'Repository', activated: true, diff --git a/src/pages/RepoPage/CoverageTab/OverviewTab/subroute/Fileviewer/Fileviewer.spec.jsx b/src/pages/RepoPage/CoverageTab/OverviewTab/subroute/Fileviewer/Fileviewer.spec.jsx index 231e0044c7..4da863a971 100644 --- a/src/pages/RepoPage/CoverageTab/OverviewTab/subroute/Fileviewer/Fileviewer.spec.jsx +++ b/src/pages/RepoPage/CoverageTab/OverviewTab/subroute/Fileviewer/Fileviewer.spec.jsx @@ -13,7 +13,7 @@ jest.mock('ui/CodeRenderer/hooks/useScrollToLine') const mockRepoSettings = (isPrivate) => ({ owner: { - isCurrentUserActivated: true, + isCurrentUserPartOfOrg: true, repository: { __typename: 'Repository', activated: true, diff --git a/src/services/repo/useRepoSettingsTeam.spec.tsx b/src/services/repo/useRepoSettingsTeam.spec.tsx index 2eb6ae316d..78bd4c2bc3 100644 --- a/src/services/repo/useRepoSettingsTeam.spec.tsx +++ b/src/services/repo/useRepoSettingsTeam.spec.tsx @@ -31,7 +31,7 @@ afterAll(() => server.close()) const mockNotFoundError = { owner: { - isCurrentUserActivated: null, + isCurrentUserPartOfOrg: null, repository: { __typename: 'NotFoundError', message: 'repo not found', @@ -41,7 +41,7 @@ const mockNotFoundError = { const mockIncorrectResponse = { owner: { - isCurrentUserActivated: false, + isCurrentUserPartOfOrg: false, repository: { invalid: 'invalid', }, @@ -50,7 +50,7 @@ const mockIncorrectResponse = { const mockResponse = { owner: { - isCurrentUserActivated: true, + isCurrentUserPartOfOrg: true, repository: { __typename: 'Repository', defaultBranch: 'master', @@ -100,7 +100,7 @@ describe('useRepoSettingsTeam', () => { await waitFor(() => expect(result.current.data).toEqual({ - isCurrentUserActivated: true, + isCurrentUserPartOfOrg: true, repository: { __typename: 'Repository', defaultBranch: 'master', diff --git a/src/services/repo/useRepoSettingsTeam.tsx b/src/services/repo/useRepoSettingsTeam.tsx index 44243cd6fd..590d49bd06 100644 --- a/src/services/repo/useRepoSettingsTeam.tsx +++ b/src/services/repo/useRepoSettingsTeam.tsx @@ -32,7 +32,7 @@ interface FetchRepoSettingsTeamArgs { const RequestSchema = z.object({ owner: z .object({ - isCurrentUserActivated: z.boolean().nullable(), + isCurrentUserPartOfOrg: z.boolean().nullable(), repository: z .discriminatedUnion('__typename', [ RepositorySchema, @@ -46,7 +46,7 @@ const RequestSchema = z.object({ const query = ` query GetRepoSettingsTeam($name: String!, $repo: String!) { owner(username:$name) { - isCurrentUserActivated + isCurrentUserPartOfOrg repository(name:$repo) { __typename ... on Repository { @@ -106,7 +106,7 @@ function fetchRepoSettingsDetails({ return { repository, - isCurrentUserActivated: data?.owner?.isCurrentUserActivated, + isCurrentUserPartOfOrg: data?.owner?.isCurrentUserPartOfOrg, } }) }