diff options
Diffstat (limited to 'spec/frontend/ide/stores')
16 files changed, 131 insertions, 121 deletions
diff --git a/spec/frontend/ide/stores/actions/file_spec.js b/spec/frontend/ide/stores/actions/file_spec.js index 6178fb08d8c..6b94d7cf6f1 100644 --- a/spec/frontend/ide/stores/actions/file_spec.js +++ b/spec/frontend/ide/stores/actions/file_spec.js @@ -29,7 +29,7 @@ describe('IDE store file actions', () => { store = createStore(); store.state.currentProjectId = 'test/test'; - store.state.currentBranchId = 'master'; + store.state.currentBranchId = 'main'; router = createRouter(store); @@ -85,7 +85,7 @@ describe('IDE store file actions', () => { .dispatch('closeFile', localFile) .then(Vue.nextTick) .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', () => { store.state.entries[localFile.path] = localFile; store.state.currentProjectId = 'test/test'; - store.state.currentBranchId = 'master'; + store.state.currentBranchId = 'main'; store.state.projects['test/test'] = { branches: { - master: { + main: { commit: { id: '7297abc', }, @@ -260,7 +260,7 @@ describe('IDE store file actions', () => { it('sets document title with the branchId', () => { 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', () => { it('sets document title considering `prevPath` on a file', () => { 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', () => { }); 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', () => { it('pushes router URL when added', () => { 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/'); }); }); }); diff --git a/spec/frontend/ide/stores/actions/merge_request_spec.js b/spec/frontend/ide/stores/actions/merge_request_spec.js index 600bd5fe9e1..e62811a4517 100644 --- a/spec/frontend/ide/stores/actions/merge_request_spec.js +++ b/spec/frontend/ide/stores/actions/merge_request_spec.js @@ -2,7 +2,7 @@ import MockAdapter from 'axios-mock-adapter'; import { range } from 'lodash'; import { TEST_HOST } from 'helpers/test_constants'; import testAction from 'helpers/vuex_action_helper'; -import { deprecatedCreateFlash as createFlash } from '~/flash'; +import createFlash from '~/flash'; import { leftSidebarViews, PERMISSION_READ_MR, MAX_MR_FILES_AUTO_OPEN } from '~/ide/constants'; import service from '~/ide/services'; import { createStore } from '~/ide/stores'; @@ -145,7 +145,9 @@ describe('IDE store merge request actions', () => { .dispatch('getMergeRequestsForBranch', { projectId: TEST_PROJECT, branchId: 'bar' }) .catch(() => { expect(createFlash).toHaveBeenCalled(); - expect(createFlash.mock.calls[0][0]).toBe('Error fetching merge requests for bar'); + expect(createFlash.mock.calls[0][0].message).toBe( + 'Error fetching merge requests for bar', + ); }) .then(done) .catch(done.fail); @@ -461,11 +463,11 @@ describe('IDE store merge request actions', () => { }; store.state.currentProjectId = 'test/test'; - store.state.currentBranchId = 'master'; + store.state.currentBranchId = 'main'; store.state.projects['test/test'] = { branches: { - master: { + main: { commit: { id: '7297abc', }, @@ -562,7 +564,9 @@ describe('IDE store merge request actions', () => { openMergeRequest(store, mr) .catch(() => { - expect(createFlash).toHaveBeenCalledWith(expect.any(String)); + expect(createFlash).toHaveBeenCalledWith({ + message: expect.any(String), + }); }) .then(done) .catch(done.fail); diff --git a/spec/frontend/ide/stores/actions/project_spec.js b/spec/frontend/ide/stores/actions/project_spec.js index 23ffb5ff56b..ca6f7169059 100644 --- a/spec/frontend/ide/stores/actions/project_spec.js +++ b/spec/frontend/ide/stores/actions/project_spec.js @@ -37,11 +37,11 @@ describe('IDE store project actions', () => { describe('refreshLastCommitData', () => { beforeEach(() => { store.state.currentProjectId = 'abc/def'; - store.state.currentBranchId = 'master'; + store.state.currentBranchId = 'main'; store.state.projects['abc/def'] = { id: 4, branches: { - master: { + main: { commit: null, }, }, @@ -60,7 +60,7 @@ describe('IDE store project actions', () => { branchId: store.state.currentBranchId, }) .then(() => { - expect(service.getBranchData).toHaveBeenCalledWith('abc/def', 'master'); + expect(service.getBranchData).toHaveBeenCalledWith('abc/def', 'main'); done(); }) @@ -81,7 +81,7 @@ describe('IDE store project actions', () => { type: 'SET_BRANCH_COMMIT', payload: { projectId: TEST_PROJECT_ID, - branchId: 'master', + branchId: 'main', commit: { id: '123' }, }, }, @@ -97,17 +97,17 @@ describe('IDE store project actions', () => { it('dispatches setErrorMessage', (done) => { testAction( showBranchNotFoundError, - 'master', + 'main', null, [], [ { type: 'setErrorMessage', 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), actionText: 'Create branch', - actionPayload: 'master', + actionPayload: 'main', }, }, ], @@ -131,7 +131,7 @@ describe('IDE store project actions', () => { }, getters: { currentProject: { - default_branch: 'master', + default_branch: 'main', }, }, dispatch() {}, @@ -140,7 +140,7 @@ describe('IDE store project actions', () => { ) .then(() => { expect(api.createBranch).toHaveBeenCalledWith('project-path', { - ref: 'master', + ref: 'main', branch: 'new-branch-name', }); }) @@ -158,7 +158,7 @@ describe('IDE store project actions', () => { }, getters: { currentProject: { - default_branch: 'master', + default_branch: 'main', }, }, dispatch: dispatchSpy, @@ -180,7 +180,7 @@ describe('IDE store project actions', () => { }, getters: { currentProject: { - default_branch: 'master', + default_branch: 'main', }, }, dispatch() {}, @@ -199,13 +199,13 @@ describe('IDE store project actions', () => { it('creates a blank tree and sets loading state to false', (done) => { testAction( loadEmptyBranch, - { projectId: TEST_PROJECT_ID, branchId: 'master' }, + { projectId: TEST_PROJECT_ID, branchId: 'main' }, store.state, [ - { type: 'CREATE_TREE', payload: { treePath: `${TEST_PROJECT_ID}/master` } }, + { type: 'CREATE_TREE', payload: { treePath: `${TEST_PROJECT_ID}/main` } }, { type: 'TOGGLE_LOADING', - payload: { entry: store.state.trees[`${TEST_PROJECT_ID}/master`], forceValue: false }, + payload: { entry: store.state.trees[`${TEST_PROJECT_ID}/main`], forceValue: false }, }, ], expect.any(Object), @@ -214,11 +214,11 @@ describe('IDE store project actions', () => { }); it('does nothing, if tree already exists', (done) => { - const trees = { [`${TEST_PROJECT_ID}/master`]: [] }; + const trees = { [`${TEST_PROJECT_ID}/main`]: [] }; testAction( loadEmptyBranch, - { projectId: TEST_PROJECT_ID, branchId: 'master' }, + { projectId: TEST_PROJECT_ID, branchId: 'main' }, { trees }, [], [], diff --git a/spec/frontend/ide/stores/actions/tree_spec.js b/spec/frontend/ide/stores/actions/tree_spec.js index 8de2188a5f4..8d7328725e9 100644 --- a/spec/frontend/ide/stores/actions/tree_spec.js +++ b/spec/frontend/ide/stores/actions/tree_spec.js @@ -18,8 +18,8 @@ describe('Multi-file store tree actions', () => { const basicCallParameters = { endpoint: 'rootEndpoint', projectId: 'abcproject', - branch: 'master', - branchId: 'master', + branch: 'main', + branchId: 'main', ref: '12345678', }; @@ -31,7 +31,7 @@ describe('Multi-file store tree actions', () => { mock = new MockAdapter(axios); store.state.currentProjectId = 'abcproject'; - store.state.currentBranchId = 'master'; + store.state.currentBranchId = 'main'; store.state.projects.abcproject = { web_url: '', path_with_namespace: 'foo/abcproject', @@ -66,7 +66,7 @@ describe('Multi-file store tree actions', () => { store .dispatch('getFiles', basicCallParameters) .then(() => { - projectTree = store.state.trees['abcproject/master']; + projectTree = store.state.trees['abcproject/main']; expect(projectTree.tree.length).toBe(2); expect(projectTree.tree[0].type).toBe('tree'); @@ -89,7 +89,7 @@ describe('Multi-file store tree actions', () => { 'abc/def': { web_url: `${TEST_HOST}/files`, branches: { - 'master-testing': { + 'main-testing': { commit: { id: '12345', }, @@ -98,7 +98,7 @@ describe('Multi-file store tree actions', () => { }, }; const getters = { - findBranch: () => store.state.projects['abc/def'].branches['master-testing'], + findBranch: () => store.state.projects['abc/def'].branches['main-testing'], }; mock.onGet(/(.*)/).replyOnce(500); @@ -112,7 +112,7 @@ describe('Multi-file store tree actions', () => { }, { projectId: 'abc/def', - branchId: 'master-testing', + branchId: 'main-testing', }, ) .then(done.fail) @@ -121,7 +121,7 @@ describe('Multi-file store tree actions', () => { text: 'An error occurred while loading all the files.', action: expect.any(Function), actionText: 'Please try again', - actionPayload: { projectId: 'abc/def', branchId: 'master-testing' }, + actionPayload: { projectId: 'abc/def', branchId: 'main-testing' }, }); done(); }); @@ -178,17 +178,17 @@ describe('Multi-file store tree actions', () => { describe('setDirectoryData', () => { it('sets tree correctly if there are no opened files yet', (done) => { const treeFile = file({ name: 'README.md' }); - store.state.trees['abcproject/master'] = {}; + store.state.trees['abcproject/main'] = {}; testAction( setDirectoryData, - { projectId: 'abcproject', branchId: 'master', treeList: [treeFile] }, + { projectId: 'abcproject', branchId: 'main', treeList: [treeFile] }, store.state, [ { type: types.SET_DIRECTORY_DATA, payload: { - treePath: 'abcproject/master', + treePath: 'abcproject/main', data: [treeFile], }, }, diff --git a/spec/frontend/ide/stores/actions_spec.js b/spec/frontend/ide/stores/actions_spec.js index ad55313da93..e575667b8c6 100644 --- a/spec/frontend/ide/stores/actions_spec.js +++ b/spec/frontend/ide/stores/actions_spec.js @@ -777,7 +777,7 @@ describe('Multi-file store actions', () => { it('routes to the renamed file if the original file has been opened', (done) => { store.state.currentProjectId = 'test/test'; - store.state.currentBranchId = 'master'; + store.state.currentBranchId = 'main'; Object.assign(store.state.entries.orig, { opened: true, @@ -790,7 +790,7 @@ describe('Multi-file store actions', () => { }) .then(() => { 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) .catch(done.fail); @@ -1019,7 +1019,7 @@ describe('Multi-file store actions', () => { }, { projectId: 'abc/def', - branchId: 'master-testing', + branchId: 'main-testing', }, ]; dispatch = jest.fn(); diff --git a/spec/frontend/ide/stores/getters_spec.js b/spec/frontend/ide/stores/getters_spec.js index 06456cdb12a..53d161ae5c9 100644 --- a/spec/frontend/ide/stores/getters_spec.js +++ b/spec/frontend/ide/stores/getters_spec.js @@ -209,12 +209,12 @@ describe('IDE store getters', () => { describe('currentBranch', () => { it('returns current projects branch', () => { localState.currentProjectId = 'abcproject'; - localState.currentBranchId = 'master'; + localState.currentBranchId = 'main'; localState.projects.abcproject = { name: 'abcproject', branches: { - master: { - name: 'master', + main: { + name: 'main', }, }, }; @@ -223,7 +223,7 @@ describe('IDE store getters', () => { }; getters.currentBranch(localState, localGetters); - expect(localGetters.findBranch).toHaveBeenCalledWith('abcproject', 'master'); + expect(localGetters.findBranch).toHaveBeenCalledWith('abcproject', 'main'); }); }); @@ -243,12 +243,12 @@ describe('IDE store getters', () => { it('returns the selected branch from a project', () => { localState.currentProjectId = 'abcproject'; - localState.currentBranchId = 'master'; + localState.currentBranchId = 'main'; localState.projects.abcproject = { name: 'abcproject', branches: { - master: { - name: 'master', + main: { + name: 'main', }, }, }; @@ -256,9 +256,9 @@ describe('IDE store getters', () => { 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', () => { it("returns true when project's default branch matches current branch", () => { const localGetters = { currentProject: { - default_branch: 'master', + default_branch: 'main', }, - branchName: 'master', + branchName: 'main', }; expect(getters.isOnDefaultBranch({}, localGetters)).toBeTruthy(); @@ -285,7 +285,7 @@ describe('IDE store getters', () => { it("returns false when project's default branch doesn't match current branch", () => { const localGetters = { currentProject: { - default_branch: 'master', + default_branch: 'main', }, branchName: 'feature', }; @@ -620,10 +620,10 @@ describe('IDE store getters', () => { describe('getUrlForPath', () => { it('returns a route url for the given path', () => { localState.currentProjectId = 'test/test'; - localState.currentBranchId = 'master'; + localState.currentBranchId = 'main'; 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', () => { describe('getJsonSchemaForPath', () => { beforeEach(() => { 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', () => { expect(localStore.getters.getJsonSchemaForPath('.gitlab-ci.yml')).toEqual({ 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', () => { localState.projects['path/to/some/project'] = { name: 'project', branches: { - master: { - name: 'master', + main: { + name: 'main', commit: { id: 'abcdef123456', }, diff --git a/spec/frontend/ide/stores/modules/commit/actions_spec.js b/spec/frontend/ide/stores/modules/commit/actions_spec.js index b124eb391f3..cb6bb7c1202 100644 --- a/spec/frontend/ide/stores/modules/commit/actions_spec.js +++ b/spec/frontend/ide/stores/modules/commit/actions_spec.js @@ -47,7 +47,7 @@ describe('IDE commit module actions', () => { jest.spyOn(router, 'push').mockImplementation(); mock - .onGet('/api/v1/projects/abcproject/repository/branches/master') + .onGet('/api/v1/projects/abcproject/repository/branches/main') .reply(200, { commit: COMMIT_RESPONSE }); }); @@ -101,7 +101,7 @@ describe('IDE commit module actions', () => { originalGon = window.gon; window.gon = { current_username: 'johndoe' }; - store.state.currentBranchId = 'master'; + store.state.currentBranchId = 'main'; }); afterEach(() => { @@ -177,7 +177,7 @@ describe('IDE commit module actions', () => { committed_date: '123', committer_name: 'root', }; - const branch = 'master'; + const branch = 'main'; let f; beforeEach(() => { @@ -192,12 +192,12 @@ describe('IDE commit module actions', () => { Object.assign(store.state, { currentProjectId: 'abcproject', - currentBranchId: 'master', + currentBranchId: 'main', projects: { abcproject: { web_url: 'web_url', branches: { - master: { + main: { workingReference: '', commit: { short_id: TEST_COMMIT_SHA, @@ -228,7 +228,7 @@ describe('IDE commit module actions', () => { branch, }) .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) .catch(done.fail); @@ -310,14 +310,14 @@ describe('IDE commit module actions', () => { changedFiles: [f], openFiles: [f], currentProjectId: 'abcproject', - currentBranchId: 'master', + currentBranchId: 'main', projects: { abcproject: { - default_branch: 'master', + default_branch: 'main', web_url: 'webUrl', branches: { - master: { - name: 'master', + main: { + name: 'main', workingReference: '1', commit: { id: TEST_COMMIT_SHA, @@ -460,7 +460,7 @@ describe('IDE commit module actions', () => { .dispatch('commit/commitChanges') .then(() => { 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(); diff --git a/spec/frontend/ide/stores/modules/commit/getters_spec.js b/spec/frontend/ide/stores/modules/commit/getters_spec.js index 0dc938bb637..7a07ed05201 100644 --- a/spec/frontend/ide/stores/modules/commit/getters_spec.js +++ b/spec/frontend/ide/stores/modules/commit/getters_spec.js @@ -46,7 +46,7 @@ describe('IDE commit module getters', () => { describe('branchName', () => { const rootState = { - currentBranchId: 'master', + currentBranchId: 'main', }; const localGetters = { placeholderBranchName: 'placeholder-branch-name', @@ -61,7 +61,7 @@ describe('IDE commit module getters', () => { it('defaults to currentBranchId when not committing to a new branch', () => { 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', () => { diff --git a/spec/frontend/ide/stores/modules/terminal/actions/checks_spec.js b/spec/frontend/ide/stores/modules/terminal/actions/checks_spec.js index e5887ca0a33..fc00bd075e7 100644 --- a/spec/frontend/ide/stores/modules/terminal/actions/checks_spec.js +++ b/spec/frontend/ide/stores/modules/terminal/actions/checks_spec.js @@ -13,7 +13,7 @@ import axios from '~/lib/utils/axios_utils'; import httpStatus from '~/lib/utils/http_status'; 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_RUNNERS_HELP_PATH = `${TEST_HOST}/test/runners/help`; diff --git a/spec/frontend/ide/stores/modules/terminal/actions/session_controls_spec.js b/spec/frontend/ide/stores/modules/terminal/actions/session_controls_spec.js index e42e760b841..ecda7f304ba 100644 --- a/spec/frontend/ide/stores/modules/terminal/actions/session_controls_spec.js +++ b/spec/frontend/ide/stores/modules/terminal/actions/session_controls_spec.js @@ -1,6 +1,6 @@ import MockAdapter from 'axios-mock-adapter'; import testAction from 'helpers/vuex_action_helper'; -import { deprecatedCreateFlash as createFlash } from '~/flash'; +import createFlash from '~/flash'; import * as actions from '~/ide/stores/modules/terminal/actions/session_controls'; import { STARTING, PENDING, STOPPING, STOPPED } from '~/ide/stores/modules/terminal/constants'; import * as messages from '~/ide/stores/modules/terminal/messages'; @@ -11,7 +11,7 @@ import httpStatus from '~/lib/utils/http_status'; jest.mock('~/flash'); const TEST_PROJECT_PATH = 'lorem/root'; -const TEST_BRANCH_ID = 'master'; +const TEST_BRANCH_ID = 'main'; const TEST_SESSION = { id: 7, status: PENDING, @@ -89,7 +89,9 @@ describe('IDE store terminal session controls actions', () => { it('flashes message', () => { actions.receiveStartSessionError({ dispatch }); - expect(createFlash).toHaveBeenCalledWith(messages.UNEXPECTED_ERROR_STARTING); + expect(createFlash).toHaveBeenCalledWith({ + message: messages.UNEXPECTED_ERROR_STARTING, + }); }); it('sets session status', () => { @@ -161,7 +163,9 @@ describe('IDE store terminal session controls actions', () => { it('flashes message', () => { actions.receiveStopSessionError({ dispatch }); - expect(createFlash).toHaveBeenCalledWith(messages.UNEXPECTED_ERROR_STOPPING); + expect(createFlash).toHaveBeenCalledWith({ + message: messages.UNEXPECTED_ERROR_STOPPING, + }); }); it('kills the session', () => { diff --git a/spec/frontend/ide/stores/modules/terminal/actions/session_status_spec.js b/spec/frontend/ide/stores/modules/terminal/actions/session_status_spec.js index 0227955754c..eabc69b23aa 100644 --- a/spec/frontend/ide/stores/modules/terminal/actions/session_status_spec.js +++ b/spec/frontend/ide/stores/modules/terminal/actions/session_status_spec.js @@ -1,6 +1,6 @@ import MockAdapter from 'axios-mock-adapter'; import testAction from 'helpers/vuex_action_helper'; -import { deprecatedCreateFlash as createFlash } from '~/flash'; +import createFlash from '~/flash'; import * as actions from '~/ide/stores/modules/terminal/actions/session_status'; import { PENDING, RUNNING, STOPPING, STOPPED } from '~/ide/stores/modules/terminal/constants'; import * as messages from '~/ide/stores/modules/terminal/messages'; @@ -115,7 +115,9 @@ describe('IDE store terminal session controls actions', () => { it('flashes message', () => { actions.receiveSessionStatusError({ dispatch }); - expect(createFlash).toHaveBeenCalledWith(messages.UNEXPECTED_ERROR_STATUS); + expect(createFlash).toHaveBeenCalledWith({ + message: messages.UNEXPECTED_ERROR_STATUS, + }); }); it('kills the session', () => { diff --git a/spec/frontend/ide/stores/mutations/branch_spec.js b/spec/frontend/ide/stores/mutations/branch_spec.js index 0900b25d5d3..30a688d2bb0 100644 --- a/spec/frontend/ide/stores/mutations/branch_spec.js +++ b/spec/frontend/ide/stores/mutations/branch_spec.js @@ -10,9 +10,9 @@ describe('Multi-file store branch mutations', () => { describe('SET_CURRENT_BRANCH', () => { 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', () => { localState.projects = { Example: { branches: { - master: {}, + main: {}, }, }, }; mutations.SET_BRANCH_COMMIT(localState, { projectId: 'Example', - branchId: 'master', + branchId: 'main', 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'); }); }); diff --git a/spec/frontend/ide/stores/mutations/file_spec.js b/spec/frontend/ide/stores/mutations/file_spec.js index 825d2a546cd..1453f26c1d9 100644 --- a/spec/frontend/ide/stores/mutations/file_spec.js +++ b/spec/frontend/ide/stores/mutations/file_spec.js @@ -319,8 +319,8 @@ describe('IDE store file mutations', () => { localFile.content = 'test'; localFile.changed = true; localState.currentProjectId = 'gitlab-ce'; - localState.currentBranchId = 'master'; - localState.trees['gitlab-ce/master'] = { + localState.currentBranchId = 'main'; + localState.trees['gitlab-ce/main'] = { tree: [], }; }); @@ -337,7 +337,7 @@ describe('IDE store file mutations', () => { 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', () => { diff --git a/spec/frontend/ide/stores/mutations/tree_spec.js b/spec/frontend/ide/stores/mutations/tree_spec.js index a4b98aa9d5a..6935e57578f 100644 --- a/spec/frontend/ide/stores/mutations/tree_spec.js +++ b/spec/frontend/ide/stores/mutations/tree_spec.js @@ -33,16 +33,16 @@ describe('Multi-file store tree mutations', () => { }); it('adds directory data', () => { - localState.trees['project/master'] = { + localState.trees['project/main'] = { tree: [], }; mutations.SET_DIRECTORY_DATA(localState, { 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[0].name).toBe('tree'); @@ -52,30 +52,30 @@ describe('Multi-file store tree mutations', () => { it('keeps loading state', () => { mutations.CREATE_TREE(localState, { - treePath: 'project/master', + treePath: 'project/main', }); mutations.SET_DIRECTORY_DATA(localState, { 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', () => { const openedFile = file('new'); - localState.trees['project/master'] = { + localState.trees['project/main'] = { loading: true, tree: [openedFile], }; mutations.SET_DIRECTORY_DATA(localState, { 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[0].name).toBe('blob'); @@ -86,17 +86,17 @@ describe('Multi-file store tree mutations', () => { it('returns tree unchanged if the opened file is already in the tree', () => { const openedFile = file('foo'); - localState.trees['project/master'] = { + localState.trees['project/main'] = { loading: true, tree: [openedFile], }; mutations.SET_DIRECTORY_DATA(localState, { data, - treePath: 'project/master', + treePath: 'project/main', }); - const { tree } = localState.trees['project/master']; + const { tree } = localState.trees['project/main']; expect(tree.length).toBe(3); diff --git a/spec/frontend/ide/stores/mutations_spec.js b/spec/frontend/ide/stores/mutations_spec.js index 09e9481e5d4..23fe23bdef9 100644 --- a/spec/frontend/ide/stores/mutations_spec.js +++ b/spec/frontend/ide/stores/mutations_spec.js @@ -98,8 +98,8 @@ describe('Multi-file store mutations', () => { describe('CREATE_TMP_ENTRY', () => { beforeEach(() => { localState.currentProjectId = 'gitlab-ce'; - localState.currentBranchId = 'master'; - localState.trees['gitlab-ce/master'] = { + localState.currentBranchId = 'main'; + localState.trees['gitlab-ce/main'] = { tree: [], }; }); @@ -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); }); }); @@ -163,8 +163,8 @@ describe('Multi-file store mutations', () => { describe('DELETE_ENTRY', () => { beforeEach(() => { localState.currentProjectId = 'gitlab-ce'; - localState.currentBranchId = 'master'; - localState.trees['gitlab-ce/master'] = { + localState.currentBranchId = 'main'; + localState.trees['gitlab-ce/main'] = { tree: [], }; }); @@ -184,11 +184,11 @@ describe('Multi-file store mutations', () => { path: 'filePath', 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'); - expect(localState.trees['gitlab-ce/master'].tree).toEqual([]); + expect(localState.trees['gitlab-ce/main'].tree).toEqual([]); }); it('removes from parent tree', () => { @@ -279,12 +279,12 @@ describe('Multi-file store mutations', () => { describe('RENAME_ENTRY', () => { beforeEach(() => { localState.trees = { - 'gitlab-ce/master': { + 'gitlab-ce/main': { tree: [], }, }; localState.currentProjectId = 'gitlab-ce'; - localState.currentBranchId = 'master'; + localState.currentBranchId = 'main'; localState.entries = { oldPath: file('oldPath', 'oldPath', 'blob'), }; @@ -462,7 +462,7 @@ describe('Multi-file store mutations', () => { gamma, }; - localState.trees['gitlab-ce/master'].tree = [alpha, beta, gamma]; + localState.trees['gitlab-ce/main'].tree = [alpha, beta, gamma]; mutations.RENAME_ENTRY(localState, { path: 'alpha', @@ -471,7 +471,7 @@ describe('Multi-file store mutations', () => { parentPath: '', }); - expect(localState.trees['gitlab-ce/master'].tree).toEqual([ + expect(localState.trees['gitlab-ce/main'].tree).toEqual([ expect.objectContaining({ name: 'beta', }), diff --git a/spec/frontend/ide/stores/utils_spec.js b/spec/frontend/ide/stores/utils_spec.js index 46a0794b2e6..8f7b8c5e311 100644 --- a/spec/frontend/ide/stores/utils_spec.js +++ b/spec/frontend/ide/stores/utils_spec.js @@ -18,13 +18,13 @@ describe('Multi-file store utils', () => { }; const state = { - currentBranchId: 'master', + currentBranchId: 'main', currentProjectId: 'test/test', }; 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', () => { { ...file('deletedFile'), path: 'deletedFile', deleted: true }, { ...file('renamedFile'), path: 'renamedFile', prevPath: 'prevPath' }, ], - currentBranchId: 'master', + currentBranchId: 'main', }; const payload = utils.createCommitPayload({ - branch: 'master', + branch: 'main', newBranch: false, state, rootState, @@ -63,7 +63,7 @@ describe('Multi-file store utils', () => { }); expect(payload).toEqual({ - branch: 'master', + branch: 'main', commit_message: 'commit message', actions: [ { @@ -122,10 +122,10 @@ describe('Multi-file store utils', () => { lastCommitSha: '123456789', }, ], - currentBranchId: 'master', + currentBranchId: 'main', }; const payload = utils.createCommitPayload({ - branch: 'master', + branch: 'main', newBranch: false, state: {}, rootState, @@ -135,7 +135,7 @@ describe('Multi-file store utils', () => { }); expect(payload).toEqual({ - branch: 'master', + branch: 'main', commit_message: 'prebuilt test commit message', actions: [ { @@ -377,7 +377,7 @@ describe('Multi-file store utils', () => { let localState; let branchInfo; const currentProjectId = '123-foo'; - const currentBranchId = 'master'; + const currentBranchId = 'main'; beforeEach(() => { localState = { |