summaryrefslogtreecommitdiff
path: root/spec/javascripts/ide
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-01-16 12:08:32 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-01-16 12:08:32 +0000
commitc158fa8d69c704663d289341a014c44c062cda88 (patch)
treed0cac82a9ac9e9ad28bb0030266eb8d5dc91fbbc /spec/javascripts/ide
parentb806264d29b8d52ccb78a41dcc3d67f2b040700c (diff)
downloadgitlab-ce-c158fa8d69c704663d289341a014c44c062cda88.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/javascripts/ide')
-rw-r--r--spec/javascripts/ide/components/commit_sidebar/form_spec.js19
-rw-r--r--spec/javascripts/ide/components/repo_tab_spec.js4
-rw-r--r--spec/javascripts/ide/stores/actions_spec.js100
3 files changed, 90 insertions, 33 deletions
diff --git a/spec/javascripts/ide/components/commit_sidebar/form_spec.js b/spec/javascripts/ide/components/commit_sidebar/form_spec.js
index fdbabf84e25..2ee0b94582c 100644
--- a/spec/javascripts/ide/components/commit_sidebar/form_spec.js
+++ b/spec/javascripts/ide/components/commit_sidebar/form_spec.js
@@ -33,6 +33,12 @@ describe('IDE commit form', () => {
});
describe('compact', () => {
+ beforeEach(done => {
+ vm.isCompact = true;
+
+ vm.$nextTick(done);
+ });
+
it('renders commit button in compact mode', () => {
expect(vm.$el.querySelector('.btn-primary')).not.toBeNull();
expect(vm.$el.querySelector('.btn-primary').textContent).toContain('Commit');
@@ -61,7 +67,7 @@ describe('IDE commit form', () => {
});
});
- it('toggles activity bar vie when clicking commit button', done => {
+ it('toggles activity bar view when clicking commit button', done => {
vm.$el.querySelector('.btn-primary').click();
vm.$nextTick(() => {
@@ -104,6 +110,17 @@ describe('IDE commit form', () => {
});
});
+ it('always opens itself in full view current activity view is not commit view when clicking commit button', done => {
+ vm.$el.querySelector('.btn-primary').click();
+
+ vm.$nextTick(() => {
+ expect(store.state.currentActivityView).toBe(activityBarViews.commit);
+ expect(vm.isCompact).toBe(false);
+
+ done();
+ });
+ });
+
describe('discard draft button', () => {
it('hidden when commitMessage is empty', () => {
expect(vm.$el.querySelector('.btn-default').textContent).toContain('Collapse');
diff --git a/spec/javascripts/ide/components/repo_tab_spec.js b/spec/javascripts/ide/components/repo_tab_spec.js
index 3b52f279bf2..7466ed5468b 100644
--- a/spec/javascripts/ide/components/repo_tab_spec.js
+++ b/spec/javascripts/ide/components/repo_tab_spec.js
@@ -93,13 +93,13 @@ describe('RepoTab', () => {
Vue.nextTick()
.then(() => {
- expect(vm.$el.querySelector('.file-modified')).toBeNull();
+ expect(vm.$el.querySelector('.file-modified-solid')).toBeNull();
vm.$el.dispatchEvent(new Event('mouseout'));
})
.then(Vue.nextTick)
.then(() => {
- expect(vm.$el.querySelector('.file-modified')).not.toBeNull();
+ expect(vm.$el.querySelector('.file-modified-solid')).not.toBeNull();
done();
})
diff --git a/spec/javascripts/ide/stores/actions_spec.js b/spec/javascripts/ide/stores/actions_spec.js
index 9c24f20ca9c..d582462d542 100644
--- a/spec/javascripts/ide/stores/actions_spec.js
+++ b/spec/javascripts/ide/stores/actions_spec.js
@@ -225,6 +225,35 @@ describe('Multi-file store actions', () => {
.catch(done.fail);
});
+ describe('when `gon.feature.stageAllByDefault` is true', () => {
+ const originalGonFeatures = Object.assign({}, gon.features);
+
+ beforeAll(() => {
+ gon.features = { stageAllByDefault: true };
+ });
+
+ afterAll(() => {
+ gon.features = originalGonFeatures;
+ });
+
+ it('adds tmp file to staged files', done => {
+ const name = 'test';
+
+ store
+ .dispatch('createTempEntry', {
+ name,
+ branchId: 'mybranch',
+ type: 'blob',
+ })
+ .then(() => {
+ expect(store.state.stagedFiles).toEqual([jasmine.objectContaining({ name })]);
+
+ done();
+ })
+ .catch(done.fail);
+ });
+ });
+
it('adds tmp file to open files', done => {
const name = 'test';
@@ -255,41 +284,25 @@ describe('Multi-file store actions', () => {
type: 'blob',
})
.then(() => {
- const f = store.state.entries[name];
-
- expect(store.state.changedFiles.length).toBe(1);
- expect(store.state.changedFiles[0].name).toBe(f.name);
+ expect(store.state.changedFiles).toEqual([
+ jasmine.objectContaining({ name, tempFile: true }),
+ ]);
done();
})
.catch(done.fail);
});
- it('sets tmp file as active', done => {
- testAction(
- createTempEntry,
- {
- name: 'test',
- branchId: 'mybranch',
- type: 'blob',
- },
- store.state,
- [
- { type: types.CREATE_TMP_ENTRY, payload: jasmine.any(Object) },
- { type: types.TOGGLE_FILE_OPEN, payload: 'test' },
- { type: types.ADD_FILE_TO_CHANGED, payload: 'test' },
- ],
- jasmine.arrayContaining([
- {
- type: 'setFileActive',
- payload: 'test',
- },
- {
- type: 'triggerFilesChange',
- },
- ]),
- done,
+ it('sets tmp file as active', () => {
+ const dispatch = jasmine.createSpy();
+ const commit = jasmine.createSpy();
+
+ createTempEntry(
+ { state: store.state, getters: store.getters, dispatch, commit },
+ { name: 'test', branchId: 'mybranch', type: 'blob' },
);
+
+ expect(dispatch).toHaveBeenCalledWith('setFileActive', 'test');
});
it('creates flash message if file already exists', done => {
@@ -800,6 +813,33 @@ describe('Multi-file store actions', () => {
});
});
+ describe('when `gon.feature.stageAllByDefault` is true', () => {
+ const originalGonFeatures = Object.assign({}, gon.features);
+
+ beforeAll(() => {
+ gon.features = { stageAllByDefault: true };
+ });
+
+ afterAll(() => {
+ gon.features = originalGonFeatures;
+ });
+
+ it('by default renames an entry and stages it', () => {
+ const dispatch = jasmine.createSpy();
+ const commit = jasmine.createSpy();
+
+ renameEntry(
+ { dispatch, commit, state: store.state, getters: store.getters },
+ { path: 'orig', name: 'renamed' },
+ );
+
+ expect(commit.calls.allArgs()).toEqual([
+ [types.RENAME_ENTRY, { path: 'orig', name: 'renamed', parentPath: undefined }],
+ [types.STAGE_CHANGE, jasmine.objectContaining({ path: 'renamed' })],
+ ]);
+ });
+ });
+
it('by default renames an entry and adds to changed', done => {
testAction(
renameEntry,
@@ -819,12 +859,12 @@ describe('Multi-file store actions', () => {
payload: 'renamed',
},
],
- [{ type: 'burstUnusedSeal' }, { type: 'triggerFilesChange' }],
+ jasmine.any(Object),
done,
);
});
- it('if not changed, completely unstages entry if renamed to original', done => {
+ it('if not changed, completely unstages and discards entry if renamed to original', done => {
testAction(
renameEntry,
{ path: 'renamed', name: 'orig' },