@gitlab/ui 78.2.2 → 78.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -39,16 +39,11 @@ const generatePartialSlashCommands = () => {
39
39
  describe('GlDuoChat', () => {
40
40
  let wrapper;
41
41
 
42
- const createComponent = ({ propsData = {}, data = {}, slots = {} } = {}) => {
42
+ const createComponent = ({ propsData = {}, slots = {} } = {}) => {
43
43
  jest.spyOn(DuoChatLoader.methods, 'computeTransitionWidth').mockImplementation();
44
44
 
45
45
  wrapper = shallowMount(GlDuoChat, {
46
46
  propsData,
47
- data() {
48
- return {
49
- ...data,
50
- };
51
- },
52
47
  slots,
53
48
  stubs: {
54
49
  DuoChatLoader,
@@ -76,6 +71,8 @@ describe('GlDuoChat', () => {
76
71
  const findSlashCommands = () => wrapper.findAllComponents(GlDropdownItem);
77
72
  const findSelectedSlashCommand = () => wrapper.find('.active-command');
78
73
 
74
+ const setPromptInput = (val) => findChatInput().vm.$emit('input', val);
75
+
79
76
  beforeEach(() => {
80
77
  createComponent();
81
78
  });
@@ -321,8 +318,8 @@ describe('GlDuoChat', () => {
321
318
  `('$event should $action the prompt form', ({ trigger, expectEmitted } = {}) => {
322
319
  createComponent({
323
320
  propsData: { messages: [], isChatAvailable: true },
324
- data: { prompt: promptStr },
325
321
  });
322
+ setPromptInput(promptStr);
326
323
  trigger();
327
324
  expect(wrapper.emitted('send-chat-prompt')).toEqual(expectEmitted);
328
325
  });
@@ -335,8 +332,8 @@ describe('GlDuoChat', () => {
335
332
  `('prevents submission when loading $desc', ({ msgs } = {}) => {
336
333
  createComponent({
337
334
  propsData: { isChatAvailable: true, isLoading: true, messages: msgs },
338
- data: { prompt: promptStr },
339
335
  });
336
+ setPromptInput(promptStr);
340
337
  clickSubmit();
341
338
  expect(wrapper.emitted('send-chat-prompt')).toBe(undefined);
342
339
  });
@@ -352,18 +349,21 @@ describe('GlDuoChat', () => {
352
349
  ])('prevents submission when streaming (messages = "%o")', (msgs = []) => {
353
350
  createComponent({
354
351
  propsData: { isChatAvailable: true, messages: msgs },
355
- data: { prompt: promptStr },
356
352
  });
353
+ setPromptInput(promptStr);
357
354
  clickSubmit();
358
355
  expect(wrapper.emitted('send-chat-prompt')).toBe(undefined);
359
356
  });
360
357
 
361
358
  it('resets the prompt after form submission', async () => {
362
359
  const prompt = 'foo';
363
- createComponent({ data: { prompt } });
360
+ createComponent();
361
+ await setPromptInput(prompt);
364
362
  expect(findChatInput().props('value')).toBe(prompt);
363
+
365
364
  clickSubmit();
366
365
  await nextTick();
366
+
367
367
  expect(findChatInput().props('value')).toBe('');
368
368
  });
369
369
 
@@ -372,7 +372,8 @@ describe('GlDuoChat', () => {
372
372
  jest.spyOn(HTMLElement.prototype, 'focus').mockImplementation(function focusMockImpl() {
373
373
  focusSpy(this);
374
374
  });
375
- createComponent({ data: { prompt: 'TEST!' } });
375
+ createComponent();
376
+ await setPromptInput('TEST!');
376
377
 
377
378
  clickSubmit();
378
379
  await nextTick();
@@ -385,8 +386,8 @@ describe('GlDuoChat', () => {
385
386
  it('emits the event with the reset prompt', () => {
386
387
  createComponent({
387
388
  propsData: { messages, isChatAvailable: true },
388
- data: { prompt: CHAT_RESET_MESSAGE },
389
389
  });
390
+ setPromptInput(CHAT_RESET_MESSAGE);
390
391
  clickSubmit();
391
392
 
392
393
  expect(wrapper.emitted('send-chat-prompt')).toEqual([[CHAT_RESET_MESSAGE]]);
@@ -396,8 +397,8 @@ describe('GlDuoChat', () => {
396
397
  it('reset does nothing when chat is loading', () => {
397
398
  createComponent({
398
399
  propsData: { messages, isChatAvailable: true, isLoading: true },
399
- data: { prompt: CHAT_RESET_MESSAGE },
400
400
  });
401
+ setPromptInput(CHAT_RESET_MESSAGE);
401
402
  clickSubmit();
402
403
 
403
404
  expect(wrapper.emitted('send-chat-prompt')).toBeUndefined();
@@ -407,8 +408,8 @@ describe('GlDuoChat', () => {
407
408
  it('reset does nothing when there are no messages', () => {
408
409
  createComponent({
409
410
  propsData: { messages: [], isChatAvailable: true },
410
- data: { prompt: CHAT_RESET_MESSAGE },
411
411
  });
412
+ setPromptInput(CHAT_RESET_MESSAGE);
412
413
  clickSubmit();
413
414
 
414
415
  expect(wrapper.emitted('send-chat-prompt')).toBeUndefined();
@@ -429,8 +430,8 @@ describe('GlDuoChat', () => {
429
430
  messages: existingMessages,
430
431
  isChatAvailable: true,
431
432
  },
432
- data: { prompt: CHAT_RESET_MESSAGE },
433
433
  });
434
+ setPromptInput(CHAT_RESET_MESSAGE);
434
435
  clickSubmit();
435
436
 
436
437
  expect(wrapper.emitted('send-chat-prompt')).toBeUndefined();
@@ -442,16 +443,17 @@ describe('GlDuoChat', () => {
442
443
  });
443
444
  });
444
445
 
445
- describe('interaction', () => {
446
- it('is hidden after the header button is clicked', async () => {
446
+ describe('when closed', () => {
447
+ beforeEach(async () => {
447
448
  findCloseButton().vm.$emit('click');
448
449
  await nextTick();
449
- expect(findChatComponent().exists()).toBe(false);
450
450
  });
451
451
 
452
- it('resets the hidden status of the component on loading', async () => {
453
- createComponent({ data: { isHidden: true } });
452
+ it('is hidden', () => {
454
453
  expect(findChatComponent().exists()).toBe(false);
454
+ });
455
+
456
+ it('when starts loading, resets hidden status', async () => {
455
457
  // setProps is justified here because we are testing the component's
456
458
  // reactive behavior which consistutes an exception
457
459
  // See https://docs.gitlab.com/ee/development/fe_guide/style/vue.html#setting-component-state
@@ -461,7 +463,9 @@ describe('GlDuoChat', () => {
461
463
  await nextTick();
462
464
  expect(findChatComponent().exists()).toBe(true);
463
465
  });
466
+ });
464
467
 
468
+ describe('interaction', () => {
465
469
  it('renders custom loader when isLoading', () => {
466
470
  createComponent({ propsData: { isLoading: true } });
467
471
  expect(findCustomLoader().exists()).toBe(true);
@@ -554,11 +558,8 @@ describe('GlDuoChat', () => {
554
558
  });
555
559
 
556
560
  it('does not render slash commands when prompt is "/"', async () => {
557
- createComponent({
558
- data: {
559
- prompt: '/',
560
- },
561
- });
561
+ createComponent();
562
+ setPromptInput('/');
562
563
 
563
564
  await nextTick();
564
565
  expect(findSlashCommandsCard().exists()).toBe(false);
@@ -582,10 +583,8 @@ describe('GlDuoChat', () => {
582
583
  propsData: {
583
584
  slashCommands,
584
585
  },
585
- data: {
586
- prompt: '/',
587
- },
588
586
  });
587
+ setPromptInput('/');
589
588
 
590
589
  await nextTick();
591
590
  expect(findSlashCommandsCard().exists()).toBe(true);
@@ -615,10 +614,8 @@ describe('GlDuoChat', () => {
615
614
  propsData: {
616
615
  slashCommands,
617
616
  },
618
- data: {
619
- prompt,
620
- },
621
617
  });
618
+ setPromptInput(prompt);
622
619
 
623
620
  await nextTick();
624
621
  expect(findSlashCommandsCard().exists()).toBe(false);
@@ -634,10 +631,8 @@ describe('GlDuoChat', () => {
634
631
  propsData: {
635
632
  slashCommands,
636
633
  },
637
- data: {
638
- prompt,
639
- },
640
634
  });
635
+ setPromptInput(prompt);
641
636
 
642
637
  await nextTick();
643
638
  expect(findSlashCommandsCard().exists()).toBe(true);
@@ -653,10 +648,8 @@ describe('GlDuoChat', () => {
653
648
  propsData: {
654
649
  slashCommands,
655
650
  },
656
- data: {
657
- prompt,
658
- },
659
651
  });
652
+ setPromptInput(prompt);
660
653
 
661
654
  await nextTick();
662
655
  expect(findSlashCommandsCard().exists()).toBe(false);
@@ -688,10 +681,8 @@ describe('GlDuoChat', () => {
688
681
  propsData: {
689
682
  slashCommands,
690
683
  },
691
- data: {
692
- prompt,
693
- },
694
684
  });
685
+ setPromptInput(prompt);
695
686
 
696
687
  await nextTick();
697
688
  expect(findSlashCommands()).toHaveLength(expectedCommands.length);
@@ -709,10 +700,8 @@ describe('GlDuoChat', () => {
709
700
  slashCommands,
710
701
  messages,
711
702
  },
712
- data: {
713
- prompt: '/',
714
- },
715
703
  });
704
+ setPromptInput('/');
716
705
  });
717
706
 
718
707
  it('toggles through commands on ArrowDown', async () => {
@@ -777,10 +766,8 @@ describe('GlDuoChat', () => {
777
766
  slashCommands,
778
767
  messages,
779
768
  },
780
- data: {
781
- prompt: '/',
782
- },
783
769
  });
770
+ setPromptInput('/');
784
771
  });
785
772
 
786
773
  it('updates the selected command when hovering over it', async () => {
package/translations.json CHANGED
@@ -4,5 +4,6 @@
4
4
  "GlSorting.sortDescending": "Sort direction: descending",
5
5
  "GlSearchBoxByType.clearButtonTitle": "Clear",
6
6
  "GlSearchBoxByType.input.placeholder": "Search",
7
+ "GlBreadcrumb.showMoreLabel": "Show more breadcrumbs",
7
8
  "GlCollapsibleListbox.srOnlyResultsLabel": "Results count"
8
9
  }