diff --git a/app/assets/javascripts/ci/runner/components/runner_list.vue b/app/assets/javascripts/ci/runner/components/runner_list.vue index 0282ac10fba03f1ad4505cbf24ffa300bb0897c9..a088e0d84e0cc877829630feb3336e46d76a21d4 100644 --- a/app/assets/javascripts/ci/runner/components/runner_list.vue +++ b/app/assets/javascripts/ci/runner/components/runner_list.vue @@ -8,7 +8,6 @@ import { tableField } from '../utils'; import RunnerBulkDelete from './runner_bulk_delete.vue'; import RunnerBulkDeleteCheckbox from './runner_bulk_delete_checkbox.vue'; import RunnerSummaryCell from './cells/runner_summary_cell.vue'; -import RunnerStatusPopover from './runner_status_popover.vue'; import RunnerStatusCell from './cells/runner_status_cell.vue'; import RunnerOwnerCell from './cells/runner_owner_cell.vue'; @@ -27,7 +26,6 @@ export default { HelpPopover, RunnerBulkDelete, RunnerBulkDeleteCheckbox, - RunnerStatusPopover, RunnerSummaryCell, RunnerStatusCell, RunnerOwnerCell, @@ -143,7 +141,6 @@ export default { <template #head(status)="{ label }"> {{ label }} - <runner-status-popover /> </template> <template #cell(status)="{ item }"> diff --git a/app/assets/javascripts/ci/runner/components/runner_status_badge.vue b/app/assets/javascripts/ci/runner/components/runner_status_badge.vue index c2c52bd756ae46067a4c245fdc7663f117e9305a..8b775197386fed3ee6bf8661447dbcc57baf8c4e 100644 --- a/app/assets/javascripts/ci/runner/components/runner_status_badge.vue +++ b/app/assets/javascripts/ci/runner/components/runner_status_badge.vue @@ -2,29 +2,42 @@ import { GlBadge, GlTooltipDirective } from '@gitlab/ui'; import { __, sprintf } from '~/locale'; import { getTimeago } from '~/lib/utils/datetime_utility'; +import { duration } from '~/lib/utils/datetime/timeago_utility'; import { I18N_STATUS_ONLINE, I18N_STATUS_NEVER_CONTACTED, I18N_STATUS_OFFLINE, I18N_STATUS_STALE, - I18N_ONLINE_TIMEAGO_TOOLTIP, + I18N_ONLINE_TOOLTIP, I18N_NEVER_CONTACTED_TOOLTIP, - I18N_OFFLINE_TIMEAGO_TOOLTIP, - I18N_STALE_TIMEAGO_TOOLTIP, - I18N_STALE_NEVER_CONTACTED_TOOLTIP, + I18N_NEVER_CONTACTED_STALE_TOOLTIP, + I18N_DISCONNECTED_TOOLTIP, STATUS_ONLINE, STATUS_NEVER_CONTACTED, STATUS_OFFLINE, STATUS_STALE, + ONLINE_CONTACT_TIMEOUT_SECS, + STALE_TIMEOUT_SECS, } from '../constants'; export default { + name: 'RunnerStatusBadge', components: { GlBadge, }, directives: { GlTooltip: GlTooltipDirective, }, + inject: { + onlineContactTimeoutSecs: { + // Real value must be provided from ::Ci::Runner::ONLINE_CONTACT_TIMEOUT + default: ONLINE_CONTACT_TIMEOUT_SECS, + }, + staleTimeoutSecs: { + // Real value must be provided from ::Ci::Runner::STALE_TIMEOUT + default: STALE_TIMEOUT_SECS, + }, + }, props: { contactedAt: { type: String, @@ -38,6 +51,12 @@ export default { }, }, computed: { + onlineContactTimeoutDuration() { + return duration(this.onlineContactTimeoutSecs * 1000); + }, + staleTimeoutDuration() { + return duration(this.staleTimeoutSecs * 1000); + }, contactedAtTimeAgo() { if (this.contactedAt) { return getTimeago().format(this.contactedAt); @@ -52,7 +71,9 @@ export default { icon: 'status-active', variant: 'success', label: I18N_STATUS_ONLINE, - tooltip: this.timeAgoTooltip(I18N_ONLINE_TIMEAGO_TOOLTIP), + tooltip: sprintf(I18N_ONLINE_TOOLTIP, { + timeAgo: this.contactedAtTimeAgo, + }), }; case STATUS_NEVER_CONTACTED: return { @@ -66,7 +87,10 @@ export default { icon: 'time-out', variant: 'muted', label: I18N_STATUS_OFFLINE, - tooltip: this.timeAgoTooltip(I18N_OFFLINE_TIMEAGO_TOOLTIP), + tooltip: sprintf(I18N_DISCONNECTED_TOOLTIP, { + elapsedTime: this.onlineContactTimeoutDuration, + timeAgo: this.contactedAtTimeAgo, + }), }; case STATUS_STALE: return { @@ -75,19 +99,19 @@ export default { label: I18N_STATUS_STALE, // runner may have contacted (or not) and be stale: consider both cases. tooltip: this.contactedAt - ? this.timeAgoTooltip(I18N_STALE_TIMEAGO_TOOLTIP) - : I18N_STALE_NEVER_CONTACTED_TOOLTIP, + ? sprintf(I18N_DISCONNECTED_TOOLTIP, { + elapsedTime: this.staleTimeoutDuration, + timeAgo: this.contactedAtTimeAgo, + }) + : sprintf(I18N_NEVER_CONTACTED_STALE_TOOLTIP, { + elapsedTime: this.staleTimeoutDuration, + }), }; default: return null; } }, }, - methods: { - timeAgoTooltip(text) { - return sprintf(text, { timeAgo: this.contactedAtTimeAgo }); - }, - }, }; </script> <template> diff --git a/app/assets/javascripts/ci/runner/components/runner_status_popover.vue b/app/assets/javascripts/ci/runner/components/runner_status_popover.vue deleted file mode 100644 index 06174d39a59244df2724a771d0b336ca55a06ca7..0000000000000000000000000000000000000000 --- a/app/assets/javascripts/ci/runner/components/runner_status_popover.vue +++ /dev/null @@ -1,75 +0,0 @@ -<script> -import { GlSprintf } from '@gitlab/ui'; -import { duration } from '~/lib/utils/datetime/timeago_utility'; -import HelpPopover from '~/vue_shared/components/help_popover.vue'; -import { - I18N_STATUS_POPOVER_TITLE, - I18N_STATUS_POPOVER_NEVER_CONTACTED, - I18N_STATUS_POPOVER_NEVER_CONTACTED_DESCRIPTION, - I18N_STATUS_POPOVER_ONLINE, - I18N_STATUS_POPOVER_ONLINE_DESCRIPTION, - I18N_STATUS_POPOVER_OFFLINE, - I18N_STATUS_POPOVER_OFFLINE_DESCRIPTION, - I18N_STATUS_POPOVER_STALE, - I18N_STATUS_POPOVER_STALE_DESCRIPTION, -} from '~/ci/runner/constants'; - -export default { - name: 'RunnerStatusPopover', - components: { - GlSprintf, - HelpPopover, - }, - inject: ['onlineContactTimeoutSecs', 'staleTimeoutSecs'], - computed: { - onlineContactTimeoutDuration() { - return duration(this.onlineContactTimeoutSecs * 1000); - }, - staleTimeoutDuration() { - return duration(this.staleTimeoutSecs * 1000); - }, - }, - I18N_STATUS_POPOVER_TITLE, - I18N_STATUS_POPOVER_NEVER_CONTACTED, - I18N_STATUS_POPOVER_NEVER_CONTACTED_DESCRIPTION, - I18N_STATUS_POPOVER_ONLINE, - I18N_STATUS_POPOVER_ONLINE_DESCRIPTION, - I18N_STATUS_POPOVER_OFFLINE, - I18N_STATUS_POPOVER_OFFLINE_DESCRIPTION, - I18N_STATUS_POPOVER_STALE, - I18N_STATUS_POPOVER_STALE_DESCRIPTION, -}; -</script> - -<template> - <help-popover> - <template #title>{{ $options.I18N_STATUS_POPOVER_TITLE }}</template> - - <p class="gl-mb-0"> - <strong>{{ $options.I18N_STATUS_POPOVER_NEVER_CONTACTED }}</strong> - <gl-sprintf :message="$options.I18N_STATUS_POPOVER_NEVER_CONTACTED_DESCRIPTION"> - <template #code="{ content }"> - <code>{{ content }}</code> - </template> - </gl-sprintf> - </p> - <p class="gl-mb-0"> - <strong>{{ $options.I18N_STATUS_POPOVER_ONLINE }}</strong> - <gl-sprintf :message="$options.I18N_STATUS_POPOVER_ONLINE_DESCRIPTION"> - <template #elapsedTime>{{ onlineContactTimeoutDuration }}</template> - </gl-sprintf> - </p> - <p class="gl-mb-0"> - <strong>{{ $options.I18N_STATUS_POPOVER_OFFLINE }}</strong> - <gl-sprintf :message="$options.I18N_STATUS_POPOVER_OFFLINE_DESCRIPTION"> - <template #elapsedTime>{{ onlineContactTimeoutDuration }}</template> - </gl-sprintf> - </p> - <p class="gl-mb-0"> - <strong>{{ $options.I18N_STATUS_POPOVER_STALE }}</strong> - <gl-sprintf :message="$options.I18N_STATUS_POPOVER_STALE_DESCRIPTION"> - <template #elapsedTime>{{ staleTimeoutDuration }}</template> - </gl-sprintf> - </p> - </help-popover> -</template> diff --git a/app/assets/javascripts/ci/runner/constants.js b/app/assets/javascripts/ci/runner/constants.js index 571e7ecdf92a9a9faadf325e128431e446b50fd4..db8feda6dbde9bed5004574bee220dfa636a927f 100644 --- a/app/assets/javascripts/ci/runner/constants.js +++ b/app/assets/javascripts/ci/runner/constants.js @@ -39,41 +39,20 @@ export const I18N_STATUS_STALE = s__('Runners|Stale'); export const I18N_JOB_STATUS_RUNNING = s__('Runners|Running'); export const I18N_JOB_STATUS_IDLE = s__('Runners|Idle'); -// Status help popover -export const I18N_STATUS_POPOVER_TITLE = s__('Runners|Runner statuses'); - -export const I18N_STATUS_POPOVER_NEVER_CONTACTED = s__('Runners|Never contacted:'); -export const I18N_STATUS_POPOVER_NEVER_CONTACTED_DESCRIPTION = s__( - 'Runners|Runner has never contacted GitLab (when you register a runner, use %{codeStart}gitlab-runner run%{codeEnd} to bring it online)', -); -export const I18N_STATUS_POPOVER_ONLINE = s__('Runners|Online:'); -export const I18N_STATUS_POPOVER_ONLINE_DESCRIPTION = s__( - 'Runners|Runner has contacted GitLab within the last %{elapsedTime}', -); -export const I18N_STATUS_POPOVER_OFFLINE = s__('Runners|Offline:'); -export const I18N_STATUS_POPOVER_OFFLINE_DESCRIPTION = s__( - 'Runners|Runner has not contacted GitLab in more than %{elapsedTime}', -); -export const I18N_STATUS_POPOVER_STALE = s__('Runners|Stale:'); -export const I18N_STATUS_POPOVER_STALE_DESCRIPTION = s__( - 'Runners|Runner has not contacted GitLab in more than %{elapsedTime}', -); - // Status tooltips -export const I18N_ONLINE_TIMEAGO_TOOLTIP = s__( - 'Runners|Runner is online; last contact was %{timeAgo}', -); +export const I18N_ONLINE_TOOLTIP = s__('Runners|Last contact was %{timeAgo}'); export const I18N_NEVER_CONTACTED_TOOLTIP = s__('Runners|Runner has never contacted this instance'); -export const I18N_OFFLINE_TIMEAGO_TOOLTIP = s__( - 'Runners|Runner is offline; last contact was %{timeAgo}', +export const I18N_NEVER_CONTACTED_STALE_TOOLTIP = s__( + 'Runners|Runner is older than %{elapsedTime} and has never contacted GitLab', ); -export const I18N_STALE_TIMEAGO_TOOLTIP = s__( - 'Runners|Runner is stale; last contact was %{timeAgo}', -); -export const I18N_STALE_NEVER_CONTACTED_TOOLTIP = s__( - 'Runners|Runner is stale; it has never contacted this instance', +export const I18N_DISCONNECTED_TOOLTIP = s__( + "Runners|Runner hasn't contacted GitLab in more than %{elapsedTime} and last contact was %{timeAgo}", ); +// Default online/stale status timeouts, actual values +export const ONLINE_CONTACT_TIMEOUT_SECS = 2 * 60 * 60; // 2 hours +export const STALE_TIMEOUT_SECS = 7889238; // Ruby's `3.months` + // Registration dropdown export const I18N_REGISTER_INSTANCE_TYPE = s__('Runners|Register an instance runner'); export const I18N_REGISTER_GROUP_TYPE = s__('Runners|Register a group runner'); diff --git a/ee/spec/frontend/ci/runner/admin_runners/admin_runners_app_spec.js b/ee/spec/frontend/ci/runner/admin_runners/admin_runners_app_spec.js index b95c55a455cd0c3876497eea2ad8ad47c1556a5d..2831f6d31caf8c4bd839804505086c479df35cd9 100644 --- a/ee/spec/frontend/ci/runner/admin_runners/admin_runners_app_spec.js +++ b/ee/spec/frontend/ci/runner/admin_runners/admin_runners_app_spec.js @@ -16,8 +16,6 @@ import runnerJobCountQuery from '~/ci/runner/graphql/list/runner_job_count.query import { runnerJobCountData, runnersCountData, - onlineContactTimeoutSecs, - staleTimeoutSecs, mockRegistrationToken, newRunnerPath, } from 'jest/ci/runner/mock_data'; @@ -54,8 +52,6 @@ describe('AdminRunnersApp', () => { }, provide: { localMutations, - onlineContactTimeoutSecs, - staleTimeoutSecs, ...provide, }, ...options, diff --git a/ee/spec/frontend/ci/runner/admin_runners/provide_spec.js b/ee/spec/frontend/ci/runner/admin_runners/provide_spec.js index a2597e485e7e825473a4697e22dabc324457ac44..057aed71840dc0b5f0b3562a4415092e0b3925a0 100644 --- a/ee/spec/frontend/ci/runner/admin_runners/provide_spec.js +++ b/ee/spec/frontend/ci/runner/admin_runners/provide_spec.js @@ -1,16 +1,13 @@ import { provide } from 'ee/ci/runner/admin_runners/provide'; -import { - onlineContactTimeoutSecs, - staleTimeoutSecs, - runnerInstallHelpPage, -} from 'jest/ci/runner/mock_data'; +import { runnerInstallHelpPage } from 'jest/ci/runner/mock_data'; import { runnerDashboardPath } from 'ee_jest/ci/runner/mock_data'; +import { ONLINE_CONTACT_TIMEOUT_SECS, STALE_TIMEOUT_SECS } from '~/ci/runner/constants'; const mockDataset = { runnerInstallHelpPage, - onlineContactTimeoutSecs, - staleTimeoutSecs, + onlineContactTimeoutSecs: ONLINE_CONTACT_TIMEOUT_SECS, + staleTimeoutSecs: STALE_TIMEOUT_SECS, runnerDashboardPath, }; diff --git a/ee/spec/frontend/group_settings/components/stale_runner_cleanup_toggle_spec.js b/ee/spec/frontend/group_settings/components/stale_runner_cleanup_toggle_spec.js index 58314851cfab353505664104a8a53aee8823de8c..f9bad438e379c547c6f236a09c065ca7223178bc 100644 --- a/ee/spec/frontend/group_settings/components/stale_runner_cleanup_toggle_spec.js +++ b/ee/spec/frontend/group_settings/components/stale_runner_cleanup_toggle_spec.js @@ -7,7 +7,7 @@ import { confirmAction } from '~/lib/utils/confirm_via_gl_modal/confirm_via_gl_m import { shallowMountExtended, mountExtended } from 'helpers/vue_test_utils_helper'; import waitForPromises from 'helpers/wait_for_promises'; import { createAlert } from '~/alert'; -import { staleTimeoutSecs } from 'jest/ci/runner/mock_data'; +import { STALE_TIMEOUT_SECS } from '~/ci/runner/constants'; import groupStaleRunnerPruningQuery from 'ee/group_settings/graphql/group_stale_runner_pruning.query.graphql'; import setGroupStaleRunnerPruningMutation from 'ee/group_settings/graphql/set_group_stale_runner_pruning.mutation.graphql'; @@ -74,7 +74,7 @@ describe('StaleRunnerCleanupToggle', () => { wrapper = mountFn(StaleRunnerCleanupToggle, { propsData: { groupFullPath: mockGroupFullPath, - staleTimeoutSecs, + staleTimeoutSecs: STALE_TIMEOUT_SECS, }, apolloProvider, }); diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 65bb8ec785da09ba5b52e9127a4a637c13146203..ef18224312a63d4ef49bc613a728e0edce3be187 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -42639,6 +42639,9 @@ msgstr "" msgid "Runners|Last contact" msgstr "" +msgid "Runners|Last contact was %{timeAgo}" +msgstr "" + msgid "Runners|Last contact: %{timeAgo}" msgstr "" @@ -42690,9 +42693,6 @@ msgstr "" msgid "Runners|Never contacted" msgstr "" -msgid "Runners|Never contacted:" -msgstr "" - msgid "Runners|Never expires" msgstr "" @@ -42747,15 +42747,9 @@ msgstr "" msgid "Runners|Offline" msgstr "" -msgid "Runners|Offline:" -msgstr "" - msgid "Runners|Online" msgstr "" -msgid "Runners|Online:" -msgstr "" - msgid "Runners|Only administrators can view this." msgstr "" @@ -42889,16 +42883,10 @@ msgstr "" msgid "Runners|Runner description" msgstr "" -msgid "Runners|Runner has contacted GitLab within the last %{elapsedTime}" -msgstr "" - -msgid "Runners|Runner has never contacted GitLab (when you register a runner, use %{codeStart}gitlab-runner run%{codeEnd} to bring it online)" -msgstr "" - msgid "Runners|Runner has never contacted this instance" msgstr "" -msgid "Runners|Runner has not contacted GitLab in more than %{elapsedTime}" +msgid "Runners|Runner hasn't contacted GitLab in more than %{elapsedTime} and last contact was %{timeAgo}" msgstr "" msgid "Runners|Runner is locked and available for currently assigned projects only. Only administrators can change the assigned projects." @@ -42907,33 +42895,24 @@ msgstr "" msgid "Runners|Runner is offline; last contact was %{runner_contact} ago" msgstr "" -msgid "Runners|Runner is offline; last contact was %{timeAgo}" +msgid "Runners|Runner is older than %{elapsedTime} and has never contacted GitLab" msgstr "" msgid "Runners|Runner is online; last contact was %{runner_contact} ago" msgstr "" -msgid "Runners|Runner is online; last contact was %{timeAgo}" -msgstr "" - msgid "Runners|Runner is stale; it has never contacted this instance" msgstr "" msgid "Runners|Runner is stale; last contact was %{runner_contact} ago" msgstr "" -msgid "Runners|Runner is stale; last contact was %{timeAgo}" -msgstr "" - msgid "Runners|Runner performance insights" msgstr "" msgid "Runners|Runner registration" msgstr "" -msgid "Runners|Runner statuses" -msgstr "" - msgid "Runners|Runner unassigned from project." msgstr "" @@ -43012,9 +42991,6 @@ msgstr "" msgid "Runners|Stale" msgstr "" -msgid "Runners|Stale:" -msgstr "" - msgid "Runners|Status" msgstr "" diff --git a/spec/frontend/ci/runner/admin_runners/admin_runners_app_spec.js b/spec/frontend/ci/runner/admin_runners/admin_runners_app_spec.js index 798cef252c9b5f513a95e585a2437da2568a9ffb..542f3503d2fc5f90f69655adb7e02dab3912e1aa 100644 --- a/spec/frontend/ci/runner/admin_runners/admin_runners_app_spec.js +++ b/spec/frontend/ci/runner/admin_runners/admin_runners_app_spec.js @@ -58,8 +58,6 @@ import { runnersCountData, runnerJobCountData, allRunnersDataPaginated, - onlineContactTimeoutSecs, - staleTimeoutSecs, mockRegistrationToken, newRunnerPath, emptyPageInfo, @@ -123,8 +121,6 @@ describe('AdminRunnersApp', () => { }, provide: { localMutations, - onlineContactTimeoutSecs, - staleTimeoutSecs, ...provide, }, mocks: { diff --git a/spec/frontend/ci/runner/admin_runners/provide_spec.js b/spec/frontend/ci/runner/admin_runners/provide_spec.js index b24ddabbb665a1ce3b5de4187386c4352f74eda3..ef68999acf9f3a12067f5fe280268952f9a49141 100644 --- a/spec/frontend/ci/runner/admin_runners/provide_spec.js +++ b/spec/frontend/ci/runner/admin_runners/provide_spec.js @@ -1,23 +1,20 @@ import { provide } from '~/ci/runner/admin_runners/provide'; -import { - onlineContactTimeoutSecs, - staleTimeoutSecs, - runnerInstallHelpPage, -} from 'jest/ci/runner/mock_data'; +import { runnerInstallHelpPage } from 'jest/ci/runner/mock_data'; +import { ONLINE_CONTACT_TIMEOUT_SECS, STALE_TIMEOUT_SECS } from '~/ci/runner/constants'; const mockDataset = { runnerInstallHelpPage, - onlineContactTimeoutSecs, - staleTimeoutSecs, + onlineContactTimeoutSecs: ONLINE_CONTACT_TIMEOUT_SECS, + staleTimeoutSecs: STALE_TIMEOUT_SECS, }; describe('admin runners provide', () => { it('returns provide values', () => { expect(provide(mockDataset)).toMatchObject({ runnerInstallHelpPage, - onlineContactTimeoutSecs, - staleTimeoutSecs, + onlineContactTimeoutSecs: ONLINE_CONTACT_TIMEOUT_SECS, + staleTimeoutSecs: STALE_TIMEOUT_SECS, }); }); diff --git a/spec/frontend/ci/runner/components/__snapshots__/runner_status_popover_spec.js.snap b/spec/frontend/ci/runner/components/__snapshots__/runner_status_popover_spec.js.snap deleted file mode 100644 index b27a1adf01b8bb882c01d0fbdd70cd3a32b2335e..0000000000000000000000000000000000000000 --- a/spec/frontend/ci/runner/components/__snapshots__/runner_status_popover_spec.js.snap +++ /dev/null @@ -1,3 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`RunnerStatusPopover renders complete text 1`] = `"Never contacted: Runner has never contacted GitLab (when you register a runner, use gitlab-runner run to bring it online) Online: Runner has contacted GitLab within the last 2 hours Offline: Runner has not contacted GitLab in more than 2 hours Stale: Runner has not contacted GitLab in more than 3 months"`; diff --git a/spec/frontend/ci/runner/components/runner_list_spec.js b/spec/frontend/ci/runner/components/runner_list_spec.js index 7c00aa48d31f6f28d95b8d767b0fa37405d6e4f4..30177a1c0fa19b47b17df6606d12054a4f5b2661 100644 --- a/spec/frontend/ci/runner/components/runner_list_spec.js +++ b/spec/frontend/ci/runner/components/runner_list_spec.js @@ -12,7 +12,7 @@ import RunnerBulkDelete from '~/ci/runner/components/runner_bulk_delete.vue'; import RunnerBulkDeleteCheckbox from '~/ci/runner/components/runner_bulk_delete_checkbox.vue'; import { I18N_PROJECT_TYPE, I18N_STATUS_NEVER_CONTACTED } from '~/ci/runner/constants'; -import { allRunnersData, onlineContactTimeoutSecs, staleTimeoutSecs } from '../mock_data'; +import { allRunnersData } from '../mock_data'; const mockRunners = allRunnersData.data.runners.nodes; @@ -41,8 +41,6 @@ describe('RunnerList', () => { }, provide: { localMutations, - onlineContactTimeoutSecs, - staleTimeoutSecs, }, ...options, }); @@ -62,7 +60,6 @@ describe('RunnerList', () => { const headerLabels = findHeaders().wrappers.map((w) => w.text()); - expect(findHeaders().at(0).findComponent(HelpPopover).exists()).toBe(true); expect(findHeaders().at(2).findComponent(HelpPopover).exists()).toBe(true); expect(headerLabels).toEqual([ diff --git a/spec/frontend/ci/runner/components/runner_status_badge_spec.js b/spec/frontend/ci/runner/components/runner_status_badge_spec.js index 781193d8afa8dc8fe9d985f25cdb3e2be5bc5785..05478c1769b08a1d1faab787a77550f06d53f2e6 100644 --- a/spec/frontend/ci/runner/components/runner_status_badge_spec.js +++ b/spec/frontend/ci/runner/components/runner_status_badge_spec.js @@ -7,8 +7,6 @@ import { I18N_STATUS_NEVER_CONTACTED, I18N_STATUS_OFFLINE, I18N_STATUS_STALE, - I18N_NEVER_CONTACTED_TOOLTIP, - I18N_STALE_NEVER_CONTACTED_TOOLTIP, STATUS_ONLINE, STATUS_OFFLINE, STATUS_STALE, @@ -21,7 +19,7 @@ describe('RunnerTypeBadge', () => { const findBadge = () => wrapper.findComponent(GlBadge); const getTooltip = () => getBinding(findBadge().element, 'gl-tooltip'); - const createComponent = ({ props = {} } = {}) => { + const createComponent = ({ props = {}, ...options } = {}) => { wrapper = shallowMount(RunnerStatusBadge, { propsData: { contactedAt: '2020-12-31T23:59:00Z', @@ -31,6 +29,7 @@ describe('RunnerTypeBadge', () => { directives: { GlTooltip: createMockDirective('gl-tooltip'), }, + ...options, }); }; @@ -48,7 +47,7 @@ describe('RunnerTypeBadge', () => { expect(wrapper.text()).toBe(I18N_STATUS_ONLINE); expect(findBadge().props('variant')).toBe('success'); - expect(getTooltip().value).toBe('Runner is online; last contact was 1 minute ago'); + expect(getTooltip().value).toBe('Last contact was 1 minute ago'); }); it('renders never contacted state', () => { @@ -61,7 +60,7 @@ describe('RunnerTypeBadge', () => { expect(wrapper.text()).toBe(I18N_STATUS_NEVER_CONTACTED); expect(findBadge().props('variant')).toBe('muted'); - expect(getTooltip().value).toBe(I18N_NEVER_CONTACTED_TOOLTIP); + expect(getTooltip().value).toBe('Runner has never contacted this instance'); }); it('renders offline state', () => { @@ -74,7 +73,9 @@ describe('RunnerTypeBadge', () => { expect(wrapper.text()).toBe(I18N_STATUS_OFFLINE); expect(findBadge().props('variant')).toBe('muted'); - expect(getTooltip().value).toBe('Runner is offline; last contact was 1 day ago'); + expect(getTooltip().value).toBe( + "Runner hasn't contacted GitLab in more than 2 hours and last contact was 1 day ago", + ); }); it('renders stale state', () => { @@ -87,7 +88,9 @@ describe('RunnerTypeBadge', () => { expect(wrapper.text()).toBe(I18N_STATUS_STALE); expect(findBadge().props('variant')).toBe('warning'); - expect(getTooltip().value).toBe('Runner is stale; last contact was 1 year ago'); + expect(getTooltip().value).toBe( + "Runner hasn't contacted GitLab in more than 3 months and last contact was 1 year ago", + ); }); it('renders stale state with no contact time', () => { @@ -100,7 +103,7 @@ describe('RunnerTypeBadge', () => { expect(wrapper.text()).toBe(I18N_STATUS_STALE); expect(findBadge().props('variant')).toBe('warning'); - expect(getTooltip().value).toBe(I18N_STALE_NEVER_CONTACTED_TOOLTIP); + expect(getTooltip().value).toBe('Runner is older than 3 months and has never contacted GitLab'); }); describe('does not fail when data is missing', () => { @@ -113,7 +116,7 @@ describe('RunnerTypeBadge', () => { }); expect(wrapper.text()).toBe(I18N_STATUS_ONLINE); - expect(getTooltip().value).toBe('Runner is online; last contact was never'); + expect(getTooltip().value).toBe('Last contact was never'); }); it('status is missing', () => { @@ -126,4 +129,34 @@ describe('RunnerTypeBadge', () => { expect(wrapper.text()).toBe(''); }); }); + + describe('default timeout values are overridden', () => { + it('shows a different offline timeout', () => { + createComponent({ + props: { + contactedAt: '2020-12-31T00:00:00Z', + status: STATUS_OFFLINE, + }, + provide: { + onlineContactTimeoutSecs: 60, + }, + }); + + expect(getTooltip().value).toContain('1 minute'); + }); + + it('shows a different stale timeout', () => { + createComponent({ + props: { + contactedAt: '2020-01-01T00:00:00Z', + status: STATUS_STALE, + }, + provide: { + staleTimeoutSecs: 20 * 60, + }, + }); + + expect(getTooltip().value).toContain('20 minutes'); + }); + }); }); diff --git a/spec/frontend/ci/runner/components/runner_status_popover_spec.js b/spec/frontend/ci/runner/components/runner_status_popover_spec.js deleted file mode 100644 index 89fb95f2da4cc432cad46269b4353f1a76832532..0000000000000000000000000000000000000000 --- a/spec/frontend/ci/runner/components/runner_status_popover_spec.js +++ /dev/null @@ -1,36 +0,0 @@ -import { GlSprintf } from '@gitlab/ui'; -import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; -import RunnerStatusPopover from '~/ci/runner/components/runner_status_popover.vue'; -import HelpPopover from '~/vue_shared/components/help_popover.vue'; -import { onlineContactTimeoutSecs, staleTimeoutSecs } from '../mock_data'; - -describe('RunnerStatusPopover', () => { - let wrapper; - - const createComponent = ({ provide = {} } = {}) => { - wrapper = shallowMountExtended(RunnerStatusPopover, { - provide: { - onlineContactTimeoutSecs, - staleTimeoutSecs, - ...provide, - }, - stubs: { - GlSprintf, - }, - }); - }; - - const findHelpPopover = () => wrapper.findComponent(HelpPopover); - - it('renders popoover', () => { - createComponent(); - - expect(findHelpPopover().exists()).toBe(true); - }); - - it('renders complete text', () => { - createComponent(); - - expect(findHelpPopover().text()).toMatchSnapshot(); - }); -}); diff --git a/spec/frontend/ci/runner/group_runners/group_runners_app_spec.js b/spec/frontend/ci/runner/group_runners/group_runners_app_spec.js index 3e4cdecb07b434a4bcee4d4b3b603b729572badc..2af877f86c93da361d2401eb6d2588b3da564493 100644 --- a/spec/frontend/ci/runner/group_runners/group_runners_app_spec.js +++ b/spec/frontend/ci/runner/group_runners/group_runners_app_spec.js @@ -58,8 +58,6 @@ import { groupRunnersDataPaginated, groupRunnersCountData, runnerJobCountData, - onlineContactTimeoutSecs, - staleTimeoutSecs, mockRegistrationToken, newRunnerPath, emptyPageInfo, @@ -124,8 +122,6 @@ describe('GroupRunnersApp', () => { }, provide: { localMutations, - onlineContactTimeoutSecs, - staleTimeoutSecs, ...provide, }, mocks: { diff --git a/spec/frontend/ci/runner/mock_data.js b/spec/frontend/ci/runner/mock_data.js index 58d8e0ee74af82cb4f88bcf082f118a092432f07..783abec9ade0e729330d624495400c3019614131 100644 --- a/spec/frontend/ci/runner/mock_data.js +++ b/spec/frontend/ci/runner/mock_data.js @@ -338,9 +338,6 @@ export const mockSearchExamples = [ }, ]; -export const onlineContactTimeoutSecs = 2 * 60 * 60; -export const staleTimeoutSecs = 7889238; // Ruby's `3.months` - export const mockRegistrationToken = 'MOCK_REGISTRATION_TOKEN'; export const mockAuthenticationToken = 'MOCK_AUTHENTICATION_TOKEN';