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>2020-10-21 10:08:36 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-10-21 10:08:36 +0300
commit48aff82709769b098321c738f3444b9bdaa694c6 (patch)
treee00c7c43e2d9b603a5a6af576b1685e400410dee /spec/frontend/blob
parent879f5329ee916a948223f8f43d77fba4da6cd028 (diff)
Add latest changes from gitlab-org/gitlab@13-5-stable-eev13.5.0-rc42
Diffstat (limited to 'spec/frontend/blob')
-rw-r--r--spec/frontend/blob/components/__snapshots__/blob_header_filepath_spec.js.snap2
-rw-r--r--spec/frontend/blob/pipeline_tour_success_modal_spec.js5
-rw-r--r--spec/frontend/blob/sketch/index_spec.js7
-rw-r--r--spec/frontend/blob/suggest_web_ide_ci/web_ide_alert_spec.js67
-rw-r--r--spec/frontend/blob/viewer/index_spec.js55
5 files changed, 38 insertions, 98 deletions
diff --git a/spec/frontend/blob/components/__snapshots__/blob_header_filepath_spec.js.snap b/spec/frontend/blob/components/__snapshots__/blob_header_filepath_spec.js.snap
index 0f5b3cd3f5e..53815820bbe 100644
--- a/spec/frontend/blob/components/__snapshots__/blob_header_filepath_spec.js.snap
+++ b/spec/frontend/blob/components/__snapshots__/blob_header_filepath_spec.js.snap
@@ -27,8 +27,10 @@ exports[`Blob Header Filepath rendering matches the snapshot 1`] = `
</small>
<clipboard-button-stub
+ category="tertiary"
cssclass="btn-clipboard btn-transparent lh-100 position-static"
gfm="\`foo/bar/dummy.md\`"
+ size="medium"
text="foo/bar/dummy.md"
title="Copy file path"
tooltipplacement="top"
diff --git a/spec/frontend/blob/pipeline_tour_success_modal_spec.js b/spec/frontend/blob/pipeline_tour_success_modal_spec.js
index 50db1675e13..a02c968c4b5 100644
--- a/spec/frontend/blob/pipeline_tour_success_modal_spec.js
+++ b/spec/frontend/blob/pipeline_tour_success_modal_spec.js
@@ -16,6 +16,7 @@ describe('PipelineTourSuccessModal', () => {
stubs: {
GlModal,
GlSprintf,
+ 'gl-emoji': '<img/>',
},
});
};
@@ -66,9 +67,11 @@ describe('PipelineTourSuccessModal', () => {
it('has expected structure', () => {
const modal = wrapper.find(GlModal);
const sprintf = modal.find(GlSprintf);
+ const emoji = modal.find('img');
- expect(modal.attributes('title')).toContain("That's it, well done!");
+ expect(wrapper.text()).toContain("That's it, well done!");
expect(sprintf.exists()).toBe(true);
+ expect(emoji.exists()).toBe(true);
});
it('renders the link for codeQualityLink', () => {
diff --git a/spec/frontend/blob/sketch/index_spec.js b/spec/frontend/blob/sketch/index_spec.js
index f5e9da21b2a..cd12d5e17a8 100644
--- a/spec/frontend/blob/sketch/index_spec.js
+++ b/spec/frontend/blob/sketch/index_spec.js
@@ -8,13 +8,6 @@ describe('Sketch viewer', () => {
beforeEach(() => {
loadFixtures('static/sketch_viewer.html');
- window.URL = {
- createObjectURL: jest.fn(() => 'http://foo/bar'),
- };
- });
-
- afterEach(() => {
- window.URL = {};
});
describe('with error message', () => {
diff --git a/spec/frontend/blob/suggest_web_ide_ci/web_ide_alert_spec.js b/spec/frontend/blob/suggest_web_ide_ci/web_ide_alert_spec.js
deleted file mode 100644
index 8dc71f99010..00000000000
--- a/spec/frontend/blob/suggest_web_ide_ci/web_ide_alert_spec.js
+++ /dev/null
@@ -1,67 +0,0 @@
-import MockAdapter from 'axios-mock-adapter';
-import waitForPromises from 'helpers/wait_for_promises';
-import { shallowMount } from '@vue/test-utils';
-import { GlButton, GlAlert } from '@gitlab/ui';
-import axios from '~/lib/utils/axios_utils';
-import WebIdeAlert from '~/blob/suggest_web_ide_ci/components/web_ide_alert.vue';
-
-const dismissEndpoint = '/-/user_callouts';
-const featureId = 'web_ide_alert_dismissed';
-const editPath = 'edit/master/-/.gitlab-ci.yml';
-
-describe('WebIdeAlert', () => {
- let wrapper;
- let mock;
-
- const findButton = () => wrapper.find(GlButton);
- const findAlert = () => wrapper.find(GlAlert);
- const dismissAlert = alertWrapper => alertWrapper.vm.$emit('dismiss');
- const getPostPayload = () => JSON.parse(mock.history.post[0].data);
-
- const createComponent = () => {
- wrapper = shallowMount(WebIdeAlert, {
- propsData: {
- dismissEndpoint,
- featureId,
- editPath,
- },
- });
- };
-
- beforeEach(() => {
- mock = new MockAdapter(axios);
-
- mock.onPost(dismissEndpoint).reply(200);
-
- createComponent();
- });
-
- afterEach(() => {
- wrapper.destroy();
- wrapper = null;
-
- mock.restore();
- });
-
- describe('with defaults', () => {
- it('displays alert correctly', () => {
- expect(findAlert().exists()).toBe(true);
- });
-
- it('web ide button link has correct path', () => {
- expect(findButton().attributes('href')).toBe(editPath);
- });
-
- it('dismisses alert correctly', async () => {
- const alertWrapper = findAlert();
-
- dismissAlert(alertWrapper);
-
- await waitForPromises();
-
- expect(alertWrapper.exists()).toBe(false);
- expect(mock.history.post).toHaveLength(1);
- expect(getPostPayload()).toEqual({ feature_name: featureId });
- });
- });
-});
diff --git a/spec/frontend/blob/viewer/index_spec.js b/spec/frontend/blob/viewer/index_spec.js
index 97ac42a10bf..69ec22b1f94 100644
--- a/spec/frontend/blob/viewer/index_spec.js
+++ b/spec/frontend/blob/viewer/index_spec.js
@@ -2,6 +2,7 @@
import $ from 'jquery';
import MockAdapter from 'axios-mock-adapter';
+import { setTestTimeout } from 'helpers/timeout';
import BlobViewer from '~/blob/viewer/index';
import axios from '~/lib/utils/axios_utils';
@@ -13,26 +14,22 @@ describe('Blob viewer', () => {
tooltip: jest.fn(),
};
- preloadFixtures('snippets/show.html');
+ setTestTimeout(2000);
+
+ preloadFixtures('blob/show_readme.html');
beforeEach(() => {
$.fn.extend(jQueryMock);
mock = new MockAdapter(axios);
- loadFixtures('snippets/show.html');
+ loadFixtures('blob/show_readme.html');
$('#modal-upload-blob').remove();
- blob = new BlobViewer();
-
- mock.onGet('http://test.host/-/snippets/1.json?viewer=rich').reply(200, {
- html: '<div>testing</div>',
- });
-
- mock.onGet('http://test.host/-/snippets/1.json?viewer=simple').reply(200, {
+ mock.onGet(/blob\/master\/README\.md/).reply(200, {
html: '<div>testing</div>',
});
- jest.spyOn(axios, 'get');
+ blob = new BlobViewer();
});
afterEach(() => {
@@ -71,12 +68,11 @@ describe('Blob viewer', () => {
});
it('doesnt reload file if already loaded', () => {
- const asyncClick = () =>
- new Promise(resolve => {
- document.querySelector('.js-blob-viewer-switch-btn[data-viewer="simple"]').click();
+ const asyncClick = async () => {
+ document.querySelector('.js-blob-viewer-switch-btn[data-viewer="simple"]').click();
- setImmediate(resolve);
- });
+ await axios.waitForAll();
+ };
return asyncClick()
.then(() => asyncClick())
@@ -163,17 +159,30 @@ describe('Blob viewer', () => {
expect(simpleBtn.blur).toHaveBeenCalled();
});
- it('sends AJAX request when switching to simple view', () => {
- blob.switchToViewer('simple');
-
- expect(axios.get).toHaveBeenCalled();
+ it('makes request for initial view', () => {
+ expect(mock.history).toMatchObject({
+ get: [{ url: expect.stringMatching(/README\.md\?.*viewer=rich/) }],
+ });
});
- it('does not send AJAX request when switching to rich view', () => {
- blob.switchToViewer('simple');
- blob.switchToViewer('rich');
+ describe.each`
+ views
+ ${['simple']}
+ ${['simple', 'rich']}
+ `('when view switches to $views', ({ views }) => {
+ beforeEach(async () => {
+ views.forEach(view => blob.switchToViewer(view));
+ await axios.waitForAll();
+ });
- expect(axios.get.mock.calls.length).toBe(1);
+ it('sends 1 AJAX request for new view', async () => {
+ expect(mock.history).toMatchObject({
+ get: [
+ { url: expect.stringMatching(/README\.md\?.*viewer=rich/) },
+ { url: expect.stringMatching(/README\.md\?.*viewer=simple/) },
+ ],
+ });
+ });
});
});
});