Skip to content

Commit

Permalink
Update to reflect is current user part of org
Browse files Browse the repository at this point in the history
  • Loading branch information
RulaKhaled committed Aug 26, 2024
1 parent 9bd8046 commit 06acd57
Show file tree
Hide file tree
Showing 20 changed files with 42 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ const mockErroredUploads = {

const mockRepoSettingsTeamData = (isPrivate = false) => ({
owner: {
isCurrentUserActivated: null,
isCurrentUserPartOfOrg: null,
repository: {
__typename: 'Repository',
defaultBranch: 'master',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import CommitCoverageTabs from './CommitCoverageTabs'

const mockRepoSettings = (isPrivate) => ({
owner: {
isCurrentUserActivated: true,
isCurrentUserPartOfOrg: true,
repository: {
__typename: 'Repository',
defaultBranch: 'main',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const mockProTier = {

const mockRepoSettings = (isPrivate: boolean) => ({
owner: {
isCurrentUserActivated: true,
isCurrentUserPartOfOrg: true,
repository: {
__typename: 'Repository',
defaultBranch: 'master',
Expand Down
2 changes: 1 addition & 1 deletion src/pages/CommitDetailPage/Header/Header.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion src/pages/PullRequestPage/Header/Header.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ describe('Summary', () => {
ctx.status(200),
ctx.data({
owner: {
isCurrentUserActivated: true,
isCurrentUserPartOfOrg: true,
repository: {
__typename: 'Repository',
defaultBranch: 'master',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ const mockTreeData = {

const mockRepoSettings = {
owner: {
isCurrentUserActivated: true,
isCurrentUserPartOfOrg: true,
repository: {
__typename: 'Repository',
activated: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ describe('FilesChangedTab', () => {
ctx.status(200),
ctx.data({
owner: {
isCurrentUserActivated: true,
isCurrentUserPartOfOrg: true,
repository: {
__typename: 'Repository',
activated: true,
Expand Down
2 changes: 1 addition & 1 deletion src/pages/RepoPage/CommitsTab/CommitsTab.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ const mockBranch = (branchName) => ({

const mockRepoSettings = (isPrivate = false) => ({
owner: {
isCurrentUserActivated: true,
isCurrentUserPartOfOrg: true,
repository: {
__typename: 'Repository',
activated: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('TokensTeam', () => {
ctx.status(200),
ctx.data({
owner: {
isCurrentUserActivated: true,
isCurrentUserPartOfOrg: true,
repository: {
__typename: 'Repository',
activated: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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) => {
Expand All @@ -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) =>
Expand Down Expand Up @@ -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: {
Expand All @@ -353,13 +353,15 @@ describe('Components Tab', () => {
},
},
},
isCurrentUserActivated: false,
isCurrentUserPartOfOrg: false,
})
})

it('renders empty state message', async () => {
render(<ComponentsTab />, { wrapper })
const componentsText = await screen.findByText(/No data to display/)
const componentsText = await screen.findByText(
/Component analytics is disabled./
)
expect(componentsText).toBeInTheDocument()
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ function ComponentsTab() {
})
}
>
{repoSettings?.isCurrentUserActivated ? (
{repoSettings?.isCurrentUserPartOfOrg ? (
<BackfillBanners />
) : (
<div className="mt-3 text-center">
<hr />
<p className="mt-4 p-3">No data to display</p>
<p className="mt-4 p-3">Component analytics is disabled.</p>
</div>
)}
</Header>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/RepoPage/CoverageTab/CoverageTab.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import CoverageTab from './CoverageTab'

const mockRepoSettingsTeam = {
owner: {
isCurrentUserActivated: true,
isCurrentUserPartOfOrg: true,
repository: {
__typename: 'Repository',
defaultBranch: 'master',
Expand Down
4 changes: 2 additions & 2 deletions src/pages/RepoPage/CoverageTab/FlagsTab/FlagsTab.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ function FlagsTab() {
isRepoBackfilling,
})}
>
{repoSettings?.isCurrentUserActivated ? (
{repoSettings?.isCurrentUserPartOfOrg ? (
<BackfillBanners />
) : (
<div className="mt-3 text-center">
<hr />
<p className="mt-4 p-3">No data to display</p>
<p className="mt-4 p-3">Flag analytics is disabled.</p>
</div>
)}
</Header>
Expand Down
14 changes: 7 additions & 7 deletions src/pages/RepoPage/CoverageTab/FlagsTab/FlagsTab.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ const flagsData = [

const mockRepoSettings = (
isPrivate = false,
isCurrentUserActivated = true
isCurrentUserPartOfOrg = true
) => ({
owner: {
isCurrentUserActivated,
isCurrentUserPartOfOrg,
repository: {
__typename: 'Repository',
activated: true,
Expand Down Expand Up @@ -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)
Expand All @@ -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))
)
})
)
Expand Down Expand Up @@ -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: {
Expand All @@ -348,13 +348,13 @@ describe('Flags Tab', () => {
name: 'flag2',
},
],
isCurrentUserActivated: false,
isCurrentUserPartOfOrg: false,
})
})

it('renders empty state message', async () => {
render(<FlagsTab />, { wrapper })
const flagsText = await screen.findByText(/No data to display/)
const flagsText = await screen.findByText(/Flag analytics is disabled./)
expect(flagsText).toBeInTheDocument()
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jest.mock('./subroute/Fileviewer', () => () => 'FileViewer')

const mockRepoSettings = (isPrivate = false) => ({
owner: {
isCurrentUserActivated: true,
isCurrentUserPartOfOrg: true,
repository: {
defaultBranch: 'master',
private: isPrivate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jest.mock('react-use/lib/useIntersection')

const mockRepoSettings = (isPrivate) => ({
owner: {
isCurrentUserActivated: true,
isCurrentUserPartOfOrg: true,
repository: {
__typename: 'Repository',
activated: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jest.mock('ui/CodeRenderer/hooks/useScrollToLine')

const mockRepoSettings = (isPrivate) => ({
owner: {
isCurrentUserActivated: true,
isCurrentUserPartOfOrg: true,
repository: {
__typename: 'Repository',
activated: true,
Expand Down
8 changes: 4 additions & 4 deletions src/services/repo/useRepoSettingsTeam.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ afterAll(() => server.close())

const mockNotFoundError = {
owner: {
isCurrentUserActivated: null,
isCurrentUserPartOfOrg: null,
repository: {
__typename: 'NotFoundError',
message: 'repo not found',
Expand All @@ -41,7 +41,7 @@ const mockNotFoundError = {

const mockIncorrectResponse = {
owner: {
isCurrentUserActivated: false,
isCurrentUserPartOfOrg: false,
repository: {
invalid: 'invalid',
},
Expand All @@ -50,7 +50,7 @@ const mockIncorrectResponse = {

const mockResponse = {
owner: {
isCurrentUserActivated: true,
isCurrentUserPartOfOrg: true,
repository: {
__typename: 'Repository',
defaultBranch: 'master',
Expand Down Expand Up @@ -100,7 +100,7 @@ describe('useRepoSettingsTeam', () => {

await waitFor(() =>
expect(result.current.data).toEqual({
isCurrentUserActivated: true,
isCurrentUserPartOfOrg: true,
repository: {
__typename: 'Repository',
defaultBranch: 'master',
Expand Down
6 changes: 3 additions & 3 deletions src/services/repo/useRepoSettingsTeam.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 {
Expand Down Expand Up @@ -106,7 +106,7 @@ function fetchRepoSettingsDetails({

return {
repository,
isCurrentUserActivated: data?.owner?.isCurrentUserActivated,
isCurrentUserPartOfOrg: data?.owner?.isCurrentUserPartOfOrg,
}
})
}
Expand Down

0 comments on commit 06acd57

Please sign in to comment.