summaryrefslogtreecommitdiff
path: root/spec/frontend/ide/stores
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-05-19 15:44:42 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-05-19 15:44:42 +0000
commit4555e1b21c365ed8303ffb7a3325d773c9b8bf31 (patch)
tree5423a1c7516cffe36384133ade12572cf709398d /spec/frontend/ide/stores
parente570267f2f6b326480d284e0164a6464ba4081bc (diff)
downloadgitlab-ce-4555e1b21c365ed8303ffb7a3325d773c9b8bf31.tar.gz
Add latest changes from gitlab-org/gitlab@13-12-stable-eev13.12.0-rc42
Diffstat (limited to 'spec/frontend/ide/stores')
-rw-r--r--spec/frontend/ide/stores/actions/alert_spec.js46
-rw-r--r--spec/frontend/ide/stores/actions_spec.js19
-rw-r--r--spec/frontend/ide/stores/getters/alert_spec.js46
-rw-r--r--spec/frontend/ide/stores/mutations/alert_spec.js26
4 files changed, 128 insertions, 9 deletions
diff --git a/spec/frontend/ide/stores/actions/alert_spec.js b/spec/frontend/ide/stores/actions/alert_spec.js
new file mode 100644
index 00000000000..1321c402ebb
--- /dev/null
+++ b/spec/frontend/ide/stores/actions/alert_spec.js
@@ -0,0 +1,46 @@
+import testAction from 'helpers/vuex_action_helper';
+import service from '~/ide/services';
+import {
+ detectEnvironmentsGuidance,
+ dismissEnvironmentsGuidance,
+} from '~/ide/stores/actions/alert';
+import * as types from '~/ide/stores/mutation_types';
+
+jest.mock('~/ide/services');
+
+describe('~/ide/stores/actions/alert', () => {
+ describe('detectEnvironmentsGuidance', () => {
+ it('should try to fetch CI info', () => {
+ const stages = ['a', 'b', 'c'];
+ service.getCiConfig.mockResolvedValue({ stages });
+
+ return testAction(
+ detectEnvironmentsGuidance,
+ 'the content',
+ { currentProjectId: 'gitlab/test' },
+ [{ type: types.DETECT_ENVIRONMENTS_GUIDANCE_ALERT, payload: stages }],
+ [],
+ () => expect(service.getCiConfig).toHaveBeenCalledWith('gitlab/test', 'the content'),
+ );
+ });
+ });
+ describe('dismissCallout', () => {
+ it('should try to dismiss the given callout', () => {
+ const callout = { featureName: 'test', dismissedAt: 'now' };
+
+ service.dismissUserCallout.mockResolvedValue({ userCalloutCreate: { userCallout: callout } });
+
+ return testAction(
+ dismissEnvironmentsGuidance,
+ undefined,
+ {},
+ [{ type: types.DISMISS_ENVIRONMENTS_GUIDANCE_ALERT }],
+ [],
+ () =>
+ expect(service.dismissUserCallout).toHaveBeenCalledWith(
+ 'web_ide_ci_environments_guidance',
+ ),
+ );
+ });
+ });
+});
diff --git a/spec/frontend/ide/stores/actions_spec.js b/spec/frontend/ide/stores/actions_spec.js
index d47dd88dd47..ad55313da93 100644
--- a/spec/frontend/ide/stores/actions_spec.js
+++ b/spec/frontend/ide/stores/actions_spec.js
@@ -4,6 +4,7 @@ import eventHub from '~/ide/eventhub';
import { createRouter } from '~/ide/ide_router';
import { createStore } from '~/ide/stores';
import {
+ init,
stageAllChanges,
unstageAllChanges,
toggleFileFinder,
@@ -54,15 +55,15 @@ describe('Multi-file store actions', () => {
});
});
- describe('setInitialData', () => {
- it('commits initial data', (done) => {
- store
- .dispatch('setInitialData', { canCommit: true })
- .then(() => {
- expect(store.state.canCommit).toBeTruthy();
- done();
- })
- .catch(done.fail);
+ describe('init', () => {
+ it('commits initial data and requests user callouts', () => {
+ return testAction(
+ init,
+ { canCommit: true },
+ store.state,
+ [{ type: 'SET_INITIAL_DATA', payload: { canCommit: true } }],
+ [],
+ );
});
});
diff --git a/spec/frontend/ide/stores/getters/alert_spec.js b/spec/frontend/ide/stores/getters/alert_spec.js
new file mode 100644
index 00000000000..7068b8e637f
--- /dev/null
+++ b/spec/frontend/ide/stores/getters/alert_spec.js
@@ -0,0 +1,46 @@
+import { getAlert } from '~/ide/lib/alerts';
+import EnvironmentsMessage from '~/ide/lib/alerts/environments.vue';
+import { createStore } from '~/ide/stores';
+import * as getters from '~/ide/stores/getters/alert';
+import { file } from '../../helpers';
+
+describe('IDE store alert getters', () => {
+ let localState;
+ let localStore;
+
+ beforeEach(() => {
+ localStore = createStore();
+ localState = localStore.state;
+ });
+
+ describe('alerts', () => {
+ describe('shows an alert about environments', () => {
+ let alert;
+
+ beforeEach(() => {
+ const f = file('.gitlab-ci.yml');
+ localState.openFiles.push(f);
+ localState.currentActivityView = 'repo-commit-section';
+ localState.environmentsGuidanceAlertDetected = true;
+ localState.environmentsGuidanceAlertDismissed = false;
+
+ const alertKey = getters.getAlert(localState)(f);
+ alert = getAlert(alertKey);
+ });
+
+ it('has a message suggesting to use environments', () => {
+ expect(alert.message).toEqual(EnvironmentsMessage);
+ });
+
+ it('dispatches to dismiss the callout on dismiss', () => {
+ jest.spyOn(localStore, 'dispatch').mockImplementation();
+ alert.dismiss(localStore);
+ expect(localStore.dispatch).toHaveBeenCalledWith('dismissEnvironmentsGuidance');
+ });
+
+ it('should be a tip alert', () => {
+ expect(alert.props).toEqual({ variant: 'tip' });
+ });
+ });
+ });
+});
diff --git a/spec/frontend/ide/stores/mutations/alert_spec.js b/spec/frontend/ide/stores/mutations/alert_spec.js
new file mode 100644
index 00000000000..2840ec4ebb7
--- /dev/null
+++ b/spec/frontend/ide/stores/mutations/alert_spec.js
@@ -0,0 +1,26 @@
+import * as types from '~/ide/stores/mutation_types';
+import mutations from '~/ide/stores/mutations/alert';
+
+describe('~/ide/stores/mutations/alert', () => {
+ const state = {};
+
+ describe(types.DETECT_ENVIRONMENTS_GUIDANCE_ALERT, () => {
+ it('checks the stages for any that configure environments', () => {
+ mutations[types.DETECT_ENVIRONMENTS_GUIDANCE_ALERT](state, {
+ nodes: [{ groups: { nodes: [{ jobs: { nodes: [{}] } }] } }],
+ });
+ expect(state.environmentsGuidanceAlertDetected).toBe(true);
+ mutations[types.DETECT_ENVIRONMENTS_GUIDANCE_ALERT](state, {
+ nodes: [{ groups: { nodes: [{ jobs: { nodes: [{ environment: {} }] } }] } }],
+ });
+ expect(state.environmentsGuidanceAlertDetected).toBe(false);
+ });
+ });
+
+ describe(types.DISMISS_ENVIRONMENTS_GUIDANCE_ALERT, () => {
+ it('stops environments guidance', () => {
+ mutations[types.DISMISS_ENVIRONMENTS_GUIDANCE_ALERT](state);
+ expect(state.environmentsGuidanceAlertDismissed).toBe(true);
+ });
+ });
+});