summaryrefslogtreecommitdiff
path: root/spec/javascripts
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-13 12:09:22 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-13 12:09:22 +0000
commit286fe61013674fe2d245ffc8d2233baf09923e70 (patch)
tree2037291f5863105e54e75be056b49f7d62007cae /spec/javascripts
parent4cb5e5011abfe8d50ac3a7ebd0018c563c6d7af4 (diff)
downloadgitlab-ce-286fe61013674fe2d245ffc8d2233baf09923e70.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/javascripts')
-rw-r--r--spec/javascripts/ide/components/commit_sidebar/form_spec.js2
-rw-r--r--spec/javascripts/ide/components/file_row_extra_spec.js30
-rw-r--r--spec/javascripts/ide/components/repo_commit_section_spec.js14
-rw-r--r--spec/javascripts/releases/components/app_index_spec.js123
4 files changed, 110 insertions, 59 deletions
diff --git a/spec/javascripts/ide/components/commit_sidebar/form_spec.js b/spec/javascripts/ide/components/commit_sidebar/form_spec.js
index 5cb804938ed..f5d1a9de59c 100644
--- a/spec/javascripts/ide/components/commit_sidebar/form_spec.js
+++ b/spec/javascripts/ide/components/commit_sidebar/form_spec.js
@@ -52,7 +52,7 @@ describe('IDE commit form', () => {
vm.$store.state.stagedFiles.push('test');
vm.$nextTick(() => {
- expect(vm.$el.querySelector('p').textContent).toContain('1 staged and 1 unstaged changes');
+ expect(vm.$el.querySelector('p').textContent).toContain('1 changed file');
done();
});
});
diff --git a/spec/javascripts/ide/components/file_row_extra_spec.js b/spec/javascripts/ide/components/file_row_extra_spec.js
index f498d8251c8..9fd014b50ef 100644
--- a/spec/javascripts/ide/components/file_row_extra_spec.js
+++ b/spec/javascripts/ide/components/file_row_extra_spec.js
@@ -41,30 +41,20 @@ describe('IDE extra file row component', () => {
describe('folderChangesTooltip', () => {
it('returns undefined when changes count is 0', () => {
- expect(vm.folderChangesTooltip).toBe(undefined);
- });
-
- it('returns unstaged changes text', () => {
- changesCount = 1;
- unstagedFilesCount = 1;
-
- expect(vm.folderChangesTooltip).toBe('1 unstaged change');
- });
+ changesCount = 0;
- it('returns staged changes text', () => {
- changesCount = 1;
- stagedFilesCount = 1;
-
- expect(vm.folderChangesTooltip).toBe('1 staged change');
+ expect(vm.folderChangesTooltip).toBe(undefined);
});
- it('returns staged and unstaged changes text', () => {
- changesCount = 1;
- stagedFilesCount = 1;
- unstagedFilesCount = 1;
+ [{ input: 1, output: '1 changed file' }, { input: 2, output: '2 changed files' }].forEach(
+ ({ input, output }) => {
+ it('returns changed files count if changes count is not 0', () => {
+ changesCount = input;
- expect(vm.folderChangesTooltip).toBe('1 staged and 1 unstaged changes');
- });
+ expect(vm.folderChangesTooltip).toBe(output);
+ });
+ },
+ );
});
describe('show tree changes count', () => {
diff --git a/spec/javascripts/ide/components/repo_commit_section_spec.js b/spec/javascripts/ide/components/repo_commit_section_spec.js
index 917eb1438bd..0ba8c86a036 100644
--- a/spec/javascripts/ide/components/repo_commit_section_spec.js
+++ b/spec/javascripts/ide/components/repo_commit_section_spec.js
@@ -30,19 +30,13 @@ describe('RepoCommitSection', () => {
const files = [file('file1'), file('file2')].map(f =>
Object.assign(f, {
type: 'blob',
+ content: 'orginal content',
}),
);
vm.$store.state.rightPanelCollapsed = false;
vm.$store.state.currentBranch = 'master';
- vm.$store.state.changedFiles = [...files];
- vm.$store.state.changedFiles.forEach(f =>
- Object.assign(f, {
- changed: true,
- content: 'changedFile testing',
- }),
- );
-
+ vm.$store.state.changedFiles = [];
vm.$store.state.stagedFiles = [{ ...files[0] }, { ...files[1] }];
vm.$store.state.stagedFiles.forEach(f =>
Object.assign(f, {
@@ -51,7 +45,7 @@ describe('RepoCommitSection', () => {
}),
);
- vm.$store.state.changedFiles.forEach(f => {
+ files.forEach(f => {
vm.$store.state.entries[f.path] = f;
});
@@ -96,7 +90,7 @@ describe('RepoCommitSection', () => {
const changedFileElements = [...vm.$el.querySelectorAll('.multi-file-commit-list > li')];
const allFiles = vm.$store.state.changedFiles.concat(vm.$store.state.stagedFiles);
- expect(changedFileElements.length).toEqual(4);
+ expect(changedFileElements).toHaveLength(2);
changedFileElements.forEach((changedFile, i) => {
expect(changedFile.textContent.trim()).toContain(allFiles[i].path);
diff --git a/spec/javascripts/releases/components/app_index_spec.js b/spec/javascripts/releases/components/app_index_spec.js
index 83b0652d59b..020937d07e5 100644
--- a/spec/javascripts/releases/components/app_index_spec.js
+++ b/spec/javascripts/releases/components/app_index_spec.js
@@ -13,6 +13,7 @@ import {
releases,
} from '../mock_data';
import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils';
+import waitForPromises from 'spec/helpers/wait_for_promises';
describe('Releases App ', () => {
const Component = Vue.extend(app);
@@ -22,7 +23,7 @@ describe('Releases App ', () => {
const props = {
projectId: 'gitlab-ce',
- documentationLink: 'help/releases',
+ documentationPath: 'help/releases',
illustrationPath: 'illustration/path',
};
@@ -51,9 +52,9 @@ describe('Releases App ', () => {
expect(vm.$el.querySelector('.js-success-state')).toBeNull();
expect(vm.$el.querySelector('.gl-pagination')).toBeNull();
- setTimeout(() => {
- done();
- }, 0);
+ waitForPromises()
+ .then(done)
+ .catch(done.fail);
});
});
@@ -66,14 +67,16 @@ describe('Releases App ', () => {
});
it('renders success state', done => {
- setTimeout(() => {
- expect(vm.$el.querySelector('.js-loading')).toBeNull();
- expect(vm.$el.querySelector('.js-empty-state')).toBeNull();
- expect(vm.$el.querySelector('.js-success-state')).not.toBeNull();
- expect(vm.$el.querySelector('.gl-pagination')).toBeNull();
-
- done();
- }, 0);
+ waitForPromises()
+ .then(() => {
+ expect(vm.$el.querySelector('.js-loading')).toBeNull();
+ expect(vm.$el.querySelector('.js-empty-state')).toBeNull();
+ expect(vm.$el.querySelector('.js-success-state')).not.toBeNull();
+ expect(vm.$el.querySelector('.gl-pagination')).toBeNull();
+
+ done();
+ })
+ .catch(done.fail);
});
});
@@ -86,14 +89,16 @@ describe('Releases App ', () => {
});
it('renders success state', done => {
- setTimeout(() => {
- expect(vm.$el.querySelector('.js-loading')).toBeNull();
- expect(vm.$el.querySelector('.js-empty-state')).toBeNull();
- expect(vm.$el.querySelector('.js-success-state')).not.toBeNull();
- expect(vm.$el.querySelector('.gl-pagination')).not.toBeNull();
-
- done();
- }, 0);
+ waitForPromises()
+ .then(() => {
+ expect(vm.$el.querySelector('.js-loading')).toBeNull();
+ expect(vm.$el.querySelector('.js-empty-state')).toBeNull();
+ expect(vm.$el.querySelector('.js-success-state')).not.toBeNull();
+ expect(vm.$el.querySelector('.gl-pagination')).not.toBeNull();
+
+ done();
+ })
+ .catch(done.fail);
});
});
@@ -104,14 +109,76 @@ describe('Releases App ', () => {
});
it('renders empty state', done => {
- setTimeout(() => {
- expect(vm.$el.querySelector('.js-loading')).toBeNull();
- expect(vm.$el.querySelector('.js-empty-state')).not.toBeNull();
- expect(vm.$el.querySelector('.js-success-state')).toBeNull();
- expect(vm.$el.querySelector('.gl-pagination')).toBeNull();
-
- done();
- }, 0);
+ waitForPromises()
+ .then(() => {
+ expect(vm.$el.querySelector('.js-loading')).toBeNull();
+ expect(vm.$el.querySelector('.js-empty-state')).not.toBeNull();
+ expect(vm.$el.querySelector('.js-success-state')).toBeNull();
+ expect(vm.$el.querySelector('.gl-pagination')).toBeNull();
+
+ done();
+ })
+ .catch(done.fail);
+ });
+ });
+
+ describe('"New release" button', () => {
+ const findNewReleaseButton = () => vm.$el.querySelector('.js-new-release-btn');
+
+ beforeEach(() => {
+ spyOn(api, 'releases').and.returnValue(Promise.resolve({ data: [], headers: {} }));
+ });
+
+ const factory = additionalProps => {
+ vm = mountComponentWithStore(Component, {
+ props: {
+ ...props,
+ ...additionalProps,
+ },
+ store,
+ });
+ };
+
+ describe('when the user is allowed to create a new Release', () => {
+ const newReleasePath = 'path/to/new/release';
+
+ beforeEach(() => {
+ factory({ newReleasePath });
+ });
+
+ it('renders the "New release" button', done => {
+ waitForPromises()
+ .then(() => {
+ expect(findNewReleaseButton()).not.toBeNull();
+
+ done();
+ })
+ .catch(done.fail);
+ });
+
+ it('renders the "New release" button with the correct href', done => {
+ waitForPromises()
+ .then(() => {
+ expect(findNewReleaseButton().getAttribute('href')).toBe(newReleasePath);
+
+ done();
+ })
+ .catch(done.fail);
+ });
+ });
+
+ describe('when the user is not allowed to create a new Release', () => {
+ beforeEach(() => factory());
+
+ it('does not render the "New release" button', done => {
+ waitForPromises()
+ .then(() => {
+ expect(findNewReleaseButton()).toBeNull();
+
+ done();
+ })
+ .catch(done.fail);
+ });
});
});
});