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-05-31 00:09:08 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-05-31 00:09:08 +0300
commite690e4ea1fff57191fb1166e5022c2bcfe308c86 (patch)
tree927defa8c5dc5eccc0842a47a78166072f6b8daf /spec/frontend/environments
parent2655ac9cd596526f2ea89a86e4f615139ee40fc4 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/environments')
-rw-r--r--spec/frontend/environments/edit_environment_spec.js66
-rw-r--r--spec/frontend/environments/environment_form_spec.js17
2 files changed, 53 insertions, 30 deletions
diff --git a/spec/frontend/environments/edit_environment_spec.js b/spec/frontend/environments/edit_environment_spec.js
index c0be1558c43..f436c96f4a5 100644
--- a/spec/frontend/environments/edit_environment_spec.js
+++ b/spec/frontend/environments/edit_environment_spec.js
@@ -18,7 +18,12 @@ jest.mock('~/lib/utils/url_utility');
jest.mock('~/alert');
const newExternalUrl = 'https://google.ca';
-const environment = { id: '1', name: 'foo', externalUrl: 'https://foo.example.com' };
+const environment = {
+ id: '1',
+ name: 'foo',
+ externalUrl: 'https://foo.example.com',
+ clusterAgent: null,
+};
const resolvedEnvironment = { project: { id: '1', environment } };
const environmentUpdate = {
environment: { id: '1', path: 'path/to/environment', clusterAgentId: null },
@@ -34,40 +39,43 @@ const provide = {
updateEnvironmentPath: '/projects/environments/1',
protectedEnvironmentSettingsPath: '/projects/1/settings/ci_cd',
projectPath: '/path/to/project',
- environmentName: environment.name,
};
describe('~/environments/components/edit.vue', () => {
let wrapper;
let mock;
- const createMockApolloProvider = (mutationResult, environmentSettingsToGraphql) => {
+ const createMockApolloProvider = (mutationResult) => {
Vue.use(VueApollo);
- const mocks = [[getEnvironment, jest.fn().mockResolvedValue({ data: resolvedEnvironment })]];
-
- if (environmentSettingsToGraphql) {
- mocks.push([
+ const mocks = [
+ [getEnvironment, jest.fn().mockResolvedValue({ data: resolvedEnvironment })],
+ [
updateEnvironment,
jest.fn().mockResolvedValue({ data: { environmentUpdate: mutationResult } }),
- ]);
- }
+ ],
+ ];
return createMockApollo(mocks);
};
- const createWrapper = async ({
- mutationResult = environmentUpdate,
- environmentSettingsToGraphql = false,
- } = {}) => {
+ const createWrapper = () => {
wrapper = mountExtended(EditEnvironment, {
+ propsData: { environment: { id: '1', name: 'foo', external_url: 'https://foo.example.com' } },
+ provide,
+ });
+ };
+
+ const createWrapperWithApollo = async ({ mutationResult = environmentUpdate } = {}) => {
+ wrapper = mountExtended(EditEnvironment, {
+ propsData: { environment: {} },
provide: {
...provide,
glFeatures: {
- environmentSettingsToGraphql,
+ environmentSettingsToGraphql: true,
},
},
- apolloProvider: createMockApolloProvider(mutationResult, environmentSettingsToGraphql),
+ apolloProvider: createMockApolloProvider(mutationResult),
});
await waitForPromises();
@@ -109,9 +117,18 @@ describe('~/environments/components/edit.vue', () => {
});
describe('when environmentSettingsToGraphql feature is enabled', () => {
+ describe('when mounted', () => {
+ beforeEach(() => {
+ createWrapperWithApollo();
+ });
+ it('renders loading icon when environment query is loading', () => {
+ expect(showsLoading()).toBe(true);
+ });
+ });
+
describe('when mutation successful', () => {
beforeEach(async () => {
- await createWrapper({ environmentSettingsToGraphql: true });
+ await createWrapperWithApollo();
});
it('shows loader after form is submitted', async () => {
@@ -132,9 +149,8 @@ describe('~/environments/components/edit.vue', () => {
describe('when mutation failed', () => {
beforeEach(async () => {
- await createWrapper({
+ await createWrapperWithApollo({
mutationResult: environmentUpdateError,
- environmentSettingsToGraphql: true,
});
});
@@ -149,9 +165,9 @@ describe('~/environments/components/edit.vue', () => {
});
describe('when environmentSettingsToGraphql feature is disabled', () => {
- beforeEach(async () => {
+ beforeEach(() => {
mock = new MockAdapter(axios);
- await createWrapper();
+ createWrapper();
});
afterEach(() => {
@@ -202,14 +218,4 @@ describe('~/environments/components/edit.vue', () => {
expect(showsLoading()).toBe(false);
});
});
-
- describe('when environment query is loading', () => {
- beforeEach(() => {
- createWrapper();
- });
-
- it('renders loading icon', () => {
- expect(showsLoading()).toBe(true);
- });
- });
});
diff --git a/spec/frontend/environments/environment_form_spec.js b/spec/frontend/environments/environment_form_spec.js
index 9c70d8924b2..db81c490747 100644
--- a/spec/frontend/environments/environment_form_spec.js
+++ b/spec/frontend/environments/environment_form_spec.js
@@ -270,4 +270,21 @@ describe('~/environments/components/form.vue', () => {
]);
});
});
+
+ describe('when environment has an associated agent', () => {
+ const environmentWithAgent = {
+ ...DEFAULT_PROPS.environment,
+ clusterAgent: { id: '1', name: 'agent-1' },
+ clusterAgentId: '1',
+ };
+ beforeEach(() => {
+ wrapper = createWrapperWithApollo({
+ propsData: { environment: environmentWithAgent },
+ });
+ });
+
+ it('updates agent selector field with the name of the associated agent', () => {
+ expect(findAgentSelector().props('toggleText')).toBe('agent-1');
+ });
+ });
});