Commit 940c812d authored by Enrique Alcántara's avatar Enrique Alcántara Committed by Phil Hughes

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.
parent 431f33fe
...@@ -142,8 +142,7 @@ export default class Clusters { ...@@ -142,8 +142,7 @@ export default class Clusters {
addListeners() { addListeners() {
if (this.showTokenButton) this.showTokenButton.addEventListener('click', this.showToken); if (this.showTokenButton) this.showTokenButton.addEventListener('click', this.showToken);
eventHub.$on('installApplication', this.installApplication); eventHub.$on('installApplication', this.installApplication);
eventHub.$on('upgradeApplication', data => this.upgradeApplication(data)); eventHub.$on('updateApplication', data => this.updateApplication(data));
eventHub.$on('dismissUpgradeSuccess', appId => this.dismissUpgradeSuccess(appId));
eventHub.$on('saveKnativeDomain', data => this.saveKnativeDomain(data)); eventHub.$on('saveKnativeDomain', data => this.saveKnativeDomain(data));
eventHub.$on('setKnativeHostname', data => this.setKnativeHostname(data)); eventHub.$on('setKnativeHostname', data => this.setKnativeHostname(data));
eventHub.$on('uninstallApplication', data => this.uninstallApplication(data)); eventHub.$on('uninstallApplication', data => this.uninstallApplication(data));
...@@ -155,8 +154,7 @@ export default class Clusters { ...@@ -155,8 +154,7 @@ export default class Clusters {
removeListeners() { removeListeners() {
if (this.showTokenButton) this.showTokenButton.removeEventListener('click', this.showToken); if (this.showTokenButton) this.showTokenButton.removeEventListener('click', this.showToken);
eventHub.$off('installApplication', this.installApplication); eventHub.$off('installApplication', this.installApplication);
eventHub.$off('upgradeApplication', this.upgradeApplication); eventHub.$off('updateApplication', this.updateApplication);
eventHub.$off('dismissUpgradeSuccess', this.dismissUpgradeSuccess);
eventHub.$off('saveKnativeDomain'); eventHub.$off('saveKnativeDomain');
eventHub.$off('setKnativeHostname'); eventHub.$off('setKnativeHostname');
eventHub.$off('uninstallApplication'); eventHub.$off('uninstallApplication');
...@@ -331,19 +329,13 @@ export default class Clusters { ...@@ -331,19 +329,13 @@ export default class Clusters {
}); });
} }
upgradeApplication(data) { updateApplication({ id: appId, params }) {
const appId = data.id;
this.store.updateApplication(appId); this.store.updateApplication(appId);
this.service.installApplication(appId, data.params).catch(() => { this.service.installApplication(appId, params).catch(() => {
this.store.notifyUpdateFailure(appId); this.store.notifyUpdateFailure(appId);
}); });
} }
dismissUpgradeSuccess(appId) {
this.store.acknowledgeSuccessfulUpdate(appId);
}
toggleIngressDomainHelpText({ externalIp }, { externalIp: newExternalIp }) { toggleIngressDomainHelpText({ externalIp }, { externalIp: newExternalIp }) {
if (externalIp !== newExternalIp) { if (externalIp !== newExternalIp) {
this.ingressDomainHelpText.classList.toggle('hide', !newExternalIp); this.ingressDomainHelpText.classList.toggle('hide', !newExternalIp);
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/* eslint-disable vue/require-default-prop */ /* eslint-disable vue/require-default-prop */
import { GlLink, GlModalDirective } from '@gitlab/ui'; import { GlLink, GlModalDirective } from '@gitlab/ui';
import TimeagoTooltip from '../../vue_shared/components/time_ago_tooltip.vue'; import TimeagoTooltip from '../../vue_shared/components/time_ago_tooltip.vue';
import { s__, sprintf } from '../../locale'; import { s__, __, sprintf } from '~/locale';
import eventHub from '../event_hub'; import eventHub from '../event_hub';
import identicon from '../../vue_shared/components/identicon.vue'; import identicon from '../../vue_shared/components/identicon.vue';
import loadingButton from '../../vue_shared/components/loading_button.vue'; import loadingButton from '../../vue_shared/components/loading_button.vue';
...@@ -85,7 +85,7 @@ export default { ...@@ -85,7 +85,7 @@ export default {
type: String, type: String,
required: false, required: false,
}, },
upgradeAvailable: { updateAvailable: {
type: Boolean, type: Boolean,
required: false, required: false,
}, },
...@@ -113,11 +113,6 @@ export default { ...@@ -113,11 +113,6 @@ export default {
required: false, required: false,
default: false, default: false,
}, },
updateAcknowledged: {
type: Boolean,
required: false,
default: true,
},
installApplicationRequestParams: { installApplicationRequestParams: {
type: Object, type: Object,
required: false, required: false,
...@@ -174,11 +169,11 @@ export default { ...@@ -174,11 +169,11 @@ export default {
installButtonLabel() { installButtonLabel() {
let label; let label;
if (this.canInstall) { if (this.canInstall) {
label = s__('ClusterIntegration|Install'); label = __('Install');
} else if (this.isInstalling) { } else if (this.isInstalling) {
label = s__('ClusterIntegration|Installing'); label = __('Installing');
} else if (this.installed) { } else if (this.installed) {
label = s__('ClusterIntegration|Installed'); label = __('Installed');
} }
return label; return label;
...@@ -187,7 +182,7 @@ export default { ...@@ -187,7 +182,7 @@ export default {
return this.manageLink && this.status === APPLICATION_STATUS.INSTALLED; return this.manageLink && this.status === APPLICATION_STATUS.INSTALLED;
}, },
manageButtonLabel() { manageButtonLabel() {
return s__('ClusterIntegration|Manage'); return __('Manage');
}, },
hasError() { hasError() {
return this.installFailed || this.uninstallFailed; return this.installFailed || this.uninstallFailed;
...@@ -207,42 +202,42 @@ export default { ...@@ -207,42 +202,42 @@ export default {
}, },
versionLabel() { versionLabel() {
if (this.updateFailed) { if (this.updateFailed) {
return s__('ClusterIntegration|Upgrade failed'); return __('Update failed');
} else if (this.isUpgrading) { } else if (this.isUpdating) {
return s__('ClusterIntegration|Upgrading'); return __('Updating');
} }
return s__('ClusterIntegration|Upgraded'); return __('Updated');
}, },
upgradeFailureDescription() { updateFailureDescription() {
return s__('ClusterIntegration|Update failed. Please check the logs and try again.'); return s__('ClusterIntegration|Update failed. Please check the logs and try again.');
}, },
upgradeSuccessDescription() { updateSuccessDescription() {
return sprintf(s__('ClusterIntegration|%{title} upgraded successfully.'), { return sprintf(s__('ClusterIntegration|%{title} updated successfully.'), {
title: this.title, title: this.title,
}); });
}, },
upgradeButtonLabel() { updateButtonLabel() {
let label; let label;
if (this.upgradeAvailable && !this.updateFailed && !this.isUpgrading) { if (this.updateAvailable && !this.updateFailed && !this.isUpdating) {
label = s__('ClusterIntegration|Upgrade'); label = __('Update');
} else if (this.isUpgrading) { } else if (this.isUpdating) {
label = s__('ClusterIntegration|Updating'); label = __('Updating');
} else if (this.updateFailed) { } else if (this.updateFailed) {
label = s__('ClusterIntegration|Retry update'); label = __('Retry update');
} }
return label; return label;
}, },
isUpgrading() { isUpdating() {
// Since upgrading is handled asynchronously on the backend we need this check to prevent any delay on the frontend // Since upgrading is handled asynchronously on the backend we need this check to prevent any delay on the frontend
return this.status === APPLICATION_STATUS.UPDATING; return this.status === APPLICATION_STATUS.UPDATING;
}, },
shouldShowUpgradeDetails() { shouldShowUpdateDetails() {
// This method only returns true when; // This method only returns true when;
// Upgrade was successful OR Upgrade failed // Update was successful OR Update failed
// AND new upgrade is unavailable AND version information is present. // AND new update is unavailable AND version information is present.
return (this.updateSuccessful || this.updateFailed) && !this.upgradeAvailable && this.version; return (this.updateSuccessful || this.updateFailed) && !this.updateAvailable && this.version;
}, },
uninstallSuccessDescription() { uninstallSuccessDescription() {
return sprintf(s__('ClusterIntegration|%{title} uninstalled successfully.'), { return sprintf(s__('ClusterIntegration|%{title} uninstalled successfully.'), {
...@@ -253,7 +248,7 @@ export default { ...@@ -253,7 +248,7 @@ export default {
watch: { watch: {
updateSuccessful(updateSuccessful) { updateSuccessful(updateSuccessful) {
if (updateSuccessful) { if (updateSuccessful) {
this.$toast.show(this.upgradeSuccessDescription); this.$toast.show(this.updateSuccessDescription);
} }
}, },
uninstallSuccessful(uninstallSuccessful) { uninstallSuccessful(uninstallSuccessful) {
...@@ -269,8 +264,8 @@ export default { ...@@ -269,8 +264,8 @@ export default {
params: this.installApplicationRequestParams, params: this.installApplicationRequestParams,
}); });
}, },
upgradeClicked() { updateClicked() {
eventHub.$emit('upgradeApplication', { eventHub.$emit('updateApplication', {
id: this.id, id: this.id,
params: this.installApplicationRequestParams, params: this.installApplicationRequestParams,
}); });
...@@ -332,8 +327,8 @@ export default { ...@@ -332,8 +327,8 @@ export default {
<div v-if="updateable"> <div v-if="updateable">
<div <div
v-if="shouldShowUpgradeDetails" v-if="shouldShowUpdateDetails"
class="form-text text-muted label p-0 js-cluster-application-upgrade-details" class="form-text text-muted label p-0 js-cluster-application-update-details"
> >
{{ versionLabel }} {{ versionLabel }}
<span v-if="updateSuccessful">to</span> <span v-if="updateSuccessful">to</span>
...@@ -342,24 +337,24 @@ export default { ...@@ -342,24 +337,24 @@ export default {
v-if="updateSuccessful" v-if="updateSuccessful"
:href="chartRepo" :href="chartRepo"
target="_blank" target="_blank"
class="js-cluster-application-upgrade-version" class="js-cluster-application-update-version"
>chart v{{ version }}</gl-link >chart v{{ version }}</gl-link
> >
</div> </div>
<div <div
v-if="updateFailed && !isUpgrading" v-if="updateFailed && !isUpdating"
class="bs-callout bs-callout-danger cluster-application-banner mt-2 mb-0 js-cluster-application-upgrade-failure-message" class="bs-callout bs-callout-danger cluster-application-banner mt-2 mb-0 js-cluster-application-update-details"
> >
{{ upgradeFailureDescription }} {{ updateFailureDescription }}
</div> </div>
<loading-button <loading-button
v-if="upgradeAvailable || updateFailed || isUpgrading" v-if="updateAvailable || updateFailed || isUpdating"
class="btn btn-primary js-cluster-application-upgrade-button mt-2" class="btn btn-primary js-cluster-application-update-button mt-2"
:loading="isUpgrading" :loading="isUpdating"
:disabled="isUpgrading" :disabled="isUpdating"
:label="upgradeButtonLabel" :label="updateButtonLabel"
@click="upgradeClicked" @click="updateClicked"
/> />
</div> </div>
</div> </div>
......
...@@ -376,7 +376,7 @@ export default { ...@@ -376,7 +376,7 @@ export default {
:request-reason="applications.runner.requestReason" :request-reason="applications.runner.requestReason"
:version="applications.runner.version" :version="applications.runner.version"
:chart-repo="applications.runner.chartRepo" :chart-repo="applications.runner.chartRepo"
:upgrade-available="applications.runner.upgradeAvailable" :update-available="applications.runner.updateAvailable"
:installed="applications.runner.installed" :installed="applications.runner.installed"
:install-failed="applications.runner.installFailed" :install-failed="applications.runner.installFailed"
:update-successful="applications.runner.updateSuccessful" :update-successful="applications.runner.updateSuccessful"
......
...@@ -123,7 +123,6 @@ const applicationStateMachine = { ...@@ -123,7 +123,6 @@ const applicationStateMachine = {
target: INSTALLED, target: INSTALLED,
effects: { effects: {
updateSuccessful: true, updateSuccessful: true,
updateAcknowledged: false,
}, },
}, },
[UPDATE_ERRORED]: { [UPDATE_ERRORED]: {
......
...@@ -56,8 +56,7 @@ export default class ClusterStore { ...@@ -56,8 +56,7 @@ export default class ClusterStore {
title: s__('ClusterIntegration|GitLab Runner'), title: s__('ClusterIntegration|GitLab Runner'),
version: null, version: null,
chartRepo: 'https://gitlab.com/charts/gitlab-runner', chartRepo: 'https://gitlab.com/charts/gitlab-runner',
upgradeAvailable: null, updateAvailable: null,
updateAcknowledged: true,
updateSuccessful: false, updateSuccessful: false,
updateFailed: false, updateFailed: false,
}, },
...@@ -136,10 +135,6 @@ export default class ClusterStore { ...@@ -136,10 +135,6 @@ export default class ClusterStore {
this.state.applications[appId] = transitionApplicationState(currentAppState, event); this.state.applications[appId] = transitionApplicationState(currentAppState, event);
} }
acknowledgeSuccessfulUpdate(appId) {
this.state.applications[appId].updateAcknowledged = true;
}
updateAppProperty(appId, prop, value) { updateAppProperty(appId, prop, value) {
this.state.applications[appId][prop] = value; this.state.applications[appId][prop] = value;
} }
...@@ -154,7 +149,7 @@ export default class ClusterStore { ...@@ -154,7 +149,7 @@ export default class ClusterStore {
status, status,
status_reason: statusReason, status_reason: statusReason,
version, version,
update_available: upgradeAvailable, update_available: updateAvailable,
can_uninstall: uninstallable, can_uninstall: uninstallable,
} = serverAppEntry; } = serverAppEntry;
const currentApplicationState = this.state.applications[appId] || {}; const currentApplicationState = this.state.applications[appId] || {};
...@@ -191,7 +186,7 @@ export default class ClusterStore { ...@@ -191,7 +186,7 @@ export default class ClusterStore {
serverAppEntry.external_hostname || this.state.applications.knative.externalHostname; serverAppEntry.external_hostname || this.state.applications.knative.externalHostname;
} else if (appId === RUNNER) { } else if (appId === RUNNER) {
this.state.applications.runner.version = version; this.state.applications.runner.version = version;
this.state.applications.runner.upgradeAvailable = upgradeAvailable; this.state.applications.runner.updateAvailable = updateAvailable;
} }
}); });
} }
......
...@@ -2136,7 +2136,7 @@ msgstr "" ...@@ -2136,7 +2136,7 @@ msgstr ""
msgid "ClusterIntegration|%{title} uninstalled successfully." msgid "ClusterIntegration|%{title} uninstalled successfully."
msgstr "" msgstr ""
msgid "ClusterIntegration|%{title} upgraded successfully." msgid "ClusterIntegration|%{title} updated successfully."
msgstr "" msgstr ""
msgid "ClusterIntegration|A service token scoped to %{code}kube-system%{end_code} with %{code}cluster-admin%{end_code} privileges." msgid "ClusterIntegration|A service token scoped to %{code}kube-system%{end_code} with %{code}cluster-admin%{end_code} privileges."
...@@ -2331,15 +2331,6 @@ msgstr "" ...@@ -2331,15 +2331,6 @@ msgstr ""
msgid "ClusterIntegration|Ingress gives you a way to route requests to services based on the request host or path, centralizing a number of services into a single entrypoint." msgid "ClusterIntegration|Ingress gives you a way to route requests to services based on the request host or path, centralizing a number of services into a single entrypoint."
msgstr "" msgstr ""
msgid "ClusterIntegration|Install"
msgstr ""
msgid "ClusterIntegration|Installed"
msgstr ""
msgid "ClusterIntegration|Installing"
msgstr ""
msgid "ClusterIntegration|Installing Ingress may incur additional costs. Learn more about %{pricingLink}." msgid "ClusterIntegration|Installing Ingress may incur additional costs. Learn more about %{pricingLink}."
msgstr "" msgstr ""
...@@ -2427,9 +2418,6 @@ msgstr "" ...@@ -2427,9 +2418,6 @@ msgstr ""
msgid "ClusterIntegration|Make sure your account %{link_to_requirements} to create Kubernetes clusters" msgid "ClusterIntegration|Make sure your account %{link_to_requirements} to create Kubernetes clusters"
msgstr "" msgstr ""
msgid "ClusterIntegration|Manage"
msgstr ""
msgid "ClusterIntegration|Manage your Kubernetes cluster by visiting %{link_gke}" msgid "ClusterIntegration|Manage your Kubernetes cluster by visiting %{link_gke}"
msgstr "" msgstr ""
...@@ -2496,9 +2484,6 @@ msgstr "" ...@@ -2496,9 +2484,6 @@ msgstr ""
msgid "ClusterIntegration|Request to begin uninstalling failed" msgid "ClusterIntegration|Request to begin uninstalling failed"
msgstr "" msgstr ""
msgid "ClusterIntegration|Retry update"
msgstr ""
msgid "ClusterIntegration|Save changes" msgid "ClusterIntegration|Save changes"
msgstr "" msgstr ""
...@@ -2598,21 +2583,6 @@ msgstr "" ...@@ -2598,21 +2583,6 @@ msgstr ""
msgid "ClusterIntegration|Update failed. Please check the logs and try again." msgid "ClusterIntegration|Update failed. Please check the logs and try again."
msgstr "" msgstr ""
msgid "ClusterIntegration|Updating"
msgstr ""
msgid "ClusterIntegration|Upgrade"
msgstr ""
msgid "ClusterIntegration|Upgrade failed"
msgstr ""
msgid "ClusterIntegration|Upgraded"
msgstr ""
msgid "ClusterIntegration|Upgrading"
msgstr ""
msgid "ClusterIntegration|Validating project billing status" msgid "ClusterIntegration|Validating project billing status"
msgstr "" msgstr ""
...@@ -5339,6 +5309,9 @@ msgstr "" ...@@ -5339,6 +5309,9 @@ msgstr ""
msgid "Insert suggestion" msgid "Insert suggestion"
msgstr "" msgstr ""
msgid "Install"
msgstr ""
msgid "Install GitLab Runner" msgid "Install GitLab Runner"
msgstr "" msgstr ""
...@@ -5348,6 +5321,12 @@ msgstr "" ...@@ -5348,6 +5321,12 @@ msgstr ""
msgid "Install a soft token authenticator like %{free_otp_link} or Google Authenticator from your application repository and scan this QR code. More information is available in the %{help_link_start}documentation%{help_link_end}." msgid "Install a soft token authenticator like %{free_otp_link} or Google Authenticator from your application repository and scan this QR code. More information is available in the %{help_link_start}documentation%{help_link_end}."
msgstr "" msgstr ""
msgid "Installed"
msgstr ""
msgid "Installing"
msgstr ""
msgid "Instance Statistics" msgid "Instance Statistics"
msgstr "" msgstr ""
...@@ -5940,6 +5919,9 @@ msgstr "" ...@@ -5940,6 +5919,9 @@ msgstr ""
msgid "Makes this issue confidential" msgid "Makes this issue confidential"
msgstr "" msgstr ""
msgid "Manage"
msgstr ""
msgid "Manage Git repositories with fine-grained access controls that keep your code secure. Perform code reviews and enhance collaboration with merge requests. Each project can also have an issue tracker and a wiki." msgid "Manage Git repositories with fine-grained access controls that keep your code secure. Perform code reviews and enhance collaboration with merge requests. Each project can also have an issue tracker and a wiki."
msgstr "" msgstr ""
...@@ -8535,6 +8517,9 @@ msgstr "" ...@@ -8535,6 +8517,9 @@ msgstr ""
msgid "Retry this job in order to create the necessary resources." msgid "Retry this job in order to create the necessary resources."
msgstr "" msgstr ""
msgid "Retry update"
msgstr ""
msgid "Retry verification" msgid "Retry verification"
msgstr "" msgstr ""
...@@ -11011,6 +10996,9 @@ msgstr "" ...@@ -11011,6 +10996,9 @@ msgstr ""
msgid "UpdateProject|Project could not be updated!" msgid "UpdateProject|Project could not be updated!"
msgstr "" msgstr ""
msgid "Updated"
msgstr ""
msgid "Updating" msgid "Updating"
msgstr "" msgstr ""
......
...@@ -8,8 +8,8 @@ module QA ...@@ -8,8 +8,8 @@ module QA
class Show < Page::Base class Show < Page::Base
view 'app/assets/javascripts/clusters/components/application_row.vue' do view 'app/assets/javascripts/clusters/components/application_row.vue' do
element :application_row, 'js-cluster-application-row-${this.id}' # rubocop:disable QA/ElementWithPattern element :application_row, 'js-cluster-application-row-${this.id}' # rubocop:disable QA/ElementWithPattern
element :install_button, "s__('ClusterIntegration|Install')" # rubocop:disable QA/ElementWithPattern element :install_button, "__('Install')" # rubocop:disable QA/ElementWithPattern
element :installed_button, "s__('ClusterIntegration|Installed')" # rubocop:disable QA/ElementWithPattern element :installed_button, "__('Installed')" # rubocop:disable QA/ElementWithPattern
end end
view 'app/assets/javascripts/clusters/components/applications.vue' do view 'app/assets/javascripts/clusters/components/applications.vue' do
......
import Clusters from '~/clusters/clusters_bundle'; 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 MockAdapter from 'axios-mock-adapter';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { loadHTMLFixture } from 'helpers/fixtures'; import { loadHTMLFixture } from 'helpers/fixtures';
...@@ -353,4 +358,30 @@ describe('Clusters', () => { ...@@ -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);
});
});
}); });
...@@ -245,26 +245,26 @@ describe('Application Row', () => { ...@@ -245,26 +245,26 @@ describe('Application Row', () => {
}); });
}); });
describe('Upgrade button', () => { describe('Update button', () => {
it('has indeterminate state on page load', () => { it('has indeterminate state on page load', () => {
vm = mountComponent(ApplicationRow, { vm = mountComponent(ApplicationRow, {
...DEFAULT_APPLICATION_STATE, ...DEFAULT_APPLICATION_STATE,
status: null, 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, { vm = mountComponent(ApplicationRow, {
...DEFAULT_APPLICATION_STATE, ...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(updateBtn).not.toBe(null);
expect(upgradeBtn.innerHTML).toContain('Upgrade'); expect(updateBtn.innerHTML).toContain('Update');
}); });
it('has enabled "Retry update" when update process fails', () => { it('has enabled "Retry update" when update process fails', () => {
...@@ -273,10 +273,10 @@ describe('Application Row', () => { ...@@ -273,10 +273,10 @@ describe('Application Row', () => {
status: APPLICATION_STATUS.INSTALLED, status: APPLICATION_STATUS.INSTALLED,
updateFailed: true, 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(updateBtn).not.toBe(null);
expect(upgradeBtn.innerHTML).toContain('Retry update'); expect(updateBtn.innerHTML).toContain('Retry update');
}); });
it('has disabled "Updating" when APPLICATION_STATUS.UPDATING', () => { it('has disabled "Updating" when APPLICATION_STATUS.UPDATING', () => {
...@@ -284,53 +284,51 @@ describe('Application Row', () => { ...@@ -284,53 +284,51 @@ describe('Application Row', () => {
...DEFAULT_APPLICATION_STATE, ...DEFAULT_APPLICATION_STATE,
status: APPLICATION_STATUS.UPDATING, 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(updateBtn).not.toBe(null);
expect(vm.isUpgrading).toBe(true); expect(vm.isUpdating).toBe(true);
expect(upgradeBtn.innerHTML).toContain('Updating'); expect(updateBtn.innerHTML).toContain('Updating');
}); });
it('clicking upgrade button emits event', () => { it('clicking update button emits event', () => {
jest.spyOn(eventHub, '$emit'); jest.spyOn(eventHub, '$emit');
vm = mountComponent(ApplicationRow, { vm = mountComponent(ApplicationRow, {
...DEFAULT_APPLICATION_STATE, ...DEFAULT_APPLICATION_STATE,
status: APPLICATION_STATUS.INSTALLED, 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, id: DEFAULT_APPLICATION_STATE.id,
params: {}, params: {},
}); });
}); });
it('clicking disabled upgrade button emits nothing', () => { it('clicking disabled update button emits nothing', () => {
jest.spyOn(eventHub, '$emit'); jest.spyOn(eventHub, '$emit');
vm = mountComponent(ApplicationRow, { vm = mountComponent(ApplicationRow, {
...DEFAULT_APPLICATION_STATE, ...DEFAULT_APPLICATION_STATE,
status: APPLICATION_STATUS.UPDATING, 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(); 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, { vm = mountComponent(ApplicationRow, {
...DEFAULT_APPLICATION_STATE, ...DEFAULT_APPLICATION_STATE,
title: 'GitLab Runner', title: 'GitLab Runner',
status: APPLICATION_STATUS.INSTALLED, status: APPLICATION_STATUS.INSTALLED,
updateFailed: true, updateFailed: true,
}); });
const failureMessage = vm.$el.querySelector( const failureMessage = vm.$el.querySelector('.js-cluster-application-update-details');
'.js-cluster-application-upgrade-failure-message',
);
expect(failureMessage).not.toBe(null); expect(failureMessage).not.toBe(null);
expect(failureMessage.innerHTML).toContain( expect(failureMessage.innerHTML).toContain(
...@@ -338,7 +336,7 @@ describe('Application Row', () => { ...@@ -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, { vm = mountComponent(ApplicationRow, {
...DEFAULT_APPLICATION_STATE, ...DEFAULT_APPLICATION_STATE,
title: 'GitLab Runner', title: 'GitLab Runner',
...@@ -349,13 +347,13 @@ describe('Application Row', () => { ...@@ -349,13 +347,13 @@ describe('Application Row', () => {
vm.updateSuccessful = true; vm.updateSuccessful = true;
return vm.$nextTick(() => { return vm.$nextTick(() => {
expect(vm.$toast.show).toHaveBeenCalledWith('GitLab Runner upgraded successfully.'); expect(vm.$toast.show).toHaveBeenCalledWith('GitLab Runner updated successfully.');
}); });
}); });
}); });
describe('Version', () => { 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'; const version = '0.1.45';
vm = mountComponent(ApplicationRow, { vm = mountComponent(ApplicationRow, {
...DEFAULT_APPLICATION_STATE, ...DEFAULT_APPLICATION_STATE,
...@@ -363,15 +361,15 @@ describe('Application Row', () => { ...@@ -363,15 +361,15 @@ describe('Application Row', () => {
updateSuccessful: true, updateSuccessful: true,
version, version,
}); });
const upgradeDetails = vm.$el.querySelector('.js-cluster-application-upgrade-details'); const updateDetails = vm.$el.querySelector('.js-cluster-application-update-details');
const versionEl = vm.$el.querySelector('.js-cluster-application-upgrade-version'); 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).not.toBe(null);
expect(versionEl.innerHTML).toContain(version); 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 version = '0.1.45';
const chartRepo = 'https://gitlab.com/charts/gitlab-runner'; const chartRepo = 'https://gitlab.com/charts/gitlab-runner';
vm = mountComponent(ApplicationRow, { vm = mountComponent(ApplicationRow, {
...@@ -381,13 +379,13 @@ describe('Application Row', () => { ...@@ -381,13 +379,13 @@ describe('Application Row', () => {
chartRepo, chartRepo,
version, 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.href).toEqual(chartRepo);
expect(versionEl.target).toEqual('_blank'); 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'; const version = '0.1.45';
vm = mountComponent(ApplicationRow, { vm = mountComponent(ApplicationRow, {
...DEFAULT_APPLICATION_STATE, ...DEFAULT_APPLICATION_STATE,
...@@ -395,10 +393,10 @@ describe('Application Row', () => { ...@@ -395,10 +393,10 @@ describe('Application Row', () => {
updateFailed: true, updateFailed: true,
version, version,
}); });
const upgradeDetails = vm.$el.querySelector('.js-cluster-application-upgrade-details'); const updateDetails = vm.$el.querySelector('.js-cluster-application-update-details');
const versionEl = vm.$el.querySelector('.js-cluster-application-upgrade-version'); const versionEl = vm.$el.querySelector('.js-cluster-application-update-version');
expect(upgradeDetails.innerHTML).toContain('failed'); expect(updateDetails.innerHTML).toContain('failed');
expect(versionEl).toBe(null); expect(versionEl).toBe(null);
}); });
}); });
......
...@@ -127,7 +127,7 @@ describe('applicationStateMachine', () => { ...@@ -127,7 +127,7 @@ describe('applicationStateMachine', () => {
describe(`current state is ${UPDATING}`, () => { describe(`current state is ${UPDATING}`, () => {
it.each` it.each`
expectedState | event | effects expectedState | event | effects
${INSTALLED} | ${UPDATED} | ${{ updateSuccessful: true, updateAcknowledged: false }} ${INSTALLED} | ${UPDATED} | ${{ updateSuccessful: true }}
${INSTALLED} | ${UPDATE_ERRORED} | ${{ updateFailed: true }} ${INSTALLED} | ${UPDATE_ERRORED} | ${{ updateFailed: true }}
`(`transitions to $expectedState on $event event and applies $effects`, data => { `(`transitions to $expectedState on $event event and applies $effects`, data => {
const { expectedState, event, effects } = data; const { expectedState, event, effects } = data;
......
...@@ -85,11 +85,10 @@ describe('Clusters Store', () => { ...@@ -85,11 +85,10 @@ describe('Clusters Store', () => {
statusReason: mockResponseData.applications[2].status_reason, statusReason: mockResponseData.applications[2].status_reason,
requestReason: null, requestReason: null,
version: mockResponseData.applications[2].version, version: mockResponseData.applications[2].version,
upgradeAvailable: mockResponseData.applications[2].update_available, updateAvailable: mockResponseData.applications[2].update_available,
chartRepo: 'https://gitlab.com/charts/gitlab-runner', chartRepo: 'https://gitlab.com/charts/gitlab-runner',
installed: false, installed: false,
installFailed: false, installFailed: false,
updateAcknowledged: true,
updateFailed: false, updateFailed: false,
updateSuccessful: false, updateSuccessful: false,
uninstallable: false, uninstallable: false,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment