diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-19 14:01:45 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-19 14:01:45 +0300 |
commit | 9297025d0b7ddf095eb618dfaaab2ff8f2018d8b (patch) | |
tree | 865198c01d1824a9b098127baa3ab980c9cd2c06 /spec/frontend/environments/kubernetes_pods_spec.js | |
parent | 6372471f43ee03c05a7c1f8b0c6ac6b8a7431dbe (diff) |
Add latest changes from gitlab-org/gitlab@16-7-stable-eev16.7.0-rc42
Diffstat (limited to 'spec/frontend/environments/kubernetes_pods_spec.js')
-rw-r--r-- | spec/frontend/environments/kubernetes_pods_spec.js | 57 |
1 files changed, 30 insertions, 27 deletions
diff --git a/spec/frontend/environments/kubernetes_pods_spec.js b/spec/frontend/environments/kubernetes_pods_spec.js index a51c85468b4..6c3e49e4d8a 100644 --- a/spec/frontend/environments/kubernetes_pods_spec.js +++ b/spec/frontend/environments/kubernetes_pods_spec.js @@ -2,10 +2,10 @@ import Vue from 'vue'; import VueApollo from 'vue-apollo'; import { shallowMount } from '@vue/test-utils'; import { GlLoadingIcon } from '@gitlab/ui'; -import { GlSingleStat } from '@gitlab/ui/dist/charts'; import waitForPromises from 'helpers/wait_for_promises'; import createMockApollo from 'helpers/mock_apollo_helper'; import KubernetesPods from '~/environments/components/kubernetes_pods.vue'; +import WorkloadStats from '~/kubernetes_dashboard/components/workload_stats.vue'; import { mockKasTunnelUrl } from './mock_data'; import { k8sPodsMock } from './graphql/mock_data'; @@ -23,8 +23,7 @@ describe('~/environments/components/kubernetes_pods.vue', () => { }; const findLoadingIcon = () => wrapper.findComponent(GlLoadingIcon); - const findAllStats = () => wrapper.findAllComponents(GlSingleStat); - const findSingleStat = (at) => findAllStats().at(at); + const findWorkloadStats = () => wrapper.findComponent(WorkloadStats); const createApolloProvider = () => { const mockResolvers = { @@ -67,37 +66,41 @@ describe('~/environments/components/kubernetes_pods.vue', () => { }); describe('when gets pods data', () => { - it('renders stats', async () => { + it('renders workload stats with the correct data', async () => { createWrapper(); await waitForPromises(); - expect(findAllStats()).toHaveLength(4); + expect(findWorkloadStats().props('stats')).toEqual([ + { + value: 2, + title: 'Running', + }, + { + value: 1, + title: 'Pending', + }, + { + value: 1, + title: 'Succeeded', + }, + { + value: 2, + title: 'Failed', + }, + ]); }); - it.each` - count | title | index - ${2} | ${KubernetesPods.i18n.runningPods} | ${0} - ${1} | ${KubernetesPods.i18n.pendingPods} | ${1} - ${1} | ${KubernetesPods.i18n.succeededPods} | ${2} - ${2} | ${KubernetesPods.i18n.failedPods} | ${3} - `( - 'renders stat with title "$title" and count "$count" at index $index', - async ({ count, title, index }) => { - createWrapper(); - await waitForPromises(); - - expect(findSingleStat(index).props()).toMatchObject({ - value: count, - title, - }); - }, - ); - - it('emits a failed event when there are failed pods', async () => { + it('emits a update-failed-state event for each pod', async () => { createWrapper(); await waitForPromises(); - expect(wrapper.emitted('failed')).toHaveLength(1); + expect(wrapper.emitted('update-failed-state')).toHaveLength(4); + expect(wrapper.emitted('update-failed-state')).toEqual([ + [{ pods: false }], + [{ pods: false }], + [{ pods: false }], + [{ pods: true }], + ]); }); }); @@ -119,7 +122,7 @@ describe('~/environments/components/kubernetes_pods.vue', () => { }); it("doesn't show pods stats", () => { - expect(findAllStats()).toHaveLength(0); + expect(findWorkloadStats().exists()).toBe(false); }); it('emits an error message', () => { |