summaryrefslogtreecommitdiff
path: root/spec/frontend/jira_connect
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-04-26 03:18:41 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2023-04-26 03:18:41 +0000
commit77da08b6e8159daae9b352082bad0c55a003994f (patch)
tree4606ebcf8e9f864b4bee18f152f8e744fc1befb1 /spec/frontend/jira_connect
parent7d4bff6fe8d0716b9634709325e5857452b82ca5 (diff)
downloadgitlab-ce-77da08b6e8159daae9b352082bad0c55a003994f.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/jira_connect')
-rw-r--r--spec/frontend/jira_connect/subscriptions/components/add_namespace_modal/groups_list_item_spec.js101
-rw-r--r--spec/frontend/jira_connect/subscriptions/components/app_spec.js283
-rw-r--r--spec/frontend/jira_connect/subscriptions/components/user_link_spec.js46
-rw-r--r--spec/frontend/jira_connect/subscriptions/pages/sign_in/sign_in_gitlab_com_spec.js66
-rw-r--r--spec/frontend/jira_connect/subscriptions/pages/sign_in/sign_in_page_spec.js30
5 files changed, 188 insertions, 338 deletions
diff --git a/spec/frontend/jira_connect/subscriptions/components/add_namespace_modal/groups_list_item_spec.js b/spec/frontend/jira_connect/subscriptions/components/add_namespace_modal/groups_list_item_spec.js
index e437e6e0398..9b54c6d5c49 100644
--- a/spec/frontend/jira_connect/subscriptions/components/add_namespace_modal/groups_list_item_spec.js
+++ b/spec/frontend/jira_connect/subscriptions/components/add_namespace_modal/groups_list_item_spec.js
@@ -1,22 +1,11 @@
import { GlButton } from '@gitlab/ui';
import { mount, shallowMount } from '@vue/test-utils';
-import { nextTick } from 'vue';
-import waitForPromises from 'helpers/wait_for_promises';
-import * as JiraConnectApi from '~/jira_connect/subscriptions/api';
import GroupItemName from '~/jira_connect/subscriptions/components/group_item_name.vue';
import GroupsListItem from '~/jira_connect/subscriptions/components/add_namespace_modal/groups_list_item.vue';
-import { persistAlert, reloadPage } from '~/jira_connect/subscriptions/utils';
-import {
- I18N_ADD_SUBSCRIPTION_SUCCESS_ALERT_TITLE,
- I18N_ADD_SUBSCRIPTION_SUCCESS_ALERT_MESSAGE,
- INTEGRATIONS_DOC_LINK,
-} from '~/jira_connect/subscriptions/constants';
import createStore from '~/jira_connect/subscriptions/store';
import { mockGroup1 } from '../../mock_data';
-jest.mock('~/jira_connect/subscriptions/utils');
-
describe('GroupsListItem', () => {
let wrapper;
let store;
@@ -61,88 +50,24 @@ describe('GroupsListItem', () => {
});
describe('on Link button click', () => {
- describe('when jiraConnectOauth feature flag is disabled', () => {
- let addSubscriptionSpy;
-
- beforeEach(() => {
- createComponent({ mountFn: mount });
-
- addSubscriptionSpy = jest.spyOn(JiraConnectApi, 'addSubscription').mockResolvedValue();
- });
-
- it('sets button to loading and sends request', async () => {
- expect(findLinkButton().props('loading')).toBe(false);
-
- clickLinkButton();
- await nextTick();
+ const mockSubscriptionsPath = '/subscriptions';
- expect(findLinkButton().props('loading')).toBe(true);
- await waitForPromises();
-
- expect(addSubscriptionSpy).toHaveBeenCalledWith(
- mockAddSubscriptionsPath,
- mockGroup1.full_path,
- );
- expect(persistAlert).toHaveBeenCalledWith({
- linkUrl: INTEGRATIONS_DOC_LINK,
- message: I18N_ADD_SUBSCRIPTION_SUCCESS_ALERT_MESSAGE,
- title: I18N_ADD_SUBSCRIPTION_SUCCESS_ALERT_TITLE,
- variant: 'success',
- });
- });
-
- describe('when request is successful', () => {
- it('reloads the page', async () => {
- clickLinkButton();
-
- await waitForPromises();
-
- expect(reloadPage).toHaveBeenCalled();
- });
- });
-
- describe('when request has errors', () => {
- const mockErrorMessage = 'error message';
- const mockError = { response: { data: { error: mockErrorMessage } } };
-
- beforeEach(() => {
- addSubscriptionSpy = jest
- .spyOn(JiraConnectApi, 'addSubscription')
- .mockRejectedValue(mockError);
- });
-
- it('emits `error` event', async () => {
- clickLinkButton();
-
- await waitForPromises();
-
- expect(reloadPage).not.toHaveBeenCalled();
- expect(wrapper.emitted('error')[0][0]).toBe(mockErrorMessage);
- });
+ beforeEach(() => {
+ createComponent({
+ mountFn: mount,
+ provide: {
+ subscriptionsPath: mockSubscriptionsPath,
+ },
});
});
- describe('when jiraConnectOauth feature flag is enabled', () => {
- const mockSubscriptionsPath = '/subscriptions';
-
- beforeEach(() => {
- createComponent({
- mountFn: mount,
- provide: {
- subscriptionsPath: mockSubscriptionsPath,
- glFeatures: { jiraConnectOauth: true },
- },
- });
- });
+ it('dispatches `addSubscription` action', () => {
+ clickLinkButton();
- it('dispatches `addSubscription` action', async () => {
- clickLinkButton();
- await nextTick();
-
- expect(store.dispatch).toHaveBeenCalledWith('addSubscription', {
- namespacePath: mockGroup1.full_path,
- subscriptionsPath: mockSubscriptionsPath,
- });
+ expect(store.dispatch).toHaveBeenCalledTimes(1);
+ expect(store.dispatch).toHaveBeenCalledWith('addSubscription', {
+ namespacePath: mockGroup1.full_path,
+ subscriptionsPath: mockSubscriptionsPath,
});
});
});
diff --git a/spec/frontend/jira_connect/subscriptions/components/app_spec.js b/spec/frontend/jira_connect/subscriptions/components/app_spec.js
index aa4feaa5261..15a7e2e4ea0 100644
--- a/spec/frontend/jira_connect/subscriptions/components/app_spec.js
+++ b/spec/frontend/jira_connect/subscriptions/components/app_spec.js
@@ -1,6 +1,6 @@
-import { GlLink } from '@gitlab/ui';
+import { GlLink, GlSprintf } from '@gitlab/ui';
import { nextTick } from 'vue';
-import { mountExtended, shallowMountExtended } from 'helpers/vue_test_utils_helper';
+import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import JiraConnectApp from '~/jira_connect/subscriptions/components/app.vue';
import SignInPage from '~/jira_connect/subscriptions/pages/sign_in/sign_in_page.vue';
@@ -10,74 +10,48 @@ import BrowserSupportAlert from '~/jira_connect/subscriptions/components/browser
import createStore from '~/jira_connect/subscriptions/store';
import { SET_ALERT } from '~/jira_connect/subscriptions/store/mutation_types';
import { I18N_DEFAULT_SIGN_IN_ERROR_MESSAGE } from '~/jira_connect/subscriptions/constants';
+import { retrieveAlert } from '~/jira_connect/subscriptions/utils';
import { __ } from '~/locale';
import AccessorUtilities from '~/lib/utils/accessor';
import * as api from '~/jira_connect/subscriptions/api';
import { mockSubscription } from '../mock_data';
-jest.mock('~/jira_connect/subscriptions/utils', () => ({
- retrieveAlert: jest.fn().mockReturnValue({ message: 'error message' }),
- getGitlabSignInURL: jest.fn(),
-}));
+jest.mock('~/jira_connect/subscriptions/utils');
describe('JiraConnectApp', () => {
let wrapper;
let store;
+ const mockCurrentUser = { name: 'root' };
+
const findAlert = () => wrapper.findByTestId('jira-connect-persisted-alert');
+ const findJiraConnectApp = () => wrapper.findByTestId('jira-connect-app');
const findAlertLink = () => findAlert().findComponent(GlLink);
const findSignInPage = () => wrapper.findComponent(SignInPage);
const findSubscriptionsPage = () => wrapper.findComponent(SubscriptionsPage);
const findUserLink = () => wrapper.findComponent(UserLink);
const findBrowserSupportAlert = () => wrapper.findComponent(BrowserSupportAlert);
- const createComponent = ({ provide, mountFn = shallowMountExtended, initialState = {} } = {}) => {
+ const createComponent = ({ provide, initialState = {} } = {}) => {
store = createStore({ ...initialState, subscriptions: [mockSubscription] });
jest.spyOn(store, 'dispatch').mockImplementation();
- wrapper = mountFn(JiraConnectApp, {
+ wrapper = shallowMountExtended(JiraConnectApp, {
store,
provide,
+ stubs: {
+ GlSprintf,
+ },
});
};
describe('template', () => {
- describe.each`
- scenario | usersPath | shouldRenderSignInPage | shouldRenderSubscriptionsPage
- ${'user is not signed in'} | ${'/users'} | ${true} | ${false}
- ${'user is signed in'} | ${undefined} | ${false} | ${true}
- `('when $scenario', ({ usersPath, shouldRenderSignInPage, shouldRenderSubscriptionsPage }) => {
- beforeEach(() => {
- createComponent({
- provide: {
- usersPath,
- },
- });
- });
-
- it(`${shouldRenderSignInPage ? 'renders' : 'does not render'} sign in page`, () => {
- expect(findSignInPage().isVisible()).toBe(shouldRenderSignInPage);
- if (shouldRenderSignInPage) {
- expect(findSignInPage().props('hasSubscriptions')).toBe(true);
- }
- });
-
- it(`${
- shouldRenderSubscriptionsPage ? 'renders' : 'does not render'
- } subscriptions page`, () => {
- expect(findSubscriptionsPage().exists()).toBe(shouldRenderSubscriptionsPage);
- if (shouldRenderSubscriptionsPage) {
- expect(findSubscriptionsPage().props('hasSubscriptions')).toBe(true);
- }
- });
+ beforeEach(() => {
+ jest.spyOn(AccessorUtilities, 'canUseCrypto').mockReturnValue(true);
});
it('renders UserLink component', () => {
- createComponent({
- provide: {
- usersPath: '/user',
- },
- });
+ createComponent();
const userLink = findUserLink();
expect(userLink.exists()).toBe(true);
@@ -87,147 +61,170 @@ describe('JiraConnectApp', () => {
userSignedIn: false,
});
});
- });
-
- describe('alert', () => {
- it.each`
- message | variant | alertShouldRender
- ${'Test error'} | ${'danger'} | ${true}
- ${'Test notice'} | ${'info'} | ${true}
- ${''} | ${undefined} | ${false}
- ${undefined} | ${undefined} | ${false}
- `(
- 'renders correct alert when message is `$message` and variant is `$variant`',
- async ({ message, alertShouldRender, variant }) => {
- createComponent();
- store.commit(SET_ALERT, { message, variant });
- await nextTick();
+ it('renders only Jira Connect app', () => {
+ createComponent();
- const alert = findAlert();
+ expect(findBrowserSupportAlert().exists()).toBe(false);
+ expect(findJiraConnectApp().exists()).toBe(true);
+ });
- expect(alert.exists()).toBe(alertShouldRender);
- if (alertShouldRender) {
- expect(alert.isVisible()).toBe(alertShouldRender);
- expect(alert.html()).toContain(message);
- expect(alert.props('variant')).toBe(variant);
- expect(findAlertLink().exists()).toBe(false);
- }
- },
- );
+ it('renders only BrowserSupportAlert when canUseCrypto is false', () => {
+ jest.spyOn(AccessorUtilities, 'canUseCrypto').mockReturnValue(false);
- it('hides alert on @dismiss event', async () => {
createComponent();
- store.commit(SET_ALERT, { message: 'test message' });
- await nextTick();
-
- findAlert().vm.$emit('dismiss');
- await nextTick();
-
- expect(findAlert().exists()).toBe(false);
+ expect(findBrowserSupportAlert().exists()).toBe(true);
+ expect(findJiraConnectApp().exists()).toBe(false);
});
- it('renders link when `linkUrl` is set', async () => {
- createComponent({ provide: { usersPath: '' }, mountFn: mountExtended });
-
- store.commit(SET_ALERT, {
- message: __('test message %{linkStart}test link%{linkEnd}'),
- linkUrl: 'https://gitlab.com',
- });
- await nextTick();
+ describe.each`
+ scenario | currentUser | shouldRenderSignInPage | shouldRenderSubscriptionsPage
+ ${'user is not signed in'} | ${undefined} | ${true} | ${false}
+ ${'user is signed in'} | ${mockCurrentUser} | ${false} | ${true}
+ `(
+ 'when $scenario',
+ ({ currentUser, shouldRenderSignInPage, shouldRenderSubscriptionsPage }) => {
+ beforeEach(() => {
+ createComponent({
+ initialState: {
+ currentUser,
+ },
+ });
+ });
- const alertLink = findAlertLink();
+ it(`${shouldRenderSignInPage ? 'renders' : 'does not render'} sign in page`, () => {
+ expect(findSignInPage().isVisible()).toBe(shouldRenderSignInPage);
+ if (shouldRenderSignInPage) {
+ expect(findSignInPage().props('hasSubscriptions')).toBe(true);
+ }
+ });
- expect(alertLink.exists()).toBe(true);
- expect(alertLink.text()).toContain('test link');
- expect(alertLink.attributes('href')).toBe('https://gitlab.com');
- });
+ it(`${
+ shouldRenderSubscriptionsPage ? 'renders' : 'does not render'
+ } subscriptions page`, () => {
+ expect(findSubscriptionsPage().exists()).toBe(shouldRenderSubscriptionsPage);
+ if (shouldRenderSubscriptionsPage) {
+ expect(findSubscriptionsPage().props('hasSubscriptions')).toBe(true);
+ }
+ });
+ },
+ );
- describe('when alert is set in localStoage', () => {
- it('renders alert on mount', () => {
+ describe('when sign in page emits `error` event', () => {
+ beforeEach(() => {
createComponent();
+ findSignInPage().vm.$emit('error');
+ });
+ it('displays alert', () => {
const alert = findAlert();
expect(alert.exists()).toBe(true);
- expect(alert.html()).toContain('error message');
+ expect(alert.text()).toContain(I18N_DEFAULT_SIGN_IN_ERROR_MESSAGE);
+ expect(alert.props('variant')).toBe('danger');
});
});
- });
- describe('when user signed out', () => {
- describe('when sign in page emits `error` event', () => {
- beforeEach(async () => {
+ describe('when sign in page emits `sign-in-oauth` event', () => {
+ const mockSubscriptionsPath = '/mockSubscriptionsPath';
+
+ beforeEach(() => {
+ jest.spyOn(api, 'fetchSubscriptions').mockResolvedValue({ data: { subscriptions: [] } });
+
createComponent({
+ initialState: {
+ currentUser: mockCurrentUser,
+ },
provide: {
- usersPath: '/mock',
+ subscriptionsPath: mockSubscriptionsPath,
},
});
- findSignInPage().vm.$emit('error');
- await nextTick();
+ findSignInPage().vm.$emit('sign-in-oauth');
});
- it('displays alert', () => {
- const alert = findAlert();
-
- expect(alert.exists()).toBe(true);
- expect(alert.html()).toContain(I18N_DEFAULT_SIGN_IN_ERROR_MESSAGE);
- expect(alert.props('variant')).toBe('danger');
+ it('dispatches `fetchSubscriptions` action', () => {
+ expect(store.dispatch).toHaveBeenCalledWith('fetchSubscriptions', mockSubscriptionsPath);
});
});
- });
- describe.each`
- jiraConnectOauthEnabled | canUseCrypto | shouldShowAlert
- ${false} | ${false} | ${false}
- ${false} | ${true} | ${false}
- ${true} | ${false} | ${true}
- ${true} | ${true} | ${false}
- `(
- 'when `jiraConnectOauth` feature flag is $jiraConnectOauthEnabled and `AccessorUtilities.canUseCrypto` returns $canUseCrypto',
- ({ jiraConnectOauthEnabled, canUseCrypto, shouldShowAlert }) => {
- beforeEach(() => {
- jest.spyOn(AccessorUtilities, 'canUseCrypto').mockReturnValue(canUseCrypto);
+ describe('alert', () => {
+ const mockAlertData = { message: 'error message' };
- createComponent({ provide: { glFeatures: { jiraConnectOauth: jiraConnectOauthEnabled } } });
- });
+ describe.each`
+ alertData | expectAlert
+ ${undefined} | ${false}
+ ${mockAlertData} | ${true}
+ `('when retrieveAlert returns $alertData', ({ alertData, expectAlert }) => {
+ beforeEach(() => {
+ retrieveAlert.mockReturnValue(alertData);
- it(`does ${shouldShowAlert ? '' : 'not'} render BrowserSupportAlert component`, () => {
- expect(findBrowserSupportAlert().exists()).toBe(shouldShowAlert);
- });
+ createComponent();
+ });
+
+ it(`${expectAlert ? 'renders' : 'does not render'} alert on mount`, () => {
+ const alert = findAlert();
- it(`does ${!shouldShowAlert ? '' : 'not'} render the main Jira Connect app template`, () => {
- expect(wrapper.findByTestId('jira-connect-app').exists()).toBe(!shouldShowAlert);
+ expect(alert.exists()).toBe(expectAlert);
+ if (expectAlert) {
+ expect(alert.text()).toContain(mockAlertData.message);
+ }
+ });
});
- },
- );
- describe('when `jiraConnectOauth` feature flag is enabled', () => {
- const mockSubscriptionsPath = '/mockSubscriptionsPath';
+ it.each`
+ message | variant | alertShouldRender
+ ${'Test error'} | ${'danger'} | ${true}
+ ${'Test notice'} | ${'info'} | ${true}
+ ${''} | ${undefined} | ${false}
+ ${undefined} | ${undefined} | ${false}
+ `(
+ 'renders correct alert when message is `$message` and variant is `$variant`',
+ async ({ message, alertShouldRender, variant }) => {
+ createComponent();
+
+ store.commit(SET_ALERT, { message, variant });
+ await nextTick();
+
+ const alert = findAlert();
+
+ expect(alert.exists()).toBe(alertShouldRender);
+ if (alertShouldRender) {
+ expect(alert.isVisible()).toBe(alertShouldRender);
+ expect(alert.text()).toContain(message);
+ expect(alert.props('variant')).toBe(variant);
+ expect(findAlertLink().exists()).toBe(false);
+ }
+ },
+ );
- beforeEach(async () => {
- jest.spyOn(api, 'fetchSubscriptions').mockResolvedValue({ data: { subscriptions: [] } });
- jest.spyOn(AccessorUtilities, 'canUseCrypto').mockReturnValue(true);
+ it('hides alert on @dismiss event', async () => {
+ createComponent();
- createComponent({
- initialState: {
- currentUser: { name: 'root' },
- },
- provide: {
- glFeatures: { jiraConnectOauth: true },
- subscriptionsPath: mockSubscriptionsPath,
- },
+ store.commit(SET_ALERT, { message: 'test message' });
+ await nextTick();
+
+ findAlert().vm.$emit('dismiss');
+ await nextTick();
+
+ expect(findAlert().exists()).toBe(false);
});
- findSignInPage().vm.$emit('sign-in-oauth');
- await nextTick();
- });
+ it('renders link when `linkUrl` is set', async () => {
+ createComponent();
- describe('when oauth button emits `sign-in-oauth` event', () => {
- it('dispatches `fetchSubscriptions` action', () => {
- expect(store.dispatch).toHaveBeenCalledWith('fetchSubscriptions', mockSubscriptionsPath);
+ store.commit(SET_ALERT, {
+ message: __('test message %{linkStart}test link%{linkEnd}'),
+ linkUrl: 'https://gitlab.com',
+ });
+ await nextTick();
+
+ const alertLink = findAlertLink();
+
+ expect(alertLink.exists()).toBe(true);
+ expect(alertLink.text()).toContain('test link');
+ expect(alertLink.attributes('href')).toBe('https://gitlab.com');
});
});
});
diff --git a/spec/frontend/jira_connect/subscriptions/components/user_link_spec.js b/spec/frontend/jira_connect/subscriptions/components/user_link_spec.js
index c0bd908da0f..20cbcda8661 100644
--- a/spec/frontend/jira_connect/subscriptions/components/user_link_spec.js
+++ b/spec/frontend/jira_connect/subscriptions/components/user_link_spec.js
@@ -3,7 +3,6 @@ import UserLink from '~/jira_connect/subscriptions/components/user_link.vue';
import SignInOauthButton from '~/jira_connect/subscriptions/components/sign_in_oauth_button.vue';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
-import waitForPromises from 'helpers/wait_for_promises';
jest.mock('~/jira_connect/subscriptions/utils', () => ({
getGitlabSignInURL: jest.fn().mockImplementation((path) => Promise.resolve(path)),
@@ -23,28 +22,19 @@ describe('UserLink', () => {
});
};
- const findSignInLink = () => wrapper.findByTestId('sign-in-link');
const findGitlabUserLink = () => wrapper.findByTestId('gitlab-user-link');
const findSprintf = () => wrapper.findComponent(GlSprintf);
const findOauthButton = () => wrapper.findComponent(SignInOauthButton);
describe.each`
- userSignedIn | hasSubscriptions | expectGlSprintf | expectGlLink | expectOauthButton | jiraConnectOauthEnabled
- ${true} | ${false} | ${true} | ${false} | ${false} | ${false}
- ${false} | ${true} | ${false} | ${true} | ${false} | ${false}
- ${true} | ${true} | ${true} | ${false} | ${false} | ${false}
- ${false} | ${false} | ${false} | ${false} | ${false} | ${false}
- ${false} | ${true} | ${false} | ${false} | ${true} | ${true}
+ userSignedIn | hasSubscriptions | expectGlSprintf | expectOauthButton
+ ${false} | ${false} | ${false} | ${false}
+ ${false} | ${true} | ${false} | ${true}
+ ${true} | ${false} | ${true} | ${false}
+ ${true} | ${true} | ${true} | ${false}
`(
- 'when `userSignedIn` is $userSignedIn, `hasSubscriptions` is $hasSubscriptions, `jiraConnectOauthEnabled` is $jiraConnectOauthEnabled',
- ({
- userSignedIn,
- hasSubscriptions,
- expectGlSprintf,
- expectGlLink,
- expectOauthButton,
- jiraConnectOauthEnabled,
- }) => {
+ 'when `userSignedIn` is $userSignedIn, `hasSubscriptions` is $hasSubscriptions',
+ ({ userSignedIn, hasSubscriptions, expectGlSprintf, expectOauthButton }) => {
it('renders template correctly', () => {
createComponent(
{
@@ -53,39 +43,17 @@ describe('UserLink', () => {
},
{
provide: {
- glFeatures: {
- jiraConnectOauth: jiraConnectOauthEnabled,
- },
oauthMetadata: {},
},
},
);
expect(findSprintf().exists()).toBe(expectGlSprintf);
- expect(findSignInLink().exists()).toBe(expectGlLink);
expect(findOauthButton().exists()).toBe(expectOauthButton);
});
},
);
- describe('sign in link', () => {
- it('renders with correct href', async () => {
- const mockUsersPath = '/user';
- createComponent(
- {
- userSignedIn: false,
- hasSubscriptions: true,
- },
- { provide: { usersPath: mockUsersPath } },
- );
-
- await waitForPromises();
-
- expect(findSignInLink().exists()).toBe(true);
- expect(findSignInLink().attributes('href')).toBe(mockUsersPath);
- });
- });
-
describe('gitlab user link', () => {
describe.each`
current_username | gitlabUserPath | user | expectedUserHandle | expectedUserLink
diff --git a/spec/frontend/jira_connect/subscriptions/pages/sign_in/sign_in_gitlab_com_spec.js b/spec/frontend/jira_connect/subscriptions/pages/sign_in/sign_in_gitlab_com_spec.js
index be46c1d1609..cb9eb5f67f9 100644
--- a/spec/frontend/jira_connect/subscriptions/pages/sign_in/sign_in_gitlab_com_spec.js
+++ b/spec/frontend/jira_connect/subscriptions/pages/sign_in/sign_in_gitlab_com_spec.js
@@ -19,20 +19,16 @@ describe('SignInGitlabCom', () => {
let wrapper;
let store;
- const findSignInLegacyButton = () => wrapper.findComponent(SignInLegacyButton);
const findSignInOauthButton = () => wrapper.findComponent(SignInOauthButton);
const findSubscriptionsList = () => wrapper.findComponent(SubscriptionsList);
- const createComponent = ({ props, jiraConnectOauthEnabled } = {}) => {
+ const createComponent = ({ props } = {}) => {
store = createStore();
wrapper = shallowMount(SignInGitlabCom, {
store,
provide: {
...defaultProvide,
- glFeatures: {
- jiraConnectOauth: jiraConnectOauthEnabled,
- },
},
propsData: props,
stubs: {
@@ -48,57 +44,37 @@ describe('SignInGitlabCom', () => {
${'with subscriptions'} | ${true} | ${SignInGitlabCom.i18n.signInButtonTextWithSubscriptions}
${'without subscriptions'} | ${false} | ${I18N_DEFAULT_SIGN_IN_BUTTON_TEXT}
`('$scenario', ({ hasSubscriptions, signInButtonText }) => {
- describe('when `jiraConnectOauthEnabled` feature flag is disabled', () => {
- beforeEach(() => {
- createComponent({
- jiraConnectOauthEnabled: false,
- props: {
- hasSubscriptions,
- },
- });
- });
-
- it('renders legacy sign in button', () => {
- const button = findSignInLegacyButton();
- expect(button.props('usersPath')).toBe(mockUsersPath);
- expect(button.text()).toMatchInterpolatedText(signInButtonText);
+ beforeEach(() => {
+ createComponent({
+ props: {
+ hasSubscriptions,
+ },
});
});
- describe('when `jiraConnectOauthEnabled` feature flag is enabled', () => {
- beforeEach(() => {
- createComponent({
- jiraConnectOauthEnabled: true,
- props: {
- hasSubscriptions,
- },
- });
+ describe('oauth sign in button', () => {
+ it('renders oauth sign in button', () => {
+ const button = findSignInOauthButton();
+ expect(button.text()).toMatchInterpolatedText(signInButtonText);
});
- describe('oauth sign in button', () => {
- it('renders oauth sign in button', () => {
+ describe('when button emits `sign-in` event', () => {
+ it('emits `sign-in-oauth` event', () => {
const button = findSignInOauthButton();
- expect(button.text()).toMatchInterpolatedText(signInButtonText);
- });
- describe('when button emits `sign-in` event', () => {
- it('emits `sign-in-oauth` event', () => {
- const button = findSignInOauthButton();
+ const mockUser = { name: 'test' };
+ button.vm.$emit('sign-in', mockUser);
- const mockUser = { name: 'test' };
- button.vm.$emit('sign-in', mockUser);
-
- expect(wrapper.emitted('sign-in-oauth')[0]).toEqual([mockUser]);
- });
+ expect(wrapper.emitted('sign-in-oauth')[0]).toEqual([mockUser]);
});
+ });
- describe('when button emits `error` event', () => {
- it('emits `error` event', () => {
- const button = findSignInOauthButton();
- button.vm.$emit('error');
+ describe('when button emits `error` event', () => {
+ it('emits `error` event', () => {
+ const button = findSignInOauthButton();
+ button.vm.$emit('error');
- expect(wrapper.emitted('error')).toHaveLength(1);
- });
+ expect(wrapper.emitted('error')).toHaveLength(1);
});
});
});
diff --git a/spec/frontend/jira_connect/subscriptions/pages/sign_in/sign_in_page_spec.js b/spec/frontend/jira_connect/subscriptions/pages/sign_in/sign_in_page_spec.js
index 7639c3a9c3f..36e78ff309e 100644
--- a/spec/frontend/jira_connect/subscriptions/pages/sign_in/sign_in_page_spec.js
+++ b/spec/frontend/jira_connect/subscriptions/pages/sign_in/sign_in_page_spec.js
@@ -12,20 +12,11 @@ describe('SignInPage', () => {
const findSignInGitlabCom = () => wrapper.findComponent(SignInGitlabCom);
const findSignInGitabMultiversion = () => wrapper.findComponent(SignInGitlabMultiversion);
- const createComponent = ({
- props = {},
- jiraConnectOauthEnabled,
- publicKeyStorageEnabled,
- } = {}) => {
+ const createComponent = ({ props = {}, publicKeyStorageEnabled } = {}) => {
store = createStore();
wrapper = shallowMount(SignInPage, {
store,
- provide: {
- glFeatures: {
- jiraConnectOauth: jiraConnectOauthEnabled,
- },
- },
propsData: {
hasSubscriptions: false,
publicKeyStorageEnabled,
@@ -35,20 +26,13 @@ describe('SignInPage', () => {
};
it.each`
- jiraConnectOauthEnabled | publicKeyStorageEnabled | shouldRenderDotCom | shouldRenderMultiversion
- ${false} | ${true} | ${true} | ${false}
- ${false} | ${false} | ${true} | ${false}
- ${true} | ${true} | ${false} | ${true}
- ${true} | ${false} | ${true} | ${false}
+ publicKeyStorageEnabled | shouldRenderDotCom | shouldRenderMultiversion
+ ${true} | ${false} | ${true}
+ ${false} | ${true} | ${false}
`(
- 'renders correct component when jiraConnectOauth is $jiraConnectOauthEnabled',
- ({
- jiraConnectOauthEnabled,
- publicKeyStorageEnabled,
- shouldRenderDotCom,
- shouldRenderMultiversion,
- }) => {
- createComponent({ jiraConnectOauthEnabled, publicKeyStorageEnabled });
+ 'renders correct component when publicKeyStorageEnabled is $publicKeyStorageEnabled',
+ ({ publicKeyStorageEnabled, shouldRenderDotCom, shouldRenderMultiversion }) => {
+ createComponent({ publicKeyStorageEnabled });
expect(findSignInGitlabCom().exists()).toBe(shouldRenderDotCom);
expect(findSignInGitabMultiversion().exists()).toBe(shouldRenderMultiversion);