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-12-16 00:15:55 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-12-16 00:15:55 +0300
commit73778b9c53d13a2e06a693c30073366deedead8f (patch)
treed0ccbde07ae68feb9d7cfe68ffeea96ddedf2371 /spec/frontend
parent19ccf5e6435280a5fc3abc0748f78fd1ce103890 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend')
-rw-r--r--spec/frontend/fixtures/static/whats_new_notification.html7
-rw-r--r--spec/frontend/super_sidebar/components/help_center_spec.js7
-rw-r--r--spec/frontend/vue_merge_request_widget/components/approvals/approvals_spec.js36
-rw-r--r--spec/frontend/whats_new/utils/notification_spec.js73
4 files changed, 26 insertions, 97 deletions
diff --git a/spec/frontend/fixtures/static/whats_new_notification.html b/spec/frontend/fixtures/static/whats_new_notification.html
deleted file mode 100644
index bc8a27c779f..00000000000
--- a/spec/frontend/fixtures/static/whats_new_notification.html
+++ /dev/null
@@ -1,7 +0,0 @@
-<div class='whats-new-notification-fixture-root'>
- <div class='app' data-version-digest='version-digest'></div>
- <div data-testid='without-digest'></div>
- <div class='header-help'>
- <div class='js-whats-new-notification-count'></div>
- </div>
-</div>
diff --git a/spec/frontend/super_sidebar/components/help_center_spec.js b/spec/frontend/super_sidebar/components/help_center_spec.js
index 8ef742ba946..8e9e3e8ba20 100644
--- a/spec/frontend/super_sidebar/components/help_center_spec.js
+++ b/spec/frontend/super_sidebar/components/help_center_spec.js
@@ -168,14 +168,13 @@ describe('HelpCenter component', () => {
describe('showWhatsNew', () => {
beforeEach(() => {
- beforeEach(() => {
- createWrapper({ ...sidebarData, show_version_check: true });
- });
+ createWrapper({ ...sidebarData, show_version_check: true });
+
findButton("What's new 5").click();
});
it('shows the "What\'s new" slideout', () => {
- expect(toggleWhatsNewDrawer).toHaveBeenCalledWith(expect.any(Object));
+ expect(toggleWhatsNewDrawer).toHaveBeenCalledWith(sidebarData.whats_new_version_digest);
});
it('shows the existing "What\'s new" slideout instance on subsequent clicks', () => {
diff --git a/spec/frontend/vue_merge_request_widget/components/approvals/approvals_spec.js b/spec/frontend/vue_merge_request_widget/components/approvals/approvals_spec.js
index c81f4328d2a..c3ed131d6e3 100644
--- a/spec/frontend/vue_merge_request_widget/components/approvals/approvals_spec.js
+++ b/spec/frontend/vue_merge_request_widget/components/approvals/approvals_spec.js
@@ -1,11 +1,11 @@
import Vue, { nextTick } from 'vue';
import VueApollo from 'vue-apollo';
import { GlButton, GlSprintf } from '@gitlab/ui';
-import { shallowMount } from '@vue/test-utils';
import { createMockSubscription as createMockApolloSubscription } from 'mock-apollo-client';
import approvedByCurrentUser from 'test_fixtures/graphql/merge_requests/approvals/approvals.query.graphql.json';
-import { visitUrl } from '~/lib/utils/url_utility';
+import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import createMockApollo from 'helpers/mock_apollo_helper';
+import { stubComponent } from 'helpers/stub_component';
import waitForPromises from 'helpers/wait_for_promises';
import { getIdFromGraphQLId } from '~/graphql_shared/utils';
import { createAlert } from '~/alert';
@@ -29,11 +29,6 @@ jest.mock('~/alert', () => ({
dismiss: mockAlertDismiss,
})),
}));
-jest.mock('~/lib/utils/url_utility', () => ({
- ...jest.requireActual('~/lib/utils/url_utility'),
- visitUrl: jest.fn(),
-}));
-
const TEST_HELP_PATH = 'help/path';
const testApprovedBy = () => [1, 7, 10].map((id) => ({ id }));
const testApprovals = () => ({
@@ -53,6 +48,9 @@ describe('MRWidget approvals', () => {
let wrapper;
let service;
let mr;
+ const submitSpy = jest.fn().mockImplementation((e) => {
+ e.preventDefault();
+ });
const createComponent = (options = {}, responses = { query: approvedByCurrentUser }) => {
mockedSubscription = createMockApolloSubscription();
@@ -68,7 +66,7 @@ describe('MRWidget approvals', () => {
apolloProvider.defaultClient.setRequestHandler(query, stream);
});
- wrapper = shallowMount(Approvals, {
+ wrapper = shallowMountExtended(Approvals, {
apolloProvider,
propsData: {
mr,
@@ -78,7 +76,18 @@ describe('MRWidget approvals', () => {
provide,
stubs: {
GlSprintf,
+ GlForm: {
+ data() {
+ return { submitSpy };
+ },
+ // Workaround jsdom not implementing form submit
+ template: '<form @submit="submitSpy"><slot></slot></form>',
+ },
+ GlButton: stubComponent(GlButton, {
+ template: '<button><slot></slot></button>',
+ }),
},
+ attachTo: document.body,
});
};
@@ -257,11 +266,11 @@ describe('MRWidget approvals', () => {
});
describe('when SAML auth is required and user clicks Approve with SAML', () => {
- const fakeGroupSamlPath = '/example_group_saml';
+ const fakeSamlPath = '/example_group_saml';
beforeEach(async () => {
mr.requireSamlAuthToApprove = true;
- mr.samlApprovalPath = fakeGroupSamlPath;
+ mr.samlApprovalPath = fakeSamlPath;
createComponent({}, { query: createCanApproveResponse() });
await waitForPromises();
@@ -269,9 +278,10 @@ describe('MRWidget approvals', () => {
it('redirects the user to the group SAML path', async () => {
const action = findAction();
- action.vm.$emit('click');
- await nextTick();
- expect(visitUrl).toHaveBeenCalledWith(fakeGroupSamlPath);
+
+ await action.trigger('click');
+
+ expect(submitSpy).toHaveBeenCalled();
});
});
diff --git a/spec/frontend/whats_new/utils/notification_spec.js b/spec/frontend/whats_new/utils/notification_spec.js
deleted file mode 100644
index 020d833c578..00000000000
--- a/spec/frontend/whats_new/utils/notification_spec.js
+++ /dev/null
@@ -1,73 +0,0 @@
-import htmlWhatsNewNotification from 'test_fixtures_static/whats_new_notification.html';
-import { setHTMLFixture, resetHTMLFixture } from 'helpers/fixtures';
-import { useLocalStorageSpy } from 'helpers/local_storage_helper';
-import { setNotification, getVersionDigest } from '~/whats_new/utils/notification';
-
-describe('~/whats_new/utils/notification', () => {
- useLocalStorageSpy();
-
- let wrapper;
-
- const findNotificationEl = () => wrapper.querySelector('.header-help');
- const findNotificationCountEl = () => wrapper.querySelector('.js-whats-new-notification-count');
- const getAppEl = () => wrapper.querySelector('.app');
-
- beforeEach(() => {
- setHTMLFixture(htmlWhatsNewNotification);
- wrapper = document.querySelector('.whats-new-notification-fixture-root');
- });
-
- afterEach(() => {
- wrapper.remove();
- resetHTMLFixture();
- });
-
- describe('setNotification', () => {
- const subject = () => setNotification(getAppEl());
-
- it("when storage key doesn't exist it adds notifications class", () => {
- const notificationEl = findNotificationEl();
-
- expect(notificationEl.classList).not.toContain('with-notifications');
-
- subject();
-
- expect(findNotificationCountEl()).not.toBe(null);
- expect(notificationEl.classList).toContain('with-notifications');
- });
-
- it('removes class and count element when storage key has current digest', () => {
- const notificationEl = findNotificationEl();
-
- notificationEl.classList.add('with-notifications');
- localStorage.setItem('display-whats-new-notification', 'version-digest');
-
- expect(findNotificationCountEl()).not.toBe(null);
-
- subject();
-
- expect(findNotificationCountEl()).toBe(null);
- expect(notificationEl.classList).not.toContain('with-notifications');
- });
-
- it('removes class and count element when no records and digest undefined', () => {
- const notificationEl = findNotificationEl();
-
- notificationEl.classList.add('with-notifications');
- localStorage.setItem('display-whats-new-notification', 'version-digest');
-
- expect(findNotificationCountEl()).not.toBe(null);
-
- setNotification(wrapper.querySelector('[data-testid="without-digest"]'));
-
- expect(findNotificationCountEl()).toBe(null);
- expect(notificationEl.classList).not.toContain('with-notifications');
- });
- });
-
- describe('getVersionDigest', () => {
- it('retrieves the storage key data attribute from the el', () => {
- expect(getVersionDigest(getAppEl())).toBe('version-digest');
- });
- });
-});