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:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-05-14 03:11:05 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-05-14 03:11:05 +0300
commit980faa8f3421499e36ad0d9834a6353c0aeb3d3e (patch)
treee89d93e611acb30a553a5c7a9e453c00d7b28504 /spec/frontend
parent52b32eecb72bceac7e1b7f57a641d25b9a7f58bc (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend')
-rw-r--r--spec/frontend/ci_variable_list/components/ci_variable_modal_spec.js2
-rw-r--r--spec/frontend/members/components/members_tabs_spec.js194
-rw-r--r--spec/frontend/pipeline_editor/components/drawer/pipeline_editor_drawer_spec.js17
3 files changed, 211 insertions, 2 deletions
diff --git a/spec/frontend/ci_variable_list/components/ci_variable_modal_spec.js b/spec/frontend/ci_variable_list/components/ci_variable_modal_spec.js
index 752783a306a..eb18147fcef 100644
--- a/spec/frontend/ci_variable_list/components/ci_variable_modal_spec.js
+++ b/spec/frontend/ci_variable_list/components/ci_variable_modal_spec.js
@@ -226,7 +226,7 @@ describe('Ci variable modal', () => {
};
createComponent(mount);
store.state.variable = validMaskandKeyVariable;
- store.state.maskableRegex = /^[a-zA-Z0-9_+=/@:-]{8,}$/;
+ store.state.maskableRegex = /^[a-zA-Z0-9_+=/@:.~-]{8,}$/;
});
it('does not disable the submit button', () => {
diff --git a/spec/frontend/members/components/members_tabs_spec.js b/spec/frontend/members/components/members_tabs_spec.js
new file mode 100644
index 00000000000..28614b52706
--- /dev/null
+++ b/spec/frontend/members/components/members_tabs_spec.js
@@ -0,0 +1,194 @@
+import Vue, { nextTick } from 'vue';
+import Vuex from 'vuex';
+import { mountExtended } from 'helpers/vue_test_utils_helper';
+import MembersApp from '~/members/components/app.vue';
+import MembersTabs from '~/members/components/members_tabs.vue';
+import { MEMBER_TYPES } from '~/members/constants';
+import { pagination } from '../mock_data';
+
+describe('MembersApp', () => {
+ Vue.use(Vuex);
+
+ let wrapper;
+
+ const createComponent = ({ totalItems = 10, options = {} } = {}) => {
+ const store = new Vuex.Store({
+ modules: {
+ [MEMBER_TYPES.user]: {
+ namespaced: true,
+ state: {
+ pagination: {
+ ...pagination,
+ totalItems,
+ },
+ filteredSearchBar: {
+ searchParam: 'search',
+ },
+ },
+ },
+ [MEMBER_TYPES.group]: {
+ namespaced: true,
+ state: {
+ pagination: {
+ ...pagination,
+ totalItems,
+ paramName: 'groups_page',
+ },
+ filteredSearchBar: {
+ searchParam: 'search_groups',
+ },
+ },
+ },
+ [MEMBER_TYPES.invite]: {
+ namespaced: true,
+ state: {
+ pagination: {
+ ...pagination,
+ totalItems,
+ paramName: 'invited_page',
+ },
+ filteredSearchBar: {
+ searchParam: 'search_invited',
+ },
+ },
+ },
+ [MEMBER_TYPES.accessRequest]: {
+ namespaced: true,
+ state: {
+ pagination: {
+ ...pagination,
+ totalItems,
+ paramName: 'access_requests_page',
+ },
+ filteredSearchBar: {
+ searchParam: 'search_access_requests',
+ },
+ },
+ },
+ },
+ });
+
+ wrapper = mountExtended(MembersTabs, {
+ store,
+ stubs: ['members-app'],
+ provide: {
+ canManageMembers: true,
+ },
+ ...options,
+ });
+
+ return nextTick();
+ };
+
+ const findTabs = () => wrapper.findAllByRole('tab').wrappers;
+ const findTabByText = (text) => findTabs().find((tab) => tab.text().includes(text));
+ const findActiveTab = () => wrapper.findByRole('tab', { selected: true });
+
+ beforeEach(() => {
+ delete window.location;
+ window.location = new URL('https://localhost');
+ });
+
+ afterEach(() => {
+ wrapper.destroy();
+ });
+
+ describe('when tabs have a count', () => {
+ it('renders tabs with count', async () => {
+ await createComponent();
+
+ const tabs = findTabs();
+
+ expect(tabs[0].text()).toBe('Members 10');
+ expect(tabs[1].text()).toBe('Groups 10');
+ expect(tabs[2].text()).toBe('Invited 10');
+ expect(tabs[3].text()).toBe('Access requests 10');
+ expect(findActiveTab().text()).toContain('Members');
+ });
+
+ it('renders `MembersApp` and passes `namespace` prop', async () => {
+ await createComponent();
+
+ const membersApps = wrapper.findAllComponents(MembersApp).wrappers;
+
+ expect(membersApps[0].attributes('namespace')).toBe(MEMBER_TYPES.user);
+ expect(membersApps[1].attributes('namespace')).toBe(MEMBER_TYPES.group);
+ expect(membersApps[2].attributes('namespace')).toBe(MEMBER_TYPES.invite);
+ expect(membersApps[3].attributes('namespace')).toBe(MEMBER_TYPES.accessRequest);
+ });
+ });
+
+ describe('when tabs do not have a count', () => {
+ it('only renders `Members` tab', async () => {
+ await createComponent({ totalItems: 0 });
+
+ expect(findTabByText('Members')).not.toBeUndefined();
+ expect(findTabByText('Groups')).toBeUndefined();
+ expect(findTabByText('Invited')).toBeUndefined();
+ expect(findTabByText('Access requests')).toBeUndefined();
+ });
+ });
+
+ describe('when url param matches `filteredSearchBar.searchParam`', () => {
+ beforeEach(() => {
+ window.location.search = '?search_groups=foo+bar';
+ });
+
+ const expectGroupsTabActive = () => {
+ expect(findActiveTab().text()).toContain('Groups');
+ };
+
+ describe('when tab has a count', () => {
+ it('sets tab that corresponds to search param as active tab', async () => {
+ await createComponent();
+
+ expectGroupsTabActive();
+ });
+ });
+
+ describe('when tab does not have a count', () => {
+ it('sets tab that corresponds to search param as active tab', async () => {
+ await createComponent({ totalItems: 0 });
+
+ expectGroupsTabActive();
+ });
+ });
+ });
+
+ describe('when url param matches `pagination.paramName`', () => {
+ beforeEach(() => {
+ window.location.search = '?invited_page=2';
+ });
+
+ const expectInvitedTabActive = () => {
+ expect(findActiveTab().text()).toContain('Invited');
+ };
+
+ describe('when tab has a count', () => {
+ it('sets tab that corresponds to pagination param as active tab', async () => {
+ await createComponent();
+
+ expectInvitedTabActive();
+ });
+ });
+
+ describe('when tab does not have a count', () => {
+ it('sets tab that corresponds to pagination param as active tab', async () => {
+ await createComponent({ totalItems: 0 });
+
+ expectInvitedTabActive();
+ });
+ });
+ });
+
+ describe('when `canManageMembers` is `false`', () => {
+ it('shows all tabs except `Invited` and `Access requests`', async () => {
+ await createComponent({ options: { provide: { canManageMembers: false } } });
+
+ expect(findTabByText('Members')).not.toBeUndefined();
+ expect(findTabByText('Groups')).not.toBeUndefined();
+ expect(findTabByText('Invited')).toBeUndefined();
+ expect(findTabByText('Access requests')).toBeUndefined();
+ });
+ });
+});
diff --git a/spec/frontend/pipeline_editor/components/drawer/pipeline_editor_drawer_spec.js b/spec/frontend/pipeline_editor/components/drawer/pipeline_editor_drawer_spec.js
index 1dfecf75ad8..1b68cd3dc43 100644
--- a/spec/frontend/pipeline_editor/components/drawer/pipeline_editor_drawer_spec.js
+++ b/spec/frontend/pipeline_editor/components/drawer/pipeline_editor_drawer_spec.js
@@ -38,6 +38,16 @@ describe('Pipeline editor drawer', () => {
localStorage.clear();
});
+ it('it sets the drawer to be opened by default', async () => {
+ createComponent();
+
+ expect(findDrawerContent().exists()).toBe(false);
+
+ await nextTick();
+
+ expect(findDrawerContent().exists()).toBe(true);
+ });
+
describe('when the drawer is collapsed', () => {
beforeEach(async () => {
createComponent();
@@ -100,10 +110,15 @@ describe('Pipeline editor drawer', () => {
describe('local storage', () => {
it('saves the drawer expanded value to local storage', async () => {
+ localStorage.setItem(DRAWER_EXPANDED_KEY, 'false');
+
createComponent();
await clickToggleBtn();
- expect(localStorage.setItem.mock.calls).toEqual([[DRAWER_EXPANDED_KEY, 'false']]);
+ expect(localStorage.setItem.mock.calls).toEqual([
+ [DRAWER_EXPANDED_KEY, 'false'],
+ [DRAWER_EXPANDED_KEY, 'true'],
+ ]);
});
it('loads the drawer collapsed when local storage is set to `false`, ', async () => {