diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-03 18:09:26 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-03 18:09:26 +0300 |
commit | f5f6cb45c73c8aa059c3006a3696014522a41a4b (patch) | |
tree | bde1e1c22c83276f49858e827909a1e13ef0f0c2 /spec/frontend | |
parent | c74f702c747d1b14c3ddea951ceb7970941dc8f5 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend')
4 files changed, 52 insertions, 29 deletions
diff --git a/spec/frontend/__helpers__/dl_locator_helper.js b/spec/frontend/__helpers__/dl_locator_helper.js new file mode 100644 index 00000000000..b507dcd599d --- /dev/null +++ b/spec/frontend/__helpers__/dl_locator_helper.js @@ -0,0 +1,28 @@ +import { createWrapper, ErrorWrapper } from '@vue/test-utils'; + +/** + * Find the definition (<dd>) that corresponds to this term (<dt>) + * + * Given html in the `wrapper`: + * + * <dl> + * <dt>My label</dt> + * <dd>Value</dd> + * </dl> + * + * findDd('My label', wrapper) + * + * Returns `<dd>Value</dd>` + * + * @param {object} wrapper - Parent wrapper + * @param {string} dtLabel - Label for this value + * @returns Wrapper + */ +export const findDd = (dtLabel, wrapper) => { + const dt = wrapper.findByText(dtLabel).element; + const dd = dt.nextElementSibling; + if (dt.tagName === 'DT' && dd.tagName === 'DD') { + return createWrapper(dd, {}); + } + return ErrorWrapper(dtLabel); +}; diff --git a/spec/frontend/members/components/table/members_table_spec.js b/spec/frontend/members/components/table/members_table_spec.js index 7d58b822916..08baa663bf0 100644 --- a/spec/frontend/members/components/table/members_table_spec.js +++ b/spec/frontend/members/components/table/members_table_spec.js @@ -16,9 +16,9 @@ import { MEMBER_STATE_CREATED, MEMBER_STATE_AWAITING, MEMBER_STATE_ACTIVE, - USER_STATE_BLOCKED_PENDING_APPROVAL, - BADGE_LABELS_AWAITING_USER_SIGNUP, - BADGE_LABELS_PENDING_OWNER_ACTION, + USER_STATE_BLOCKED, + BADGE_LABELS_AWAITING_SIGNUP, + BADGE_LABELS_PENDING, TAB_QUERY_PARAM_VALUES, } from '~/members/constants'; import { @@ -133,14 +133,14 @@ describe('MembersTable', () => { describe('Invited column', () => { describe.each` - state | userState | expectedBadgeLabel - ${MEMBER_STATE_CREATED} | ${null} | ${BADGE_LABELS_AWAITING_USER_SIGNUP} - ${MEMBER_STATE_CREATED} | ${USER_STATE_BLOCKED_PENDING_APPROVAL} | ${BADGE_LABELS_PENDING_OWNER_ACTION} - ${MEMBER_STATE_AWAITING} | ${''} | ${BADGE_LABELS_AWAITING_USER_SIGNUP} - ${MEMBER_STATE_AWAITING} | ${USER_STATE_BLOCKED_PENDING_APPROVAL} | ${BADGE_LABELS_PENDING_OWNER_ACTION} - ${MEMBER_STATE_AWAITING} | ${'something_else'} | ${BADGE_LABELS_PENDING_OWNER_ACTION} - ${MEMBER_STATE_ACTIVE} | ${null} | ${''} - ${MEMBER_STATE_ACTIVE} | ${'something_else'} | ${''} + state | userState | expectedBadgeLabel + ${MEMBER_STATE_CREATED} | ${null} | ${BADGE_LABELS_AWAITING_SIGNUP} + ${MEMBER_STATE_CREATED} | ${USER_STATE_BLOCKED} | ${BADGE_LABELS_PENDING} + ${MEMBER_STATE_AWAITING} | ${''} | ${BADGE_LABELS_AWAITING_SIGNUP} + ${MEMBER_STATE_AWAITING} | ${USER_STATE_BLOCKED} | ${BADGE_LABELS_PENDING} + ${MEMBER_STATE_AWAITING} | ${'something_else'} | ${BADGE_LABELS_PENDING} + ${MEMBER_STATE_ACTIVE} | ${null} | ${''} + ${MEMBER_STATE_ACTIVE} | ${'something_else'} | ${''} `('Invited Badge', ({ state, userState, expectedBadgeLabel }) => { it(`${ expectedBadgeLabel ? 'shows' : 'hides' diff --git a/spec/frontend/runner/components/runner_details_spec.js b/spec/frontend/runner/components/runner_details_spec.js index 162d21febfd..47847cead1d 100644 --- a/spec/frontend/runner/components/runner_details_spec.js +++ b/spec/frontend/runner/components/runner_details_spec.js @@ -1,8 +1,8 @@ import { GlSprintf, GlIntersperse, GlTab } from '@gitlab/ui'; -import { createWrapper, ErrorWrapper } from '@vue/test-utils'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import TimeAgo from '~/vue_shared/components/time_ago_tooltip.vue'; import { useFakeDate } from 'helpers/fake_date'; +import { findDd } from 'helpers/dl_locator_helper'; import { ACCESS_LEVEL_REF_PROTECTED, ACCESS_LEVEL_NOT_PROTECTED } from '~/runner/constants'; import RunnerDetails from '~/runner/components/runner_details.vue'; @@ -24,20 +24,6 @@ describe('RunnerDetails', () => { useFakeDate(mockNow); - /** - * Find the definition (<dd>) that corresponds to this term (<dt>) - * @param {string} dtLabel - Label for this value - * @returns Wrapper - */ - const findDd = (dtLabel) => { - const dt = wrapper.findByText(dtLabel).element; - const dd = dt.nextElementSibling; - if (dt.tagName === 'DT' && dd.tagName === 'DD') { - return createWrapper(dd, {}); - } - return ErrorWrapper(dtLabel); - }; - const findDetailGroups = () => wrapper.findComponent(RunnerGroups); const findRunnersJobs = () => wrapper.findComponent(RunnersJobs); const findJobCountBadge = () => wrapper.findByTestId('job-count-badge'); @@ -108,7 +94,7 @@ describe('RunnerDetails', () => { }); it(`displays expected value "${expectedValue}"`, () => { - expect(findDd(field).text()).toBe(expectedValue); + expect(findDd(field, wrapper).text()).toBe(expectedValue); }); }); @@ -123,7 +109,7 @@ describe('RunnerDetails', () => { stubs, }); - expect(findDd('Tags').text().replace(/\s+/g, ' ')).toBe('tag-1 tag-2'); + expect(findDd('Tags', wrapper).text().replace(/\s+/g, ' ')).toBe('tag-1 tag-2'); }); it('displays "None" when runner has no tags', () => { @@ -134,7 +120,7 @@ describe('RunnerDetails', () => { stubs, }); - expect(findDd('Tags').text().replace(/\s+/g, ' ')).toBe('None'); + expect(findDd('Tags', wrapper).text().replace(/\s+/g, ' ')).toBe('None'); }); }); diff --git a/spec/frontend/vue_shared/components/form/input_copy_toggle_visibility_spec.js b/spec/frontend/vue_shared/components/form/input_copy_toggle_visibility_spec.js index 6d176e1bf6a..11abde04361 100644 --- a/spec/frontend/vue_shared/components/form/input_copy_toggle_visibility_spec.js +++ b/spec/frontend/vue_shared/components/form/input_copy_toggle_visibility_spec.js @@ -77,6 +77,15 @@ describe('InputCopyToggleVisibility', () => { expect(event.preventDefault).toHaveBeenCalled(); }); + it('emits `copy` event when manually copied the token', () => { + expect(wrapper.emitted('copy')).toBeUndefined(); + + findFormInput().element.dispatchEvent(createCopyEvent()); + + expect(wrapper.emitted('copy')).toHaveLength(1); + expect(wrapper.emitted('copy')[0]).toEqual([]); + }); + describe('visibility toggle button', () => { it('renders a reveal button', () => { const revealButton = findRevealButton(); |