Skip to content

Commit 630bd02

Browse files
Refactor test and fix lint issues
1 parent 805711d commit 630bd02

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

  • x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/add_source

x-pack/plugins/enterprise_search/public/applications/workplace_search/views/content_sources/components/add_source/add_source_logic.test.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -361,28 +361,27 @@ describe('AddSourceLogic', () => {
361361
});
362362

363363
describe('Github error edge case', () => {
364+
const GITHUB_ERROR =
365+
'The redirect_uri MUST match the registered callback URL for this application.';
366+
const errorParams = { ...params, error_description: GITHUB_ERROR };
364367
const getGithubQueryString = (context: 'organization' | 'account') =>
365368
`?error=redirect_uri_mismatch&error_description=The+redirect_uri+MUST+match+the+registered+callback+URL+for+this+application.&error_uri=https%3A%2F%2Fdocs.github.com%2Fapps%2Fmanaging-oauth-apps%2Ftroubleshooting-authorization-request-errors%2F%23redirect-uri-mismatch&state=%7B%22action%22%3A%22create%22%2C%22context%22%3A%22${context}%22%2C%22service_type%22%3A%22github%22%2C%22csrf_token%22%3A%22TOKEN%3D%3D%22%2C%22index_permissions%22%3Afalse%7D`;
366369

367370
it('handles "organization" redirect and displays error', () => {
368371
const githubQueryString = getGithubQueryString('organization');
369-
AddSourceLogic.actions.saveSourceParams(githubQueryString);
372+
AddSourceLogic.actions.saveSourceParams(githubQueryString, errorParams, true);
370373

371374
expect(navigateToUrl).toHaveBeenCalledWith('/');
372-
expect(setErrorMessage).toHaveBeenCalledWith(
373-
'The redirect_uri MUST match the registered callback URL for this application.'
374-
);
375+
expect(setErrorMessage).toHaveBeenCalledWith(GITHUB_ERROR);
375376
});
376377

377378
it('handles "account" redirect and displays error', () => {
378379
const githubQueryString = getGithubQueryString('account');
379-
AddSourceLogic.actions.saveSourceParams(githubQueryString);
380+
AddSourceLogic.actions.saveSourceParams(githubQueryString, errorParams, false);
380381

381382
expect(navigateToUrl).toHaveBeenCalledWith(PERSONAL_SOURCES_PATH);
382383
expect(setErrorMessage).toHaveBeenCalledWith(
383-
PERSONAL_DASHBOARD_SOURCE_ERROR(
384-
'The redirect_uri MUST match the registered callback URL for this application.'
385-
)
384+
PERSONAL_DASHBOARD_SOURCE_ERROR(GITHUB_ERROR)
386385
);
387386
});
388387
});

0 commit comments

Comments
 (0)