From fb89d02f33e43a09f2cde20c1f122033311318f2 Mon Sep 17 00:00:00 2001 From: Cindy Halim Date: Wed, 15 May 2024 15:04:52 -0400 Subject: [PATCH 01/16] Base workspaces list component --- .../workspaces_list/base_workspaces_list.vue | 73 +++++++++++++++ .../base_workspaces_list_spec.js | 90 +++++++++++++++++++ 2 files changed, 163 insertions(+) create mode 100644 ee/app/assets/javascripts/workspaces/common/components/workspaces_list/base_workspaces_list.vue create mode 100644 ee/spec/frontend/workspaces/common/components/workspaces_list/base_workspaces_list_spec.js diff --git a/ee/app/assets/javascripts/workspaces/common/components/workspaces_list/base_workspaces_list.vue b/ee/app/assets/javascripts/workspaces/common/components/workspaces_list/base_workspaces_list.vue new file mode 100644 index 00000000000000..c1f69caf3376be --- /dev/null +++ b/ee/app/assets/javascripts/workspaces/common/components/workspaces_list/base_workspaces_list.vue @@ -0,0 +1,73 @@ + + diff --git a/ee/spec/frontend/workspaces/common/components/workspaces_list/base_workspaces_list_spec.js b/ee/spec/frontend/workspaces/common/components/workspaces_list/base_workspaces_list_spec.js new file mode 100644 index 00000000000000..6fd4f4d6ba822f --- /dev/null +++ b/ee/spec/frontend/workspaces/common/components/workspaces_list/base_workspaces_list_spec.js @@ -0,0 +1,90 @@ +import { shallowMount } from '@vue/test-utils'; +import { GlSkeletonLoader, GlAlert } from '@gitlab/ui'; + +import BaseWorkspacesList from 'ee/workspaces/common/components/workspaces_list/base_workspaces_list.vue'; +import WorkspaceEmptyState from 'ee/workspaces/common/components/workspaces_list/empty_state.vue'; +import { extendedWrapper } from 'helpers/vue_test_utils_helper'; + +const findAlert = (wrapper) => wrapper.findComponent(GlAlert); + +describe('BaseWorkspacesList', () => { + let wrapper; + + function createWrapper(props) { + wrapper = extendedWrapper( + shallowMount(BaseWorkspacesList, { + propsData: { + empty: true, + loading: false, + error: null, + newWorkspacePath: '/some-path', + ...props, + }, + }), + ); + } + + describe('is empty', () => { + beforeEach(() => { + createWrapper(); + }); + + it('renders an empty state', () => { + const emptyState = wrapper.findComponent(WorkspaceEmptyState); + expect(emptyState.exists()).toBe(true); + }); + + it('does not render header', () => { + const header = wrapper.findByTestId('workspaces-list-header'); + expect(header.exists()).toBe(false); + }); + + it('does not render error', () => { + expect(findAlert(wrapper).exists()).toBe(false); + }); + }); + + describe('is not empty', () => { + beforeEach(() => { + createWrapper({ + empty: false, + loading: false, + }); + }); + + it('does not render loading state', () => { + expect(wrapper.findComponent(GlSkeletonLoader).exists()).toBe(false); + }); + + it('does not render empty state', () => { + const emptyState = wrapper.findComponent(WorkspaceEmptyState); + expect(emptyState.exists()).toBe(false); + }); + + it('renders header', () => { + const header = wrapper.findByTestId('workspaces-list-header'); + expect(header.exists()).toBe(true); + }); + + it('does not render error', () => { + expect(findAlert(wrapper).exists()).toBe(false); + }); + }); + + describe('on error', () => { + const MOCK_ERROR = + 'Unable to load current workspaces. Please try again or contact an administrator.'; + + beforeEach(() => { + createWrapper({ + empty: false, + loading: false, + error: MOCK_ERROR, + }); + }); + + it('shows alert', () => { + expect(findAlert(wrapper).text()).toBe(MOCK_ERROR); + }); + }); +}); -- GitLab From 6d56c83d31c6b153aba7d1de689dac35ea6104bd Mon Sep 17 00:00:00 2001 From: Cindy Halim Date: Wed, 15 May 2024 17:58:48 -0400 Subject: [PATCH 02/16] Workspace tab component --- .../common/components/workspace_tab.vue | 110 +++++++++++++ .../workspaces_list/workspaces_table.vue | 1 + .../common/components/workspace_tab_spec.js | 147 ++++++++++++++++++ .../base_workspaces_list_spec.js | 2 +- 4 files changed, 259 insertions(+), 1 deletion(-) create mode 100644 ee/app/assets/javascripts/workspaces/common/components/workspace_tab.vue create mode 100644 ee/spec/frontend/workspaces/common/components/workspace_tab_spec.js diff --git a/ee/app/assets/javascripts/workspaces/common/components/workspace_tab.vue b/ee/app/assets/javascripts/workspaces/common/components/workspace_tab.vue new file mode 100644 index 00000000000000..c3ebc908f594c6 --- /dev/null +++ b/ee/app/assets/javascripts/workspaces/common/components/workspace_tab.vue @@ -0,0 +1,110 @@ + + diff --git a/ee/app/assets/javascripts/workspaces/common/components/workspaces_list/workspaces_table.vue b/ee/app/assets/javascripts/workspaces/common/components/workspaces_list/workspaces_table.vue index b0a594f8ad0d4e..45595e67d40f5d 100644 --- a/ee/app/assets/javascripts/workspaces/common/components/workspaces_list/workspaces_table.vue +++ b/ee/app/assets/javascripts/workspaces/common/components/workspaces_list/workspaces_table.vue @@ -144,6 +144,7 @@ export default { :fields="$options.fields" :tbody-transition-props="transitionProps" primary-key="name" + class="gl-my-5" :tbody-tr-attr="(item) => ({ 'data-testid': item.name })" >