summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/assets/javascripts/behaviors/markdown/copy_as_gfm.js4
-rw-r--r--app/assets/javascripts/blob_edit/blob_bundle.js7
-rw-r--r--app/assets/javascripts/gl_form.js3
-rw-r--r--app/assets/javascripts/lib/utils/common_utils.js92
-rw-r--r--app/assets/javascripts/lib/utils/datetime_utility.js1
-rw-r--r--app/assets/javascripts/members.js3
-rw-r--r--app/assets/javascripts/sidebar/mount_sidebar.js5
-rw-r--r--app/assets/javascripts/vue_shared/components/pagination/table_pagination.vue2
-rw-r--r--db/migrate/20200628210938_add_maintenance_mode_application_to_settings.rb29
-rw-r--r--db/structure.sql4
-rw-r--r--doc/api/settings.md2
-rw-r--r--doc/user/application_security/dast/index.md2
-rw-r--r--doc/user/application_security/sast/index.md1
-rw-r--r--lib/gitlab/usage_data.rb9
-rw-r--r--spec/frontend/batch_comments/stores/modules/batch_comments/actions_spec.js28
-rw-r--r--spec/frontend/behaviors/copy_as_gfm_spec.js5
-rw-r--r--spec/frontend/behaviors/shortcuts/shortcuts_issuable_spec.js2
-rw-r--r--spec/frontend/boards/components/board_form_spec.js5
-rw-r--r--spec/frontend/diffs/store/actions_spec.js11
-rw-r--r--spec/frontend/filtered_search/filtered_search_manager_spec.js4
-rw-r--r--spec/frontend/filtered_search/visual_token_value_spec.js3
-rw-r--r--spec/frontend/gl_form_spec.js2
-rw-r--r--spec/frontend/ide/stores/actions/tree_spec.js3
-rw-r--r--spec/frontend/image_diff/helpers/comment_indicator_helper_spec.js3
-rw-r--r--spec/frontend/image_diff/helpers/utils_helper_spec.js3
-rw-r--r--spec/frontend/image_diff/image_diff_spec.js3
-rw-r--r--spec/frontend/image_diff/replaced_image_diff_spec.js7
-rw-r--r--spec/frontend/issuable_suggestions/components/item_spec.js5
-rw-r--r--spec/frontend/issuable_suggestions/mock_data.js8
-rw-r--r--spec/frontend/jobs/components/job_app_spec.js5
-rw-r--r--spec/frontend/lib/utils/common_utils_spec.js47
-rw-r--r--spec/frontend/notes/stores/actions_spec.js8
-rw-r--r--spec/frontend/pager_spec.js7
-rw-r--r--spec/frontend/pages/admin/jobs/index/components/stop_jobs_modal_spec.js5
-rw-r--r--spec/frontend/pages/labels/components/promote_label_modal_spec.js5
-rw-r--r--spec/frontend/pages/milestones/shared/components/delete_milestone_modal_spec.js5
-rw-r--r--spec/frontend/pages/milestones/shared/components/promote_milestone_modal_spec.js5
-rw-r--r--spec/frontend/projects/project_new_spec.js3
-rw-r--r--spec/frontend/search_autocomplete_spec.js1
-rw-r--r--spec/frontend/vue_shared/components/issue/related_issuable_item_spec.js3
-rw-r--r--spec/frontend/vue_shared/components/issue/related_issuable_mock_data.js18
41 files changed, 140 insertions, 228 deletions
diff --git a/app/assets/javascripts/behaviors/markdown/copy_as_gfm.js b/app/assets/javascripts/behaviors/markdown/copy_as_gfm.js
index 03c1b5a0169..bbcfa50ba35 100644
--- a/app/assets/javascripts/behaviors/markdown/copy_as_gfm.js
+++ b/app/assets/javascripts/behaviors/markdown/copy_as_gfm.js
@@ -1,5 +1,5 @@
import $ from 'jquery';
-import { getSelectedFragment } from '~/lib/utils/common_utils';
+import { getSelectedFragment, insertText } from '~/lib/utils/common_utils';
export class CopyAsGFM {
constructor() {
@@ -79,7 +79,7 @@ export class CopyAsGFM {
}
static insertPastedText(target, text, gfm) {
- window.gl.utils.insertText(target, textBefore => {
+ insertText(target, textBefore => {
// If the text before the cursor contains an odd number of backticks,
// we are either inside an inline code span that starts with 1 backtick
// or a code block that starts with 3 backticks.
diff --git a/app/assets/javascripts/blob_edit/blob_bundle.js b/app/assets/javascripts/blob_edit/blob_bundle.js
index 95b84497de3..9b9ade28623 100644
--- a/app/assets/javascripts/blob_edit/blob_bundle.js
+++ b/app/assets/javascripts/blob_edit/blob_bundle.js
@@ -5,7 +5,7 @@ import NewCommitForm from '../new_commit_form';
import EditBlob from './edit_blob';
import BlobFileDropzone from '../blob/blob_file_dropzone';
import initPopover from '~/blob/suggest_gitlab_ci_yml';
-import { setCookie } from '~/lib/utils/common_utils';
+import { disableButtonIfEmptyField, setCookie } from '~/lib/utils/common_utils';
import Tracking from '~/tracking';
export default () => {
@@ -51,10 +51,7 @@ export default () => {
new BlobFileDropzone(uploadBlobForm, method);
new NewCommitForm(uploadBlobForm);
- window.gl.utils.disableButtonIfEmptyField(
- uploadBlobForm.find('.js-commit-message'),
- '.btn-upload-file',
- );
+ disableButtonIfEmptyField(uploadBlobForm.find('.js-commit-message'), '.btn-upload-file');
}
if (deleteBlobForm.length) {
diff --git a/app/assets/javascripts/gl_form.js b/app/assets/javascripts/gl_form.js
index 4793a5c6250..0a1e5490237 100644
--- a/app/assets/javascripts/gl_form.js
+++ b/app/assets/javascripts/gl_form.js
@@ -3,6 +3,7 @@ import autosize from 'autosize';
import GfmAutoComplete, { defaultAutocompleteConfig } from 'ee_else_ce/gfm_auto_complete';
import dropzoneInput from './dropzone_input';
import { addMarkdownListeners, removeMarkdownListeners } from './lib/utils/text_markdown';
+import { disableButtonIfEmptyField } from '~/lib/utils/common_utils';
export default class GLForm {
constructor(form, enableGFM = {}) {
@@ -45,7 +46,7 @@ export default class GLForm {
this.form.find('.div-dropzone').remove();
this.form.addClass('gfm-form');
// remove notify commit author checkbox for non-commit notes
- gl.utils.disableButtonIfEmptyField(
+ disableButtonIfEmptyField(
this.form.find('.js-note-text'),
this.form.find('.js-comment-button, .js-note-new-discussion'),
);
diff --git a/app/assets/javascripts/lib/utils/common_utils.js b/app/assets/javascripts/lib/utils/common_utils.js
index f0b12454474..8bf9a281151 100644
--- a/app/assets/javascripts/lib/utils/common_utils.js
+++ b/app/assets/javascripts/lib/utils/common_utils.js
@@ -53,16 +53,6 @@ export const getCspNonceValue = () => {
return metaTag && metaTag.content;
};
-export const ajaxGet = url =>
- axios
- .get(url, {
- params: { format: 'js' },
- responseType: 'text',
- })
- .then(({ data }) => {
- $.globalEval(data, { nonce: getCspNonceValue() });
- });
-
export const rstrip = val => {
if (val) {
return val.replace(/\s+$/, '');
@@ -375,34 +365,6 @@ export const insertText = (target, text) => {
target.dispatchEvent(event);
};
-export const nodeMatchesSelector = (node, selector) => {
- const matches =
- Element.prototype.matches ||
- Element.prototype.matchesSelector ||
- Element.prototype.mozMatchesSelector ||
- Element.prototype.msMatchesSelector ||
- Element.prototype.oMatchesSelector ||
- Element.prototype.webkitMatchesSelector;
-
- if (matches) {
- return matches.call(node, selector);
- }
-
- // IE11 doesn't support `node.matches(selector)`
-
- let { parentNode } = node;
-
- if (!parentNode) {
- parentNode = document.createElement('div');
- // eslint-disable-next-line no-param-reassign
- node = node.cloneNode(true);
- parentNode.appendChild(node);
- }
-
- const matchingNodes = parentNode.querySelectorAll(selector);
- return Array.prototype.indexOf.call(matchingNodes, node) !== -1;
-};
-
/**
this will take in the headers from an API response and normalize them
this way we don't run into production issues when nginx gives us lowercased header keys
@@ -418,24 +380,6 @@ export const normalizeHeaders = headers => {
};
/**
- this will take in the getAllResponseHeaders result and normalize them
- this way we don't run into production issues when nginx gives us lowercased header keys
-*/
-export const normalizeCRLFHeaders = headers => {
- const headersObject = {};
- const headersArray = headers.split('\n');
-
- headersArray.forEach(header => {
- const keyValue = header.split(': ');
-
- // eslint-disable-next-line prefer-destructuring
- headersObject[keyValue[0]] = keyValue[1];
- });
-
- return normalizeHeaders(headersObject);
-};
-
-/**
* Parses pagination object string values into numbers.
*
* @param {Object} paginationInformation
@@ -643,13 +587,6 @@ export const setFaviconOverlay = overlayPath => {
);
};
-export const setFavicon = faviconPath => {
- const faviconEl = document.getElementById('favicon');
- if (faviconEl && faviconPath) {
- faviconEl.setAttribute('href', faviconPath);
- }
-};
-
export const resetFavicon = () => {
const faviconEl = document.getElementById('favicon');
@@ -888,35 +825,6 @@ export const searchBy = (query = '', searchSpace = {}) => {
*/
export const isScopedLabel = ({ title = '' }) => title.indexOf('::') !== -1;
-window.gl = window.gl || {};
-window.gl.utils = {
- ...(window.gl.utils || {}),
- getPagePath,
- isInGroupsPage,
- isInProjectPage,
- getProjectSlug,
- getGroupSlug,
- isInIssuePage,
- ajaxGet,
- rstrip,
- updateTooltipTitle,
- disableButtonIfEmptyField,
- handleLocationHash,
- isInViewport,
- parseUrl,
- parseUrlPathname,
- getUrlParamsArray,
- isMetaKey,
- isMetaClick,
- scrollToElement,
- getParameterByName,
- getSelectedFragment,
- insertText,
- nodeMatchesSelector,
- spriteIcon,
- imagePath,
-};
-
// Methods to set and get Cookie
export const setCookie = (name, value) => Cookies.set(name, value, { expires: 365 });
diff --git a/app/assets/javascripts/lib/utils/datetime_utility.js b/app/assets/javascripts/lib/utils/datetime_utility.js
index b7f794e439a..6e02fc1eb91 100644
--- a/app/assets/javascripts/lib/utils/datetime_utility.js
+++ b/app/assets/javascripts/lib/utils/datetime_utility.js
@@ -427,7 +427,6 @@ export const dayInQuarter = (date, quarter) => {
window.gl = window.gl || {};
window.gl.utils = {
...(window.gl.utils || {}),
- getTimeago,
localTimeAgo,
};
diff --git a/app/assets/javascripts/members.js b/app/assets/javascripts/members.js
index d719fd8748d..f220e9e0192 100644
--- a/app/assets/javascripts/members.js
+++ b/app/assets/javascripts/members.js
@@ -1,4 +1,5 @@
import $ from 'jquery';
+import { disableButtonIfEmptyField } from '~/lib/utils/common_utils';
export default class Members {
constructor() {
@@ -13,7 +14,7 @@ export default class Members {
$('.js-edit-member-form')
.off('ajax:success')
.on('ajax:success', this.formSuccess.bind(this));
- gl.utils.disableButtonIfEmptyField('#user_ids', 'input[name=commit]', 'change');
+ disableButtonIfEmptyField('#user_ids', 'input[name=commit]', 'change');
}
dropdownClicked(options) {
diff --git a/app/assets/javascripts/sidebar/mount_sidebar.js b/app/assets/javascripts/sidebar/mount_sidebar.js
index d6fd3ba437d..2c108835c36 100644
--- a/app/assets/javascripts/sidebar/mount_sidebar.js
+++ b/app/assets/javascripts/sidebar/mount_sidebar.js
@@ -11,6 +11,7 @@ import sidebarSubscriptions from './components/subscriptions/sidebar_subscriptio
import Translate from '../vue_shared/translate';
import createDefaultClient from '~/lib/graphql';
import { store } from '~/notes/stores';
+import { isInIssuePage } from '~/lib/utils/common_utils';
Vue.use(Translate);
Vue.use(VueApollo);
@@ -43,7 +44,7 @@ function mountAssigneesComponent(mediator) {
projectPath: fullPath,
field: el.dataset.field,
signedIn: el.hasAttribute('data-signed-in'),
- issuableType: gl.utils.isInIssuePage() ? 'issue' : 'merge_request',
+ issuableType: isInIssuePage() ? 'issue' : 'merge_request',
},
}),
});
@@ -93,7 +94,7 @@ function mountLockComponent(mediator) {
isLocked: initialData.is_locked,
isEditable: initialData.is_editable,
mediator,
- issuableType: gl.utils.isInIssuePage() ? 'issue' : 'merge_request',
+ issuableType: isInIssuePage() ? 'issue' : 'merge_request',
},
}).$mount(el);
}
diff --git a/app/assets/javascripts/vue_shared/components/pagination/table_pagination.vue b/app/assets/javascripts/vue_shared/components/pagination/table_pagination.vue
index 462b6f1f56f..5f2a66ee0b7 100644
--- a/app/assets/javascripts/vue_shared/components/pagination/table_pagination.vue
+++ b/app/assets/javascripts/vue_shared/components/pagination/table_pagination.vue
@@ -20,7 +20,7 @@ export default {
Here is an example `change` method:
change(pagenum) {
- gl.utils.visitUrl(`?page=${pagenum}`);
+ visitUrl(`?page=${pagenum}`);
},
*/
change: {
diff --git a/db/migrate/20200628210938_add_maintenance_mode_application_to_settings.rb b/db/migrate/20200628210938_add_maintenance_mode_application_to_settings.rb
new file mode 100644
index 00000000000..6f1959a128f
--- /dev/null
+++ b/db/migrate/20200628210938_add_maintenance_mode_application_to_settings.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+class AddMaintenanceModeApplicationToSettings < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ unless column_exists?(:application_settings, :maintenance_mode)
+ change_table :application_settings do |t|
+ t.boolean :maintenance_mode, default: false, null: false
+ t.text :maintenance_mode_message
+ end
+ end
+
+ add_text_limit(:application_settings, :maintenance_mode_message, 255)
+ end
+
+ def down
+ if column_exists?(:application_settings, :maintenance_mode)
+ remove_column :application_settings, :maintenance_mode
+ end
+
+ if column_exists?(:application_settings, :maintenance_mode_message)
+ remove_column :application_settings, :maintenance_mode_message
+ end
+ end
+end
diff --git a/db/structure.sql b/db/structure.sql
index 493ecf4bd86..a7556b6a3c5 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -9170,7 +9170,10 @@ CREATE TABLE public.application_settings (
group_import_limit integer DEFAULT 6 NOT NULL,
group_export_limit integer DEFAULT 6 NOT NULL,
group_download_export_limit integer DEFAULT 1 NOT NULL,
+ maintenance_mode boolean DEFAULT false NOT NULL,
+ maintenance_mode_message text,
CONSTRAINT check_51700b31b5 CHECK ((char_length(default_branch_name) <= 255)),
+ CONSTRAINT check_9c6c447a13 CHECK ((char_length(maintenance_mode_message) <= 255)),
CONSTRAINT check_d03919528d CHECK ((char_length(container_registry_vendor) <= 255)),
CONSTRAINT check_d820146492 CHECK ((char_length(spam_check_endpoint_url) <= 255)),
CONSTRAINT check_e5aba18f02 CHECK ((char_length(container_registry_version) <= 255))
@@ -23741,6 +23744,7 @@ COPY "schema_migrations" (version) FROM STDIN;
20200625190458
20200626060151
20200626130220
+20200628210938
20200629192638
20200630091656
20200630110826
diff --git a/doc/api/settings.md b/doc/api/settings.md
index e5f3da7fbf6..d87a3c72a7e 100644
--- a/doc/api/settings.md
+++ b/doc/api/settings.md
@@ -291,6 +291,8 @@ are listed in the descriptions of the relevant settings.
| `mirror_max_capacity` | integer | no | **(PREMIUM)** Maximum number of mirrors that can be synchronizing at the same time. |
| `mirror_max_delay` | integer | no | **(PREMIUM)** Maximum time (in minutes) between updates that a mirror can have when scheduled to synchronize. |
| `npm_package_requests_forwarding` | boolean | no | **(PREMIUM)** Use npmjs.org as a default remote repository when the package is not found in the GitLab NPM Registry |
+| `maintenance_mode` | boolean | no | **(PREMIUM)** When instance is in maintenance mode, non-admin users can sign in with read-only access and make read-only API requests |
+| `maintenance_mode_message` | string | no | **(PREMIUM)** Message displayed when instance is in maintenance mode |
| `outbound_local_requests_whitelist` | array of strings | no | Define a list of trusted domains or ip addresses to which local requests are allowed when local requests for hooks and services are disabled.
| `pages_domain_verification_enabled` | boolean | no | Require users to prove ownership of custom domains. Domain verification is an essential security measure for public GitLab sites. Users are required to demonstrate they control a domain before it is enabled. |
| `password_authentication_enabled_for_git` | boolean | no | Enable authentication for Git over HTTP(S) via a GitLab account password. Default is `true`. |
diff --git a/doc/user/application_security/dast/index.md b/doc/user/application_security/dast/index.md
index 272195fef87..3cab5ff2cfa 100644
--- a/doc/user/application_security/dast/index.md
+++ b/doc/user/application_security/dast/index.md
@@ -456,7 +456,7 @@ DAST can be [configured](#customizing-the-dast-settings) using environment varia
| `DAST_FULL_SCAN_DOMAIN_VALIDATION_REQUIRED` | boolean | Set to `true` to require [domain validation](#domain-validation) when running DAST full scans. Not supported for API scans. Default: `false` |
| `DAST_AUTO_UPDATE_ADDONS` | boolean | ZAP add-ons are pinned to specific versions in the DAST Docker image. Set to `true` to download the latest versions when the scan starts. Default: `false` |
| `DAST_API_HOST_OVERRIDE` | string | Used to override domains defined in API specification files. Example: `example.com:8080` |
-| `DAST_EXCLUDE_RULES` | string | Set to a comma-separated list of Vulnerability Rule IDs to exclude them from the scan report. Currently, excluded rules will get executed but the alerts from them will be suppressed. Rule IDs are numbers and can be found from the DAST log or on the [ZAP project](https://github.com/zaproxy/zaproxy/blob/develop/docs/scanners.md). For example, `HTTP Parameter Override` has a rule ID of `10026`. |
+| `DAST_EXCLUDE_RULES` | string | Set to a comma-separated list of Vulnerability Rule IDs to exclude them from running during the scan. Rule IDs are numbers and can be found from the DAST log or on the [ZAP project](https://github.com/zaproxy/zaproxy/blob/develop/docs/scanners.md). For example, `HTTP Parameter Override` has a rule ID of `10026`. **Note:** In earlier versions of GitLab the excluded rules were executed but alerts they generated were supressed. [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/118641) in GitLab 12.10. |
| `DAST_REQUEST_HEADERS` | string | Set to a comma-separated list of request header names and values. Headers will be added to every request made by DAST. For example, `Cache-control: no-cache,User-Agent: DAST/1.0` |
| `DAST_DEBUG` | boolean | Enable debug message output. Default: `false` |
| `DAST_SPIDER_MINS` | number | The maximum duration of the spider scan in minutes. Set to `0` for unlimited. Default: One minute, or unlimited when the scan is a full scan. |
diff --git a/doc/user/application_security/sast/index.md b/doc/user/application_security/sast/index.md
index b5092f58d37..1bbae96a943 100644
--- a/doc/user/application_security/sast/index.md
+++ b/doc/user/application_security/sast/index.md
@@ -366,6 +366,7 @@ Some analyzers can be customized with environment variables.
| `FAIL_NEVER` | SpotBugs | Set to `1` to ignore compilation failure. |
| `SAST_GOSEC_CONFIG` | Gosec | Path to configuration for Gosec (optional). |
| `PHPCS_SECURITY_AUDIT_PHP_EXTENSIONS` | phpcs-security-audit | Comma separated list of additional PHP Extensions. |
+| `SEARCH_MAX_DEPTH` | any | Maximum number of directories traversed when searching for source code files. Default: `4`. |
#### Custom environment variables
diff --git a/lib/gitlab/usage_data.rb b/lib/gitlab/usage_data.rb
index 60e5986e0dc..483d9cfac61 100644
--- a/lib/gitlab/usage_data.rb
+++ b/lib/gitlab/usage_data.rb
@@ -369,18 +369,15 @@ module Gitlab
projects_jira_active: 0
}
- Service.active
- .by_type(:JiraService)
- .includes(:jira_tracker_data)
- .find_in_batches(batch_size: BATCH_SIZE) do |services|
+ JiraService.active.includes(:jira_tracker_data).find_in_batches(batch_size: BATCH_SIZE) do |services|
counts = services.group_by do |service|
# TODO: Simplify as part of https://gitlab.com/gitlab-org/gitlab/issues/29404
service_url = service.data_fields&.url || (service.properties && service.properties['url'])
service_url&.include?('.atlassian.net') ? :cloud : :server
end
- results[:projects_jira_server_active] += counts[:server].count if counts[:server]
- results[:projects_jira_cloud_active] += counts[:cloud].count if counts[:cloud]
+ results[:projects_jira_server_active] += counts[:server].size if counts[:server]
+ results[:projects_jira_cloud_active] += counts[:cloud].size if counts[:cloud]
results[:projects_jira_active] += services.size
end
diff --git a/spec/frontend/batch_comments/stores/modules/batch_comments/actions_spec.js b/spec/frontend/batch_comments/stores/modules/batch_comments/actions_spec.js
index 2ec114d026a..4bac6d4e3dc 100644
--- a/spec/frontend/batch_comments/stores/modules/batch_comments/actions_spec.js
+++ b/spec/frontend/batch_comments/stores/modules/batch_comments/actions_spec.js
@@ -2,6 +2,7 @@ import MockAdapter from 'axios-mock-adapter';
import testAction from 'helpers/vuex_action_helper';
import * as actions from '~/batch_comments/stores/modules/batch_comments/actions';
import axios from '~/lib/utils/axios_utils';
+import { TEST_HOST } from 'jest/helpers/test_constants';
describe('Batch comments store actions', () => {
let res = {};
@@ -33,7 +34,7 @@ describe('Batch comments store actions', () => {
testAction(
actions.addDraftToDiscussion,
- { endpoint: gl.TEST_HOST, data: 'test' },
+ { endpoint: TEST_HOST, data: 'test' },
null,
[{ type: 'ADD_NEW_DRAFT', payload: res }],
[],
@@ -46,7 +47,7 @@ describe('Batch comments store actions', () => {
testAction(
actions.addDraftToDiscussion,
- { endpoint: gl.TEST_HOST, data: 'test' },
+ { endpoint: TEST_HOST, data: 'test' },
null,
[],
[],
@@ -62,7 +63,7 @@ describe('Batch comments store actions', () => {
testAction(
actions.createNewDraft,
- { endpoint: gl.TEST_HOST, data: 'test' },
+ { endpoint: TEST_HOST, data: 'test' },
null,
[{ type: 'ADD_NEW_DRAFT', payload: res }],
[],
@@ -73,14 +74,7 @@ describe('Batch comments store actions', () => {
it('does not commit ADD_NEW_DRAFT if errors returned', done => {
mock.onAny().reply(500);
- testAction(
- actions.createNewDraft,
- { endpoint: gl.TEST_HOST, data: 'test' },
- null,
- [],
- [],
- done,
- );
+ testAction(actions.createNewDraft, { endpoint: TEST_HOST, data: 'test' }, null, [], [], done);
});
});
@@ -90,7 +84,7 @@ describe('Batch comments store actions', () => {
beforeEach(() => {
getters = {
getNotesData: {
- draftsDiscardPath: gl.TEST_HOST,
+ draftsDiscardPath: TEST_HOST,
},
};
});
@@ -137,7 +131,7 @@ describe('Batch comments store actions', () => {
beforeEach(() => {
getters = {
getNotesData: {
- draftsPath: gl.TEST_HOST,
+ draftsPath: TEST_HOST,
},
};
});
@@ -171,7 +165,7 @@ describe('Batch comments store actions', () => {
dispatch = jest.fn();
commit = jest.fn();
getters = {
- getNotesData: { draftsPublishPath: gl.TEST_HOST, discussionsPath: gl.TEST_HOST },
+ getNotesData: { draftsPublishPath: TEST_HOST, discussionsPath: TEST_HOST },
};
rootGetters = { discussionsStructuredByLineCode: 'discussions' };
});
@@ -208,7 +202,7 @@ describe('Batch comments store actions', () => {
describe('discardReview', () => {
it('commits mutations', done => {
const getters = {
- getNotesData: { draftsDiscardPath: gl.TEST_HOST },
+ getNotesData: { draftsDiscardPath: TEST_HOST },
};
const commit = jest.fn();
mock.onAny().reply(200);
@@ -225,7 +219,7 @@ describe('Batch comments store actions', () => {
it('commits error mutations', done => {
const getters = {
- getNotesData: { draftsDiscardPath: gl.TEST_HOST },
+ getNotesData: { draftsDiscardPath: TEST_HOST },
};
const commit = jest.fn();
mock.onAny().reply(500);
@@ -247,7 +241,7 @@ describe('Batch comments store actions', () => {
beforeEach(() => {
getters = {
getNotesData: {
- draftsPath: gl.TEST_HOST,
+ draftsPath: TEST_HOST,
},
};
});
diff --git a/spec/frontend/behaviors/copy_as_gfm_spec.js b/spec/frontend/behaviors/copy_as_gfm_spec.js
index cf96ac488a8..33af9bc135e 100644
--- a/spec/frontend/behaviors/copy_as_gfm_spec.js
+++ b/spec/frontend/behaviors/copy_as_gfm_spec.js
@@ -1,3 +1,4 @@
+import * as commonUtils from '~/lib/utils/common_utils';
import initCopyAsGFM, { CopyAsGFM } from '~/behaviors/markdown/copy_as_gfm';
describe('CopyAsGFM', () => {
@@ -27,7 +28,7 @@ describe('CopyAsGFM', () => {
}
it('wraps pasted code when not already in code tags', () => {
- jest.spyOn(window.gl.utils, 'insertText').mockImplementation((el, textFunc) => {
+ jest.spyOn(commonUtils, 'insertText').mockImplementation((el, textFunc) => {
const insertedText = textFunc('This is code: ', '');
expect(insertedText).toEqual('`code`');
@@ -37,7 +38,7 @@ describe('CopyAsGFM', () => {
});
it('does not wrap pasted code when already in code tags', () => {
- jest.spyOn(window.gl.utils, 'insertText').mockImplementation((el, textFunc) => {
+ jest.spyOn(commonUtils, 'insertText').mockImplementation((el, textFunc) => {
const insertedText = textFunc('This is code: `', '`');
expect(insertedText).toEqual('code');
diff --git a/spec/frontend/behaviors/shortcuts/shortcuts_issuable_spec.js b/spec/frontend/behaviors/shortcuts/shortcuts_issuable_spec.js
index 6391a544985..baedbf5771a 100644
--- a/spec/frontend/behaviors/shortcuts/shortcuts_issuable_spec.js
+++ b/spec/frontend/behaviors/shortcuts/shortcuts_issuable_spec.js
@@ -46,7 +46,7 @@ describe('ShortcutsIssuable', () => {
});
describe('replyWithSelectedText', () => {
- // Stub window.gl.utils.getSelectedFragment to return a node with the provided HTML.
+ // Stub getSelectedFragment to return a node with the provided HTML.
const stubSelection = (html, invalidNode) => {
getSelectedFragment.mockImplementation(() => {
const documentFragment = document.createDocumentFragment();
diff --git a/spec/frontend/boards/components/board_form_spec.js b/spec/frontend/boards/components/board_form_spec.js
index ee427bc2154..94f607698d7 100644
--- a/spec/frontend/boards/components/board_form_spec.js
+++ b/spec/frontend/boards/components/board_form_spec.js
@@ -3,14 +3,15 @@ import { mount } from '@vue/test-utils';
import boardsStore from '~/boards/stores/boards_store';
import boardForm from '~/boards/components/board_form.vue';
import DeprecatedModal from '~/vue_shared/components/deprecated_modal.vue';
+import { TEST_HOST } from 'jest/helpers/test_constants';
describe('board_form.vue', () => {
let wrapper;
const propsData = {
canAdminBoard: false,
- labelsPath: `${gl.TEST_HOST}/labels/path`,
- milestonePath: `${gl.TEST_HOST}/milestone/path`,
+ labelsPath: `${TEST_HOST}/labels/path`,
+ milestonePath: `${TEST_HOST}/milestone/path`,
};
const findModal = () => wrapper.find(DeprecatedModal);
diff --git a/spec/frontend/diffs/store/actions_spec.js b/spec/frontend/diffs/store/actions_spec.js
index 2b069e1ebc9..6845364a3ed 100644
--- a/spec/frontend/diffs/store/actions_spec.js
+++ b/spec/frontend/diffs/store/actions_spec.js
@@ -59,6 +59,7 @@ import { mergeUrlParams } from '~/lib/utils/url_utility';
import { useLocalStorageSpy } from 'helpers/local_storage_helper';
import { diffMetadata } from '../mock_data/diff_metadata';
import createFlash from '~/flash';
+import { TEST_HOST } from 'jest/helpers/test_constants';
jest.mock('~/flash', () => jest.fn());
@@ -1259,12 +1260,12 @@ describe('DiffsStoreActions', () => {
describe('success', () => {
beforeEach(() => {
- mock.onGet(`${gl.TEST_HOST}/context`).replyOnce(200, ['test']);
+ mock.onGet(`${TEST_HOST}/context`).replyOnce(200, ['test']);
});
it('commits the success and dispatches an action to expand the new lines', done => {
const file = {
- context_lines_path: `${gl.TEST_HOST}/context`,
+ context_lines_path: `${TEST_HOST}/context`,
file_path: 'test',
file_hash: 'test',
};
@@ -1281,13 +1282,13 @@ describe('DiffsStoreActions', () => {
describe('error', () => {
beforeEach(() => {
- mock.onGet(`${gl.TEST_HOST}/context`).replyOnce(500);
+ mock.onGet(`${TEST_HOST}/context`).replyOnce(500);
});
it('dispatches receiveFullDiffError', done => {
testAction(
fetchFullDiff,
- { context_lines_path: `${gl.TEST_HOST}/context`, file_path: 'test', file_hash: 'test' },
+ { context_lines_path: `${TEST_HOST}/context`, file_path: 'test', file_hash: 'test' },
null,
[],
[{ type: 'receiveFullDiffError', payload: 'test' }],
@@ -1451,7 +1452,7 @@ describe('DiffsStoreActions', () => {
describe('setSuggestPopoverDismissed', () => {
it('commits SET_SHOW_SUGGEST_POPOVER', done => {
- const state = { dismissEndpoint: `${gl.TEST_HOST}/-/user_callouts` };
+ const state = { dismissEndpoint: `${TEST_HOST}/-/user_callouts` };
const mock = new MockAdapter(axios);
mock.onPost(state.dismissEndpoint).reply(200, {});
diff --git a/spec/frontend/filtered_search/filtered_search_manager_spec.js b/spec/frontend/filtered_search/filtered_search_manager_spec.js
index ef87662a1ef..70e8b339d4b 100644
--- a/spec/frontend/filtered_search/filtered_search_manager_spec.js
+++ b/spec/frontend/filtered_search/filtered_search_manager_spec.js
@@ -2,7 +2,6 @@ import RecentSearchesService from '~/filtered_search/services/recent_searches_se
import RecentSearchesServiceError from '~/filtered_search/services/recent_searches_service_error';
import RecentSearchesRoot from '~/filtered_search/recent_searches_root';
import IssuableFilteredSearchTokenKeys from '~/filtered_search/issuable_filtered_search_token_keys';
-import '~/lib/utils/common_utils';
import DropdownUtils from '~/filtered_search/dropdown_utils';
import FilteredSearchVisualTokens from '~/filtered_search/filtered_search_visual_tokens';
import FilteredSearchDropdownManager from '~/filtered_search/filtered_search_dropdown_manager';
@@ -10,6 +9,7 @@ import FilteredSearchManager from '~/filtered_search/filtered_search_manager';
import FilteredSearchSpecHelper from '../helpers/filtered_search_spec_helper';
import { BACKSPACE_KEY_CODE, DELETE_KEY_CODE } from '~/lib/utils/keycodes';
import { visitUrl } from '~/lib/utils/url_utility';
+import * as commonUtils from '~/lib/utils/common_utils';
jest.mock('~/lib/utils/url_utility', () => ({
...jest.requireActual('~/lib/utils/url_utility'),
@@ -83,7 +83,7 @@ describe('Filtered Search Manager', () => {
jest
.spyOn(FilteredSearchDropdownManager.prototype, 'updateDropdownOffset')
.mockImplementation();
- jest.spyOn(gl.utils, 'getParameterByName').mockReturnValue(null);
+ jest.spyOn(commonUtils, 'getParameterByName').mockReturnValue(null);
jest.spyOn(FilteredSearchVisualTokens, 'unselectTokens');
input = document.querySelector('.filtered-search');
diff --git a/spec/frontend/filtered_search/visual_token_value_spec.js b/spec/frontend/filtered_search/visual_token_value_spec.js
index ea501423403..3a64b688c7a 100644
--- a/spec/frontend/filtered_search/visual_token_value_spec.js
+++ b/spec/frontend/filtered_search/visual_token_value_spec.js
@@ -4,6 +4,7 @@ import AjaxCache from '~/lib/utils/ajax_cache';
import UsersCache from '~/lib/utils/users_cache';
import DropdownUtils from '~/filtered_search//dropdown_utils';
import FilteredSearchSpecHelper from '../helpers/filtered_search_spec_helper';
+import { TEST_HOST } from 'jest/helpers/test_constants';
describe('Filtered Search Visual Tokens', () => {
const findElements = tokenElement => {
@@ -106,7 +107,7 @@ describe('Filtered Search Visual Tokens', () => {
it('escapes user name when creating token', done => {
const dummyUser = {
name: '<script>',
- avatar_url: `${gl.TEST_HOST}/mypics/avatar.png`,
+ avatar_url: `${TEST_HOST}/mypics/avatar.png`,
};
const { subject, tokenValueContainer, tokenValueElement } = findElements(authorToken);
const tokenValue = tokenValueElement.innerText;
diff --git a/spec/frontend/gl_form_spec.js b/spec/frontend/gl_form_spec.js
index 0b75b58431b..52e1693f8a6 100644
--- a/spec/frontend/gl_form_spec.js
+++ b/spec/frontend/gl_form_spec.js
@@ -9,6 +9,8 @@ describe('GLForm', () => {
describe('when instantiated', () => {
beforeEach(done => {
+ window.gl = window.gl || {};
+
testContext.form = $('<form class="gfm-form"><textarea class="js-gfm-input"></form>');
testContext.textarea = testContext.form.find('textarea');
jest.spyOn($.prototype, 'off').mockReturnValue(testContext.textarea);
diff --git a/spec/frontend/ide/stores/actions/tree_spec.js b/spec/frontend/ide/stores/actions/tree_spec.js
index 44e2fcab436..c20941843c4 100644
--- a/spec/frontend/ide/stores/actions/tree_spec.js
+++ b/spec/frontend/ide/stores/actions/tree_spec.js
@@ -7,6 +7,7 @@ import { createStore } from '~/ide/stores';
import service from '~/ide/services';
import { createRouter } from '~/ide/ide_router';
import { file, createEntriesFromPaths } from '../../helpers';
+import { TEST_HOST } from 'jest/helpers/test_constants';
describe('Multi-file store tree actions', () => {
let projectTree;
@@ -97,7 +98,7 @@ describe('Multi-file store tree actions', () => {
store.state.projects = {
'abc/def': {
- web_url: `${gl.TEST_HOST}/files`,
+ web_url: `${TEST_HOST}/files`,
branches: {
'master-testing': {
commit: {
diff --git a/spec/frontend/image_diff/helpers/comment_indicator_helper_spec.js b/spec/frontend/image_diff/helpers/comment_indicator_helper_spec.js
index 395bb7de362..2deb4be2b91 100644
--- a/spec/frontend/image_diff/helpers/comment_indicator_helper_spec.js
+++ b/spec/frontend/image_diff/helpers/comment_indicator_helper_spec.js
@@ -1,5 +1,6 @@
import * as commentIndicatorHelper from '~/image_diff/helpers/comment_indicator_helper';
import * as mockData from '../mock_data';
+import { TEST_HOST } from 'jest/helpers/test_constants';
describe('commentIndicatorHelper', () => {
const { coordinate } = mockData;
@@ -52,7 +53,7 @@ describe('commentIndicatorHelper', () => {
beforeEach(() => {
containerEl.innerHTML = `
<div class="comment-indicator" style="left:${coordinate.x}px; top: ${coordinate.y}px;">
- <img src="${gl.TEST_HOST}/image.png">
+ <img src="${TEST_HOST}/image.png">
</div>
`;
result = commentIndicatorHelper.removeCommentIndicator(containerEl);
diff --git a/spec/frontend/image_diff/helpers/utils_helper_spec.js b/spec/frontend/image_diff/helpers/utils_helper_spec.js
index 3b6378be883..a47c681e775 100644
--- a/spec/frontend/image_diff/helpers/utils_helper_spec.js
+++ b/spec/frontend/image_diff/helpers/utils_helper_spec.js
@@ -1,6 +1,7 @@
import * as utilsHelper from '~/image_diff/helpers/utils_helper';
import ImageBadge from '~/image_diff/image_badge';
import * as mockData from '../mock_data';
+import { TEST_HOST } from 'jest/helpers/test_constants';
describe('utilsHelper', () => {
const { noteId, discussionId, image, imageProperties, imageMeta } = mockData;
@@ -36,7 +37,7 @@ describe('utilsHelper', () => {
beforeEach(() => {
const imageFrameEl = document.createElement('div');
imageFrameEl.innerHTML = `
- <img src="${gl.TEST_HOST}/image.png">
+ <img src="${TEST_HOST}/image.png">
`;
discussionEl = document.createElement('div');
discussionEl.dataset.discussionId = discussionId;
diff --git a/spec/frontend/image_diff/image_diff_spec.js b/spec/frontend/image_diff/image_diff_spec.js
index c15718b5106..2b29a522193 100644
--- a/spec/frontend/image_diff/image_diff_spec.js
+++ b/spec/frontend/image_diff/image_diff_spec.js
@@ -2,6 +2,7 @@ import ImageDiff from '~/image_diff/image_diff';
import * as imageUtility from '~/lib/utils/image_utility';
import imageDiffHelper from '~/image_diff/helpers/index';
import * as mockData from './mock_data';
+import { TEST_HOST } from 'jest/helpers/test_constants';
describe('ImageDiff', () => {
let element;
@@ -12,7 +13,7 @@ describe('ImageDiff', () => {
<div id="element">
<div class="diff-file">
<div class="js-image-frame">
- <img src="${gl.TEST_HOST}/image.png">
+ <img src="${TEST_HOST}/image.png">
<div class="comment-indicator"></div>
<div id="badge-1" class="badge">1</div>
<div id="badge-2" class="badge">2</div>
diff --git a/spec/frontend/image_diff/replaced_image_diff_spec.js b/spec/frontend/image_diff/replaced_image_diff_spec.js
index f2a7b7f8406..38a43bfa858 100644
--- a/spec/frontend/image_diff/replaced_image_diff_spec.js
+++ b/spec/frontend/image_diff/replaced_image_diff_spec.js
@@ -2,6 +2,7 @@ import ReplacedImageDiff from '~/image_diff/replaced_image_diff';
import ImageDiff from '~/image_diff/image_diff';
import { viewTypes } from '~/image_diff/view_types';
import imageDiffHelper from '~/image_diff/helpers/index';
+import { TEST_HOST } from 'jest/helpers/test_constants';
describe('ReplacedImageDiff', () => {
let element;
@@ -12,17 +13,17 @@ describe('ReplacedImageDiff', () => {
<div id="element">
<div class="two-up">
<div class="js-image-frame">
- <img src="${gl.TEST_HOST}/image.png">
+ <img src="${TEST_HOST}/image.png">
</div>
</div>
<div class="swipe">
<div class="js-image-frame">
- <img src="${gl.TEST_HOST}/image.png">
+ <img src="${TEST_HOST}/image.png">
</div>
</div>
<div class="onion-skin">
<div class="js-image-frame">
- <img src="${gl.TEST_HOST}/image.png">
+ <img src="${TEST_HOST}/image.png">
</div>
</div>
<div class="view-modes-menu">
diff --git a/spec/frontend/issuable_suggestions/components/item_spec.js b/spec/frontend/issuable_suggestions/components/item_spec.js
index 6c3c30fcbb0..36799f4ee9f 100644
--- a/spec/frontend/issuable_suggestions/components/item_spec.js
+++ b/spec/frontend/issuable_suggestions/components/item_spec.js
@@ -4,6 +4,7 @@ import Icon from '~/vue_shared/components/icon.vue';
import UserAvatarImage from '~/vue_shared/components/user_avatar/user_avatar_image.vue';
import Suggestion from '~/issuable_suggestions/components/item.vue';
import mockData from '../mock_data';
+import { TEST_HOST } from 'jest/helpers/test_constants';
describe('Issuable suggestions suggestion component', () => {
let vm;
@@ -34,7 +35,7 @@ describe('Issuable suggestions suggestion component', () => {
const link = vm.find(GlLink);
- expect(link.attributes('href')).toBe(`${gl.TEST_HOST}/test/issue/1`);
+ expect(link.attributes('href')).toBe(`${TEST_HOST}/test/issue/1`);
});
it('renders IID', () => {
@@ -100,7 +101,7 @@ describe('Issuable suggestions suggestion component', () => {
const image = vm.find(UserAvatarImage);
- expect(image.props('imgSrc')).toBe(`${gl.TEST_HOST}/avatar`);
+ expect(image.props('imgSrc')).toBe(`${TEST_HOST}/avatar`);
});
});
diff --git a/spec/frontend/issuable_suggestions/mock_data.js b/spec/frontend/issuable_suggestions/mock_data.js
index 4f0f9ef8d62..4ce35ad5196 100644
--- a/spec/frontend/issuable_suggestions/mock_data.js
+++ b/spec/frontend/issuable_suggestions/mock_data.js
@@ -1,3 +1,5 @@
+import { TEST_HOST } from 'jest/helpers/test_constants';
+
function getDate(daysMinus) {
const today = new Date();
today.setDate(today.getDate() - daysMinus);
@@ -15,12 +17,12 @@ export default () => ({
createdAt: getDate(3),
updatedAt: getDate(2),
confidential: false,
- webUrl: `${gl.TEST_HOST}/test/issue/1`,
+ webUrl: `${TEST_HOST}/test/issue/1`,
title: 'Test issue',
author: {
- avatarUrl: `${gl.TEST_HOST}/avatar`,
+ avatarUrl: `${TEST_HOST}/avatar`,
name: 'Author Name',
username: 'author.username',
- webUrl: `${gl.TEST_HOST}/author`,
+ webUrl: `${TEST_HOST}/author`,
},
});
diff --git a/spec/frontend/jobs/components/job_app_spec.js b/spec/frontend/jobs/components/job_app_spec.js
index 8b190cd1d17..d0b3d4f6247 100644
--- a/spec/frontend/jobs/components/job_app_spec.js
+++ b/spec/frontend/jobs/components/job_app_spec.js
@@ -6,6 +6,7 @@ import axios from '~/lib/utils/axios_utils';
import JobApp from '~/jobs/components/job_app.vue';
import createStore from '~/jobs/store';
import job from '../mock_data';
+import { TEST_HOST } from 'jest/helpers/test_constants';
describe('Job App', () => {
const localVue = createLocalVue();
@@ -18,8 +19,8 @@ describe('Job App', () => {
let mock;
const initSettings = {
- endpoint: `${gl.TEST_HOST}jobs/123.json`,
- pagePath: `${gl.TEST_HOST}jobs/123`,
+ endpoint: `${TEST_HOST}jobs/123.json`,
+ pagePath: `${TEST_HOST}jobs/123`,
logState:
'eyJvZmZzZXQiOjE3NDUxLCJuX29wZW5fdGFncyI6MCwiZmdfY29sb3IiOm51bGwsImJnX2NvbG9yIjpudWxsLCJzdHlsZV9tYXNrIjowfQ%3D%3D',
};
diff --git a/spec/frontend/lib/utils/common_utils_spec.js b/spec/frontend/lib/utils/common_utils_spec.js
index f597255538c..585f0de9cc3 100644
--- a/spec/frontend/lib/utils/common_utils_spec.js
+++ b/spec/frontend/lib/utils/common_utils_spec.js
@@ -330,32 +330,6 @@ describe('common_utils', () => {
});
});
- describe('normalizeCRLFHeaders', () => {
- const testContext = {};
- beforeEach(() => {
- testContext.CLRFHeaders =
- 'a-header: a-value\nAnother-Header: ANOTHER-VALUE\nLaSt-HeAdEr: last-VALUE';
- jest.spyOn(String.prototype, 'split');
- testContext.normalizeCRLFHeaders = commonUtils.normalizeCRLFHeaders(testContext.CLRFHeaders);
- });
-
- it('should split by newline', () => {
- expect(String.prototype.split).toHaveBeenCalledWith('\n');
- });
-
- it('should split by colon+space for each header', () => {
- expect(String.prototype.split.mock.calls.filter(args => args[0] === ': ').length).toBe(3);
- });
-
- it('should return a normalized headers object', () => {
- expect(testContext.normalizeCRLFHeaders).toEqual({
- 'A-HEADER': 'a-value',
- 'ANOTHER-HEADER': 'ANOTHER-VALUE',
- 'LAST-HEADER': 'last-VALUE',
- });
- });
- });
-
describe('parseIntPagination', () => {
it('should parse to integers all string values and return pagination object', () => {
const pagination = {
@@ -510,27 +484,6 @@ describe('common_utils', () => {
});
});
- describe('setFavicon', () => {
- beforeEach(() => {
- const favicon = document.createElement('link');
- favicon.setAttribute('id', 'favicon');
- favicon.setAttribute('href', 'default/favicon');
- favicon.setAttribute('data-default-href', 'default/favicon');
- document.body.appendChild(favicon);
- });
-
- afterEach(() => {
- document.body.removeChild(document.getElementById('favicon'));
- });
-
- it('should set page favicon to provided favicon', () => {
- const faviconPath = '//custom_favicon';
- commonUtils.setFavicon(faviconPath);
-
- expect(document.getElementById('favicon').getAttribute('href')).toEqual(faviconPath);
- });
- });
-
describe('resetFavicon', () => {
beforeEach(() => {
const favicon = document.createElement('link');
diff --git a/spec/frontend/notes/stores/actions_spec.js b/spec/frontend/notes/stores/actions_spec.js
index a4d8927e89b..ac54d6e9e4d 100644
--- a/spec/frontend/notes/stores/actions_spec.js
+++ b/spec/frontend/notes/stores/actions_spec.js
@@ -492,7 +492,7 @@ describe('Actions Notes Store', () => {
it('commits ADD_NEW_NOTE and dispatches updateMergeRequestWidget', done => {
testAction(
actions.createNewNote,
- { endpoint: `${gl.TEST_HOST}`, data: {} },
+ { endpoint: `${TEST_HOST}`, data: {} },
store.state,
[
{
@@ -528,7 +528,7 @@ describe('Actions Notes Store', () => {
it('does not commit ADD_NEW_NOTE or dispatch updateMergeRequestWidget', done => {
testAction(
actions.createNewNote,
- { endpoint: `${gl.TEST_HOST}`, data: {} },
+ { endpoint: `${TEST_HOST}`, data: {} },
store.state,
[],
[],
@@ -551,7 +551,7 @@ describe('Actions Notes Store', () => {
it('commits UPDATE_NOTE and dispatches updateMergeRequestWidget', done => {
testAction(
actions.toggleResolveNote,
- { endpoint: `${gl.TEST_HOST}`, isResolved: true, discussion: false },
+ { endpoint: `${TEST_HOST}`, isResolved: true, discussion: false },
store.state,
[
{
@@ -576,7 +576,7 @@ describe('Actions Notes Store', () => {
it('commits UPDATE_DISCUSSION and dispatches updateMergeRequestWidget', done => {
testAction(
actions.toggleResolveNote,
- { endpoint: `${gl.TEST_HOST}`, isResolved: true, discussion: true },
+ { endpoint: `${TEST_HOST}`, isResolved: true, discussion: true },
store.state,
[
{
diff --git a/spec/frontend/pager_spec.js b/spec/frontend/pager_spec.js
index d7177a32cde..47056c2804c 100644
--- a/spec/frontend/pager_spec.js
+++ b/spec/frontend/pager_spec.js
@@ -3,6 +3,7 @@ import MockAdapter from 'axios-mock-adapter';
import axios from '~/lib/utils/axios_utils';
import Pager from '~/pager';
import { removeParams } from '~/lib/utils/url_utility';
+import { TEST_HOST } from 'jest/helpers/test_constants';
jest.mock('~/lib/utils/url_utility', () => ({
removeParams: jest.fn().mockName('removeParams'),
@@ -32,7 +33,7 @@ describe('pager', () => {
});
it('should use data-href attribute from list element', () => {
- const href = `${gl.TEST_HOST}/some_list.json`;
+ const href = `${TEST_HOST}/some_list.json`;
setFixtures(`<div class="content_list" data-href="${href}"></div>`);
Pager.init();
@@ -40,7 +41,7 @@ describe('pager', () => {
});
it('should use current url if data-href attribute not provided', () => {
- const href = `${gl.TEST_HOST}/some_list`;
+ const href = `${TEST_HOST}/some_list`;
removeParams.mockReturnValue(href);
Pager.init();
@@ -56,7 +57,7 @@ describe('pager', () => {
it('keeps extra query parameters from url', () => {
window.history.replaceState({}, null, '?filter=test&offset=100');
- const href = `${gl.TEST_HOST}/some_list?filter=test`;
+ const href = `${TEST_HOST}/some_list?filter=test`;
removeParams.mockReturnValue(href);
Pager.init();
diff --git a/spec/frontend/pages/admin/jobs/index/components/stop_jobs_modal_spec.js b/spec/frontend/pages/admin/jobs/index/components/stop_jobs_modal_spec.js
index fe17c03389c..fb7a07b7bc7 100644
--- a/spec/frontend/pages/admin/jobs/index/components/stop_jobs_modal_spec.js
+++ b/spec/frontend/pages/admin/jobs/index/components/stop_jobs_modal_spec.js
@@ -3,6 +3,7 @@ import { redirectTo } from '~/lib/utils/url_utility';
import mountComponent from 'helpers/vue_mount_component_helper';
import axios from '~/lib/utils/axios_utils';
import stopJobsModal from '~/pages/admin/jobs/index/components/stop_jobs_modal.vue';
+import { TEST_HOST } from 'jest/helpers/test_constants';
jest.mock('~/lib/utils/url_utility', () => ({
...jest.requireActual('~/lib/utils/url_utility'),
@@ -11,7 +12,7 @@ jest.mock('~/lib/utils/url_utility', () => ({
describe('stop_jobs_modal.vue', () => {
const props = {
- url: `${gl.TEST_HOST}/stop_jobs_modal.vue/stopAll`,
+ url: `${TEST_HOST}/stop_jobs_modal.vue/stopAll`,
};
let vm;
@@ -26,7 +27,7 @@ describe('stop_jobs_modal.vue', () => {
describe('onSubmit', () => {
it('stops jobs and redirects to overview page', done => {
- const responseURL = `${gl.TEST_HOST}/stop_jobs_modal.vue/jobs`;
+ const responseURL = `${TEST_HOST}/stop_jobs_modal.vue/jobs`;
jest.spyOn(axios, 'post').mockImplementation(url => {
expect(url).toBe(props.url);
return Promise.resolve({
diff --git a/spec/frontend/pages/labels/components/promote_label_modal_spec.js b/spec/frontend/pages/labels/components/promote_label_modal_spec.js
index 9d5beca70b5..d4aabcc02f4 100644
--- a/spec/frontend/pages/labels/components/promote_label_modal_spec.js
+++ b/spec/frontend/pages/labels/components/promote_label_modal_spec.js
@@ -3,6 +3,7 @@ import mountComponent from 'helpers/vue_mount_component_helper';
import promoteLabelModal from '~/pages/projects/labels/components/promote_label_modal.vue';
import eventHub from '~/pages/projects/labels/event_hub';
import axios from '~/lib/utils/axios_utils';
+import { TEST_HOST } from 'jest/helpers/test_constants';
describe('Promote label modal', () => {
let vm;
@@ -11,7 +12,7 @@ describe('Promote label modal', () => {
labelTitle: 'Documentation',
labelColor: '#5cb85c',
labelTextColor: '#ffffff',
- url: `${gl.TEST_HOST}/dummy/promote/labels`,
+ url: `${TEST_HOST}/dummy/promote/labels`,
groupName: 'group',
};
@@ -51,7 +52,7 @@ describe('Promote label modal', () => {
});
it('redirects when a label is promoted', done => {
- const responseURL = `${gl.TEST_HOST}/dummy/endpoint`;
+ const responseURL = `${TEST_HOST}/dummy/endpoint`;
jest.spyOn(axios, 'post').mockImplementation(url => {
expect(url).toBe(labelMockData.url);
expect(eventHub.$emit).toHaveBeenCalledWith(
diff --git a/spec/frontend/pages/milestones/shared/components/delete_milestone_modal_spec.js b/spec/frontend/pages/milestones/shared/components/delete_milestone_modal_spec.js
index ff5dc6d8988..c376cf02594 100644
--- a/spec/frontend/pages/milestones/shared/components/delete_milestone_modal_spec.js
+++ b/spec/frontend/pages/milestones/shared/components/delete_milestone_modal_spec.js
@@ -4,6 +4,7 @@ import mountComponent from 'helpers/vue_mount_component_helper';
import axios from '~/lib/utils/axios_utils';
import deleteMilestoneModal from '~/pages/milestones/shared/components/delete_milestone_modal.vue';
import eventHub from '~/pages/milestones/shared/event_hub';
+import { TEST_HOST } from 'jest/helpers/test_constants';
jest.mock('~/lib/utils/url_utility', () => ({
...jest.requireActual('~/lib/utils/url_utility'),
@@ -17,7 +18,7 @@ describe('delete_milestone_modal.vue', () => {
mergeRequestCount: 2,
milestoneId: 3,
milestoneTitle: 'my milestone title',
- milestoneUrl: `${gl.TEST_HOST}/delete_milestone_modal.vue/milestone`,
+ milestoneUrl: `${TEST_HOST}/delete_milestone_modal.vue/milestone`,
};
let vm;
@@ -32,7 +33,7 @@ describe('delete_milestone_modal.vue', () => {
});
it('deletes milestone and redirects to overview page', done => {
- const responseURL = `${gl.TEST_HOST}/delete_milestone_modal.vue/milestoneOverview`;
+ const responseURL = `${TEST_HOST}/delete_milestone_modal.vue/milestoneOverview`;
jest.spyOn(axios, 'delete').mockImplementation(url => {
expect(url).toBe(props.milestoneUrl);
expect(eventHub.$emit).toHaveBeenCalledWith(
diff --git a/spec/frontend/pages/milestones/shared/components/promote_milestone_modal_spec.js b/spec/frontend/pages/milestones/shared/components/promote_milestone_modal_spec.js
index ff896354d96..87d32a67d47 100644
--- a/spec/frontend/pages/milestones/shared/components/promote_milestone_modal_spec.js
+++ b/spec/frontend/pages/milestones/shared/components/promote_milestone_modal_spec.js
@@ -3,13 +3,14 @@ import mountComponent from 'helpers/vue_mount_component_helper';
import promoteMilestoneModal from '~/pages/milestones/shared/components/promote_milestone_modal.vue';
import eventHub from '~/pages/milestones/shared/event_hub';
import axios from '~/lib/utils/axios_utils';
+import { TEST_HOST } from 'jest/helpers/test_constants';
describe('Promote milestone modal', () => {
let vm;
const Component = Vue.extend(promoteMilestoneModal);
const milestoneMockData = {
milestoneTitle: 'v1.0',
- url: `${gl.TEST_HOST}/dummy/promote/milestones`,
+ url: `${TEST_HOST}/dummy/promote/milestones`,
groupName: 'group',
};
@@ -46,7 +47,7 @@ describe('Promote milestone modal', () => {
});
it('redirects when a milestone is promoted', done => {
- const responseURL = `${gl.TEST_HOST}/dummy/endpoint`;
+ const responseURL = `${TEST_HOST}/dummy/endpoint`;
jest.spyOn(axios, 'post').mockImplementation(url => {
expect(url).toBe(milestoneMockData.url);
expect(eventHub.$emit).toHaveBeenCalledWith(
diff --git a/spec/frontend/projects/project_new_spec.js b/spec/frontend/projects/project_new_spec.js
index 7c6ff90aff6..7aafbd33fc8 100644
--- a/spec/frontend/projects/project_new_spec.js
+++ b/spec/frontend/projects/project_new_spec.js
@@ -1,5 +1,6 @@
import $ from 'jquery';
import projectNew from '~/projects/project_new';
+import { TEST_HOST } from 'jest/helpers/test_constants';
describe('New Project', () => {
let $projectImportUrl;
@@ -33,7 +34,7 @@ describe('New Project', () => {
});
describe('deriveProjectPathFromUrl', () => {
- const dummyImportUrl = `${gl.TEST_HOST}/dummy/import/url.git`;
+ const dummyImportUrl = `${TEST_HOST}/dummy/import/url.git`;
beforeEach(() => {
projectNew.bindEvents();
diff --git a/spec/frontend/search_autocomplete_spec.js b/spec/frontend/search_autocomplete_spec.js
index 1003a076f9e..05b36474548 100644
--- a/spec/frontend/search_autocomplete_spec.js
+++ b/spec/frontend/search_autocomplete_spec.js
@@ -113,6 +113,7 @@ describe('Search autocomplete dropdown', () => {
window.gon = {};
window.gon.current_user_id = userId;
window.gon.current_username = userName;
+ window.gl = window.gl || (window.gl = {});
return (widget = initSearchAutocomplete({ autocompletePath }));
});
diff --git a/spec/frontend/vue_shared/components/issue/related_issuable_item_spec.js b/spec/frontend/vue_shared/components/issue/related_issuable_item_spec.js
index 9be0a67e4fa..fe9a5156539 100644
--- a/spec/frontend/vue_shared/components/issue/related_issuable_item_spec.js
+++ b/spec/frontend/vue_shared/components/issue/related_issuable_item_spec.js
@@ -3,6 +3,7 @@ import { mount } from '@vue/test-utils';
import { formatDate } from '~/lib/utils/datetime_utility';
import RelatedIssuableItem from '~/vue_shared/components/issue/related_issuable_item.vue';
import { defaultAssignees, defaultMilestone } from './related_issuable_mock_data';
+import { TEST_HOST } from 'jest/helpers/test_constants';
describe('RelatedIssuableItem', () => {
let wrapper;
@@ -19,7 +20,7 @@ describe('RelatedIssuableItem', () => {
idKey: 1,
displayReference: 'gitlab-org/gitlab-test#1',
pathIdSeparator: '#',
- path: `${gl.TEST_HOST}/path`,
+ path: `${TEST_HOST}/path`,
title: 'title',
confidential: true,
dueDate: '1990-12-31',
diff --git a/spec/frontend/vue_shared/components/issue/related_issuable_mock_data.js b/spec/frontend/vue_shared/components/issue/related_issuable_mock_data.js
index 5f69d761fdf..17813f2833d 100644
--- a/spec/frontend/vue_shared/components/issue/related_issuable_mock_data.js
+++ b/spec/frontend/vue_shared/components/issue/related_issuable_mock_data.js
@@ -1,3 +1,5 @@
+import { TEST_HOST } from 'jest/helpers/test_constants';
+
export const defaultProps = {
endpoint: '/foo/bar/issues/1/related_issues',
currentNamespacePath: 'foo',
@@ -83,8 +85,8 @@ export const defaultAssignees = [
name: 'Administrator',
username: 'root',
state: 'active',
- avatar_url: `${gl.TEST_HOST}`,
- web_url: `${gl.TEST_HOST}/root`,
+ avatar_url: `${TEST_HOST}`,
+ web_url: `${TEST_HOST}/root`,
status_tooltip_html: null,
path: '/root',
},
@@ -93,8 +95,8 @@ export const defaultAssignees = [
name: 'Brooks Beatty',
username: 'brynn_champlin',
state: 'active',
- avatar_url: `${gl.TEST_HOST}`,
- web_url: `${gl.TEST_HOST}/brynn_champlin`,
+ avatar_url: `${TEST_HOST}`,
+ web_url: `${TEST_HOST}/brynn_champlin`,
status_tooltip_html: null,
path: '/brynn_champlin',
},
@@ -103,8 +105,8 @@ export const defaultAssignees = [
name: 'Bryce Turcotte',
username: 'melynda',
state: 'active',
- avatar_url: `${gl.TEST_HOST}`,
- web_url: `${gl.TEST_HOST}/melynda`,
+ avatar_url: `${TEST_HOST}`,
+ web_url: `${TEST_HOST}/melynda`,
status_tooltip_html: null,
path: '/melynda',
},
@@ -113,8 +115,8 @@ export const defaultAssignees = [
name: 'Conchita Eichmann',
username: 'juliana_gulgowski',
state: 'active',
- avatar_url: `${gl.TEST_HOST}`,
- web_url: `${gl.TEST_HOST}/juliana_gulgowski`,
+ avatar_url: `${TEST_HOST}`,
+ web_url: `${TEST_HOST}/juliana_gulgowski`,
status_tooltip_html: null,
path: '/juliana_gulgowski',
},