Commit 8ed5f601 authored by Denys Mishunov's avatar Denys Mishunov

Changed master-to-main in WebIDE files

We're preparing to move to main as default branch
parent 726054b8
...@@ -112,3 +112,5 @@ export const LIVE_PREVIEW_DEBOUNCE = 2000; ...@@ -112,3 +112,5 @@ export const LIVE_PREVIEW_DEBOUNCE = 2000;
// This is the maximum number of files to auto open when opening the Web IDE // This is the maximum number of files to auto open when opening the Web IDE
// from a merge request // from a merge request
export const MAX_MR_FILES_AUTO_OPEN = 10; export const MAX_MR_FILES_AUTO_OPEN = 10;
export const DEFAULT_BRANCH = 'main';
...@@ -16,8 +16,8 @@ Vue.use(IdeRouter); ...@@ -16,8 +16,8 @@ Vue.use(IdeRouter);
/** /**
* Routes below /-/ide/: * Routes below /-/ide/:
/project/h5bp/html5-boilerplate/blob/master /project/h5bp/html5-boilerplate/blob/main
/project/h5bp/html5-boilerplate/blob/master/app/js/test.js /project/h5bp/html5-boilerplate/blob/main/app/js/test.js
/project/h5bp/html5-boilerplate/mr/123 /project/h5bp/html5-boilerplate/mr/123
/project/h5bp/html5-boilerplate/mr/123/app/js/test.js /project/h5bp/html5-boilerplate/mr/123/app/js/test.js
...@@ -39,7 +39,7 @@ const EmptyRouterComponent = { ...@@ -39,7 +39,7 @@ const EmptyRouterComponent = {
}, },
}; };
export const createRouter = (store) => { export const createRouter = (store, defaultBranch) => {
const router = new IdeRouter({ const router = new IdeRouter({
mode: 'history', mode: 'history',
base: joinPaths(gon.relative_url_root || '', '/-/ide/'), base: joinPaths(gon.relative_url_root || '', '/-/ide/'),
...@@ -58,7 +58,7 @@ export const createRouter = (store) => { ...@@ -58,7 +58,7 @@ export const createRouter = (store) => {
}, },
{ {
path: ':targetmode(edit|tree|blob)', path: ':targetmode(edit|tree|blob)',
redirect: (to) => joinPaths(to.path, '/master/-/'), redirect: (to) => joinPaths(to.path, `/${defaultBranch}/-/`),
}, },
{ {
path: 'merge_requests/:mrid', path: 'merge_requests/:mrid',
...@@ -66,7 +66,7 @@ export const createRouter = (store) => { ...@@ -66,7 +66,7 @@ export const createRouter = (store) => {
}, },
{ {
path: '', path: '',
redirect: (to) => joinPaths(to.path, '/edit/master/-/'), redirect: (to) => joinPaths(to.path, `/edit/${defaultBranch}/-/`),
}, },
], ],
}, },
......
import { identity } from 'lodash'; import { identity } from 'lodash';
import Vue from 'vue'; import Vue from 'vue';
import { mapActions } from 'vuex'; import { mapActions } from 'vuex';
import { DEFAULT_BRANCH } from '~/ide/constants';
import PerformancePlugin from '~/performance/vue_performance_plugin'; import PerformancePlugin from '~/performance/vue_performance_plugin';
import Translate from '~/vue_shared/translate'; import Translate from '~/vue_shared/translate';
import { parseBoolean } from '../lib/utils/common_utils'; import { parseBoolean } from '../lib/utils/common_utils';
...@@ -38,7 +39,7 @@ export function initIde(el, options = {}) { ...@@ -38,7 +39,7 @@ export function initIde(el, options = {}) {
const { rootComponent = ide, extendStore = identity } = options; const { rootComponent = ide, extendStore = identity } = options;
const store = createStore(); const store = createStore();
const router = createRouter(store); const router = createRouter(store, el.dataset.defaultBranch || DEFAULT_BRANCH);
return new Vue({ return new Vue({
el, el,
......
...@@ -146,7 +146,7 @@ export function getFileEOL(content = '') { ...@@ -146,7 +146,7 @@ export function getFileEOL(content = '') {
* hello.md -> hello-1.md * hello.md -> hello-1.md
* hello_2.md -> hello_3.md * hello_2.md -> hello_3.md
* hello_ -> hello_1 * hello_ -> hello_1
* master-patch-22432 -> master-patch-22433 * main-patch-22432 -> main-patch-22433
* patch_332 -> patch_333 * patch_332 -> patch_333
* *
* @param {string} filename File name or branch name * @param {string} filename File name or branch name
......
...@@ -4,7 +4,7 @@ import { buildTextToken, buildUneditableInlineTokens } from './build_uneditable_ ...@@ -4,7 +4,7 @@ import { buildTextToken, buildUneditableInlineTokens } from './build_uneditable_
Use case examples: Use case examples:
- Majority: two bracket pairs, back-to-back, each with content (including spaces) - Majority: two bracket pairs, back-to-back, each with content (including spaces)
- `[environment terraform plans][terraform]` - `[environment terraform plans][terraform]`
- `[an issue labelled `~"master:broken"`][broken-master-issues]` - `[an issue labelled `~"main:broken"`][broken-main-issues]`
- Minority: two bracket pairs the latter being empty or only one pair with content (including spaces) - Minority: two bracket pairs the latter being empty or only one pair with content (including spaces)
- `[this link][]` - `[this link][]`
- `[this link]` - `[this link]`
......
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
/** /**
* Styling below ensures that YouTube videos are displayed in the editor the same as they would in about.gitlab.com * Styling below ensures that YouTube videos are displayed in the editor the same as they would in about.gitlab.com
* https://gitlab.com/gitlab-com/www-gitlab-com/-/blob/master/source/stylesheets/_base.scss#L977 * https://gitlab.com/gitlab-com/www-gitlab-com/-/blob/main/source/stylesheets/_base.scss#L977
*/ */
.video_container { .video_container {
padding-bottom: 56.25%; padding-bottom: 56.25%;
......
...@@ -14,6 +14,7 @@ module IdeHelper ...@@ -14,6 +14,7 @@ module IdeHelper
'render-whitespace-in-code': current_user.render_whitespace_in_code.to_s, 'render-whitespace-in-code': current_user.render_whitespace_in_code.to_s,
'codesandbox-bundler-url': Gitlab::CurrentSettings.web_ide_clientside_preview_bundler_url, 'codesandbox-bundler-url': Gitlab::CurrentSettings.web_ide_clientside_preview_bundler_url,
'branch-name' => @branch, 'branch-name' => @branch,
'default-branch' => @project && @project.default_branch,
'file-path' => @path, 'file-path' => @path,
'merge-request' => @merge_request, 'merge-request' => @merge_request,
'fork-info' => @fork_info&.to_json, 'fork-info' => @fork_info&.to_json,
......
...@@ -7,7 +7,7 @@ import Timeago from '~/vue_shared/components/time_ago_tooltip.vue'; ...@@ -7,7 +7,7 @@ import Timeago from '~/vue_shared/components/time_ago_tooltip.vue';
import { projectData } from '../../mock_data'; import { projectData } from '../../mock_data';
const TEST_BRANCH = { const TEST_BRANCH = {
name: 'master', name: 'main',
committedDate: '2018-01-05T05:50Z', committedDate: '2018-01-05T05:50Z',
}; };
const TEST_PROJECT_ID = projectData.name_with_namespace; const TEST_PROJECT_ID = projectData.name_with_namespace;
......
...@@ -10,7 +10,7 @@ import { ...@@ -10,7 +10,7 @@ import {
const ACTION_UPDATE_COMMIT_ACTION = 'commit/updateCommitAction'; const ACTION_UPDATE_COMMIT_ACTION = 'commit/updateCommitAction';
const BRANCH_DEFAULT = 'master'; const BRANCH_DEFAULT = 'main';
const BRANCH_PROTECTED = 'protected/access'; const BRANCH_PROTECTED = 'protected/access';
const BRANCH_PROTECTED_NO_ACCESS = 'protected/no-access'; const BRANCH_PROTECTED_NO_ACCESS = 'protected/no-access';
const BRANCH_REGULAR = 'regular'; const BRANCH_REGULAR = 'regular';
...@@ -20,11 +20,7 @@ describe('IDE commit sidebar actions', () => { ...@@ -20,11 +20,7 @@ describe('IDE commit sidebar actions', () => {
let store; let store;
let vm; let vm;
const createComponent = ({ const createComponent = ({ hasMR = false, currentBranchId = 'main', emptyRepo = false } = {}) => {
hasMR = false,
currentBranchId = 'master',
emptyRepo = false,
} = {}) => {
const Component = Vue.extend(commitActions); const Component = Vue.extend(commitActions);
vm = createComponentWithStore(Component, store); vm = createComponentWithStore(Component, store);
...@@ -72,7 +68,7 @@ describe('IDE commit sidebar actions', () => { ...@@ -72,7 +68,7 @@ describe('IDE commit sidebar actions', () => {
it('renders current branch text', () => { it('renders current branch text', () => {
createComponent(); createComponent();
expect(findText()).toContain('Commit to master branch'); expect(findText()).toContain('Commit to main branch');
}); });
it('hides merge request option when project merge requests are disabled', (done) => { it('hides merge request option when project merge requests are disabled', (done) => {
...@@ -112,7 +108,7 @@ describe('IDE commit sidebar actions', () => { ...@@ -112,7 +108,7 @@ describe('IDE commit sidebar actions', () => {
it('calls again after staged changes', (done) => { it('calls again after staged changes', (done) => {
createComponent({ currentBranchId: null }); createComponent({ currentBranchId: null });
vm.$store.state.currentBranchId = 'master'; vm.$store.state.currentBranchId = 'main';
vm.$store.state.changedFiles.push({}); vm.$store.state.changedFiles.push({});
vm.$store.state.stagedFiles.push({}); vm.$store.state.stagedFiles.push({});
...@@ -158,7 +154,7 @@ describe('IDE commit sidebar actions', () => { ...@@ -158,7 +154,7 @@ describe('IDE commit sidebar actions', () => {
it('only renders commit to current branch', () => { it('only renders commit to current branch', () => {
expect(findRadios().length).toBe(1); expect(findRadios().length).toBe(1);
expect(findText()).toContain('Commit to master branch'); expect(findText()).toContain('Commit to main branch');
}); });
}); });
}); });
...@@ -67,7 +67,7 @@ describe('IDE commit form', () => { ...@@ -67,7 +67,7 @@ describe('IDE commit form', () => {
store = createStore(); store = createStore();
store.state.stagedFiles.push('test'); store.state.stagedFiles.push('test');
store.state.currentProjectId = 'abcproject'; store.state.currentProjectId = 'abcproject';
store.state.currentBranchId = 'master'; store.state.currentBranchId = 'main';
Vue.set(store.state.projects, 'abcproject', { Vue.set(store.state.projects, 'abcproject', {
...projectData, ...projectData,
userPermissions: { pushCode: true }, userPermissions: { pushCode: true },
......
...@@ -24,7 +24,7 @@ describe('create new MR checkbox', () => { ...@@ -24,7 +24,7 @@ describe('create new MR checkbox', () => {
store.state.projects[store.state.currentProjectId].userPermissions = permissions; store.state.projects[store.state.currentProjectId].userPermissions = permissions;
}; };
const createComponent = ({ currentBranchId = 'master', createNewBranch = false } = {}) => { const createComponent = ({ currentBranchId = 'main', createNewBranch = false } = {}) => {
const Component = Vue.extend(NewMergeRequestOption); const Component = Vue.extend(NewMergeRequestOption);
vm = createComponentWithStore(Component, store); vm = createComponentWithStore(Component, store);
...@@ -63,7 +63,7 @@ describe('create new MR checkbox', () => { ...@@ -63,7 +63,7 @@ describe('create new MR checkbox', () => {
describe('is rendered when pushing to a new branch', () => { describe('is rendered when pushing to a new branch', () => {
beforeEach(() => { beforeEach(() => {
createComponent({ createComponent({
currentBranchId: 'master', currentBranchId: 'main',
createNewBranch: true, createNewBranch: true,
}); });
}); });
...@@ -87,7 +87,7 @@ describe('create new MR checkbox', () => { ...@@ -87,7 +87,7 @@ describe('create new MR checkbox', () => {
describe('is NOT rendered when pushing to the same branch', () => { describe('is NOT rendered when pushing to the same branch', () => {
beforeEach(() => { beforeEach(() => {
createComponent({ createComponent({
currentBranchId: 'master', currentBranchId: 'main',
createNewBranch: false, createNewBranch: false,
}); });
}); });
......
...@@ -19,9 +19,9 @@ describe('IDE review mode', () => { ...@@ -19,9 +19,9 @@ describe('IDE review mode', () => {
beforeEach(() => { beforeEach(() => {
store = createStore(); store = createStore();
store.state.currentProjectId = 'abcproject'; store.state.currentProjectId = 'abcproject';
store.state.currentBranchId = 'master'; store.state.currentBranchId = 'main';
store.state.projects.abcproject = { ...projectData }; store.state.projects.abcproject = { ...projectData };
Vue.set(store.state.trees, 'abcproject/master', { Vue.set(store.state.trees, 'abcproject/main', {
tree: [file('fileName')], tree: [file('fileName')],
loading: false, loading: false,
}); });
......
...@@ -22,9 +22,9 @@ describe('WebIDE', () => { ...@@ -22,9 +22,9 @@ describe('WebIDE', () => {
const createComponent = ({ projData = emptyProjData, state = {} } = {}) => { const createComponent = ({ projData = emptyProjData, state = {} } = {}) => {
store.state.currentProjectId = 'abcproject'; store.state.currentProjectId = 'abcproject';
store.state.currentBranchId = 'master'; store.state.currentBranchId = 'main';
store.state.projects.abcproject = projData && { ...projData }; store.state.projects.abcproject = projData && { ...projData };
store.state.trees['abcproject/master'] = { store.state.trees['abcproject/main'] = {
tree: [], tree: [],
loading: false, loading: false,
}; };
......
...@@ -24,7 +24,7 @@ describe('ideStatusBar', () => { ...@@ -24,7 +24,7 @@ describe('ideStatusBar', () => {
store = createStore(); store = createStore();
store.state.currentProjectId = TEST_PROJECT_ID; store.state.currentProjectId = TEST_PROJECT_ID;
store.state.projects[TEST_PROJECT_ID] = _.clone(projectData); store.state.projects[TEST_PROJECT_ID] = _.clone(projectData);
store.state.currentBranchId = 'master'; store.state.currentBranchId = 'main';
}); });
afterEach(() => { afterEach(() => {
......
...@@ -14,9 +14,9 @@ describe('IDE tree list', () => { ...@@ -14,9 +14,9 @@ describe('IDE tree list', () => {
const bootstrapWithTree = (tree = normalBranchTree) => { const bootstrapWithTree = (tree = normalBranchTree) => {
store.state.currentProjectId = 'abcproject'; store.state.currentProjectId = 'abcproject';
store.state.currentBranchId = 'master'; store.state.currentBranchId = 'main';
store.state.projects.abcproject = { ...projectData }; store.state.projects.abcproject = { ...projectData };
Vue.set(store.state.trees, 'abcproject/master', { Vue.set(store.state.trees, 'abcproject/main', {
tree, tree,
loading: false, loading: false,
}); });
...@@ -42,7 +42,7 @@ describe('IDE tree list', () => { ...@@ -42,7 +42,7 @@ describe('IDE tree list', () => {
}); });
it('renders loading indicator', (done) => { it('renders loading indicator', (done) => {
store.state.trees['abcproject/master'].loading = true; store.state.trees['abcproject/main'].loading = true;
vm.$nextTick(() => { vm.$nextTick(() => {
expect(vm.$el.querySelector('.multi-file-loading-container')).not.toBeNull(); expect(vm.$el.querySelector('.multi-file-loading-container')).not.toBeNull();
......
...@@ -18,9 +18,9 @@ describe('IdeTree', () => { ...@@ -18,9 +18,9 @@ describe('IdeTree', () => {
store = createStore(); store = createStore();
store.state.currentProjectId = 'abcproject'; store.state.currentProjectId = 'abcproject';
store.state.currentBranchId = 'master'; store.state.currentBranchId = 'main';
store.state.projects.abcproject = { ...projectData }; store.state.projects.abcproject = { ...projectData };
Vue.set(store.state.trees, 'abcproject/master', { Vue.set(store.state.trees, 'abcproject/main', {
tree: [file('fileName')], tree: [file('fileName')],
loading: false, loading: false,
}); });
......
...@@ -21,7 +21,7 @@ describe('IDE merge requests list', () => { ...@@ -21,7 +21,7 @@ describe('IDE merge requests list', () => {
const fakeStore = new Vuex.Store({ const fakeStore = new Vuex.Store({
state: { state: {
currentMergeRequestId: '1', currentMergeRequestId: '1',
currentProjectId: 'project/master', currentProjectId: 'project/main',
...restOfState, ...restOfState,
}, },
modules: { modules: {
......
...@@ -14,14 +14,14 @@ describe('IDE NavDropdown', () => { ...@@ -14,14 +14,14 @@ describe('IDE NavDropdown', () => {
store = createStore(); store = createStore();
Object.assign(store.state, { Object.assign(store.state, {
currentProjectId: TEST_PROJECT_ID, currentProjectId: TEST_PROJECT_ID,
currentBranchId: 'master', currentBranchId: 'main',
projects: { projects: {
[TEST_PROJECT_ID]: { [TEST_PROJECT_ID]: {
userPermissions: { userPermissions: {
[PERMISSION_READ_MR]: true, [PERMISSION_READ_MR]: true,
}, },
branches: { branches: {
master: { id: 'master' }, main: { id: 'main' },
}, },
}, },
}, },
......
...@@ -13,7 +13,7 @@ describe('new dropdown component', () => { ...@@ -13,7 +13,7 @@ describe('new dropdown component', () => {
const component = Vue.extend(newDropdown); const component = Vue.extend(newDropdown);
vm = createComponentWithStore(component, store, { vm = createComponentWithStore(component, store, {
branch: 'master', branch: 'main',
path: '', path: '',
mouseOver: false, mouseOver: false,
type: 'tree', type: 'tree',
......
...@@ -22,11 +22,11 @@ describe('RepoCommitSection', () => { ...@@ -22,11 +22,11 @@ describe('RepoCommitSection', () => {
store.state.noChangesStateSvgPath = 'svg'; store.state.noChangesStateSvgPath = 'svg';
store.state.committedStateSvgPath = 'commitsvg'; store.state.committedStateSvgPath = 'commitsvg';
store.state.currentProjectId = 'abcproject'; store.state.currentProjectId = 'abcproject';
store.state.currentBranchId = 'master'; store.state.currentBranchId = 'main';
store.state.projects.abcproject = { store.state.projects.abcproject = {
web_url: '', web_url: '',
branches: { branches: {
master: { main: {
workingReference: '1', workingReference: '1',
}, },
}, },
...@@ -39,7 +39,7 @@ describe('RepoCommitSection', () => { ...@@ -39,7 +39,7 @@ describe('RepoCommitSection', () => {
}), }),
); );
store.state.currentBranch = 'master'; store.state.currentBranch = 'main';
store.state.changedFiles = []; store.state.changedFiles = [];
store.state.stagedFiles = [{ ...files[0] }, { ...files[1] }]; store.state.stagedFiles = [{ ...files[0] }, { ...files[1] }];
store.state.stagedFiles.forEach((f) => store.state.stagedFiles.forEach((f) =>
......
...@@ -63,8 +63,8 @@ const prepareStore = (state, activeFile) => { ...@@ -63,8 +63,8 @@ const prepareStore = (state, activeFile) => {
projects: { projects: {
'gitlab-org/gitlab': { 'gitlab-org/gitlab': {
branches: { branches: {
master: { main: {
name: 'master', name: 'main',
commit: { commit: {
id: 'abcdefgh', id: 'abcdefgh',
}, },
...@@ -73,7 +73,7 @@ const prepareStore = (state, activeFile) => { ...@@ -73,7 +73,7 @@ const prepareStore = (state, activeFile) => {
}, },
}, },
currentProjectId: 'gitlab-org/gitlab', currentProjectId: 'gitlab-org/gitlab',
currentBranchId: 'master', currentBranchId: 'main',
entries: { entries: {
[activeFile.path]: activeFile, [activeFile.path]: activeFile,
}, },
......
...@@ -18,14 +18,14 @@ describe('IDE router', () => { ...@@ -18,14 +18,14 @@ describe('IDE router', () => {
}); });
[ [
`/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/tree/master/-/src/blob/`, `/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/tree/main/-/src/blob/`,
`/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/tree/master/-/src/blob`, `/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/tree/main/-/src/blob`,
`/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/tree/blob/-/src/blob`, `/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/tree/blob/-/src/blob`,
`/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/tree/master/-/src/tree/`, `/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/tree/main/-/src/tree/`,
`/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/tree/weird:branch/name-123/-/src/tree/`, `/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/tree/weird:branch/name-123/-/src/tree/`,
`/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/blob/master/-/src/blob`, `/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/blob/main/-/src/blob`,
`/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/blob/master/-/src/edit`, `/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/blob/main/-/src/edit`,
`/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/blob/master/-/src/merge_requests/2`, `/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/blob/main/-/src/merge_requests/2`,
`/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/blob/blob/-/src/blob`, `/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/blob/blob/-/src/blob`,
`/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/edit/blob/-/src/blob`, `/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/edit/blob/-/src/blob`,
`/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/merge_requests/2`, `/project/${PROJECT_NAMESPACE}/${PROJECT_NAME}/merge_requests/2`,
......
...@@ -8,8 +8,8 @@ export const projectData = { ...@@ -8,8 +8,8 @@ export const projectData = {
path: '', path: '',
name_with_namespace: 'namespace/abcproject', name_with_namespace: 'namespace/abcproject',
branches: { branches: {
master: { main: {
treeId: 'abcproject/master', treeId: 'abcproject/main',
can_push: true, can_push: true,
commit: { commit: {
id: '123', id: '123',
...@@ -19,13 +19,13 @@ export const projectData = { ...@@ -19,13 +19,13 @@ export const projectData = {
mergeRequests: {}, mergeRequests: {},
merge_requests_enabled: true, merge_requests_enabled: true,
userPermissions: {}, userPermissions: {},
default_branch: 'master', default_branch: 'main',
}; };
export const pipelines = [ export const pipelines = [
{ {
id: 1, id: 1,
ref: 'master', ref: 'main',
sha: '123', sha: '123',
details: { details: {
status: { status: {
...@@ -38,7 +38,7 @@ export const pipelines = [ ...@@ -38,7 +38,7 @@ export const pipelines = [
}, },
{ {
id: 2, id: 2,
ref: 'master', ref: 'main',
sha: '213', sha: '213',
details: { details: {
status: { status: {
...@@ -178,9 +178,9 @@ export const mergeRequests = [ ...@@ -178,9 +178,9 @@ export const mergeRequests = [
export const branches = [ export const branches = [
{ {
id: 1, id: 1,
name: 'master', name: 'main',
commit: { commit: {
message: 'Update master branch', message: 'Update main branch',
committed_date: '2018-08-01T00:20:05Z', committed_date: '2018-08-01T00:20:05Z',
}, },
can_push: true, can_push: true,
......
...@@ -15,7 +15,7 @@ jest.mock('~/ide/services/gql'); ...@@ -15,7 +15,7 @@ jest.mock('~/ide/services/gql');
const TEST_NAMESPACE = 'alice'; const TEST_NAMESPACE = 'alice';
const TEST_PROJECT = 'wonderland'; const TEST_PROJECT = 'wonderland';
const TEST_PROJECT_ID = `${TEST_NAMESPACE}/${TEST_PROJECT}`; const TEST_PROJECT_ID = `${TEST_NAMESPACE}/${TEST_PROJECT}`;
const TEST_BRANCH = 'master-patch-123'; const TEST_BRANCH = 'main-patch-123';
const TEST_COMMIT_SHA = '123456789'; const TEST_COMMIT_SHA = '123456789';
const TEST_FILE_PATH = 'README2.md'; const TEST_FILE_PATH = 'README2.md';
const TEST_FILE_OLD_PATH = 'OLD_README2.md'; const TEST_FILE_OLD_PATH = 'OLD_README2.md';
......
...@@ -29,7 +29,7 @@ describe('IDE store file actions', () => { ...@@ -29,7 +29,7 @@ describe('IDE store file actions', () => {
store = createStore(); store = createStore();
store.state.currentProjectId = 'test/test'; store.state.currentProjectId = 'test/test';
store.state.currentBranchId = 'master'; store.state.currentBranchId = 'main';
router = createRouter(store); router = createRouter(store);
...@@ -85,7 +85,7 @@ describe('IDE store file actions', () => { ...@@ -85,7 +85,7 @@ describe('IDE store file actions', () => {
.dispatch('closeFile', localFile) .dispatch('closeFile', localFile)
.then(Vue.nextTick) .then(Vue.nextTick)
.then(() => { .then(() => {
expect(router.push).toHaveBeenCalledWith('/project/test/test/tree/master/-/newOpenFile/'); expect(router.push).toHaveBeenCalledWith('/project/test/test/tree/main/-/newOpenFile/');
}); });
}); });
...@@ -177,11 +177,11 @@ describe('IDE store file actions', () => { ...@@ -177,11 +177,11 @@ describe('IDE store file actions', () => {
store.state.entries[localFile.path] = localFile; store.state.entries[localFile.path] = localFile;
store.state.currentProjectId = 'test/test'; store.state.currentProjectId = 'test/test';
store.state.currentBranchId = 'master'; store.state.currentBranchId = 'main';
store.state.projects['test/test'] = { store.state.projects['test/test'] = {
branches: { branches: {
master: { main: {
commit: { commit: {
id: '7297abc', id: '7297abc',
}, },
...@@ -260,7 +260,7 @@ describe('IDE store file actions', () => { ...@@ -260,7 +260,7 @@ describe('IDE store file actions', () => {
it('sets document title with the branchId', () => { it('sets document title with the branchId', () => {
return store.dispatch('getFileData', { path: localFile.path }).then(() => { return store.dispatch('getFileData', { path: localFile.path }).then(() => {
expect(document.title).toBe(`${localFile.path} · master · test/test · GitLab`); expect(document.title).toBe(`${localFile.path} · main · test/test · GitLab`);
}); });
}); });
...@@ -329,7 +329,7 @@ describe('IDE store file actions', () => { ...@@ -329,7 +329,7 @@ describe('IDE store file actions', () => {
it('sets document title considering `prevPath` on a file', () => { it('sets document title considering `prevPath` on a file', () => {
return store.dispatch('getFileData', { path: localFile.path }).then(() => { return store.dispatch('getFileData', { path: localFile.path }).then(() => {
expect(document.title).toBe(`new-shiny-file · master · test/test · GitLab`); expect(document.title).toBe(`new-shiny-file · main · test/test · GitLab`);
}); });
}); });
}); });
...@@ -702,7 +702,7 @@ describe('IDE store file actions', () => { ...@@ -702,7 +702,7 @@ describe('IDE store file actions', () => {
}); });
it('pushes route for active file', () => { it('pushes route for active file', () => {
expect(router.push).toHaveBeenCalledWith('/project/test/test/tree/master/-/tempFile/'); expect(router.push).toHaveBeenCalledWith('/project/test/test/tree/main/-/tempFile/');
}); });
}); });
}); });
...@@ -778,7 +778,7 @@ describe('IDE store file actions', () => { ...@@ -778,7 +778,7 @@ describe('IDE store file actions', () => {
it('pushes router URL when added', () => { it('pushes router URL when added', () => {
return store.dispatch('openPendingTab', { file: f, keyPrefix: 'pending' }).then(() => { return store.dispatch('openPendingTab', { file: f, keyPrefix: 'pending' }).then(() => {
expect(router.push).toHaveBeenCalledWith('/project/test/test/tree/master/'); expect(router.push).toHaveBeenCalledWith('/project/test/test/tree/main/');
}); });
}); });
}); });
......
...@@ -463,11 +463,11 @@ describe('IDE store merge request actions', () => { ...@@ -463,11 +463,11 @@ describe('IDE store merge request actions', () => {
}; };
store.state.currentProjectId = 'test/test'; store.state.currentProjectId = 'test/test';
store.state.currentBranchId = 'master'; store.state.currentBranchId = 'main';
store.state.projects['test/test'] = { store.state.projects['test/test'] = {
branches: { branches: {
master: { main: {
commit: { commit: {
id: '7297abc', id: '7297abc',
}, },
......
...@@ -37,11 +37,11 @@ describe('IDE store project actions', () => { ...@@ -37,11 +37,11 @@ describe('IDE store project actions', () => {
describe('refreshLastCommitData', () => { describe('refreshLastCommitData', () => {
beforeEach(() => { beforeEach(() => {
store.state.currentProjectId = 'abc/def'; store.state.currentProjectId = 'abc/def';
store.state.currentBranchId = 'master'; store.state.currentBranchId = 'main';
store.state.projects['abc/def'] = { store.state.projects['abc/def'] = {
id: 4, id: 4,
branches: { branches: {
master: { main: {
commit: null, commit: null,
}, },
}, },
...@@ -60,7 +60,7 @@ describe('IDE store project actions', () => { ...@@ -60,7 +60,7 @@ describe('IDE store project actions', () => {
branchId: store.state.currentBranchId, branchId: store.state.currentBranchId,
}) })
.then(() => { .then(() => {
expect(service.getBranchData).toHaveBeenCalledWith('abc/def', 'master'); expect(service.getBranchData).toHaveBeenCalledWith('abc/def', 'main');
done(); done();
}) })
...@@ -81,7 +81,7 @@ describe('IDE store project actions', () => { ...@@ -81,7 +81,7 @@ describe('IDE store project actions', () => {
type: 'SET_BRANCH_COMMIT', type: 'SET_BRANCH_COMMIT',
payload: { payload: {
projectId: TEST_PROJECT_ID, projectId: TEST_PROJECT_ID,
branchId: 'master', branchId: 'main',
commit: { id: '123' }, commit: { id: '123' },
}, },
}, },
...@@ -97,17 +97,17 @@ describe('IDE store project actions', () => { ...@@ -97,17 +97,17 @@ describe('IDE store project actions', () => {
it('dispatches setErrorMessage', (done) => { it('dispatches setErrorMessage', (done) => {
testAction( testAction(
showBranchNotFoundError, showBranchNotFoundError,
'master', 'main',
null, null,
[], [],
[ [
{ {
type: 'setErrorMessage', type: 'setErrorMessage',
payload: { payload: {
text: "Branch <strong>master</strong> was not found in this project's repository.", text: "Branch <strong>main</strong> was not found in this project's repository.",
action: expect.any(Function), action: expect.any(Function),
actionText: 'Create branch', actionText: 'Create branch',
actionPayload: 'master', actionPayload: 'main',
}, },
}, },
], ],
...@@ -131,7 +131,7 @@ describe('IDE store project actions', () => { ...@@ -131,7 +131,7 @@ describe('IDE store project actions', () => {
}, },
getters: { getters: {
currentProject: { currentProject: {
default_branch: 'master', default_branch: 'main',
}, },
}, },
dispatch() {}, dispatch() {},
...@@ -140,7 +140,7 @@ describe('IDE store project actions', () => { ...@@ -140,7 +140,7 @@ describe('IDE store project actions', () => {
) )
.then(() => { .then(() => {
expect(api.createBranch).toHaveBeenCalledWith('project-path', { expect(api.createBranch).toHaveBeenCalledWith('project-path', {
ref: 'master', ref: 'main',
branch: 'new-branch-name', branch: 'new-branch-name',
}); });
}) })
...@@ -158,7 +158,7 @@ describe('IDE store project actions', () => { ...@@ -158,7 +158,7 @@ describe('IDE store project actions', () => {
}, },
getters: { getters: {
currentProject: { currentProject: {
default_branch: 'master', default_branch: 'main',
}, },
}, },
dispatch: dispatchSpy, dispatch: dispatchSpy,
...@@ -180,7 +180,7 @@ describe('IDE store project actions', () => { ...@@ -180,7 +180,7 @@ describe('IDE store project actions', () => {
}, },
getters: { getters: {
currentProject: { currentProject: {
default_branch: 'master', default_branch: 'main',
}, },
}, },
dispatch() {}, dispatch() {},
...@@ -199,13 +199,13 @@ describe('IDE store project actions', () => { ...@@ -199,13 +199,13 @@ describe('IDE store project actions', () => {
it('creates a blank tree and sets loading state to false', (done) => { it('creates a blank tree and sets loading state to false', (done) => {
testAction( testAction(
loadEmptyBranch, loadEmptyBranch,
{ projectId: TEST_PROJECT_ID, branchId: 'master' }, { projectId: TEST_PROJECT_ID, branchId: 'main' },
store.state, store.state,
[ [
{ type: 'CREATE_TREE', payload: { treePath: `${TEST_PROJECT_ID}/master` } }, { type: 'CREATE_TREE', payload: { treePath: `${TEST_PROJECT_ID}/main` } },
{ {
type: 'TOGGLE_LOADING', type: 'TOGGLE_LOADING',
payload: { entry: store.state.trees[`${TEST_PROJECT_ID}/master`], forceValue: false }, payload: { entry: store.state.trees[`${TEST_PROJECT_ID}/maind`], forceValue: false },
}, },
], ],
expect.any(Object), expect.any(Object),
...@@ -214,11 +214,11 @@ describe('IDE store project actions', () => { ...@@ -214,11 +214,11 @@ describe('IDE store project actions', () => {
}); });
it('does nothing, if tree already exists', (done) => { it('does nothing, if tree already exists', (done) => {
const trees = { [`${TEST_PROJECT_ID}/master`]: [] }; const trees = { [`${TEST_PROJECT_ID}/main`]: [] };
testAction( testAction(
loadEmptyBranch, loadEmptyBranch,
{ projectId: TEST_PROJECT_ID, branchId: 'master' }, { projectId: TEST_PROJECT_ID, branchId: 'main' },
{ trees }, { trees },
[], [],
[], [],
......
...@@ -18,8 +18,8 @@ describe('Multi-file store tree actions', () => { ...@@ -18,8 +18,8 @@ describe('Multi-file store tree actions', () => {
const basicCallParameters = { const basicCallParameters = {
endpoint: 'rootEndpoint', endpoint: 'rootEndpoint',
projectId: 'abcproject', projectId: 'abcproject',
branch: 'master', branch: 'main',
branchId: 'master', branchId: 'main',
ref: '12345678', ref: '12345678',
}; };
...@@ -31,7 +31,7 @@ describe('Multi-file store tree actions', () => { ...@@ -31,7 +31,7 @@ describe('Multi-file store tree actions', () => {
mock = new MockAdapter(axios); mock = new MockAdapter(axios);
store.state.currentProjectId = 'abcproject'; store.state.currentProjectId = 'abcproject';
store.state.currentBranchId = 'master'; store.state.currentBranchId = 'main';
store.state.projects.abcproject = { store.state.projects.abcproject = {
web_url: '', web_url: '',
path_with_namespace: 'foo/abcproject', path_with_namespace: 'foo/abcproject',
...@@ -66,7 +66,7 @@ describe('Multi-file store tree actions', () => { ...@@ -66,7 +66,7 @@ describe('Multi-file store tree actions', () => {
store store
.dispatch('getFiles', basicCallParameters) .dispatch('getFiles', basicCallParameters)
.then(() => { .then(() => {
projectTree = store.state.trees['abcproject/master']; projectTree = store.state.trees['abcproject/main'];
expect(projectTree.tree.length).toBe(2); expect(projectTree.tree.length).toBe(2);
expect(projectTree.tree[0].type).toBe('tree'); expect(projectTree.tree[0].type).toBe('tree');
...@@ -89,7 +89,7 @@ describe('Multi-file store tree actions', () => { ...@@ -89,7 +89,7 @@ describe('Multi-file store tree actions', () => {
'abc/def': { 'abc/def': {
web_url: `${TEST_HOST}/files`, web_url: `${TEST_HOST}/files`,
branches: { branches: {
'master-testing': { 'main-testing': {
commit: { commit: {
id: '12345', id: '12345',
}, },
...@@ -98,7 +98,7 @@ describe('Multi-file store tree actions', () => { ...@@ -98,7 +98,7 @@ describe('Multi-file store tree actions', () => {
}, },
}; };
const getters = { const getters = {
findBranch: () => store.state.projects['abc/def'].branches['master-testing'], findBranch: () => store.state.projects['abc/def'].branches['main-testing'],
}; };
mock.onGet(/(.*)/).replyOnce(500); mock.onGet(/(.*)/).replyOnce(500);
...@@ -112,7 +112,7 @@ describe('Multi-file store tree actions', () => { ...@@ -112,7 +112,7 @@ describe('Multi-file store tree actions', () => {
}, },
{ {
projectId: 'abc/def', projectId: 'abc/def',
branchId: 'master-testing', branchId: 'main-testing',
}, },
) )
.then(done.fail) .then(done.fail)
...@@ -121,7 +121,7 @@ describe('Multi-file store tree actions', () => { ...@@ -121,7 +121,7 @@ describe('Multi-file store tree actions', () => {
text: 'An error occurred while loading all the files.', text: 'An error occurred while loading all the files.',
action: expect.any(Function), action: expect.any(Function),
actionText: 'Please try again', actionText: 'Please try again',
actionPayload: { projectId: 'abc/def', branchId: 'master-testing' }, actionPayload: { projectId: 'abc/def', branchId: 'main-testing' },
}); });
done(); done();
}); });
...@@ -178,17 +178,17 @@ describe('Multi-file store tree actions', () => { ...@@ -178,17 +178,17 @@ describe('Multi-file store tree actions', () => {
describe('setDirectoryData', () => { describe('setDirectoryData', () => {
it('sets tree correctly if there are no opened files yet', (done) => { it('sets tree correctly if there are no opened files yet', (done) => {
const treeFile = file({ name: 'README.md' }); const treeFile = file({ name: 'README.md' });
store.state.trees['abcproject/master'] = {}; store.state.trees['abcproject/main'] = {};
testAction( testAction(
setDirectoryData, setDirectoryData,
{ projectId: 'abcproject', branchId: 'master', treeList: [treeFile] }, { projectId: 'abcproject', branchId: 'main', treeList: [treeFile] },
store.state, store.state,
[ [
{ {
type: types.SET_DIRECTORY_DATA, type: types.SET_DIRECTORY_DATA,
payload: { payload: {
treePath: 'abcproject/master', treePath: 'abcproject/main',
data: [treeFile], data: [treeFile],
}, },
}, },
......
...@@ -777,7 +777,7 @@ describe('Multi-file store actions', () => { ...@@ -777,7 +777,7 @@ describe('Multi-file store actions', () => {
it('routes to the renamed file if the original file has been opened', (done) => { it('routes to the renamed file if the original file has been opened', (done) => {
store.state.currentProjectId = 'test/test'; store.state.currentProjectId = 'test/test';
store.state.currentBranchId = 'master'; store.state.currentBranchId = 'main';
Object.assign(store.state.entries.orig, { Object.assign(store.state.entries.orig, {
opened: true, opened: true,
...@@ -790,7 +790,7 @@ describe('Multi-file store actions', () => { ...@@ -790,7 +790,7 @@ describe('Multi-file store actions', () => {
}) })
.then(() => { .then(() => {
expect(router.push.mock.calls).toHaveLength(1); expect(router.push.mock.calls).toHaveLength(1);
expect(router.push).toHaveBeenCalledWith(`/project/test/test/tree/master/-/renamed/`); expect(router.push).toHaveBeenCalledWith(`/project/test/test/tree/main/-/renamed/`);
}) })
.then(done) .then(done)
.catch(done.fail); .catch(done.fail);
...@@ -1019,7 +1019,7 @@ describe('Multi-file store actions', () => { ...@@ -1019,7 +1019,7 @@ describe('Multi-file store actions', () => {
}, },
{ {
projectId: 'abc/def', projectId: 'abc/def',
branchId: 'master-testing', branchId: 'main-testing',
}, },
]; ];
dispatch = jest.fn(); dispatch = jest.fn();
......
...@@ -209,12 +209,12 @@ describe('IDE store getters', () => { ...@@ -209,12 +209,12 @@ describe('IDE store getters', () => {
describe('currentBranch', () => { describe('currentBranch', () => {
it('returns current projects branch', () => { it('returns current projects branch', () => {
localState.currentProjectId = 'abcproject'; localState.currentProjectId = 'abcproject';
localState.currentBranchId = 'master'; localState.currentBranchId = 'main';
localState.projects.abcproject = { localState.projects.abcproject = {
name: 'abcproject', name: 'abcproject',
branches: { branches: {
master: { main: {
name: 'master', name: 'main',
}, },
}, },
}; };
...@@ -223,7 +223,7 @@ describe('IDE store getters', () => { ...@@ -223,7 +223,7 @@ describe('IDE store getters', () => {
}; };
getters.currentBranch(localState, localGetters); getters.currentBranch(localState, localGetters);
expect(localGetters.findBranch).toHaveBeenCalledWith('abcproject', 'master'); expect(localGetters.findBranch).toHaveBeenCalledWith('abcproject', 'main');
}); });
}); });
...@@ -243,12 +243,12 @@ describe('IDE store getters', () => { ...@@ -243,12 +243,12 @@ describe('IDE store getters', () => {
it('returns the selected branch from a project', () => { it('returns the selected branch from a project', () => {
localState.currentProjectId = 'abcproject'; localState.currentProjectId = 'abcproject';
localState.currentBranchId = 'master'; localState.currentBranchId = 'main';
localState.projects.abcproject = { localState.projects.abcproject = {
name: 'abcproject', name: 'abcproject',
branches: { branches: {
master: { main: {
name: 'master', name: 'main',
}, },
}, },
}; };
...@@ -256,9 +256,9 @@ describe('IDE store getters', () => { ...@@ -256,9 +256,9 @@ describe('IDE store getters', () => {
findProject: () => localState.projects.abcproject, findProject: () => localState.projects.abcproject,
}; };
result = getters.findBranch(localState, localGetters)('abcproject', 'master'); result = getters.findBranch(localState, localGetters)('abcproject', 'main');
expect(result.name).toBe('master'); expect(result.name).toBe('main');
}); });
}); });
...@@ -274,9 +274,9 @@ describe('IDE store getters', () => { ...@@ -274,9 +274,9 @@ describe('IDE store getters', () => {
it("returns true when project's default branch matches current branch", () => { it("returns true when project's default branch matches current branch", () => {
const localGetters = { const localGetters = {
currentProject: { currentProject: {
default_branch: 'master', default_branch: 'main',
}, },
branchName: 'master', branchName: 'main',
}; };
expect(getters.isOnDefaultBranch({}, localGetters)).toBeTruthy(); expect(getters.isOnDefaultBranch({}, localGetters)).toBeTruthy();
...@@ -285,7 +285,7 @@ describe('IDE store getters', () => { ...@@ -285,7 +285,7 @@ describe('IDE store getters', () => {
it("returns false when project's default branch doesn't match current branch", () => { it("returns false when project's default branch doesn't match current branch", () => {
const localGetters = { const localGetters = {
currentProject: { currentProject: {
default_branch: 'master', default_branch: 'main',
}, },
branchName: 'feature', branchName: 'feature',
}; };
...@@ -620,10 +620,10 @@ describe('IDE store getters', () => { ...@@ -620,10 +620,10 @@ describe('IDE store getters', () => {
describe('getUrlForPath', () => { describe('getUrlForPath', () => {
it('returns a route url for the given path', () => { it('returns a route url for the given path', () => {
localState.currentProjectId = 'test/test'; localState.currentProjectId = 'test/test';
localState.currentBranchId = 'master'; localState.currentBranchId = 'main';
expect(localStore.getters.getUrlForPath('path/to/foo/bar-1.jpg')).toBe( expect(localStore.getters.getUrlForPath('path/to/foo/bar-1.jpg')).toBe(
`/project/test/test/tree/master/-/path/to/foo/bar-1.jpg/`, `/project/test/test/tree/main/-/path/to/foo/bar-1.jpg/`,
); );
}); });
}); });
...@@ -631,13 +631,13 @@ describe('IDE store getters', () => { ...@@ -631,13 +631,13 @@ describe('IDE store getters', () => {
describe('getJsonSchemaForPath', () => { describe('getJsonSchemaForPath', () => {
beforeEach(() => { beforeEach(() => {
localState.currentProjectId = 'path/to/some/project'; localState.currentProjectId = 'path/to/some/project';
localState.currentBranchId = 'master'; localState.currentBranchId = 'main';
}); });
it('returns a json schema uri and match config for a json/yaml file that can be loaded by monaco', () => { it('returns a json schema uri and match config for a json/yaml file that can be loaded by monaco', () => {
expect(localStore.getters.getJsonSchemaForPath('.gitlab-ci.yml')).toEqual({ expect(localStore.getters.getJsonSchemaForPath('.gitlab-ci.yml')).toEqual({
fileMatch: ['*.gitlab-ci.yml'], fileMatch: ['*.gitlab-ci.yml'],
uri: `${TEST_HOST}/path/to/some/project/-/schema/master/.gitlab-ci.yml`, uri: `${TEST_HOST}/path/to/some/project/-/schema/main/.gitlab-ci.yml`,
}); });
}); });
...@@ -645,8 +645,8 @@ describe('IDE store getters', () => { ...@@ -645,8 +645,8 @@ describe('IDE store getters', () => {
localState.projects['path/to/some/project'] = { localState.projects['path/to/some/project'] = {
name: 'project', name: 'project',
branches: { branches: {
master: { main: {
name: 'master', name: 'main',
commit: { commit: {
id: 'abcdef123456', id: 'abcdef123456',
}, },
......
...@@ -47,7 +47,7 @@ describe('IDE commit module actions', () => { ...@@ -47,7 +47,7 @@ describe('IDE commit module actions', () => {
jest.spyOn(router, 'push').mockImplementation(); jest.spyOn(router, 'push').mockImplementation();
mock mock
.onGet('/api/v1/projects/abcproject/repository/branches/master') .onGet('/api/v1/projects/abcproject/repository/branches/main')
.reply(200, { commit: COMMIT_RESPONSE }); .reply(200, { commit: COMMIT_RESPONSE });
}); });
...@@ -101,7 +101,7 @@ describe('IDE commit module actions', () => { ...@@ -101,7 +101,7 @@ describe('IDE commit module actions', () => {
originalGon = window.gon; originalGon = window.gon;
window.gon = { current_username: 'johndoe' }; window.gon = { current_username: 'johndoe' };
store.state.currentBranchId = 'master'; store.state.currentBranchId = 'main';
}); });
afterEach(() => { afterEach(() => {
...@@ -177,7 +177,7 @@ describe('IDE commit module actions', () => { ...@@ -177,7 +177,7 @@ describe('IDE commit module actions', () => {
committed_date: '123', committed_date: '123',
committer_name: 'root', committer_name: 'root',
}; };
const branch = 'master'; const branch = 'main';
let f; let f;
beforeEach(() => { beforeEach(() => {
...@@ -192,12 +192,12 @@ describe('IDE commit module actions', () => { ...@@ -192,12 +192,12 @@ describe('IDE commit module actions', () => {
Object.assign(store.state, { Object.assign(store.state, {
currentProjectId: 'abcproject', currentProjectId: 'abcproject',
currentBranchId: 'master', currentBranchId: 'main',
projects: { projects: {
abcproject: { abcproject: {
web_url: 'web_url', web_url: 'web_url',
branches: { branches: {
master: { main: {
workingReference: '', workingReference: '',
commit: { commit: {
short_id: TEST_COMMIT_SHA, short_id: TEST_COMMIT_SHA,
...@@ -228,7 +228,7 @@ describe('IDE commit module actions', () => { ...@@ -228,7 +228,7 @@ describe('IDE commit module actions', () => {
branch, branch,
}) })
.then(() => { .then(() => {
expect(store.state.projects.abcproject.branches.master.workingReference).toBe(data.id); expect(store.state.projects.abcproject.branches.main.workingReference).toBe(data.id);
}) })
.then(done) .then(done)
.catch(done.fail); .catch(done.fail);
...@@ -310,14 +310,14 @@ describe('IDE commit module actions', () => { ...@@ -310,14 +310,14 @@ describe('IDE commit module actions', () => {
changedFiles: [f], changedFiles: [f],
openFiles: [f], openFiles: [f],
currentProjectId: 'abcproject', currentProjectId: 'abcproject',
currentBranchId: 'master', currentBranchId: 'main',
projects: { projects: {
abcproject: { abcproject: {
default_branch: 'master', default_branch: 'main',
web_url: 'webUrl', web_url: 'webUrl',
branches: { branches: {
master: { main: {
name: 'master', name: 'main',
workingReference: '1', workingReference: '1',
commit: { commit: {
id: TEST_COMMIT_SHA, id: TEST_COMMIT_SHA,
...@@ -460,7 +460,7 @@ describe('IDE commit module actions', () => { ...@@ -460,7 +460,7 @@ describe('IDE commit module actions', () => {
.dispatch('commit/commitChanges') .dispatch('commit/commitChanges')
.then(() => { .then(() => {
expect(visitUrl).toHaveBeenCalledWith( expect(visitUrl).toHaveBeenCalledWith(
`webUrl/-/merge_requests/new?merge_request[source_branch]=${store.getters['commit/placeholderBranchName']}&merge_request[target_branch]=master&nav_source=webide`, `webUrl/-/merge_requests/new?merge_request[source_branch]=${store.getters['commit/placeholderBranchName']}&merge_request[target_branch]=main&nav_source=webide`,
); );
done(); done();
......
...@@ -46,7 +46,7 @@ describe('IDE commit module getters', () => { ...@@ -46,7 +46,7 @@ describe('IDE commit module getters', () => {
describe('branchName', () => { describe('branchName', () => {
const rootState = { const rootState = {
currentBranchId: 'master', currentBranchId: 'main',
}; };
const localGetters = { const localGetters = {
placeholderBranchName: 'placeholder-branch-name', placeholderBranchName: 'placeholder-branch-name',
...@@ -61,7 +61,7 @@ describe('IDE commit module getters', () => { ...@@ -61,7 +61,7 @@ describe('IDE commit module getters', () => {
it('defaults to currentBranchId when not committing to a new branch', () => { it('defaults to currentBranchId when not committing to a new branch', () => {
localGetters.isCreatingNewBranch = false; localGetters.isCreatingNewBranch = false;
expect(getters.branchName(state, localGetters, rootState)).toBe('master'); expect(getters.branchName(state, localGetters, rootState)).toBe('main');
}); });
describe('commit to a new branch', () => { describe('commit to a new branch', () => {
......
...@@ -13,7 +13,7 @@ import axios from '~/lib/utils/axios_utils'; ...@@ -13,7 +13,7 @@ import axios from '~/lib/utils/axios_utils';
import httpStatus from '~/lib/utils/http_status'; import httpStatus from '~/lib/utils/http_status';
const TEST_PROJECT_PATH = 'lorem/root'; const TEST_PROJECT_PATH = 'lorem/root';
const TEST_BRANCH_ID = 'master'; const TEST_BRANCH_ID = 'main';
const TEST_YAML_HELP_PATH = `${TEST_HOST}/test/yaml/help`; const TEST_YAML_HELP_PATH = `${TEST_HOST}/test/yaml/help`;
const TEST_RUNNERS_HELP_PATH = `${TEST_HOST}/test/runners/help`; const TEST_RUNNERS_HELP_PATH = `${TEST_HOST}/test/runners/help`;
......
...@@ -11,7 +11,7 @@ import httpStatus from '~/lib/utils/http_status'; ...@@ -11,7 +11,7 @@ import httpStatus from '~/lib/utils/http_status';
jest.mock('~/flash'); jest.mock('~/flash');
const TEST_PROJECT_PATH = 'lorem/root'; const TEST_PROJECT_PATH = 'lorem/root';
const TEST_BRANCH_ID = 'master'; const TEST_BRANCH_ID = 'main';
const TEST_SESSION = { const TEST_SESSION = {
id: 7, id: 7,
status: PENDING, status: PENDING,
......
...@@ -10,9 +10,9 @@ describe('Multi-file store branch mutations', () => { ...@@ -10,9 +10,9 @@ describe('Multi-file store branch mutations', () => {
describe('SET_CURRENT_BRANCH', () => { describe('SET_CURRENT_BRANCH', () => {
it('sets currentBranch', () => { it('sets currentBranch', () => {
mutations.SET_CURRENT_BRANCH(localState, 'master'); mutations.SET_CURRENT_BRANCH(localState, 'main');
expect(localState.currentBranchId).toBe('master'); expect(localState.currentBranchId).toBe('main');
}); });
}); });
...@@ -21,20 +21,20 @@ describe('Multi-file store branch mutations', () => { ...@@ -21,20 +21,20 @@ describe('Multi-file store branch mutations', () => {
localState.projects = { localState.projects = {
Example: { Example: {
branches: { branches: {
master: {}, main: {},
}, },
}, },
}; };
mutations.SET_BRANCH_COMMIT(localState, { mutations.SET_BRANCH_COMMIT(localState, {
projectId: 'Example', projectId: 'Example',
branchId: 'master', branchId: 'main',
commit: { commit: {
title: 'Example commit', title: 'Example commit',
}, },
}); });
expect(localState.projects.Example.branches.master.commit.title).toBe('Example commit'); expect(localState.projects.Example.branches.main.commit.title).toBe('Example commit');
}); });
}); });
......
...@@ -319,8 +319,8 @@ describe('IDE store file mutations', () => { ...@@ -319,8 +319,8 @@ describe('IDE store file mutations', () => {
localFile.content = 'test'; localFile.content = 'test';
localFile.changed = true; localFile.changed = true;
localState.currentProjectId = 'gitlab-ce'; localState.currentProjectId = 'gitlab-ce';
localState.currentBranchId = 'master'; localState.currentBranchId = 'main';
localState.trees['gitlab-ce/master'] = { localState.trees['gitlab-ce/main'] = {
tree: [], tree: [],
}; };
}); });
...@@ -337,7 +337,7 @@ describe('IDE store file mutations', () => { ...@@ -337,7 +337,7 @@ describe('IDE store file mutations', () => {
mutations.DISCARD_FILE_CHANGES(localState, localFile.path); mutations.DISCARD_FILE_CHANGES(localState, localFile.path);
expect(localState.trees['gitlab-ce/master'].tree).toEqual([{ ...localFile, deleted: false }]); expect(localState.trees['gitlab-ce/main'].tree).toEqual([{ ...localFile, deleted: false }]);
}); });
it('adds to parent tree if deleted', () => { it('adds to parent tree if deleted', () => {
......
...@@ -33,16 +33,16 @@ describe('Multi-file store tree mutations', () => { ...@@ -33,16 +33,16 @@ describe('Multi-file store tree mutations', () => {
}); });
it('adds directory data', () => { it('adds directory data', () => {
localState.trees['project/master'] = { localState.trees['project/main'] = {
tree: [], tree: [],
}; };
mutations.SET_DIRECTORY_DATA(localState, { mutations.SET_DIRECTORY_DATA(localState, {
data, data,
treePath: 'project/master', treePath: 'project/main',
}); });
const tree = localState.trees['project/master']; const tree = localState.trees['project/main'];
expect(tree.tree.length).toBe(3); expect(tree.tree.length).toBe(3);
expect(tree.tree[0].name).toBe('tree'); expect(tree.tree[0].name).toBe('tree');
...@@ -52,30 +52,30 @@ describe('Multi-file store tree mutations', () => { ...@@ -52,30 +52,30 @@ describe('Multi-file store tree mutations', () => {
it('keeps loading state', () => { it('keeps loading state', () => {
mutations.CREATE_TREE(localState, { mutations.CREATE_TREE(localState, {
treePath: 'project/master', treePath: 'project/main',
}); });
mutations.SET_DIRECTORY_DATA(localState, { mutations.SET_DIRECTORY_DATA(localState, {
data, data,
treePath: 'project/master', treePath: 'project/main',
}); });
expect(localState.trees['project/master'].loading).toBe(true); expect(localState.trees['project/main'].loading).toBe(true);
}); });
it('does not override tree already in state, but merges the two with correct order', () => { it('does not override tree already in state, but merges the two with correct order', () => {
const openedFile = file('new'); const openedFile = file('new');
localState.trees['project/master'] = { localState.trees['project/main'] = {
loading: true, loading: true,
tree: [openedFile], tree: [openedFile],
}; };
mutations.SET_DIRECTORY_DATA(localState, { mutations.SET_DIRECTORY_DATA(localState, {
data, data,
treePath: 'project/master', treePath: 'project/main',
}); });
const { tree } = localState.trees['project/master']; const { tree } = localState.trees['project/main'];
expect(tree.length).toBe(4); expect(tree.length).toBe(4);
expect(tree[0].name).toBe('blob'); expect(tree[0].name).toBe('blob');
...@@ -86,17 +86,17 @@ describe('Multi-file store tree mutations', () => { ...@@ -86,17 +86,17 @@ describe('Multi-file store tree mutations', () => {
it('returns tree unchanged if the opened file is already in the tree', () => { it('returns tree unchanged if the opened file is already in the tree', () => {
const openedFile = file('foo'); const openedFile = file('foo');
localState.trees['project/master'] = { localState.trees['project/main'] = {
loading: true, loading: true,
tree: [openedFile], tree: [openedFile],
}; };
mutations.SET_DIRECTORY_DATA(localState, { mutations.SET_DIRECTORY_DATA(localState, {
data, data,
treePath: 'project/master', treePath: 'project/main',
}); });
const { tree } = localState.trees['project/master']; const { tree } = localState.trees['project/main'];
expect(tree.length).toBe(3); expect(tree.length).toBe(3);
......
...@@ -98,8 +98,8 @@ describe('Multi-file store mutations', () => { ...@@ -98,8 +98,8 @@ describe('Multi-file store mutations', () => {
describe('CREATE_TMP_ENTRY', () => { describe('CREATE_TMP_ENTRY', () => {
beforeEach(() => { beforeEach(() => {
localState.currentProjectId = 'gitlab-ce'; localState.currentProjectId = 'gitlab-ce';
localState.currentBranchId = 'master'; localState.currentBranchId = 'main';
localState.trees['gitlab-ce/master'] = { localState.trees['gitlab-ce/main'] = {
tree: [], tree: [],
}; };
}); });
...@@ -115,7 +115,7 @@ describe('Multi-file store mutations', () => { ...@@ -115,7 +115,7 @@ describe('Multi-file store mutations', () => {
}, },
}); });
expect(localState.trees['gitlab-ce/master'].tree.length).toEqual(1); expect(localState.trees['gitlab-ce/main'].tree.length).toEqual(1);
expect(localState.entries.test.tempFile).toEqual(true); expect(localState.entries.test.tempFile).toEqual(true);
}); });
}); });
...@@ -163,8 +163,8 @@ describe('Multi-file store mutations', () => { ...@@ -163,8 +163,8 @@ describe('Multi-file store mutations', () => {
describe('DELETE_ENTRY', () => { describe('DELETE_ENTRY', () => {
beforeEach(() => { beforeEach(() => {
localState.currentProjectId = 'gitlab-ce'; localState.currentProjectId = 'gitlab-ce';
localState.currentBranchId = 'master'; localState.currentBranchId = 'main';
localState.trees['gitlab-ce/master'] = { localState.trees['gitlab-ce/main'] = {
tree: [], tree: [],
}; };
}); });
...@@ -184,11 +184,11 @@ describe('Multi-file store mutations', () => { ...@@ -184,11 +184,11 @@ describe('Multi-file store mutations', () => {
path: 'filePath', path: 'filePath',
deleted: false, deleted: false,
}; };
localState.trees['gitlab-ce/master'].tree.push(localState.entries.filePath); localState.trees['gitlab-ce/main'].tree.push(localState.entries.filePath);
mutations.DELETE_ENTRY(localState, 'filePath'); mutations.DELETE_ENTRY(localState, 'filePath');
expect(localState.trees['gitlab-ce/master'].tree).toEqual([]); expect(localState.trees['gitlab-ce/main'].tree).toEqual([]);
}); });
it('removes from parent tree', () => { it('removes from parent tree', () => {
...@@ -279,12 +279,12 @@ describe('Multi-file store mutations', () => { ...@@ -279,12 +279,12 @@ describe('Multi-file store mutations', () => {
describe('RENAME_ENTRY', () => { describe('RENAME_ENTRY', () => {
beforeEach(() => { beforeEach(() => {
localState.trees = { localState.trees = {
'gitlab-ce/master': { 'gitlab-ce/main': {
tree: [], tree: [],
}, },
}; };
localState.currentProjectId = 'gitlab-ce'; localState.currentProjectId = 'gitlab-ce';
localState.currentBranchId = 'master'; localState.currentBranchId = 'main';
localState.entries = { localState.entries = {
oldPath: file('oldPath', 'oldPath', 'blob'), oldPath: file('oldPath', 'oldPath', 'blob'),
}; };
...@@ -462,7 +462,7 @@ describe('Multi-file store mutations', () => { ...@@ -462,7 +462,7 @@ describe('Multi-file store mutations', () => {
gamma, gamma,
}; };
localState.trees['gitlab-ce/master'].tree = [alpha, beta, gamma]; localState.trees['gitlab-ce/main'].tree = [alpha, beta, gamma];
mutations.RENAME_ENTRY(localState, { mutations.RENAME_ENTRY(localState, {
path: 'alpha', path: 'alpha',
...@@ -471,7 +471,7 @@ describe('Multi-file store mutations', () => { ...@@ -471,7 +471,7 @@ describe('Multi-file store mutations', () => {
parentPath: '', parentPath: '',
}); });
expect(localState.trees['gitlab-ce/master'].tree).toEqual([ expect(localState.trees['gitlab-ce/main'].tree).toEqual([
expect.objectContaining({ expect.objectContaining({
name: 'beta', name: 'beta',
}), }),
......
...@@ -18,13 +18,13 @@ describe('Multi-file store utils', () => { ...@@ -18,13 +18,13 @@ describe('Multi-file store utils', () => {
}; };
const state = { const state = {
currentBranchId: 'master', currentBranchId: 'main',
currentProjectId: 'test/test', currentProjectId: 'test/test',
}; };
utils.setPageTitleForFile(state, f); utils.setPageTitleForFile(state, f);
expect(document.title).toBe('README.md · master · test/test · GitLab'); expect(document.title).toBe('README.md · main · test/test · GitLab');
}); });
}); });
...@@ -52,10 +52,10 @@ describe('Multi-file store utils', () => { ...@@ -52,10 +52,10 @@ describe('Multi-file store utils', () => {
{ ...file('deletedFile'), path: 'deletedFile', deleted: true }, { ...file('deletedFile'), path: 'deletedFile', deleted: true },
{ ...file('renamedFile'), path: 'renamedFile', prevPath: 'prevPath' }, { ...file('renamedFile'), path: 'renamedFile', prevPath: 'prevPath' },
], ],
currentBranchId: 'master', currentBranchId: 'main',
}; };
const payload = utils.createCommitPayload({ const payload = utils.createCommitPayload({
branch: 'master', branch: 'main',
newBranch: false, newBranch: false,
state, state,
rootState, rootState,
...@@ -63,7 +63,7 @@ describe('Multi-file store utils', () => { ...@@ -63,7 +63,7 @@ describe('Multi-file store utils', () => {
}); });
expect(payload).toEqual({ expect(payload).toEqual({
branch: 'master', branch: 'main',
commit_message: 'commit message', commit_message: 'commit message',
actions: [ actions: [
{ {
...@@ -122,10 +122,10 @@ describe('Multi-file store utils', () => { ...@@ -122,10 +122,10 @@ describe('Multi-file store utils', () => {
lastCommitSha: '123456789', lastCommitSha: '123456789',
}, },
], ],
currentBranchId: 'master', currentBranchId: 'main',
}; };
const payload = utils.createCommitPayload({ const payload = utils.createCommitPayload({
branch: 'master', branch: 'main',
newBranch: false, newBranch: false,
state: {}, state: {},
rootState, rootState,
...@@ -135,7 +135,7 @@ describe('Multi-file store utils', () => { ...@@ -135,7 +135,7 @@ describe('Multi-file store utils', () => {
}); });
expect(payload).toEqual({ expect(payload).toEqual({
branch: 'master', branch: 'main',
commit_message: 'prebuilt test commit message', commit_message: 'prebuilt test commit message',
actions: [ actions: [
{ {
...@@ -377,7 +377,7 @@ describe('Multi-file store utils', () => { ...@@ -377,7 +377,7 @@ describe('Multi-file store utils', () => {
let localState; let localState;
let branchInfo; let branchInfo;
const currentProjectId = '123-foo'; const currentProjectId = '123-foo';
const currentBranchId = 'master'; const currentBranchId = 'main';
beforeEach(() => { beforeEach(() => {
localState = { localState = {
......
...@@ -274,7 +274,7 @@ describe('WebIDE utils', () => { ...@@ -274,7 +274,7 @@ describe('WebIDE utils', () => {
* hello.md -> hello-1.md * hello.md -> hello-1.md
* hello_2.md -> hello_3.md * hello_2.md -> hello_3.md
* hello_ -> hello_1 * hello_ -> hello_1
* master-patch-22432 -> master-patch-22433 * main-patch-22432 -> main-patch-22433
* patch_332 -> patch_333 * patch_332 -> patch_333
*/ */
...@@ -286,7 +286,7 @@ describe('WebIDE utils', () => { ...@@ -286,7 +286,7 @@ describe('WebIDE utils', () => {
${'hello.md'} | ${'hello-1.md'} ${'hello.md'} | ${'hello-1.md'}
${'hello_2.md'} | ${'hello_3.md'} ${'hello_2.md'} | ${'hello_3.md'}
${'hello_'} | ${'hello_1'} ${'hello_'} | ${'hello_1'}
${'master-patch-22432'} | ${'master-patch-22433'} ${'main-patch-22432'} | ${'main-patch-22433'}
${'patch_332'} | ${'patch_333'} ${'patch_332'} | ${'patch_333'}
`('adds a numeric suffix to a given filename/branch name: $input', ({ input, output }) => { `('adds a numeric suffix to a given filename/branch name: $input', ({ input, output }) => {
expect(addNumericSuffix(input)).toBe(output); expect(addNumericSuffix(input)).toBe(output);
...@@ -299,7 +299,7 @@ describe('WebIDE utils', () => { ...@@ -299,7 +299,7 @@ describe('WebIDE utils', () => {
${'hello.md'} | ${'hello-39135.md'} ${'hello.md'} | ${'hello-39135.md'}
${'hello_2.md'} | ${'hello_39135.md'} ${'hello_2.md'} | ${'hello_39135.md'}
${'hello_'} | ${'hello_39135'} ${'hello_'} | ${'hello_39135'}
${'master-patch-22432'} | ${'master-patch-39135'} ${'main-patch-22432'} | ${'main-patch-39135'}
${'patch_332'} | ${'patch_39135'} ${'patch_332'} | ${'patch_39135'}
`('adds a random suffix if randomize=true is passed for name: $input', ({ input, output }) => { `('adds a random suffix if randomize=true is passed for name: $input', ({ input, output }) => {
jest.spyOn(Math, 'random').mockReturnValue(0.391352525); jest.spyOn(Math, 'random').mockReturnValue(0.391352525);
......
...@@ -3,8 +3,8 @@ import ActionsButton from '~/vue_shared/components/actions_button.vue'; ...@@ -3,8 +3,8 @@ import ActionsButton from '~/vue_shared/components/actions_button.vue';
import LocalStorageSync from '~/vue_shared/components/local_storage_sync.vue'; import LocalStorageSync from '~/vue_shared/components/local_storage_sync.vue';
import WebIdeLink from '~/vue_shared/components/web_ide_link.vue'; import WebIdeLink from '~/vue_shared/components/web_ide_link.vue';
const TEST_EDIT_URL = '/gitlab-test/test/-/edit/master/'; const TEST_EDIT_URL = '/gitlab-test/test/-/edit/main/';
const TEST_WEB_IDE_URL = '/-/ide/project/gitlab-test/test/edit/master/-/'; const TEST_WEB_IDE_URL = '/-/ide/project/gitlab-test/test/edit/main/-/';
const TEST_GITPOD_URL = 'https://gitpod.test/'; const TEST_GITPOD_URL = 'https://gitpod.test/';
const ACTION_EDIT = { const ACTION_EDIT = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment