Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/issuable')
-rw-r--r--spec/frontend/issuable/components/issuable_header_warnings_spec.js10
-rw-r--r--spec/frontend/issuable/components/status_box_spec.js76
-rw-r--r--spec/frontend/issuable/issuable_form_spec.js10
-rw-r--r--spec/frontend/issuable/related_issues/components/related_issues_root_spec.js27
4 files changed, 64 insertions, 59 deletions
diff --git a/spec/frontend/issuable/components/issuable_header_warnings_spec.js b/spec/frontend/issuable/components/issuable_header_warnings_spec.js
index c8380e42787..e3a36dc8820 100644
--- a/spec/frontend/issuable/components/issuable_header_warnings_spec.js
+++ b/spec/frontend/issuable/components/issuable_header_warnings_spec.js
@@ -66,7 +66,15 @@ describe('IssuableHeaderWarnings', () => {
});
it(`${renderTestMessage(confidentialStatus)} the confidential icon`, () => {
- expect(findConfidentialIcon().exists()).toBe(confidentialStatus);
+ const confidentialEl = findConfidentialIcon();
+ expect(confidentialEl.exists()).toBe(confidentialStatus);
+
+ if (confidentialStatus && !hiddenStatus) {
+ expect(confidentialEl.props()).toMatchObject({
+ workspaceType: 'project',
+ issuableType: 'issue',
+ });
+ }
});
it(`${renderTestMessage(confidentialStatus)} the hidden icon`, () => {
diff --git a/spec/frontend/issuable/components/status_box_spec.js b/spec/frontend/issuable/components/status_box_spec.js
index 9cbf023dbd6..728b8958b9b 100644
--- a/spec/frontend/issuable/components/status_box_spec.js
+++ b/spec/frontend/issuable/components/status_box_spec.js
@@ -1,71 +1,53 @@
-import { GlIcon, GlSprintf } from '@gitlab/ui';
+import { GlBadge, GlIcon } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import StatusBox from '~/issuable/components/status_box.vue';
let wrapper;
function factory(propsData) {
- wrapper = shallowMount(StatusBox, { propsData, stubs: { GlSprintf } });
+ wrapper = shallowMount(StatusBox, { propsData, stubs: { GlBadge } });
}
-const testCases = [
- {
- name: 'Open',
- state: 'opened',
- class: 'status-box-open',
- icon: 'issue-open-m',
- },
- {
- name: 'Open',
- state: 'locked',
- class: 'status-box-open',
- icon: 'issue-open-m',
- },
- {
- name: 'Closed',
- state: 'closed',
- class: 'status-box-mr-closed',
- icon: 'issue-close',
- },
- {
- name: 'Merged',
- state: 'merged',
- class: 'status-box-mr-merged',
- icon: 'git-merge',
- },
-];
-
describe('Merge request status box component', () => {
+ const findBadge = () => wrapper.findComponent(GlBadge);
+
afterEach(() => {
wrapper.destroy();
wrapper = null;
});
- testCases.forEach((testCase) => {
- describe(`when merge request is ${testCase.name}`, () => {
- it('renders human readable test', () => {
+ describe.each`
+ issuableType | badgeText | initialState | badgeClass | badgeVariant | badgeIcon
+ ${'merge_request'} | ${'Open'} | ${'opened'} | ${'issuable-status-badge-open'} | ${'success'} | ${'merge-request-open'}
+ ${'merge_request'} | ${'Closed'} | ${'closed'} | ${'issuable-status-badge-closed'} | ${'danger'} | ${'merge-request-close'}
+ ${'merge_request'} | ${'Merged'} | ${'merged'} | ${'issuable-status-badge-merged'} | ${'info'} | ${'merge'}
+ ${'issue'} | ${'Open'} | ${'opened'} | ${'issuable-status-badge-open'} | ${'success'} | ${'issues'}
+ ${'issue'} | ${'Closed'} | ${'closed'} | ${'issuable-status-badge-closed'} | ${'info'} | ${'issue-closed'}
+ `(
+ 'with issuableType set to "$issuableType" and state set to "$initialState"',
+ ({ issuableType, badgeText, initialState, badgeClass, badgeVariant, badgeIcon }) => {
+ beforeEach(() => {
factory({
- initialState: testCase.state,
+ initialState,
+ issuableType,
});
-
- expect(wrapper.text()).toContain(testCase.name);
});
- it('sets css class', () => {
- factory({
- initialState: testCase.state,
- });
+ it(`renders badge with text '${badgeText}'`, () => {
+ expect(findBadge().text()).toBe(badgeText);
+ });
- expect(wrapper.classes()).toContain(testCase.class);
+ it(`sets badge css class as '${badgeClass}'`, () => {
+ expect(findBadge().classes()).toContain(badgeClass);
});
- it('renders icon', () => {
- factory({
- initialState: testCase.state,
- });
+ it(`sets badge variant as '${badgeVariant}`, () => {
+ expect(findBadge().props('variant')).toBe(badgeVariant);
+ });
- expect(wrapper.findComponent(GlIcon).props('name')).toBe(testCase.icon);
+ it(`sets badge icon as '${badgeIcon}'`, () => {
+ expect(findBadge().findComponent(GlIcon).props('name')).toBe(badgeIcon);
});
- });
- });
+ },
+ );
});
diff --git a/spec/frontend/issuable/issuable_form_spec.js b/spec/frontend/issuable/issuable_form_spec.js
index 99ed18cf5bd..a1583076b41 100644
--- a/spec/frontend/issuable/issuable_form_spec.js
+++ b/spec/frontend/issuable/issuable_form_spec.js
@@ -1,5 +1,5 @@
import $ from 'jquery';
-
+import { setHTMLFixture, resetHTMLFixture } from 'helpers/fixtures';
import IssuableForm from '~/issuable/issuable_form';
import setWindowLocation from 'helpers/set_window_location_helper';
@@ -11,7 +11,7 @@ describe('IssuableForm', () => {
};
beforeEach(() => {
- setFixtures(`
+ setHTMLFixture(`
<form>
<input name="[title]" />
</form>
@@ -19,6 +19,10 @@ describe('IssuableForm', () => {
createIssuable($('form'));
});
+ afterEach(() => {
+ resetHTMLFixture();
+ });
+
describe('initAutosave', () => {
it('creates autosave with the searchTerm included', () => {
setWindowLocation('https://gitlab.test/foo?bar=true');
@@ -28,7 +32,7 @@ describe('IssuableForm', () => {
});
it("creates autosave fields without the searchTerm if it's an issue new form", () => {
- setFixtures(`
+ setHTMLFixture(`
<form data-new-issue-path="/issues/new">
<input name="[title]" />
</form>
diff --git a/spec/frontend/issuable/related_issues/components/related_issues_root_spec.js b/spec/frontend/issuable/related_issues/components/related_issues_root_spec.js
index b59717a1f60..1a03ea58b60 100644
--- a/spec/frontend/issuable/related_issues/components/related_issues_root_spec.js
+++ b/spec/frontend/issuable/related_issues/components/related_issues_root_spec.js
@@ -300,16 +300,27 @@ describe('RelatedIssuesRoot', () => {
expect(wrapper.vm.state.pendingReferences[1]).toEqual('random');
});
- it('prepends # when user enters a numeric value [0-9]', async () => {
- const input = '23';
+ it.each`
+ pathIdSeparator
+ ${'#'}
+ ${'&'}
+ `(
+ 'prepends $pathIdSeparator when user enters a numeric value [0-9]',
+ async ({ pathIdSeparator }) => {
+ const input = '23';
+
+ await wrapper.setProps({
+ pathIdSeparator,
+ });
- wrapper.vm.onInput({
- untouchedRawReferences: input.trim().split(/\s/),
- touchedReference: input,
- });
+ wrapper.vm.onInput({
+ untouchedRawReferences: input.trim().split(/\s/),
+ touchedReference: input,
+ });
- expect(wrapper.vm.inputValue).toBe(`#${input}`);
- });
+ expect(wrapper.vm.inputValue).toBe(`${pathIdSeparator}${input}`);
+ },
+ );
it('prepends # when user enters a number', async () => {
const input = 23;