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:
Diffstat (limited to 'spec/frontend/clusters_list/components/agent_token_spec.js')
-rw-r--r--spec/frontend/clusters_list/components/agent_token_spec.js40
1 files changed, 36 insertions, 4 deletions
diff --git a/spec/frontend/clusters_list/components/agent_token_spec.js b/spec/frontend/clusters_list/components/agent_token_spec.js
index 8d3130b45a6..a92a03fedb6 100644
--- a/spec/frontend/clusters_list/components/agent_token_spec.js
+++ b/spec/frontend/clusters_list/components/agent_token_spec.js
@@ -1,7 +1,13 @@
-import { GlAlert, GlFormInputGroup } from '@gitlab/ui';
+import { GlAlert, GlFormInputGroup, GlSprintf, GlLink, GlIcon } from '@gitlab/ui';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
+import { sprintf } from '~/locale';
import AgentToken from '~/clusters_list/components/agent_token.vue';
-import { I18N_AGENT_TOKEN, INSTALL_AGENT_MODAL_ID } from '~/clusters_list/constants';
+import {
+ I18N_AGENT_TOKEN,
+ INSTALL_AGENT_MODAL_ID,
+ NAME_MAX_LENGTH,
+ HELM_VERSION_POLICY_URL,
+} from '~/clusters_list/constants';
import { generateAgentRegistrationCommand } from '~/clusters_list/clusters_util';
import CodeBlock from '~/vue_shared/components/code_block.vue';
import ModalCopyButton from '~/vue_shared/components/modal_copy_button.vue';
@@ -19,15 +25,17 @@ describe('InstallAgentModal', () => {
const findCodeBlock = () => wrapper.findComponent(CodeBlock);
const findCopyButton = () => wrapper.findComponent(ModalCopyButton);
const findInput = () => wrapper.findComponent(GlFormInputGroup);
+ const findHelmVersionPolicyLink = () => wrapper.findComponent(GlLink);
+ const findHelmExternalLinkIcon = () => wrapper.findComponent(GlIcon);
- const createWrapper = () => {
+ const createWrapper = (newAgentName = agentName) => {
const provide = {
kasAddress,
kasVersion,
};
const propsData = {
- agentName,
+ agentName: newAgentName,
agentToken,
modalId,
};
@@ -35,6 +43,9 @@ describe('InstallAgentModal', () => {
wrapper = shallowMountExtended(AgentToken, {
provide,
propsData,
+ stubs: {
+ GlSprintf,
+ },
});
};
@@ -52,6 +63,17 @@ describe('InstallAgentModal', () => {
expect(wrapper.text()).toContain(I18N_AGENT_TOKEN.basicInstallBody);
});
+ it('shows Helm version policy text with an external link', () => {
+ expect(wrapper.text()).toContain(
+ sprintf(I18N_AGENT_TOKEN.helmVersionText, { linkStart: '', linkEnd: ' ' }),
+ );
+ expect(findHelmVersionPolicyLink().attributes()).toMatchObject({
+ href: HELM_VERSION_POLICY_URL,
+ target: '_blank',
+ });
+ expect(findHelmExternalLinkIcon().props()).toMatchObject({ name: 'external-link', size: 12 });
+ });
+
it('shows advanced agent installation instructions', () => {
expect(wrapper.text()).toContain(I18N_AGENT_TOKEN.advancedInstallTitle);
});
@@ -79,9 +101,19 @@ describe('InstallAgentModal', () => {
it('shows code block with agent installation command', () => {
expect(findCodeBlock().props('code')).toContain(`helm upgrade --install ${agentName}`);
+ expect(findCodeBlock().props('code')).toContain(`--namespace gitlab-agent-${agentName}`);
expect(findCodeBlock().props('code')).toContain(`--set config.token=${agentToken}`);
expect(findCodeBlock().props('code')).toContain(`--set config.kasAddress=${kasAddress}`);
expect(findCodeBlock().props('code')).toContain(`--set image.tag=v${kasVersion}`);
});
+
+ it('truncates the namespace name if it exceeds the maximum length', () => {
+ const newAgentName = 'agent-name-that-is-too-long-and-needs-to-be-truncated-to-use';
+ createWrapper(newAgentName);
+
+ expect(findCodeBlock().props('code')).toContain(
+ `--namespace gitlab-agent-${newAgentName.substring(0, NAME_MAX_LENGTH)}`,
+ );
+ });
});
});