Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-12-19 14:01:45 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-12-19 14:01:45 +0300
commit9297025d0b7ddf095eb618dfaaab2ff8f2018d8b (patch)
tree865198c01d1824a9b098127baa3ab980c9cd2c06 /spec/frontend/ide/mount_oauth_callback_spec.js
parent6372471f43ee03c05a7c1f8b0c6ac6b8a7431dbe (diff)
Add latest changes from gitlab-org/gitlab@16-7-stable-eev16.7.0-rc42
Diffstat (limited to 'spec/frontend/ide/mount_oauth_callback_spec.js')
-rw-r--r--spec/frontend/ide/mount_oauth_callback_spec.js53
1 files changed, 53 insertions, 0 deletions
diff --git a/spec/frontend/ide/mount_oauth_callback_spec.js b/spec/frontend/ide/mount_oauth_callback_spec.js
new file mode 100644
index 00000000000..6ac0b4e4615
--- /dev/null
+++ b/spec/frontend/ide/mount_oauth_callback_spec.js
@@ -0,0 +1,53 @@
+import { oauthCallback } from '@gitlab/web-ide';
+import { TEST_HOST } from 'helpers/test_constants';
+import { mountOAuthCallback } from '~/ide/mount_oauth_callback';
+
+jest.mock('@gitlab/web-ide');
+
+const TEST_USERNAME = 'gandalf.the.grey';
+const TEST_GITLAB_WEB_IDE_PUBLIC_PATH = 'test/webpack/assets/gitlab-web-ide/public/path';
+
+const TEST_OAUTH_CLIENT_ID = 'oauth-client-id-123abc';
+const TEST_OAUTH_CALLBACK_URL = 'https://example.com/oauth_callback';
+
+describe('~/ide/mount_oauth_callback', () => {
+ const createRootElement = () => {
+ const el = document.createElement('div');
+
+ el.id = 'ide';
+ el.dataset.clientId = TEST_OAUTH_CLIENT_ID;
+ el.dataset.callbackUrl = TEST_OAUTH_CALLBACK_URL;
+
+ document.body.append(el);
+ };
+
+ beforeEach(() => {
+ gon.current_username = TEST_USERNAME;
+ process.env.GITLAB_WEB_IDE_PUBLIC_PATH = TEST_GITLAB_WEB_IDE_PUBLIC_PATH;
+
+ createRootElement();
+ });
+
+ afterEach(() => {
+ document.body.innerHTML = '';
+ });
+
+ it('calls oauthCallback', () => {
+ expect(oauthCallback).not.toHaveBeenCalled();
+
+ mountOAuthCallback();
+
+ expect(oauthCallback).toHaveBeenCalledTimes(1);
+ expect(oauthCallback).toHaveBeenCalledWith({
+ auth: {
+ type: 'oauth',
+ callbackUrl: TEST_OAUTH_CALLBACK_URL,
+ clientId: TEST_OAUTH_CLIENT_ID,
+ protectRefreshToken: true,
+ },
+ gitlabUrl: TEST_HOST,
+ baseUrl: `${TEST_HOST}/${TEST_GITLAB_WEB_IDE_PUBLIC_PATH}`,
+ username: TEST_USERNAME,
+ });
+ });
+});