Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/serverless')
-rw-r--r--spec/frontend/serverless/components/__snapshots__/empty_state_spec.js.snap22
-rw-r--r--spec/frontend/serverless/components/area_spec.js121
-rw-r--r--spec/frontend/serverless/components/empty_state_spec.js25
-rw-r--r--spec/frontend/serverless/components/environment_row_spec.js68
-rw-r--r--spec/frontend/serverless/components/function_details_spec.js100
-rw-r--r--spec/frontend/serverless/components/function_row_spec.js34
-rw-r--r--spec/frontend/serverless/components/functions_spec.js86
-rw-r--r--spec/frontend/serverless/components/missing_prometheus_spec.js38
-rw-r--r--spec/frontend/serverless/components/pod_box_spec.js22
-rw-r--r--spec/frontend/serverless/components/url_spec.js26
-rw-r--r--spec/frontend/serverless/mock_data.js145
-rw-r--r--spec/frontend/serverless/store/actions_spec.js80
-rw-r--r--spec/frontend/serverless/store/getters_spec.js43
-rw-r--r--spec/frontend/serverless/store/mutations_spec.js86
-rw-r--r--spec/frontend/serverless/utils.js17
15 files changed, 0 insertions, 913 deletions
diff --git a/spec/frontend/serverless/components/__snapshots__/empty_state_spec.js.snap b/spec/frontend/serverless/components/__snapshots__/empty_state_spec.js.snap
deleted file mode 100644
index 0f4dfdf8a75..00000000000
--- a/spec/frontend/serverless/components/__snapshots__/empty_state_spec.js.snap
+++ /dev/null
@@ -1,22 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`EmptyStateComponent should render content 1`] = `
-"<section class=\\"gl-display-flex empty-state gl-text-center gl-flex-direction-column\\">
- <div class=\\"gl-max-w-full\\">
- <div class=\\"svg-250 svg-content\\"><img src=\\"/image.svg\\" alt=\\"\\" role=\\"img\\" class=\\"gl-max-w-full gl-dark-invert-keep-hue\\"></div>
- </div>
- <div class=\\"gl-max-w-full gl-m-auto\\">
- <div class=\\"gl-mx-auto gl-my-0 gl-p-5\\">
- <h1 class=\\"gl-font-size-h-display gl-line-height-36 h4\\">
- Getting started with serverless
- </h1>
- <p class=\\"gl-mt-3\\">Serverless was <gl-link-stub target=\\"_blank\\" href=\\"https://about.gitlab.com/releases/2021/09/22/gitlab-14-3-released/#gitlab-serverless\\">deprecated</gl-link-stub>. But if you opt to use it, you must install Knative in your Kubernetes cluster first. <gl-link-stub href=\\"/help\\">Learn more.</gl-link-stub>
- </p>
- <div class=\\"gl-display-flex gl-flex-wrap gl-justify-content-center\\">
- <!---->
- <!---->
- </div>
- </div>
- </div>
-</section>"
-`;
diff --git a/spec/frontend/serverless/components/area_spec.js b/spec/frontend/serverless/components/area_spec.js
deleted file mode 100644
index 05c9ee44307..00000000000
--- a/spec/frontend/serverless/components/area_spec.js
+++ /dev/null
@@ -1,121 +0,0 @@
-import { shallowMount } from '@vue/test-utils';
-import Area from '~/serverless/components/area.vue';
-import { mockNormalizedMetrics } from '../mock_data';
-
-describe('Area component', () => {
- const mockWidgets = 'mockWidgets';
- const mockGraphData = mockNormalizedMetrics;
- let areaChart;
-
- beforeEach(() => {
- areaChart = shallowMount(Area, {
- propsData: {
- graphData: mockGraphData,
- containerWidth: 0,
- },
- slots: {
- default: mockWidgets,
- },
- });
- });
-
- afterEach(() => {
- areaChart.destroy();
- });
-
- it('renders chart title', () => {
- expect(areaChart.find({ ref: 'graphTitle' }).text()).toBe(mockGraphData.title);
- });
-
- it('contains graph widgets from slot', () => {
- expect(areaChart.find({ ref: 'graphWidgets' }).text()).toBe(mockWidgets);
- });
-
- describe('methods', () => {
- describe('formatTooltipText', () => {
- const mockDate = mockNormalizedMetrics.queries[0].result[0].values[0].time;
- const generateSeriesData = (type) => ({
- seriesData: [
- {
- componentSubType: type,
- value: [mockDate, 4],
- },
- ],
- value: mockDate,
- });
-
- describe('series is of line type', () => {
- beforeEach(() => {
- areaChart.vm.formatTooltipText(generateSeriesData('line'));
- });
-
- it('formats tooltip title', () => {
- expect(areaChart.vm.tooltipPopoverTitle).toBe('28 Feb 2019, 11:11AM');
- });
-
- it('formats tooltip content', () => {
- expect(areaChart.vm.tooltipPopoverContent).toBe('Invocations (requests): 4');
- });
- });
-
- it('verify default interval value of 1', () => {
- expect(areaChart.vm.getInterval).toBe(1);
- });
- });
-
- describe('onResize', () => {
- const mockWidth = 233;
-
- beforeEach(() => {
- jest.spyOn(Element.prototype, 'getBoundingClientRect').mockImplementation(() => ({
- width: mockWidth,
- }));
- areaChart.vm.onResize();
- });
-
- it('sets area chart width', () => {
- expect(areaChart.vm.width).toBe(mockWidth);
- });
- });
- });
-
- describe('computed', () => {
- describe('chartData', () => {
- it('utilizes all data points', () => {
- expect(Object.keys(areaChart.vm.chartData)).toEqual(['requests']);
- expect(areaChart.vm.chartData.requests.length).toBe(2);
- });
-
- it('creates valid data', () => {
- const data = areaChart.vm.chartData.requests;
-
- expect(
- data.filter(
- (datum) => new Date(datum.time).getTime() > 0 && typeof datum.value === 'number',
- ).length,
- ).toBe(data.length);
- });
- });
-
- describe('generateSeries', () => {
- it('utilizes correct time data', () => {
- expect(areaChart.vm.generateSeries.data).toEqual([
- ['2019-02-28T11:11:38.756Z', 0],
- ['2019-02-28T11:12:38.756Z', 0],
- ]);
- });
- });
-
- describe('xAxisLabel', () => {
- it('constructs a label for the chart x-axis', () => {
- expect(areaChart.vm.xAxisLabel).toBe('invocations / minute');
- });
- });
-
- describe('yAxisLabel', () => {
- it('constructs a label for the chart y-axis', () => {
- expect(areaChart.vm.yAxisLabel).toBe('Invocations (requests)');
- });
- });
- });
-});
diff --git a/spec/frontend/serverless/components/empty_state_spec.js b/spec/frontend/serverless/components/empty_state_spec.js
deleted file mode 100644
index d63882c2a6d..00000000000
--- a/spec/frontend/serverless/components/empty_state_spec.js
+++ /dev/null
@@ -1,25 +0,0 @@
-import { GlEmptyState, GlSprintf } from '@gitlab/ui';
-import { shallowMount } from '@vue/test-utils';
-import EmptyStateComponent from '~/serverless/components/empty_state.vue';
-import { createStore } from '~/serverless/store';
-
-describe('EmptyStateComponent', () => {
- let wrapper;
-
- beforeEach(() => {
- const store = createStore({
- clustersPath: '/clusters',
- helpPath: '/help',
- emptyImagePath: '/image.svg',
- });
- wrapper = shallowMount(EmptyStateComponent, { store, stubs: { GlEmptyState, GlSprintf } });
- });
-
- afterEach(() => {
- wrapper.destroy();
- });
-
- it('should render content', () => {
- expect(wrapper.html()).toMatchSnapshot();
- });
-});
diff --git a/spec/frontend/serverless/components/environment_row_spec.js b/spec/frontend/serverless/components/environment_row_spec.js
deleted file mode 100644
index 944283136d0..00000000000
--- a/spec/frontend/serverless/components/environment_row_spec.js
+++ /dev/null
@@ -1,68 +0,0 @@
-import { shallowMount } from '@vue/test-utils';
-import environmentRowComponent from '~/serverless/components/environment_row.vue';
-
-import { translate } from '~/serverless/utils';
-import { mockServerlessFunctions, mockServerlessFunctionsDiffEnv } from '../mock_data';
-
-const createComponent = (env, envName) =>
- shallowMount(environmentRowComponent, {
- propsData: { env, envName },
- }).vm;
-
-describe('environment row component', () => {
- describe('default global cluster case', () => {
- let vm;
-
- beforeEach(() => {
- vm = createComponent(translate(mockServerlessFunctions.functions)['*'], '*');
- });
-
- afterEach(() => vm.$destroy());
-
- it('has the correct envId', () => {
- expect(vm.envId).toEqual('env-global');
- });
-
- it('is open by default', () => {
- expect(vm.isOpenClass).toEqual({ 'is-open': true });
- });
-
- it('generates correct output', () => {
- expect(vm.$el.id).toEqual('env-global');
- expect(vm.$el.classList.contains('is-open')).toBe(true);
- expect(vm.$el.querySelector('div.title').innerHTML.trim()).toEqual('*');
- });
-
- it('opens and closes correctly', () => {
- expect(vm.isOpen).toBe(true);
-
- vm.toggleOpen();
-
- expect(vm.isOpen).toBe(false);
- });
- });
-
- describe('default named cluster case', () => {
- let vm;
-
- beforeEach(() => {
- vm = createComponent(translate(mockServerlessFunctionsDiffEnv.functions).test, 'test');
- });
-
- afterEach(() => vm.$destroy());
-
- it('has the correct envId', () => {
- expect(vm.envId).toEqual('env-test');
- });
-
- it('is open by default', () => {
- expect(vm.isOpenClass).toEqual({ 'is-open': true });
- });
-
- it('generates correct output', () => {
- expect(vm.$el.id).toEqual('env-test');
- expect(vm.$el.classList.contains('is-open')).toBe(true);
- expect(vm.$el.querySelector('div.title').innerHTML.trim()).toEqual('test');
- });
- });
-});
diff --git a/spec/frontend/serverless/components/function_details_spec.js b/spec/frontend/serverless/components/function_details_spec.js
deleted file mode 100644
index 0c9b2498589..00000000000
--- a/spec/frontend/serverless/components/function_details_spec.js
+++ /dev/null
@@ -1,100 +0,0 @@
-import { shallowMount } from '@vue/test-utils';
-import Vue from 'vue';
-import Vuex from 'vuex';
-
-import functionDetailsComponent from '~/serverless/components/function_details.vue';
-import { createStore } from '~/serverless/store';
-
-describe('functionDetailsComponent', () => {
- let component;
- let store;
-
- beforeEach(() => {
- Vue.use(Vuex);
-
- store = createStore({ clustersPath: '/clusters', helpPath: '/help' });
- });
-
- afterEach(() => {
- component.vm.$destroy();
- });
-
- describe('Verify base functionality', () => {
- const serviceStub = {
- name: 'test',
- description: 'a description',
- environment: '*',
- url: 'http://service.com/test',
- namespace: 'test-ns',
- podcount: 0,
- metricsUrl: '/metrics',
- };
-
- it('has a name, description, URL, and no pods loaded', () => {
- component = shallowMount(functionDetailsComponent, {
- store,
- propsData: {
- func: serviceStub,
- hasPrometheus: false,
- },
- });
-
- expect(
- component.vm.$el.querySelector('.serverless-function-name').innerHTML.trim(),
- ).toContain('test');
-
- expect(
- component.vm.$el.querySelector('.serverless-function-description').innerHTML.trim(),
- ).toContain('a description');
-
- expect(component.vm.$el.querySelector('p').innerHTML.trim()).toContain(
- 'No pods loaded at this time.',
- );
- });
-
- it('has a pods loaded', () => {
- serviceStub.podcount = 1;
-
- component = shallowMount(functionDetailsComponent, {
- store,
- propsData: {
- func: serviceStub,
- hasPrometheus: false,
- },
- });
-
- expect(component.vm.$el.querySelector('p').innerHTML.trim()).toContain('1 pod in use');
- });
-
- it('has multiple pods loaded', () => {
- serviceStub.podcount = 3;
-
- component = shallowMount(functionDetailsComponent, {
- store,
- propsData: {
- func: serviceStub,
- hasPrometheus: false,
- },
- });
-
- expect(component.vm.$el.querySelector('p').innerHTML.trim()).toContain('3 pods in use');
- });
-
- it('can support a missing description', () => {
- serviceStub.description = null;
-
- component = shallowMount(functionDetailsComponent, {
- store,
- propsData: {
- func: serviceStub,
- hasPrometheus: false,
- },
- });
-
- expect(
- component.vm.$el.querySelector('.serverless-function-description').querySelector('div')
- .innerHTML.length,
- ).toEqual(0);
- });
- });
-});
diff --git a/spec/frontend/serverless/components/function_row_spec.js b/spec/frontend/serverless/components/function_row_spec.js
deleted file mode 100644
index 081edd33b3b..00000000000
--- a/spec/frontend/serverless/components/function_row_spec.js
+++ /dev/null
@@ -1,34 +0,0 @@
-import { shallowMount } from '@vue/test-utils';
-import functionRowComponent from '~/serverless/components/function_row.vue';
-import Timeago from '~/vue_shared/components/time_ago_tooltip.vue';
-
-import { mockServerlessFunction } from '../mock_data';
-
-describe('functionRowComponent', () => {
- let wrapper;
-
- const createComponent = (func) => {
- wrapper = shallowMount(functionRowComponent, {
- propsData: { func },
- });
- };
-
- afterEach(() => {
- wrapper.destroy();
- });
-
- it('Parses the function details correctly', () => {
- createComponent(mockServerlessFunction);
-
- expect(wrapper.find('b').text()).toBe(mockServerlessFunction.name);
- expect(wrapper.find('span').text()).toBe(mockServerlessFunction.image);
- expect(wrapper.find(Timeago).attributes('time')).not.toBe(null);
- });
-
- it('handles clicks correctly', () => {
- createComponent(mockServerlessFunction);
- const { vm } = wrapper;
-
- expect(vm.checkClass(vm.$el.querySelector('p'))).toBe(true); // check somewhere inside the row
- });
-});
diff --git a/spec/frontend/serverless/components/functions_spec.js b/spec/frontend/serverless/components/functions_spec.js
deleted file mode 100644
index 846fd63e918..00000000000
--- a/spec/frontend/serverless/components/functions_spec.js
+++ /dev/null
@@ -1,86 +0,0 @@
-import { GlLoadingIcon, GlAlert, GlSprintf } from '@gitlab/ui';
-import { shallowMount } from '@vue/test-utils';
-import Vue, { nextTick } from 'vue';
-import AxiosMockAdapter from 'axios-mock-adapter';
-import Vuex from 'vuex';
-import { TEST_HOST } from 'helpers/test_constants';
-import axios from '~/lib/utils/axios_utils';
-import EmptyState from '~/serverless/components/empty_state.vue';
-import EnvironmentRow from '~/serverless/components/environment_row.vue';
-import functionsComponent from '~/serverless/components/functions.vue';
-import { createStore } from '~/serverless/store';
-import { mockServerlessFunctions } from '../mock_data';
-
-describe('functionsComponent', () => {
- const statusPath = `${TEST_HOST}/statusPath`;
-
- let component;
- let store;
- let axiosMock;
-
- beforeEach(() => {
- axiosMock = new AxiosMockAdapter(axios);
- axiosMock.onGet(statusPath).reply(200);
-
- Vue.use(Vuex);
-
- store = createStore({});
- component = shallowMount(functionsComponent, { store, stubs: { GlSprintf } });
- });
-
- afterEach(() => {
- component.destroy();
- axiosMock.restore();
- });
-
- it('should render deprecation notice', () => {
- expect(component.findComponent(GlAlert).text()).toBe(
- 'Serverless was deprecated in GitLab 14.3.',
- );
- });
-
- it('should render empty state when Knative is not installed', async () => {
- await store.dispatch('receiveFunctionsSuccess', { knative_installed: false });
-
- expect(component.findComponent(EmptyState).exists()).toBe(true);
- });
-
- it('should render a loading component', async () => {
- await store.dispatch('requestFunctionsLoading');
-
- expect(component.findComponent(GlLoadingIcon).exists()).toBe(true);
- });
-
- it('should render empty state when there is no function data', async () => {
- await store.dispatch('receiveFunctionsNoDataSuccess', { knative_installed: true });
-
- expect(
- component.vm.$el
- .querySelector('.empty-state, .js-empty-state')
- .classList.contains('js-empty-state'),
- ).toBe(true);
-
- expect(component.vm.$el.querySelector('.state-title, .text-center').innerHTML.trim()).toEqual(
- 'No functions available',
- );
- });
-
- it('should render functions and a loader when functions are partially fetched', async () => {
- await store.dispatch('receiveFunctionsPartial', {
- ...mockServerlessFunctions,
- knative_installed: 'checking',
- });
-
- expect(component.find('.js-functions-wrapper').exists()).toBe(true);
- expect(component.find('.js-functions-loader').exists()).toBe(true);
- });
-
- it('should render the functions list', async () => {
- store = createStore({ clustersPath: 'clustersPath', helpPath: 'helpPath', statusPath });
-
- await component.vm.$store.dispatch('receiveFunctionsSuccess', mockServerlessFunctions);
-
- await nextTick();
- expect(component.findComponent(EnvironmentRow).exists()).toBe(true);
- });
-});
diff --git a/spec/frontend/serverless/components/missing_prometheus_spec.js b/spec/frontend/serverless/components/missing_prometheus_spec.js
deleted file mode 100644
index 1b93fd784e1..00000000000
--- a/spec/frontend/serverless/components/missing_prometheus_spec.js
+++ /dev/null
@@ -1,38 +0,0 @@
-import { GlButton } from '@gitlab/ui';
-import { shallowMount } from '@vue/test-utils';
-import missingPrometheusComponent from '~/serverless/components/missing_prometheus.vue';
-import { createStore } from '~/serverless/store';
-
-describe('missingPrometheusComponent', () => {
- let wrapper;
-
- const createComponent = (missingData) => {
- const store = createStore({ clustersPath: '/clusters', helpPath: '/help' });
-
- wrapper = shallowMount(missingPrometheusComponent, { store, propsData: { missingData } });
- };
-
- afterEach(() => {
- wrapper.destroy();
- });
-
- it('should render missing prometheus message', () => {
- createComponent(false);
- const { vm } = wrapper;
-
- expect(vm.$el.querySelector('.state-description').innerHTML.trim()).toContain(
- 'Function invocation metrics require the Prometheus cluster integration.',
- );
-
- expect(wrapper.find(GlButton).attributes('variant')).toBe('success');
- });
-
- it('should render no prometheus data message', () => {
- createComponent(true);
- const { vm } = wrapper;
-
- expect(vm.$el.querySelector('.state-description').innerHTML.trim()).toContain(
- 'Invocation metrics loading or not available at this time.',
- );
- });
-});
diff --git a/spec/frontend/serverless/components/pod_box_spec.js b/spec/frontend/serverless/components/pod_box_spec.js
deleted file mode 100644
index cf0c14a2cac..00000000000
--- a/spec/frontend/serverless/components/pod_box_spec.js
+++ /dev/null
@@ -1,22 +0,0 @@
-import { shallowMount } from '@vue/test-utils';
-import podBoxComponent from '~/serverless/components/pod_box.vue';
-
-const createComponent = (count) =>
- shallowMount(podBoxComponent, {
- propsData: {
- count,
- },
- }).vm;
-
-describe('podBoxComponent', () => {
- it('should render three boxes', () => {
- const count = 3;
- const vm = createComponent(count);
- const rects = vm.$el.querySelectorAll('rect');
-
- expect(rects.length).toEqual(3);
- expect(parseInt(rects[2].getAttribute('x'), 10)).toEqual(40);
-
- vm.$destroy();
- });
-});
diff --git a/spec/frontend/serverless/components/url_spec.js b/spec/frontend/serverless/components/url_spec.js
deleted file mode 100644
index 8c839577aa0..00000000000
--- a/spec/frontend/serverless/components/url_spec.js
+++ /dev/null
@@ -1,26 +0,0 @@
-import { shallowMount } from '@vue/test-utils';
-import Vue from 'vue';
-import urlComponent from '~/serverless/components/url.vue';
-import ClipboardButton from '~/vue_shared/components/clipboard_button.vue';
-
-const createComponent = (uri) =>
- shallowMount(Vue.extend(urlComponent), {
- propsData: {
- uri,
- },
- });
-
-describe('urlComponent', () => {
- it('should render correctly', () => {
- const uri = 'http://testfunc.apps.example.com';
- const wrapper = createComponent(uri);
- const { vm } = wrapper;
-
- expect(vm.$el.classList.contains('clipboard-group')).toBe(true);
- expect(wrapper.find(ClipboardButton).attributes('text')).toEqual(uri);
-
- expect(vm.$el.querySelector('[data-testid="url-text-field"]').innerHTML).toContain(uri);
-
- vm.$destroy();
- });
-});
diff --git a/spec/frontend/serverless/mock_data.js b/spec/frontend/serverless/mock_data.js
deleted file mode 100644
index 1816ad62a04..00000000000
--- a/spec/frontend/serverless/mock_data.js
+++ /dev/null
@@ -1,145 +0,0 @@
-export const mockServerlessFunctions = {
- knative_installed: true,
- functions: [
- {
- name: 'testfunc1',
- namespace: 'tm-example',
- environment_scope: '*',
- cluster_id: 46,
- detail_url: '/testuser/testproj/serverless/functions/*/testfunc1',
- podcount: null,
- created_at: '2019-02-05T01:01:23Z',
- url: 'http://testfunc1.tm-example.apps.example.com',
- description: 'A test service',
- image: 'knative-test-container-buildtemplate',
- },
- {
- name: 'testfunc2',
- namespace: 'tm-example',
- environment_scope: '*',
- cluster_id: 46,
- detail_url: '/testuser/testproj/serverless/functions/*/testfunc2',
- podcount: null,
- created_at: '2019-02-05T01:01:23Z',
- url: 'http://testfunc2.tm-example.apps.example.com',
- description: 'A second test service\nThis one with additional descriptions',
- image: 'knative-test-echo-buildtemplate',
- },
- ],
-};
-
-export const mockServerlessFunctionsDiffEnv = {
- knative_installed: true,
- functions: [
- {
- name: 'testfunc1',
- namespace: 'tm-example',
- environment_scope: '*',
- cluster_id: 46,
- detail_url: '/testuser/testproj/serverless/functions/*/testfunc1',
- podcount: null,
- created_at: '2019-02-05T01:01:23Z',
- url: 'http://testfunc1.tm-example.apps.example.com',
- description: 'A test service',
- image: 'knative-test-container-buildtemplate',
- },
- {
- name: 'testfunc2',
- namespace: 'tm-example',
- environment_scope: 'test',
- cluster_id: 46,
- detail_url: '/testuser/testproj/serverless/functions/*/testfunc2',
- podcount: null,
- created_at: '2019-02-05T01:01:23Z',
- url: 'http://testfunc2.tm-example.apps.example.com',
- description: 'A second test service\nThis one with additional descriptions',
- image: 'knative-test-echo-buildtemplate',
- },
- ],
-};
-
-export const mockServerlessFunction = {
- name: 'testfunc1',
- namespace: 'tm-example',
- environment_scope: '*',
- cluster_id: 46,
- detail_url: '/testuser/testproj/serverless/functions/*/testfunc1',
- podcount: '3',
- created_at: '2019-02-05T01:01:23Z',
- url: 'http://testfunc1.tm-example.apps.example.com',
- description: 'A test service',
- image: 'knative-test-container-buildtemplate',
-};
-
-export const mockMultilineServerlessFunction = {
- name: 'testfunc1',
- namespace: 'tm-example',
- environment_scope: '*',
- cluster_id: 46,
- detail_url: '/testuser/testproj/serverless/functions/*/testfunc1',
- podcount: '3',
- created_at: '2019-02-05T01:01:23Z',
- url: 'http://testfunc1.tm-example.apps.example.com',
- description: 'testfunc1\nA test service line\\nWith additional services',
- image: 'knative-test-container-buildtemplate',
-};
-
-export const mockMetrics = {
- success: true,
- last_update: '2019-02-28T19:11:38.926Z',
- metrics: {
- id: 22,
- title: 'Knative function invocations',
- required_metrics: ['container_memory_usage_bytes', 'container_cpu_usage_seconds_total'],
- weight: 0,
- y_label: 'Invocations',
- queries: [
- {
- query_range:
- 'floor(sum(rate(istio_revision_request_count{destination_configuration="%{function_name}", destination_namespace="%{kube_namespace}"}[1m])*30))',
- unit: 'requests',
- label: 'invocations / minute',
- result: [
- {
- metric: {},
- values: [
- [1551352298.756, '0'],
- [1551352358.756, '0'],
- ],
- },
- ],
- },
- ],
- },
-};
-
-export const mockNormalizedMetrics = {
- id: 22,
- title: 'Knative function invocations',
- required_metrics: ['container_memory_usage_bytes', 'container_cpu_usage_seconds_total'],
- weight: 0,
- y_label: 'Invocations',
- queries: [
- {
- query_range:
- 'floor(sum(rate(istio_revision_request_count{destination_configuration="%{function_name}", destination_namespace="%{kube_namespace}"}[1m])*30))',
- unit: 'requests',
- label: 'invocations / minute',
- result: [
- {
- metric: {},
- values: [
- {
- time: '2019-02-28T11:11:38.756Z',
- value: 0,
- },
- {
- time: '2019-02-28T11:12:38.756Z',
- value: 0,
- },
- ],
- },
- ],
- },
- ],
-};
diff --git a/spec/frontend/serverless/store/actions_spec.js b/spec/frontend/serverless/store/actions_spec.js
deleted file mode 100644
index 5fbecf081a6..00000000000
--- a/spec/frontend/serverless/store/actions_spec.js
+++ /dev/null
@@ -1,80 +0,0 @@
-import MockAdapter from 'axios-mock-adapter';
-import testAction from 'helpers/vuex_action_helper';
-import axios from '~/lib/utils/axios_utils';
-import statusCodes from '~/lib/utils/http_status';
-import { fetchFunctions, fetchMetrics } from '~/serverless/store/actions';
-import { mockServerlessFunctions, mockMetrics } from '../mock_data';
-import { adjustMetricQuery } from '../utils';
-
-describe('ServerlessActions', () => {
- let mock;
-
- beforeEach(() => {
- mock = new MockAdapter(axios);
- });
-
- afterEach(() => {
- mock.restore();
- });
-
- describe('fetchFunctions', () => {
- it('should successfully fetch functions', () => {
- const endpoint = '/functions';
- mock.onGet(endpoint).reply(statusCodes.OK, JSON.stringify(mockServerlessFunctions));
-
- return testAction(
- fetchFunctions,
- { functionsPath: endpoint },
- {},
- [],
- [
- { type: 'requestFunctionsLoading' },
- { type: 'receiveFunctionsSuccess', payload: mockServerlessFunctions },
- ],
- );
- });
-
- it('should successfully retry', () => {
- const endpoint = '/functions';
- mock
- .onGet(endpoint)
- .reply(() => new Promise((resolve) => setTimeout(() => resolve(200), Infinity)));
-
- return testAction(
- fetchFunctions,
- { functionsPath: endpoint },
- {},
- [],
- [{ type: 'requestFunctionsLoading' }],
- );
- });
- });
-
- describe('fetchMetrics', () => {
- it('should return no prometheus', () => {
- const endpoint = '/metrics';
- mock.onGet(endpoint).reply(statusCodes.NO_CONTENT);
-
- return testAction(
- fetchMetrics,
- { metricsPath: endpoint, hasPrometheus: false },
- {},
- [],
- [{ type: 'receiveMetricsNoPrometheus' }],
- );
- });
-
- it('should successfully fetch metrics', () => {
- const endpoint = '/metrics';
- mock.onGet(endpoint).reply(statusCodes.OK, JSON.stringify(mockMetrics));
-
- return testAction(
- fetchMetrics,
- { metricsPath: endpoint, hasPrometheus: true },
- {},
- [],
- [{ type: 'receiveMetricsSuccess', payload: adjustMetricQuery(mockMetrics) }],
- );
- });
- });
-});
diff --git a/spec/frontend/serverless/store/getters_spec.js b/spec/frontend/serverless/store/getters_spec.js
deleted file mode 100644
index e1942bd2759..00000000000
--- a/spec/frontend/serverless/store/getters_spec.js
+++ /dev/null
@@ -1,43 +0,0 @@
-import * as getters from '~/serverless/store/getters';
-import serverlessState from '~/serverless/store/state';
-import { mockServerlessFunctions } from '../mock_data';
-
-describe('Serverless Store Getters', () => {
- let state;
-
- beforeEach(() => {
- state = serverlessState;
- });
-
- describe('hasPrometheusMissingData', () => {
- it('should return false if Prometheus is not installed', () => {
- state.hasPrometheus = false;
-
- expect(getters.hasPrometheusMissingData(state)).toEqual(false);
- });
-
- it('should return false if Prometheus is installed and there is data', () => {
- state.hasPrometheusData = true;
-
- expect(getters.hasPrometheusMissingData(state)).toEqual(false);
- });
-
- it('should return true if Prometheus is installed and there is no data', () => {
- state.hasPrometheus = true;
- state.hasPrometheusData = false;
-
- expect(getters.hasPrometheusMissingData(state)).toEqual(true);
- });
- });
-
- describe('getFunctions', () => {
- it('should translate the raw function array to group the functions per environment scope', () => {
- state.functions = mockServerlessFunctions.functions;
-
- const funcs = getters.getFunctions(state);
-
- expect(Object.keys(funcs)).toContain('*');
- expect(funcs['*'].length).toEqual(2);
- });
- });
-});
diff --git a/spec/frontend/serverless/store/mutations_spec.js b/spec/frontend/serverless/store/mutations_spec.js
deleted file mode 100644
index a1a8f9a2ca7..00000000000
--- a/spec/frontend/serverless/store/mutations_spec.js
+++ /dev/null
@@ -1,86 +0,0 @@
-import * as types from '~/serverless/store/mutation_types';
-import mutations from '~/serverless/store/mutations';
-import { mockServerlessFunctions, mockMetrics } from '../mock_data';
-
-describe('ServerlessMutations', () => {
- describe('Functions List Mutations', () => {
- it('should ensure loading is true', () => {
- const state = {};
-
- mutations[types.REQUEST_FUNCTIONS_LOADING](state);
-
- expect(state.isLoading).toEqual(true);
- });
-
- it('should set proper state once functions are loaded', () => {
- const state = {};
-
- mutations[types.RECEIVE_FUNCTIONS_SUCCESS](state, mockServerlessFunctions);
-
- expect(state.isLoading).toEqual(false);
- expect(state.hasFunctionData).toEqual(true);
- expect(state.functions).toEqual(mockServerlessFunctions.functions);
- });
-
- it('should ensure loading has stopped and hasFunctionData is false when there are no functions available', () => {
- const state = {};
-
- mutations[types.RECEIVE_FUNCTIONS_NODATA_SUCCESS](state, { knative_installed: true });
-
- expect(state.isLoading).toEqual(false);
- expect(state.hasFunctionData).toEqual(false);
- expect(state.functions).toBe(undefined);
- });
-
- it('should ensure loading has stopped, and an error is raised', () => {
- const state = {};
-
- mutations[types.RECEIVE_FUNCTIONS_ERROR](state, 'sample error');
-
- expect(state.isLoading).toEqual(false);
- expect(state.hasFunctionData).toEqual(false);
- expect(state.functions).toBe(undefined);
- expect(state.error).not.toBe(undefined);
- });
- });
-
- describe('Function Details Metrics Mutations', () => {
- it('should ensure isLoading and hasPrometheus data flags indicate data is loaded', () => {
- const state = {};
-
- mutations[types.RECEIVE_METRICS_SUCCESS](state, mockMetrics);
-
- expect(state.isLoading).toEqual(false);
- expect(state.hasPrometheusData).toEqual(true);
- expect(state.graphData).toEqual(mockMetrics);
- });
-
- it('should ensure isLoading and hasPrometheus data flags are cleared indicating no functions available', () => {
- const state = {};
-
- mutations[types.RECEIVE_METRICS_NODATA_SUCCESS](state);
-
- expect(state.isLoading).toEqual(false);
- expect(state.hasPrometheusData).toEqual(false);
- expect(state.graphData).toBe(undefined);
- });
-
- it('should properly indicate an error', () => {
- const state = {};
-
- mutations[types.RECEIVE_METRICS_ERROR](state, 'sample error');
-
- expect(state.hasPrometheusData).toEqual(false);
- expect(state.error).not.toBe(undefined);
- });
-
- it('should properly indicate when prometheus is installed', () => {
- const state = {};
-
- mutations[types.RECEIVE_METRICS_NO_PROMETHEUS](state);
-
- expect(state.hasPrometheus).toEqual(false);
- expect(state.hasPrometheusData).toEqual(false);
- });
- });
-});
diff --git a/spec/frontend/serverless/utils.js b/spec/frontend/serverless/utils.js
deleted file mode 100644
index 7caf7da231e..00000000000
--- a/spec/frontend/serverless/utils.js
+++ /dev/null
@@ -1,17 +0,0 @@
-export const adjustMetricQuery = (data) => {
- const updatedMetric = data.metrics;
-
- const queries = data.metrics.queries.map((query) => ({
- ...query,
- result: query.result.map((result) => ({
- ...result,
- values: result.values.map(([timestamp, value]) => ({
- time: new Date(timestamp * 1000).toISOString(),
- value: Number(value),
- })),
- })),
- }));
-
- updatedMetric.queries = queries;
- return updatedMetric;
-};