summaryrefslogtreecommitdiff
path: root/spec/frontend/terraform
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-02-11 09:09:18 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-02-11 09:09:18 +0000
commit7240fb1a06c9e1b254719426b1ac96ec2f00fe35 (patch)
treea2c0e2b679bc34c9446a5e4653f5d63f2292205d /spec/frontend/terraform
parent62d57690bc54e195b2544091725421144ce76900 (diff)
downloadgitlab-ce-7240fb1a06c9e1b254719426b1ac96ec2f00fe35.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/terraform')
-rw-r--r--spec/frontend/terraform/components/states_table_actions_spec.js39
-rw-r--r--spec/frontend/terraform/components/states_table_spec.js12
-rw-r--r--spec/frontend/terraform/components/terraform_list_spec.js36
3 files changed, 60 insertions, 27 deletions
diff --git a/spec/frontend/terraform/components/states_table_actions_spec.js b/spec/frontend/terraform/components/states_table_actions_spec.js
index 6100b1f67a2..7449ddd3d2a 100644
--- a/spec/frontend/terraform/components/states_table_actions_spec.js
+++ b/spec/frontend/terraform/components/states_table_actions_spec.js
@@ -89,17 +89,34 @@ describe('StatesTableActions', () => {
});
describe('when the state is loading', () => {
- beforeEach(() => {
- return createComponent({
- state: {
- ...defaultProps.state,
- loadingActions: true,
- },
+ describe('when lock/unlock is processing', () => {
+ beforeEach(() => {
+ return createComponent({
+ state: {
+ ...defaultProps.state,
+ loadingLock: true,
+ },
+ });
+ });
+
+ it('disables the actions dropdown', () => {
+ expect(findActionsDropdown().props('disabled')).toBe(true);
});
});
- it('disables the actions dropdown', () => {
- expect(findActionsDropdown().props('disabled')).toBe(true);
+ describe('when remove is processing', () => {
+ beforeEach(() => {
+ return createComponent({
+ state: {
+ ...defaultProps.state,
+ loadingRemove: true,
+ },
+ });
+ });
+
+ it('disables the actions dropdown', () => {
+ expect(findActionsDropdown().props('disabled')).toBe(true);
+ });
});
});
@@ -188,7 +205,8 @@ describe('StatesTableActions', () => {
...unlockedProps.state,
_showDetails: false,
errorMessages: [],
- loadingActions: true,
+ loadingLock: true,
+ loadingRemove: false,
},
},
// Apollo fields
@@ -205,7 +223,8 @@ describe('StatesTableActions', () => {
...unlockedProps.state,
_showDetails: true,
errorMessages: ['There was an error'],
- loadingActions: false,
+ loadingLock: false,
+ loadingRemove: false,
},
},
// Apollo fields
diff --git a/spec/frontend/terraform/components/states_table_spec.js b/spec/frontend/terraform/components/states_table_spec.js
index ba676c9741e..dbef4d3f495 100644
--- a/spec/frontend/terraform/components/states_table_spec.js
+++ b/spec/frontend/terraform/components/states_table_spec.js
@@ -14,6 +14,8 @@ describe('StatesTable', () => {
_showDetails: true,
errorMessages: ['State 1 has errored'],
name: 'state-1',
+ loadingLock: false,
+ loadingRemove: false,
lockedAt: '2020-10-13T00:00:00Z',
lockedByUser: {
name: 'user-1',
@@ -25,6 +27,8 @@ describe('StatesTable', () => {
_showDetails: false,
errorMessages: [],
name: 'state-2',
+ loadingLock: true,
+ loadingRemove: false,
lockedAt: null,
lockedByUser: null,
updatedAt: '2020-10-10T00:00:00Z',
@@ -34,6 +38,8 @@ describe('StatesTable', () => {
_showDetails: false,
errorMessages: [],
name: 'state-3',
+ loadingLock: true,
+ loadingRemove: false,
lockedAt: '2020-10-10T00:00:00Z',
lockedByUser: {
name: 'user-2',
@@ -63,6 +69,8 @@ describe('StatesTable', () => {
_showDetails: true,
errorMessages: ['State 4 has errored'],
name: 'state-4',
+ loadingLock: false,
+ loadingRemove: false,
lockedAt: '2020-10-10T00:00:00Z',
lockedByUser: null,
updatedAt: '2020-10-10T00:00:00Z',
@@ -106,8 +114,8 @@ describe('StatesTable', () => {
it.each`
name | toolTipText | locked | lineNumber
${'state-1'} | ${'Locked by user-1 2 days ago'} | ${true} | ${0}
- ${'state-2'} | ${null} | ${false} | ${1}
- ${'state-3'} | ${'Locked by user-2 5 days ago'} | ${true} | ${2}
+ ${'state-2'} | ${'Locking state'} | ${false} | ${1}
+ ${'state-3'} | ${'Unlocking state'} | ${false} | ${2}
${'state-4'} | ${'Locked by Unknown User 5 days ago'} | ${true} | ${3}
`(
'displays the name and locked information "$name" for line "$lineNumber"',
diff --git a/spec/frontend/terraform/components/terraform_list_spec.js b/spec/frontend/terraform/components/terraform_list_spec.js
index 20d42ebd4fd..882b7b55b3e 100644
--- a/spec/frontend/terraform/components/terraform_list_spec.js
+++ b/spec/frontend/terraform/components/terraform_list_spec.js
@@ -2,6 +2,7 @@ import { GlAlert, GlBadge, GlKeysetPagination, GlLoadingIcon, GlTab } from '@git
import { createLocalVue, shallowMount } from '@vue/test-utils';
import VueApollo from 'vue-apollo';
import createMockApollo from 'helpers/mock_apollo_helper';
+import waitForPromises from 'helpers/wait_for_promises';
import EmptyState from '~/terraform/components/empty_state.vue';
import StatesTable from '~/terraform/components/states_table.vue';
import TerraformList from '~/terraform/components/terraform_list.vue';
@@ -27,17 +28,20 @@ describe('TerraformList', () => {
},
};
- // Override @client _showDetails
- getStatesQuery.getStates.definitions[1].selectionSet.selections[0].directives = [];
-
- // Override @client errorMessages
- getStatesQuery.getStates.definitions[1].selectionSet.selections[1].directives = [];
-
- // Override @client loadingActions
- getStatesQuery.getStates.definitions[1].selectionSet.selections[2].directives = [];
+ const mockResolvers = {
+ TerraformState: {
+ _showDetails: jest.fn().mockResolvedValue(false),
+ errorMessages: jest.fn().mockResolvedValue([]),
+ loadingLock: jest.fn().mockResolvedValue(false),
+ loadingRemove: jest.fn().mockResolvedValue(false),
+ },
+ Mutation: {
+ addDataToTerraformState: jest.fn().mockResolvedValue({}),
+ },
+ };
const statsQueryResponse = queryResponse || jest.fn().mockResolvedValue(apolloQueryResponse);
- const apolloProvider = createMockApollo([[getStatesQuery, statsQueryResponse]]);
+ const apolloProvider = createMockApollo([[getStatesQuery, statsQueryResponse]], mockResolvers);
wrapper = shallowMount(TerraformList, {
localVue,
@@ -66,7 +70,8 @@ describe('TerraformList', () => {
id: 'gid://gitlab/Terraform::State/1',
name: 'state-1',
latestVersion: null,
- loadingActions: false,
+ loadingLock: false,
+ loadingRemove: false,
lockedAt: null,
lockedByUser: null,
updatedAt: null,
@@ -77,7 +82,8 @@ describe('TerraformList', () => {
id: 'gid://gitlab/Terraform::State/2',
name: 'state-2',
latestVersion: null,
- loadingActions: false,
+ loadingLock: false,
+ loadingRemove: false,
lockedAt: null,
lockedByUser: null,
updatedAt: null,
@@ -98,7 +104,7 @@ describe('TerraformList', () => {
},
});
- return wrapper.vm.$nextTick();
+ return waitForPromises();
});
it('displays a states tab and count', () => {
@@ -126,7 +132,7 @@ describe('TerraformList', () => {
},
});
- return wrapper.vm.$nextTick();
+ return waitForPromises();
});
it('renders the states table without pagination buttons', () => {
@@ -146,7 +152,7 @@ describe('TerraformList', () => {
},
});
- return wrapper.vm.$nextTick();
+ return waitForPromises();
});
it('displays a states tab with no count', () => {
@@ -164,7 +170,7 @@ describe('TerraformList', () => {
beforeEach(() => {
createWrapper({ terraformStates: null, queryResponse: jest.fn().mockRejectedValue() });
- return wrapper.vm.$nextTick();
+ return waitForPromises();
});
it('displays an alert message', () => {