diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 10:34:06 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 10:34:06 +0000 |
commit | 859a6fb938bb9ee2a317c46dfa4fcc1af49608f0 (patch) | |
tree | d7f2700abe6b4ffcb2dcfc80631b2d87d0609239 /spec/javascripts | |
parent | 446d496a6d000c73a304be52587cd9bbc7493136 (diff) | |
download | gitlab-ce-859a6fb938bb9ee2a317c46dfa4fcc1af49608f0.tar.gz |
Add latest changes from gitlab-org/gitlab@13-9-stable-eev13.9.0-rc42
Diffstat (limited to 'spec/javascripts')
-rw-r--r-- | spec/javascripts/fly_out_nav_browser_spec.js | 2 | ||||
-rw-r--r-- | spec/javascripts/matchers.js | 42 | ||||
-rw-r--r-- | spec/javascripts/monitoring/components/dashboard_resize_browser_spec.js | 6 | ||||
-rw-r--r-- | spec/javascripts/test_bundle.js | 17 |
4 files changed, 7 insertions, 60 deletions
diff --git a/spec/javascripts/fly_out_nav_browser_spec.js b/spec/javascripts/fly_out_nav_browser_spec.js index f92994594a9..12ea0e262bc 100644 --- a/spec/javascripts/fly_out_nav_browser_spec.js +++ b/spec/javascripts/fly_out_nav_browser_spec.js @@ -3,6 +3,7 @@ // see: https://gitlab.com/groups/gitlab-org/-/epics/895#what-if-theres-a-karma-spec-which-is-simply-unmovable-to-jest-ie-it-is-dependent-on-a-running-browser-environment import { GlBreakpointInstance } from '@gitlab/ui/dist/utils'; +import { SIDEBAR_COLLAPSED_CLASS } from '~/contextual_sidebar'; import { calculateTop, showSubLevelItems, @@ -19,7 +20,6 @@ import { setSidebar, subItemsMouseLeave, } from '~/fly_out_nav'; -import { SIDEBAR_COLLAPSED_CLASS } from '~/contextual_sidebar'; describe('Fly out sidebar navigation', () => { let el; diff --git a/spec/javascripts/matchers.js b/spec/javascripts/matchers.js deleted file mode 100644 index ae005e152ed..00000000000 --- a/spec/javascripts/matchers.js +++ /dev/null @@ -1,42 +0,0 @@ -import pixelmatch from 'pixelmatch'; - -export default { - toImageDiffEqual: () => { - const getImageData = (img) => { - const canvas = document.createElement('canvas'); - canvas.width = img.width; - canvas.height = img.height; - canvas.getContext('2d').drawImage(img, 0, 0); - return canvas.getContext('2d').getImageData(0, 0, img.width, img.height).data; - }; - - return { - compare(actual, expected, threshold = 0.1) { - if (actual.height !== expected.height || actual.width !== expected.width) { - return { - pass: false, - message: `Expected image dimensions (h x w) of ${expected.height}x${expected.width}. - Received an image with ${actual.height}x${actual.width}`, - }; - } - - const { width, height } = actual; - const differentPixels = pixelmatch( - getImageData(actual), - getImageData(expected), - null, - width, - height, - { threshold }, - ); - - return { - pass: differentPixels < 20, - message: `${differentPixels} pixels differ more than ${ - threshold * 100 - } percent between input and output.`, - }; - }, - }; - }, -}; diff --git a/spec/javascripts/monitoring/components/dashboard_resize_browser_spec.js b/spec/javascripts/monitoring/components/dashboard_resize_browser_spec.js index bbcdc0b879f..ec8d2778c1f 100644 --- a/spec/javascripts/monitoring/components/dashboard_resize_browser_spec.js +++ b/spec/javascripts/monitoring/components/dashboard_resize_browser_spec.js @@ -5,14 +5,14 @@ * https://gitlab.com/groups/gitlab-org/-/epics/895#what-if-theres-a-karma-spec-which-is-simply-unmovable-to-jest-ie-it-is-dependent-on-a-running-browser-environment */ -import Vue from 'vue'; import { createLocalVue } from '@vue/test-utils'; import MockAdapter from 'axios-mock-adapter'; +import Vue from 'vue'; +import axios from '~/lib/utils/axios_utils'; import Dashboard from '~/monitoring/components/dashboard.vue'; import { createStore } from '~/monitoring/stores'; -import axios from '~/lib/utils/axios_utils'; -import { mockApiEndpoint } from '../mock_data'; import { metricsDashboardPayload, dashboardProps } from '../fixture_data'; +import { mockApiEndpoint } from '../mock_data'; import { setupStoreWithData } from '../store_utils'; const localVue = createLocalVue(); diff --git a/spec/javascripts/test_bundle.js b/spec/javascripts/test_bundle.js index 59136de0b0d..be14d2ee7e7 100644 --- a/spec/javascripts/test_bundle.js +++ b/spec/javascripts/test_bundle.js @@ -2,20 +2,18 @@ jasmine/no-global-setup, no-underscore-dangle, no-console */ +import { config as testUtilsConfig } from '@vue/test-utils'; +import jasmineDiff from 'jasmine-diff'; import $ from 'jquery'; import 'core-js/features/set-immediate'; import 'vendor/jasmine-jquery'; import '~/commons'; import Vue from 'vue'; -import jasmineDiff from 'jasmine-diff'; -import { config as testUtilsConfig } from '@vue/test-utils'; +import { getDefaultAdapter } from '~/lib/utils/axios_utils'; import Translate from '~/vue_shared/translate'; -import { getDefaultAdapter } from '~/lib/utils/axios_utils'; import { FIXTURES_PATH, TEST_HOST } from './test_constants'; -import customMatchers from './matchers'; - // Tech debt issue TBD testUtilsConfig.logModifiedComponents = false; @@ -58,7 +56,6 @@ beforeAll(() => { inline: window.__karma__.config.color, }), ); - jasmine.addMatchers(customMatchers); }); // globalize common libraries @@ -81,14 +78,6 @@ window.addEventListener('unhandledrejection', (event) => { console.error(event.reason.stack || event.reason); }); -// HACK: Chrome 59 disconnects if there are too many synchronous tests in a row -// because it appears to lock up the thread that communicates to Karma's socket -// This async beforeEach gets called on every spec and releases the JS thread long -// enough for the socket to continue to communicate. -// The downside is that it creates a minor performance penalty in the time it takes -// to run our unit tests. -beforeEach((done) => done()); - let longRunningTestTimeoutHandle; beforeEach((done) => { |