diff options
author | Enrique Alcántara <ealcantara@gitlab.com> | 2019-06-06 14:15:39 +0000 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2019-06-06 14:15:39 +0000 |
commit | 940c812d5e3788d86603a87723198842af86efaf (patch) | |
tree | 7bde45b231eba6152aca1f42dd9290b6970812db /spec/frontend/clusters | |
parent | 431f33fe8e6e6fea2f5bdfcdb1e4543487e885a1 (diff) | |
download | gitlab-ce-940c812d5e3788d86603a87723198842af86efaf.tar.gz |
Replace upgrade with update
Use update term instead of update in the clusters managed app
implementation in order to make the implementation and UI
language more consistent.
Diffstat (limited to 'spec/frontend/clusters')
4 files changed, 71 insertions, 43 deletions
diff --git a/spec/frontend/clusters/clusters_bundle_spec.js b/spec/frontend/clusters/clusters_bundle_spec.js index 66b22fa2681..6de06a9e2d5 100644 --- a/spec/frontend/clusters/clusters_bundle_spec.js +++ b/spec/frontend/clusters/clusters_bundle_spec.js @@ -1,5 +1,10 @@ import Clusters from '~/clusters/clusters_bundle'; -import { APPLICATION_STATUS, INGRESS_DOMAIN_SUFFIX, APPLICATIONS } from '~/clusters/constants'; +import { + APPLICATION_STATUS, + INGRESS_DOMAIN_SUFFIX, + APPLICATIONS, + RUNNER, +} from '~/clusters/constants'; import MockAdapter from 'axios-mock-adapter'; import axios from '~/lib/utils/axios_utils'; import { loadHTMLFixture } from 'helpers/fixtures'; @@ -353,4 +358,30 @@ describe('Clusters', () => { }); }); }); + + describe('updateApplication', () => { + const params = { version: '1.0.0' }; + let storeUpdateApplication; + let installApplication; + + beforeEach(() => { + storeUpdateApplication = jest.spyOn(cluster.store, 'updateApplication'); + installApplication = jest.spyOn(cluster.service, 'installApplication'); + + cluster.updateApplication({ id: RUNNER, params }); + }); + + afterEach(() => { + storeUpdateApplication.mockRestore(); + installApplication.mockRestore(); + }); + + it('calls store updateApplication method', () => { + expect(storeUpdateApplication).toHaveBeenCalledWith(RUNNER); + }); + + it('sends installApplication request', () => { + expect(installApplication).toHaveBeenCalledWith(RUNNER, params); + }); + }); }); diff --git a/spec/frontend/clusters/components/application_row_spec.js b/spec/frontend/clusters/components/application_row_spec.js index 7c781b72355..9f127ccb690 100644 --- a/spec/frontend/clusters/components/application_row_spec.js +++ b/spec/frontend/clusters/components/application_row_spec.js @@ -245,26 +245,26 @@ describe('Application Row', () => { }); }); - describe('Upgrade button', () => { + describe('Update button', () => { it('has indeterminate state on page load', () => { vm = mountComponent(ApplicationRow, { ...DEFAULT_APPLICATION_STATE, status: null, }); - const upgradeBtn = vm.$el.querySelector('.js-cluster-application-upgrade-button'); + const updateBtn = vm.$el.querySelector('.js-cluster-application-update-button'); - expect(upgradeBtn).toBe(null); + expect(updateBtn).toBe(null); }); - it('has enabled "Upgrade" when "upgradeAvailable" is true', () => { + it('has enabled "Update" when "updateAvailable" is true', () => { vm = mountComponent(ApplicationRow, { ...DEFAULT_APPLICATION_STATE, - upgradeAvailable: true, + updateAvailable: true, }); - const upgradeBtn = vm.$el.querySelector('.js-cluster-application-upgrade-button'); + const updateBtn = vm.$el.querySelector('.js-cluster-application-update-button'); - expect(upgradeBtn).not.toBe(null); - expect(upgradeBtn.innerHTML).toContain('Upgrade'); + expect(updateBtn).not.toBe(null); + expect(updateBtn.innerHTML).toContain('Update'); }); it('has enabled "Retry update" when update process fails', () => { @@ -273,10 +273,10 @@ describe('Application Row', () => { status: APPLICATION_STATUS.INSTALLED, updateFailed: true, }); - const upgradeBtn = vm.$el.querySelector('.js-cluster-application-upgrade-button'); + const updateBtn = vm.$el.querySelector('.js-cluster-application-update-button'); - expect(upgradeBtn).not.toBe(null); - expect(upgradeBtn.innerHTML).toContain('Retry update'); + expect(updateBtn).not.toBe(null); + expect(updateBtn.innerHTML).toContain('Retry update'); }); it('has disabled "Updating" when APPLICATION_STATUS.UPDATING', () => { @@ -284,53 +284,51 @@ describe('Application Row', () => { ...DEFAULT_APPLICATION_STATE, status: APPLICATION_STATUS.UPDATING, }); - const upgradeBtn = vm.$el.querySelector('.js-cluster-application-upgrade-button'); + const updateBtn = vm.$el.querySelector('.js-cluster-application-update-button'); - expect(upgradeBtn).not.toBe(null); - expect(vm.isUpgrading).toBe(true); - expect(upgradeBtn.innerHTML).toContain('Updating'); + expect(updateBtn).not.toBe(null); + expect(vm.isUpdating).toBe(true); + expect(updateBtn.innerHTML).toContain('Updating'); }); - it('clicking upgrade button emits event', () => { + it('clicking update button emits event', () => { jest.spyOn(eventHub, '$emit'); vm = mountComponent(ApplicationRow, { ...DEFAULT_APPLICATION_STATE, status: APPLICATION_STATUS.INSTALLED, - upgradeAvailable: true, + updateAvailable: true, }); - const upgradeBtn = vm.$el.querySelector('.js-cluster-application-upgrade-button'); + const updateBtn = vm.$el.querySelector('.js-cluster-application-update-button'); - upgradeBtn.click(); + updateBtn.click(); - expect(eventHub.$emit).toHaveBeenCalledWith('upgradeApplication', { + expect(eventHub.$emit).toHaveBeenCalledWith('updateApplication', { id: DEFAULT_APPLICATION_STATE.id, params: {}, }); }); - it('clicking disabled upgrade button emits nothing', () => { + it('clicking disabled update button emits nothing', () => { jest.spyOn(eventHub, '$emit'); vm = mountComponent(ApplicationRow, { ...DEFAULT_APPLICATION_STATE, status: APPLICATION_STATUS.UPDATING, }); - const upgradeBtn = vm.$el.querySelector('.js-cluster-application-upgrade-button'); + const updateBtn = vm.$el.querySelector('.js-cluster-application-update-button'); - upgradeBtn.click(); + updateBtn.click(); expect(eventHub.$emit).not.toHaveBeenCalled(); }); - it('displays an error message if application upgrade failed', () => { + it('displays an error message if application update failed', () => { vm = mountComponent(ApplicationRow, { ...DEFAULT_APPLICATION_STATE, title: 'GitLab Runner', status: APPLICATION_STATUS.INSTALLED, updateFailed: true, }); - const failureMessage = vm.$el.querySelector( - '.js-cluster-application-upgrade-failure-message', - ); + const failureMessage = vm.$el.querySelector('.js-cluster-application-update-details'); expect(failureMessage).not.toBe(null); expect(failureMessage.innerHTML).toContain( @@ -338,7 +336,7 @@ describe('Application Row', () => { ); }); - it('displays a success toast message if application upgrade was successful', () => { + it('displays a success toast message if application update was successful', () => { vm = mountComponent(ApplicationRow, { ...DEFAULT_APPLICATION_STATE, title: 'GitLab Runner', @@ -349,13 +347,13 @@ describe('Application Row', () => { vm.updateSuccessful = true; return vm.$nextTick(() => { - expect(vm.$toast.show).toHaveBeenCalledWith('GitLab Runner upgraded successfully.'); + expect(vm.$toast.show).toHaveBeenCalledWith('GitLab Runner updated successfully.'); }); }); }); describe('Version', () => { - it('displays a version number if application has been upgraded', () => { + it('displays a version number if application has been updated', () => { const version = '0.1.45'; vm = mountComponent(ApplicationRow, { ...DEFAULT_APPLICATION_STATE, @@ -363,15 +361,15 @@ describe('Application Row', () => { updateSuccessful: true, version, }); - const upgradeDetails = vm.$el.querySelector('.js-cluster-application-upgrade-details'); - const versionEl = vm.$el.querySelector('.js-cluster-application-upgrade-version'); + const updateDetails = vm.$el.querySelector('.js-cluster-application-update-details'); + const versionEl = vm.$el.querySelector('.js-cluster-application-update-version'); - expect(upgradeDetails.innerHTML).toContain('Upgraded'); + expect(updateDetails.innerHTML).toContain('Updated'); expect(versionEl).not.toBe(null); expect(versionEl.innerHTML).toContain(version); }); - it('contains a link to the chart repo if application has been upgraded', () => { + it('contains a link to the chart repo if application has been updated', () => { const version = '0.1.45'; const chartRepo = 'https://gitlab.com/charts/gitlab-runner'; vm = mountComponent(ApplicationRow, { @@ -381,13 +379,13 @@ describe('Application Row', () => { chartRepo, version, }); - const versionEl = vm.$el.querySelector('.js-cluster-application-upgrade-version'); + const versionEl = vm.$el.querySelector('.js-cluster-application-update-version'); expect(versionEl.href).toEqual(chartRepo); expect(versionEl.target).toEqual('_blank'); }); - it('does not display a version number if application upgrade failed', () => { + it('does not display a version number if application update failed', () => { const version = '0.1.45'; vm = mountComponent(ApplicationRow, { ...DEFAULT_APPLICATION_STATE, @@ -395,10 +393,10 @@ describe('Application Row', () => { updateFailed: true, version, }); - const upgradeDetails = vm.$el.querySelector('.js-cluster-application-upgrade-details'); - const versionEl = vm.$el.querySelector('.js-cluster-application-upgrade-version'); + const updateDetails = vm.$el.querySelector('.js-cluster-application-update-details'); + const versionEl = vm.$el.querySelector('.js-cluster-application-update-version'); - expect(upgradeDetails.innerHTML).toContain('failed'); + expect(updateDetails.innerHTML).toContain('failed'); expect(versionEl).toBe(null); }); }); diff --git a/spec/frontend/clusters/services/application_state_machine_spec.js b/spec/frontend/clusters/services/application_state_machine_spec.js index e057e2ac955..c146ef79be7 100644 --- a/spec/frontend/clusters/services/application_state_machine_spec.js +++ b/spec/frontend/clusters/services/application_state_machine_spec.js @@ -127,7 +127,7 @@ describe('applicationStateMachine', () => { describe(`current state is ${UPDATING}`, () => { it.each` expectedState | event | effects - ${INSTALLED} | ${UPDATED} | ${{ updateSuccessful: true, updateAcknowledged: false }} + ${INSTALLED} | ${UPDATED} | ${{ updateSuccessful: true }} ${INSTALLED} | ${UPDATE_ERRORED} | ${{ updateFailed: true }} `(`transitions to $expectedState on $event event and applies $effects`, data => { const { expectedState, event, effects } = data; diff --git a/spec/frontend/clusters/stores/clusters_store_spec.js b/spec/frontend/clusters/stores/clusters_store_spec.js index 0d129349799..f2cc413512d 100644 --- a/spec/frontend/clusters/stores/clusters_store_spec.js +++ b/spec/frontend/clusters/stores/clusters_store_spec.js @@ -85,11 +85,10 @@ describe('Clusters Store', () => { statusReason: mockResponseData.applications[2].status_reason, requestReason: null, version: mockResponseData.applications[2].version, - upgradeAvailable: mockResponseData.applications[2].update_available, + updateAvailable: mockResponseData.applications[2].update_available, chartRepo: 'https://gitlab.com/charts/gitlab-runner', installed: false, installFailed: false, - updateAcknowledged: true, updateFailed: false, updateSuccessful: false, uninstallable: false, |