Skip to content

Commit

Permalink
refactor redirectFromGetStarted resolver to be more generic
Browse files Browse the repository at this point in the history
  • Loading branch information
rachellerathbone committed Dec 12, 2023
1 parent 6f4f6a9 commit 77eb7fe
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('redirectFromGetStarted', () => {

(invoke as jest.Mock).mockResolvedValue(contextData);
await redirectFromGetStarted();
expect(invoke).toHaveBeenCalledWith('redirectFromGetStarted');
expect(invoke).toHaveBeenCalledWith('fetchAppData');
expect(router.navigate).toHaveBeenCalledWith(
`${contextData.siteUrl}/jira/settings/apps/${contextData.appId}/${contextData.environmentId}/`
);
Expand All @@ -33,7 +33,7 @@ describe('redirectFromGetStarted', () => {

(invoke as jest.Mock).mockResolvedValue(contextData);
await redirectFromGetStarted();
expect(invoke).toHaveBeenCalledWith('redirectFromGetStarted');
expect(invoke).toHaveBeenCalledWith('fetchAppData');
expect(router.navigate).not.toHaveBeenCalledWith(
`${contextData.siteUrl}/jira/settings/apps/${contextData.appId}/${contextData.environmentId}/`
);
Expand Down
2 changes: 1 addition & 1 deletion app/jenkins-for-jira-ui/src/api/redirectFromGetStarted.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ interface Context {
}

const redirectFromGetStarted = async (): Promise<string> => {
const context: Context = await invoke('redirectFromGetStarted');
const context: Context = await invoke('fetchAppData');
const {
siteUrl,
appId,
Expand Down
6 changes: 3 additions & 3 deletions app/src/resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { deleteDeployments } from './jira-client/delete-deployments';
import { adminPermissionCheck } from './check-permissions';
import { metricResolverEmitter } from './common/metric-names';
import { generateNewSecret } from './storage/generate-new-secret';
import { RedirectFromGetStarted, redirectFromGetStarted } from './utils/redirect-from-get-started';
import { FetchAppDataProps, fetchAppData } from './utils/fetch-app-data';
import { fetchFeatureFlag } from './config/feature-flags';

const resolver = new Resolver();
Expand Down Expand Up @@ -82,10 +82,10 @@ resolver.define('fetchCloudId', async (req): Promise<string> => {
return req.context.cloudId;
});

resolver.define('redirectFromGetStarted', async (req): Promise<RedirectFromGetStarted> => {
resolver.define('fetchAppData', async (req): Promise<FetchAppDataProps> => {
await adminPermissionCheck(req);
internalMetrics.counter(metricResolverEmitter.generateNewSecretForServer).incr();
return redirectFromGetStarted(req);
return fetchAppData(req);
});

export default resolver.getDefinitions();
6 changes: 3 additions & 3 deletions app/src/utils/fetch-app-data.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { redirectFromGetStarted, RedirectFromGetStarted } from './redirect-from-get-started';
import { fetchAppData, FetchAppDataProps } from './fetch-app-data';

describe('redirectFromGetStarted', () => {
it('should return the expected RedirectFromGetStarted object', () => {
Expand All @@ -12,14 +12,14 @@ describe('redirectFromGetStarted', () => {
},
};

const result: RedirectFromGetStarted = redirectFromGetStarted(mockRequest);
const result: FetchAppDataProps = fetchAppData(mockRequest);
const {
siteUrl,
appId,
environmentId,
moduleKey
} = mockRequest.context;
const expected: RedirectFromGetStarted = {
const expected: FetchAppDataProps = {
siteUrl,
appId,
environmentId,
Expand Down

0 comments on commit 77eb7fe

Please sign in to comment.