-
Notifications
You must be signed in to change notification settings - Fork 34
feat: Use new default-org on internal user for default org decision #3905
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,7 +13,6 @@ import { type Mock, vi } from 'vitest' | |
| import config from 'config' | ||
|
|
||
| import { useLocationParams } from 'services/navigation/useLocationParams' | ||
| import { Plans } from 'shared/utils/billing' | ||
|
|
||
| import App from './App' | ||
|
|
||
|
|
@@ -60,57 +59,15 @@ const internalUser = { | |
| integrationId: null, | ||
| name: null, | ||
| ownerid: 123, | ||
| service: 'cool-service', | ||
| service: 'gh', | ||
| stats: null, | ||
| username: 'cool-guy', | ||
| }, | ||
| ], | ||
| defaultOrg: 'codecov', | ||
| termsAgreement: true, | ||
| } | ||
|
|
||
| const user = { | ||
| me: { | ||
| owner: { | ||
| defaultOrgUsername: 'codecov', | ||
| }, | ||
| email: '[email protected]', | ||
| privateAccess: true, | ||
| onboardingCompleted: true, | ||
| businessEmail: '[email protected]', | ||
| termsAgreement: true, | ||
| user: { | ||
| name: 'Jane Doe', | ||
| username: 'janedoe', | ||
| avatarUrl: 'http://127.0.0.1/avatar-url', | ||
| avatar: 'http://127.0.0.1/avatar-url', | ||
| student: false, | ||
| studentCreatedAt: null, | ||
| studentUpdatedAt: null, | ||
| }, | ||
| trackingMetadata: { | ||
| service: 'github', | ||
| ownerid: 123, | ||
| serviceId: '123', | ||
| plan: Plans.USERS_DEVELOPER, | ||
| staff: false, | ||
| hasYaml: false, | ||
| bot: null, | ||
| delinquent: null, | ||
| didTrial: null, | ||
| planProvider: null, | ||
| planUserCount: 1, | ||
| createdAt: 'timestamp', | ||
| updatedAt: 'timestamp', | ||
| profile: { | ||
| createdAt: 'timestamp', | ||
| otherGoal: null, | ||
| typeProjects: [], | ||
| goals: [], | ||
| }, | ||
| }, | ||
| }, | ||
| } | ||
|
|
||
| const mockRepoOverview = { | ||
| owner: { | ||
| repository: { | ||
|
|
@@ -198,7 +155,6 @@ afterAll(() => { | |
|
|
||
| describe('App', () => { | ||
| function setup({ | ||
| hasLoggedInUser, | ||
| hasSession, | ||
| }: { | ||
| hasLoggedInUser?: boolean | ||
|
|
@@ -218,12 +174,6 @@ describe('App', () => { | |
| graphql.query('DetailOwner', () => | ||
| HttpResponse.json({ data: { owner: 'codecov' } }) | ||
| ), | ||
| graphql.query('CurrentUser', () => { | ||
| if (hasLoggedInUser) { | ||
| return HttpResponse.json({ data: user }) | ||
| } | ||
| HttpResponse.json({ data: {} }) | ||
| }), | ||
| graphql.query('GetPlanData', () => { | ||
| return HttpResponse.json({ data: {} }) | ||
| }), | ||
|
|
@@ -436,7 +386,7 @@ describe('App', () => { | |
| 'cloud routing', | ||
| ({ testLabel, pathname, expected }) => { | ||
| beforeEach(() => { | ||
| setup({ hasLoggedInUser: true, hasSession: true }) | ||
| setup({ hasSession: true }) | ||
| }) | ||
|
|
||
| it(`renders the ${testLabel} page`, async () => { | ||
|
|
@@ -620,7 +570,7 @@ describe('App', () => { | |
| ({ testLabel, pathname, expected }) => { | ||
| beforeEach(() => { | ||
| config.IS_SELF_HOSTED = true | ||
| setup({ hasLoggedInUser: true, hasSession: true }) | ||
| setup({ hasSession: true }) | ||
| }) | ||
|
|
||
| it(`renders the ${testLabel} page`, async () => { | ||
|
|
@@ -637,32 +587,30 @@ describe('App', () => { | |
|
|
||
| describe('user not logged in', () => { | ||
| it('redirects to login', async () => { | ||
| setup({ hasLoggedInUser: true, hasSession: false }) | ||
| setup({ hasSession: false }) | ||
| render(<App />, { wrapper: wrapper(['*']) }) | ||
| await waitFor(() => expect(testLocation.pathname).toBe('/login')) | ||
| }) | ||
| }) | ||
|
|
||
| describe('user has session, not logged in', () => { | ||
| it('redirects to session default', async () => { | ||
| setup({ hasLoggedInUser: false, hasSession: true }) | ||
| setup({ hasSession: true }) | ||
|
|
||
| render(<App />, { wrapper: wrapper(['/blah']) }) | ||
| await waitFor(() => | ||
| expect(testLocation.pathname).toBe('/cool-service/cool-guy') | ||
| ) | ||
| await waitFor(() => expect(testLocation.pathname).toBe('/gh/codecov')) | ||
| }) | ||
|
|
||
| it('redirects to plan page if to param === plan', async () => { | ||
| mockedUseLocationParams.mockReturnValue({ | ||
| params: { to: 'plan' }, | ||
| }) | ||
| setup({ hasLoggedInUser: false, hasSession: true }) | ||
| setup({ hasSession: true }) | ||
|
|
||
| render(<App />, { wrapper: wrapper(['/blah']) }) | ||
|
|
||
| await waitFor(() => | ||
| expect(testLocation.pathname).toBe('/plan/cool-service/cool-guy') | ||
| expect(testLocation.pathname).toBe('/plan/gh/codecov') | ||
| ) | ||
| }) | ||
| }) | ||
|
|
@@ -673,7 +621,7 @@ describe('App', () => { | |
| mockedUseLocationParams.mockReturnValue({ | ||
| params: { setup_action: 'install' }, | ||
| }) | ||
| setup({ hasLoggedInUser: true, hasSession: true }) | ||
| setup({ hasSession: true }) | ||
| render(<App />, { wrapper: wrapper(['/gh?setup_action=install']) }) | ||
|
|
||
| await waitFor(() => expect(testLocation.pathname).toBe('/gh/codecov')) | ||
|
|
@@ -687,7 +635,7 @@ describe('App', () => { | |
| mockedUseLocationParams.mockReturnValue({ | ||
| params: { to: '/gh/codecov/test-app/pull/123' }, | ||
| }) | ||
| setup({ hasLoggedInUser: true, hasSession: true }) | ||
| setup({ hasSession: true }) | ||
|
|
||
| render(<App />, { wrapper: wrapper(['/gh']) }) | ||
|
|
||
|
|
@@ -706,7 +654,7 @@ describe('App', () => { | |
| }) | ||
| // after redirecting the param should be removed | ||
| .mockReturnValue({ params: {} }) | ||
| setup({ hasLoggedInUser: true, hasSession: true }) | ||
| setup({ hasSession: true }) | ||
|
|
||
| render(<App />, { | ||
| wrapper: wrapper(['/gh?to=/gh/path/does/not/exist']), | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -68,6 +68,7 @@ | |
| externalId: null, | ||
| owners: null, | ||
| termsAgreement: false, | ||
| defaultOrg: null, | ||
| } | ||
|
|
||
| const mocks = vi.hoisted(() => ({ | ||
|
|
@@ -157,7 +158,7 @@ | |
| describe('page renders', () => { | ||
| beforeEach(() => | ||
| setup({ | ||
| internalUserData: { | ||
|
Check failure on line 161 in src/pages/TermsOfService/TermsOfService.test.tsx
|
||
| email: '', | ||
| name: '', | ||
| externalId: '', | ||
|
|
@@ -232,7 +233,7 @@ | |
| // that the correct inputs are being sent to the server. | ||
| it('Sign TOS, sends the correct inputs to the server, emits event', async () => { | ||
| const { user, mockMutationVariables } = setup({ | ||
| internalUserData: { | ||
|
Check failure on line 236 in src/pages/TermsOfService/TermsOfService.test.tsx
|
||
| email: '[email protected]', | ||
| name: 'Chetney', | ||
| externalId: '1234', | ||
|
|
@@ -515,7 +516,7 @@ | |
| ], | ||
| ])( | ||
| 'form validation, %s', | ||
| ( | ||
|
Check failure on line 519 in src/pages/TermsOfService/TermsOfService.test.tsx
|
||
| _, | ||
| initializeTest: { | ||
| internalUserData: InternalUserData | ||
|
|
@@ -563,7 +564,7 @@ | |
| describe('when SENTRY_DSN is not defined', () => { | ||
| it('does not render', async () => { | ||
| setup({ | ||
| internalUserData: { | ||
|
Check failure on line 567 in src/pages/TermsOfService/TermsOfService.test.tsx
|
||
| email: '', | ||
| name: '', | ||
| externalId: '', | ||
|
|
@@ -589,7 +590,7 @@ | |
| describe('when SENTRY_DSN is defined', () => { | ||
| it('renders', async () => { | ||
| setup({ | ||
| internalUserData: { | ||
|
Check failure on line 593 in src/pages/TermsOfService/TermsOfService.test.tsx
|
||
| email: '', | ||
| name: '', | ||
| externalId: '', | ||
|
|
@@ -615,7 +616,7 @@ | |
| describe('and component unmounts', () => { | ||
| it('removes the widget from the dom', async () => { | ||
| setup({ | ||
| internalUserData: { | ||
|
Check failure on line 619 in src/pages/TermsOfService/TermsOfService.test.tsx
|
||
| email: '', | ||
| name: '', | ||
| externalId: '', | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.