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:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-05-23 21:08:27 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-05-23 21:08:27 +0300
commit3ca896b640def57a58485def308748b2fccbd0bb (patch)
tree7aead6484759d2a473bf9776aa7d87632f1e105f /spec/frontend/grafana_integration
parentabdb550f6937ce69ec38954f24ef221d07637438 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/grafana_integration')
-rw-r--r--spec/frontend/grafana_integration/components/__snapshots__/grafana_integration_spec.js.snap110
-rw-r--r--spec/frontend/grafana_integration/components/grafana_integration_spec.js119
-rw-r--r--spec/frontend/grafana_integration/store/mutations_spec.js35
3 files changed, 0 insertions, 264 deletions
diff --git a/spec/frontend/grafana_integration/components/__snapshots__/grafana_integration_spec.js.snap b/spec/frontend/grafana_integration/components/__snapshots__/grafana_integration_spec.js.snap
deleted file mode 100644
index 9447e7daba8..00000000000
--- a/spec/frontend/grafana_integration/components/__snapshots__/grafana_integration_spec.js.snap
+++ /dev/null
@@ -1,110 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`grafana integration component default state to match the default snapshot 1`] = `
-<section
- class="settings no-animate js-grafana-integration"
- id="grafana"
->
- <div
- class="settings-header"
- >
- <h4
- class="js-section-header settings-title js-settings-toggle js-settings-toggle-trigger-only"
- >
-
- Grafana authentication
-
- </h4>
-
- <gl-button-stub
- buttontextclasses=""
- category="primary"
- class="js-settings-toggle"
- icon=""
- size="medium"
- variant="default"
- >
- Expand
- </gl-button-stub>
-
- <p
- class="js-section-sub-header"
- >
-
- Set up Grafana authentication to embed Grafana panels in GitLab Flavored Markdown.
-
- <gl-link-stub>
- Learn more.
- </gl-link-stub>
- </p>
- </div>
-
- <div
- class="settings-content"
- >
- <form>
- <gl-form-group-stub
- label="Enable authentication"
- label-for="grafana-integration-enabled"
- labeldescription=""
- optionaltext="(optional)"
- >
- <gl-form-checkbox-stub
- id="grafana-integration-enabled"
- >
-
- Active
-
- </gl-form-checkbox-stub>
- </gl-form-group-stub>
-
- <gl-form-group-stub
- description="Enter the base URL of the Grafana instance."
- label="Grafana URL"
- label-for="grafana-url"
- labeldescription=""
- optionaltext="(optional)"
- >
- <gl-form-input-stub
- id="grafana-url"
- placeholder="https://my-grafana.example.com/"
- value="http://test.host"
- />
- </gl-form-group-stub>
-
- <gl-form-group-stub
- label="API token"
- label-for="grafana-token"
- labeldescription=""
- optionaltext="(optional)"
- >
- <gl-form-input-stub
- id="grafana-token"
- value="someToken"
- />
-
- <p
- class="form-text text-muted"
- >
- <gl-sprintf-stub
- message="Enter the %{docLinkStart}Grafana API token%{docLinkEnd}."
- />
- </p>
- </gl-form-group-stub>
-
- <gl-button-stub
- buttontextclasses=""
- category="primary"
- data-testid="save-grafana-settings-button"
- icon=""
- size="medium"
- variant="confirm"
- >
-
- Save changes
-
- </gl-button-stub>
- </form>
- </div>
-</section>
-`;
diff --git a/spec/frontend/grafana_integration/components/grafana_integration_spec.js b/spec/frontend/grafana_integration/components/grafana_integration_spec.js
deleted file mode 100644
index 540fc597aa9..00000000000
--- a/spec/frontend/grafana_integration/components/grafana_integration_spec.js
+++ /dev/null
@@ -1,119 +0,0 @@
-import { GlButton } from '@gitlab/ui';
-import { shallowMount } from '@vue/test-utils';
-import { nextTick } from 'vue';
-import { TEST_HOST } from 'helpers/test_constants';
-import { mountExtended } from 'helpers/vue_test_utils_helper';
-import { createAlert } from '~/alert';
-import GrafanaIntegration from '~/grafana_integration/components/grafana_integration.vue';
-import { createStore } from '~/grafana_integration/store';
-import axios from '~/lib/utils/axios_utils';
-import { refreshCurrentPage } from '~/lib/utils/url_utility';
-
-jest.mock('~/lib/utils/url_utility');
-jest.mock('~/alert');
-
-describe('grafana integration component', () => {
- let wrapper;
- let store;
- const operationsSettingsEndpoint = `${TEST_HOST}/mock/ops/settings/endpoint`;
- const grafanaIntegrationUrl = `${TEST_HOST}`;
- const grafanaIntegrationToken = 'someToken';
-
- beforeEach(() => {
- store = createStore({
- operationsSettingsEndpoint,
- grafanaIntegrationUrl,
- grafanaIntegrationToken,
- });
- });
-
- afterEach(() => {
- createAlert.mockReset();
- refreshCurrentPage.mockReset();
- });
-
- describe('default state', () => {
- it('to match the default snapshot', () => {
- wrapper = shallowMount(GrafanaIntegration, { store });
-
- expect(wrapper.element).toMatchSnapshot();
- });
- });
-
- it('renders header text', () => {
- wrapper = shallowMount(GrafanaIntegration, { store });
-
- expect(wrapper.find('.js-section-header').text()).toBe('Grafana authentication');
- });
-
- describe('expand/collapse button', () => {
- it('renders as an expand button by default', () => {
- wrapper = shallowMount(GrafanaIntegration, { store });
-
- const button = wrapper.findComponent(GlButton);
- expect(button.text()).toBe('Expand');
- });
- });
-
- describe('sub-header', () => {
- it('renders descriptive text', () => {
- wrapper = shallowMount(GrafanaIntegration, { store });
-
- expect(wrapper.find('.js-section-sub-header').text()).toContain(
- 'Set up Grafana authentication to embed Grafana panels in GitLab Flavored Markdown.\n Learn more.',
- );
- });
- });
-
- describe('form', () => {
- beforeEach(() => {
- jest.spyOn(axios, 'patch').mockImplementation();
- wrapper = mountExtended(GrafanaIntegration, { store });
- });
-
- afterEach(() => {
- axios.patch.mockReset();
- });
-
- describe('submit button', () => {
- const findSubmitButton = () => wrapper.findByTestId('save-grafana-settings-button');
-
- const endpointRequest = [
- operationsSettingsEndpoint,
- {
- project: {
- grafana_integration_attributes: {
- grafana_url: grafanaIntegrationUrl,
- token: grafanaIntegrationToken,
- enabled: false,
- },
- },
- },
- ];
-
- it('submits form on click', async () => {
- axios.patch.mockResolvedValue();
- findSubmitButton(wrapper).trigger('click');
-
- expect(axios.patch).toHaveBeenCalledWith(...endpointRequest);
- await nextTick();
- expect(refreshCurrentPage).toHaveBeenCalled();
- });
-
- it('creates alert banner on error', async () => {
- const message = 'mockErrorMessage';
- axios.patch.mockRejectedValue({ response: { data: { message } } });
-
- findSubmitButton().trigger('click');
-
- expect(axios.patch).toHaveBeenCalledWith(...endpointRequest);
-
- await nextTick();
- await jest.runAllTicks();
- expect(createAlert).toHaveBeenCalledWith({
- message: `There was an error saving your changes. ${message}`,
- });
- });
- });
- });
-});
diff --git a/spec/frontend/grafana_integration/store/mutations_spec.js b/spec/frontend/grafana_integration/store/mutations_spec.js
deleted file mode 100644
index 18e87394189..00000000000
--- a/spec/frontend/grafana_integration/store/mutations_spec.js
+++ /dev/null
@@ -1,35 +0,0 @@
-import mutations from '~/grafana_integration/store/mutations';
-import createState from '~/grafana_integration/store/state';
-
-describe('grafana integration mutations', () => {
- let localState;
-
- beforeEach(() => {
- localState = createState();
- });
-
- describe('SET_GRAFANA_URL', () => {
- it('sets grafanaUrl', () => {
- const mockUrl = 'mockUrl';
- mutations.SET_GRAFANA_URL(localState, mockUrl);
-
- expect(localState.grafanaUrl).toBe(mockUrl);
- });
- });
-
- describe('SET_GRAFANA_TOKEN', () => {
- it('sets grafanaToken', () => {
- const mockToken = 'mockToken';
- mutations.SET_GRAFANA_TOKEN(localState, mockToken);
-
- expect(localState.grafanaToken).toBe(mockToken);
- });
- });
- describe('SET_GRAFANA_ENABLED', () => {
- it('updates grafanaEnabled for integration', () => {
- mutations.SET_GRAFANA_ENABLED(localState, true);
-
- expect(localState.grafanaEnabled).toBe(true);
- });
- });
-});