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-03-12 00:09:19 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-12 00:09:19 +0300
commitfca89bb73ff5b1d14c98c72481f9268fee107ea0 (patch)
treee1c8a2c4fe5df7f054fd09e49f53bcfb51e51c84 /spec/frontend
parent76e9fc7b29c1ce716c26932e9fbec0f3c99f53f4 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend')
-rw-r--r--spec/frontend/boards/issue_card_spec.js19
-rw-r--r--spec/frontend/ide/utils_spec.js60
-rw-r--r--spec/frontend/monitoring/components/panel_type_spec.js76
3 files changed, 146 insertions, 9 deletions
diff --git a/spec/frontend/boards/issue_card_spec.js b/spec/frontend/boards/issue_card_spec.js
index f78e4dad2c0..09b5c664bee 100644
--- a/spec/frontend/boards/issue_card_spec.js
+++ b/spec/frontend/boards/issue_card_spec.js
@@ -155,18 +155,17 @@ describe('Issue card component', () => {
describe('assignee default avatar', () => {
beforeEach(done => {
+ global.gon.default_avatar_url = 'default_avatar';
+
wrapper.setProps({
issue: {
...wrapper.props('issue'),
assignees: [
- new ListAssignee(
- {
- id: 1,
- name: 'testing 123',
- username: 'test',
- },
- 'default_avatar',
- ),
+ new ListAssignee({
+ id: 1,
+ name: 'testing 123',
+ username: 'test',
+ }),
],
},
});
@@ -174,6 +173,10 @@ describe('Issue card component', () => {
wrapper.vm.$nextTick(done);
});
+ afterEach(() => {
+ global.gon.default_avatar_url = null;
+ });
+
it('displays defaults avatar if users avatar is null', () => {
expect(wrapper.find('.board-card-assignee img').exists()).toBe(true);
expect(wrapper.find('.board-card-assignee img').attributes('src')).toBe(
diff --git a/spec/frontend/ide/utils_spec.js b/spec/frontend/ide/utils_spec.js
index 9d7926a4d06..44eae7eacbe 100644
--- a/spec/frontend/ide/utils_spec.js
+++ b/spec/frontend/ide/utils_spec.js
@@ -1,8 +1,66 @@
import { commitItemIconMap } from '~/ide/constants';
-import { getCommitIconMap } from '~/ide/utils';
+import { getCommitIconMap, isTextFile } from '~/ide/utils';
import { decorateData } from '~/ide/stores/utils';
describe('WebIDE utils', () => {
+ describe('isTextFile', () => {
+ it('returns false for known binary types', () => {
+ expect(isTextFile('file content', 'image/png', 'my.png')).toBeFalsy();
+ // mime types are case insensitive
+ expect(isTextFile('file content', 'IMAGE/PNG', 'my.png')).toBeFalsy();
+ });
+
+ it('returns true for known text types', () => {
+ expect(isTextFile('file content', 'text/plain', 'my.txt')).toBeTruthy();
+ // mime types are case insensitive
+ expect(isTextFile('file content', 'TEXT/PLAIN', 'my.txt')).toBeTruthy();
+ });
+
+ it('returns true for file extensions that Monaco supports syntax highlighting for', () => {
+ // test based on both MIME and extension
+ expect(isTextFile('{"éêė":"value"}', 'application/json', 'my.json')).toBeTruthy();
+ expect(isTextFile('{"éêė":"value"}', 'application/json', '.tsconfig')).toBeTruthy();
+ expect(isTextFile('SELECT "éêė" from tablename', 'application/sql', 'my.sql')).toBeTruthy();
+ });
+
+ it('returns true even irrespective of whether the mimes, extensions or file names are lowercase or upper case', () => {
+ expect(isTextFile('{"éêė":"value"}', 'application/json', 'MY.JSON')).toBeTruthy();
+ expect(isTextFile('SELECT "éêė" from tablename', 'application/sql', 'MY.SQL')).toBeTruthy();
+ expect(
+ isTextFile('var code = "something"', 'application/javascript', 'Gruntfile'),
+ ).toBeTruthy();
+ expect(
+ isTextFile(
+ 'MAINTAINER Александр "alexander11354322283@me.com"',
+ 'application/octet-stream',
+ 'dockerfile',
+ ),
+ ).toBeTruthy();
+ });
+
+ it('returns false if filename is same as the expected extension', () => {
+ expect(isTextFile('SELECT "éêė" from tablename', 'application/sql', 'sql')).toBeFalsy();
+ });
+
+ it('returns true for ASCII only content for unknown types', () => {
+ expect(isTextFile('plain text', 'application/x-new-type', 'hello.mytype')).toBeTruthy();
+ });
+
+ it('returns true for relevant filenames', () => {
+ expect(
+ isTextFile(
+ 'MAINTAINER Александр "alexander11354322283@me.com"',
+ 'application/octet-stream',
+ 'Dockerfile',
+ ),
+ ).toBeTruthy();
+ });
+
+ it('returns false for non-ASCII content for unknown types', () => {
+ expect(isTextFile('{"éêė":"value"}', 'application/octet-stream', 'my.random')).toBeFalsy();
+ });
+ });
+
const createFile = (name = 'name', id = name, type = '', parent = null) =>
decorateData({
id,
diff --git a/spec/frontend/monitoring/components/panel_type_spec.js b/spec/frontend/monitoring/components/panel_type_spec.js
index dbbe3f55298..058c201d325 100644
--- a/spec/frontend/monitoring/components/panel_type_spec.js
+++ b/spec/frontend/monitoring/components/panel_type_spec.js
@@ -148,6 +148,82 @@ describe('Panel Type component', () => {
});
});
+ describe('Edit custom metric dropdown item', () => {
+ const findEditCustomMetricLink = () => wrapper.find({ ref: 'editMetricLink' });
+
+ beforeEach(() => {
+ createWrapper({
+ graphData: {
+ ...graphDataPrometheusQueryRange,
+ },
+ });
+
+ return wrapper.vm.$nextTick();
+ });
+
+ it('is not present if the panel is not a custom metric', () => {
+ expect(findEditCustomMetricLink().exists()).toBe(false);
+ });
+
+ it('is present when the panel contains an edit_path property', () => {
+ wrapper.setProps({
+ graphData: {
+ ...graphDataPrometheusQueryRange,
+ metrics: [
+ {
+ ...graphDataPrometheusQueryRange.metrics[0],
+ edit_path: '/root/kubernetes-gke-project/prometheus/metrics/23/edit',
+ },
+ ],
+ },
+ });
+
+ return wrapper.vm.$nextTick(() => {
+ expect(findEditCustomMetricLink().exists()).toBe(true);
+ });
+ });
+
+ it('shows an "Edit metric" link for a panel with a single metric', () => {
+ wrapper.setProps({
+ graphData: {
+ ...graphDataPrometheusQueryRange,
+ metrics: [
+ {
+ ...graphDataPrometheusQueryRange.metrics[0],
+ edit_path: '/root/kubernetes-gke-project/prometheus/metrics/23/edit',
+ },
+ ],
+ },
+ });
+
+ return wrapper.vm.$nextTick(() => {
+ expect(findEditCustomMetricLink().text()).toBe('Edit metric');
+ });
+ });
+
+ it('shows an "Edit metrics" link for a panel with multiple metrics', () => {
+ wrapper.setProps({
+ graphData: {
+ ...graphDataPrometheusQueryRange,
+ metrics: [
+ {
+ ...graphDataPrometheusQueryRange.metrics[0],
+ edit_path: '/root/kubernetes-gke-project/prometheus/metrics/23/edit',
+ },
+ {
+ ...graphDataPrometheusQueryRange.metrics[0],
+ edit_path: '/root/kubernetes-gke-project/prometheus/metrics/23/edit',
+ },
+ ],
+ },
+ });
+
+ return wrapper.vm.$nextTick(() => {
+ expect(findEditCustomMetricLink().text()).toBe('Edit metrics');
+ });
+ });
+ });
+
describe('View Logs dropdown item', () => {
const mockLogsPath = '/path/to/logs';
const mockTimeRange = { duration: { seconds: 120 } };