summaryrefslogtreecommitdiff
path: root/spec/frontend/vue_shared/components/runner_instructions/instructions/runner_aws_instructions_spec.js
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-02-20 13:49:51 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2023-02-20 13:49:51 +0000
commit71786ddc8e28fbd3cb3fcc4b3ff15e5962a1c82e (patch)
tree6a2d93ef3fb2d353bb7739e4b57e6541f51cdd71 /spec/frontend/vue_shared/components/runner_instructions/instructions/runner_aws_instructions_spec.js
parenta7253423e3403b8c08f8a161e5937e1488f5f407 (diff)
downloadgitlab-ce-71786ddc8e28fbd3cb3fcc4b3ff15e5962a1c82e.tar.gz
Add latest changes from gitlab-org/gitlab@15-9-stable-eev15.9.0-rc42
Diffstat (limited to 'spec/frontend/vue_shared/components/runner_instructions/instructions/runner_aws_instructions_spec.js')
-rw-r--r--spec/frontend/vue_shared/components/runner_instructions/instructions/runner_aws_instructions_spec.js29
1 files changed, 27 insertions, 2 deletions
diff --git a/spec/frontend/vue_shared/components/runner_instructions/instructions/runner_aws_instructions_spec.js b/spec/frontend/vue_shared/components/runner_instructions/instructions/runner_aws_instructions_spec.js
index 4d566dbec0c..6d8f895a185 100644
--- a/spec/frontend/vue_shared/components/runner_instructions/instructions/runner_aws_instructions_spec.js
+++ b/spec/frontend/vue_shared/components/runner_instructions/instructions/runner_aws_instructions_spec.js
@@ -16,14 +16,18 @@ import {
AWS_TEMPLATES_BASE_URL,
AWS_EASY_BUTTONS,
} from '~/vue_shared/components/runner_instructions/constants';
-import RunnerAwsInstructions from '~/vue_shared/components/runner_instructions/instructions/runner_aws_instructions.vue';
import { __ } from '~/locale';
+import RunnerAwsInstructions from '~/vue_shared/components/runner_instructions/instructions/runner_aws_instructions.vue';
+import ModalCopyButton from '~/vue_shared/components/modal_copy_button.vue';
+
jest.mock('~/lib/utils/url_utility', () => ({
...jest.requireActual('~/lib/utils/url_utility'),
visitUrl: jest.fn(),
}));
+const mockRegistrationToken = 'MY_TOKEN';
+
describe('RunnerAwsInstructions', () => {
let wrapper;
@@ -31,6 +35,7 @@ describe('RunnerAwsInstructions', () => {
const findEasyButtons = () => wrapper.findAllComponents(GlFormRadio);
const findEasyButtonAt = (i) => findEasyButtons().at(i);
const findLink = () => wrapper.findComponent(GlLink);
+ const findModalCopyButton = () => wrapper.findComponent(ModalCopyButton);
const findOkButton = () =>
wrapper
.findAllComponents(GlButton)
@@ -38,8 +43,12 @@ describe('RunnerAwsInstructions', () => {
.at(0);
const findCloseButton = () => wrapper.findByText(__('Close'));
- const createComponent = () => {
+ const createComponent = ({ props = {} } = {}) => {
wrapper = shallowMountExtended(RunnerAwsInstructions, {
+ propsData: {
+ registrationToken: mockRegistrationToken,
+ ...props,
+ },
stubs: {
GlSprintf,
},
@@ -109,6 +118,22 @@ describe('RunnerAwsInstructions', () => {
expect(findLink().attributes('href')).toBe(AWS_README_URL);
});
+ it('shows registration token and copy button', () => {
+ const token = wrapper.findByText(mockRegistrationToken);
+
+ expect(token.exists()).toBe(true);
+ expect(token.element.tagName).toBe('PRE');
+
+ expect(findModalCopyButton().props('text')).toBe(mockRegistrationToken);
+ });
+
+ it('does not show registration token and copy button when token is not present', () => {
+ createComponent({ props: { registrationToken: null } });
+
+ expect(wrapper.find('pre').exists()).toBe(false);
+ expect(findModalCopyButton().exists()).toBe(false);
+ });
+
it('triggers the modal to close', () => {
findCloseButton().vm.$emit('click');