summaryrefslogtreecommitdiff
path: root/spec/frontend/projects/new/components/new_project_push_tip_popover_spec.js
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/projects/new/components/new_project_push_tip_popover_spec.js')
-rw-r--r--spec/frontend/projects/new/components/new_project_push_tip_popover_spec.js75
1 files changed, 75 insertions, 0 deletions
diff --git a/spec/frontend/projects/new/components/new_project_push_tip_popover_spec.js b/spec/frontend/projects/new/components/new_project_push_tip_popover_spec.js
new file mode 100644
index 00000000000..31ddbc80ae4
--- /dev/null
+++ b/spec/frontend/projects/new/components/new_project_push_tip_popover_spec.js
@@ -0,0 +1,75 @@
+import { GlPopover, GlFormInputGroup } from '@gitlab/ui';
+import { shallowMount } from '@vue/test-utils';
+import NewProjectPushTipPopover from '~/projects/new/components/new_project_push_tip_popover.vue';
+import ClipboardButton from '~/vue_shared/components/clipboard_button.vue';
+
+describe('New project push tip popover', () => {
+ let wrapper;
+ const targetId = 'target';
+ const pushToCreateProjectCommand = 'command';
+ const workingWithProjectsHelpPath = 'path';
+
+ const findPopover = () => wrapper.findComponent(GlPopover);
+ const findClipboardButton = () => wrapper.findComponent(ClipboardButton);
+ const findFormInput = () => wrapper.findComponent(GlFormInputGroup);
+ const findHelpLink = () => wrapper.find('a');
+ const findTarget = () => document.getElementById(targetId);
+
+ const buildWrapper = () => {
+ wrapper = shallowMount(NewProjectPushTipPopover, {
+ propsData: {
+ target: findTarget(),
+ },
+ stubs: {
+ GlFormInputGroup,
+ },
+ provide: {
+ pushToCreateProjectCommand,
+ workingWithProjectsHelpPath,
+ },
+ });
+ };
+
+ beforeEach(() => {
+ setFixtures(`<a id="${targetId}"></a>`);
+ buildWrapper();
+ });
+
+ afterEach(() => {
+ wrapper.destroy();
+ });
+
+ it('renders popover that targets the specified target', () => {
+ expect(findPopover().props()).toMatchObject({
+ target: findTarget(),
+ triggers: 'click blur',
+ placement: 'top',
+ title: 'Push to create a project',
+ });
+ });
+
+ it('renders a readonly form input with the push to create command', () => {
+ expect(findFormInput().props()).toMatchObject({
+ value: pushToCreateProjectCommand,
+ selectOnClick: true,
+ });
+ expect(findFormInput().attributes()).toMatchObject({
+ 'aria-label': 'Push project from command line',
+ readonly: 'readonly',
+ });
+ });
+
+ it('allows copying the push command using the clipboard button', () => {
+ expect(findClipboardButton().props()).toMatchObject({
+ text: pushToCreateProjectCommand,
+ tooltipPlacement: 'right',
+ title: 'Copy command',
+ });
+ });
+
+ it('displays a link to open the push command help page reference', () => {
+ expect(findHelpLink().attributes().href).toBe(
+ `${workingWithProjectsHelpPath}#push-to-create-a-new-project`,
+ );
+ });
+});