@gitlab/ui 68.2.1 → 68.4.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.
- package/CHANGELOG.md +14 -0
- package/dist/components/experimental/duo/chat/duo_chat.js +93 -4
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/tokens/css/tokens.css +1 -1
- package/dist/tokens/css/tokens.dark.css +1 -1
- package/dist/tokens/js/tokens.dark.js +1 -1
- package/dist/tokens/js/tokens.js +1 -1
- package/dist/tokens/scss/_tokens.dark.scss +1 -1
- package/dist/tokens/scss/_tokens.scss +1 -1
- package/package.json +6 -6
- package/src/components/base/alert/alert.scss +16 -6
- package/src/components/base/alert/alert.stories.js +12 -0
- package/src/components/base/broadcast_message/broadcast_message.scss +12 -2
- package/src/components/base/broadcast_message/broadcast_message.stories.js +9 -0
- package/src/components/experimental/duo/chat/duo_chat.scss +19 -0
- package/src/components/experimental/duo/chat/duo_chat.spec.js +305 -8
- package/src/components/experimental/duo/chat/duo_chat.stories.js +6 -1
- package/src/components/experimental/duo/chat/duo_chat.vue +119 -1
- package/src/scss/mixins.scss +0 -1
package/dist/tokens/js/tokens.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gitlab/ui",
|
|
3
|
-
"version": "68.
|
|
3
|
+
"version": "68.4.0",
|
|
4
4
|
"description": "GitLab UI Components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -89,14 +89,14 @@
|
|
|
89
89
|
},
|
|
90
90
|
"devDependencies": {
|
|
91
91
|
"@arkweid/lefthook": "0.7.7",
|
|
92
|
-
"@babel/core": "^7.23.
|
|
93
|
-
"@babel/preset-env": "^7.23.
|
|
94
|
-
"@babel/preset-react": "^7.
|
|
92
|
+
"@babel/core": "^7.23.3",
|
|
93
|
+
"@babel/preset-env": "^7.23.3",
|
|
94
|
+
"@babel/preset-react": "^7.23.3",
|
|
95
95
|
"@cypress/grep": "^4.0.1",
|
|
96
96
|
"@gitlab/eslint-plugin": "19.2.0",
|
|
97
97
|
"@gitlab/fonts": "^1.3.0",
|
|
98
98
|
"@gitlab/stylelint-config": "5.0.1",
|
|
99
|
-
"@gitlab/svgs": "3.
|
|
99
|
+
"@gitlab/svgs": "3.71.0",
|
|
100
100
|
"@rollup/plugin-commonjs": "^11.1.0",
|
|
101
101
|
"@rollup/plugin-node-resolve": "^7.1.3",
|
|
102
102
|
"@rollup/plugin-replace": "^2.3.2",
|
|
@@ -124,7 +124,7 @@
|
|
|
124
124
|
"babel-loader": "^8.0.5",
|
|
125
125
|
"babel-plugin-require-context-hook": "^1.0.0",
|
|
126
126
|
"bootstrap": "4.6.2",
|
|
127
|
-
"cypress": "13.
|
|
127
|
+
"cypress": "13.5.0",
|
|
128
128
|
"cypress-axe": "^1.4.0",
|
|
129
129
|
"cypress-real-events": "^1.11.0",
|
|
130
130
|
"dompurify": "^3.0.0",
|
|
@@ -1,15 +1,25 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* --gl-alert-padding-x
|
|
3
|
+
*
|
|
4
|
+
* Way to hook into spacing of gl-alert.
|
|
5
|
+
* This is used e.g. for page wide containers
|
|
6
|
+
* in GitLab.
|
|
7
|
+
*/
|
|
8
|
+
// stylelint-disable length-zero-no-unit
|
|
9
|
+
$gl-alert-padding-x: var(--gl-alert-padding-x, 0px);
|
|
10
|
+
|
|
1
11
|
.gl-alert {
|
|
2
12
|
@include gl-font-base;
|
|
3
13
|
@include gl-relative;
|
|
4
|
-
|
|
14
|
+
padding-inline: calc(#{$gl-spacing-scale-9} + #{$gl-alert-padding-x});
|
|
5
15
|
@include gl-py-5;
|
|
6
16
|
|
|
7
17
|
&-not-dismissible {
|
|
8
|
-
|
|
18
|
+
padding-right: calc(#{$gl-spacing-scale-5} + #{$gl-alert-padding-x});
|
|
9
19
|
}
|
|
10
20
|
|
|
11
21
|
&-no-icon {
|
|
12
|
-
|
|
22
|
+
padding-left: calc(#{$gl-spacing-scale-5} + #{$gl-alert-padding-x});
|
|
13
23
|
}
|
|
14
24
|
|
|
15
25
|
.gl-link:not(.gl-label-link) {
|
|
@@ -35,14 +45,14 @@
|
|
|
35
45
|
.gl-alert-icon-container {
|
|
36
46
|
@include gl-absolute;
|
|
37
47
|
@include gl-top-5;
|
|
38
|
-
|
|
48
|
+
left: calc(#{$gl-spacing-scale-5} + #{$gl-alert-padding-x});
|
|
39
49
|
@include gl-display-flex;
|
|
40
50
|
@include gl-align-items-center;
|
|
41
51
|
height: $gl-line-height-20;
|
|
42
52
|
|
|
43
53
|
.gl-alert-has-title & {
|
|
44
54
|
@include gl-heading-scale-500; // get dynamic font-size
|
|
45
|
-
height: $gl-line-height-heading * 1em; // give unit to unitless relative line-height (1.25)
|
|
55
|
+
height: $gl-line-height-heading * 1em; // give unit to unitless relative line-height (1.25)
|
|
46
56
|
}
|
|
47
57
|
}
|
|
48
58
|
|
|
@@ -69,7 +79,7 @@
|
|
|
69
79
|
.gl-dismiss-btn {
|
|
70
80
|
@include gl-absolute;
|
|
71
81
|
@include gl-top-4;
|
|
72
|
-
|
|
82
|
+
right: calc(#{$gl-spacing-scale-4} + #{$gl-alert-padding-x});
|
|
73
83
|
}
|
|
74
84
|
|
|
75
85
|
.gl-alert-danger {
|
|
@@ -143,6 +143,18 @@ export const Sticky = () => ({
|
|
|
143
143
|
</div>`,
|
|
144
144
|
});
|
|
145
145
|
|
|
146
|
+
export const IncreasedSpacing = (args, { argTypes }) => ({
|
|
147
|
+
components: { GlAlert },
|
|
148
|
+
props: Object.keys(argTypes),
|
|
149
|
+
template: `
|
|
150
|
+
<div style="--gl-alert-padding-x: 0.5rem;">
|
|
151
|
+
<gl-alert>
|
|
152
|
+
Lorem ipsum dolor sit <a class="gl-link" href="#">text link</a> amet
|
|
153
|
+
</gl-alert>
|
|
154
|
+
</div>`,
|
|
155
|
+
});
|
|
156
|
+
IncreasedSpacing.args = generateProps();
|
|
157
|
+
|
|
146
158
|
export default {
|
|
147
159
|
title: 'base/alert',
|
|
148
160
|
component: GlAlert,
|
|
@@ -1,11 +1,21 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* --gl-broadcast-message-padding-x
|
|
3
|
+
*
|
|
4
|
+
* Way to hook into spacing of gl-alert.
|
|
5
|
+
* This is used e.g. for page wide containers
|
|
6
|
+
* in GitLab.
|
|
7
|
+
*/
|
|
8
|
+
// stylelint-disable length-zero-no-unit
|
|
9
|
+
$gl-broadcast-message-padding-x: var(--gl-broadcast-message-padding-x, 0px);
|
|
10
|
+
|
|
1
11
|
.gl-broadcast-message {
|
|
2
12
|
@include gl-display-flex;
|
|
3
13
|
@include gl-justify-content-space-between;
|
|
4
14
|
@include gl-align-items-flex-start;
|
|
5
15
|
@include gl-font-base;
|
|
6
16
|
@include gl-line-height-20;
|
|
7
|
-
|
|
8
|
-
|
|
17
|
+
padding-left: calc(#{$gl-spacing-scale-5} + #{$gl-broadcast-message-padding-x});
|
|
18
|
+
padding-right: calc(#{$gl-spacing-scale-4} + #{$gl-broadcast-message-padding-x});
|
|
9
19
|
@include gl-py-5;
|
|
10
20
|
|
|
11
21
|
&.indigo {
|
|
@@ -77,6 +77,15 @@ Stacked.parameters = {
|
|
|
77
77
|
storyshots: { disable: true },
|
|
78
78
|
};
|
|
79
79
|
|
|
80
|
+
export const IncreasedSpacing = (args, { argTypes }) => ({
|
|
81
|
+
components: {
|
|
82
|
+
GlBroadcastMessage,
|
|
83
|
+
},
|
|
84
|
+
props: Object.keys(argTypes),
|
|
85
|
+
template: `<div style="--gl-broadcast-message-padding-x: 0.5rem;">${template}</div>`,
|
|
86
|
+
});
|
|
87
|
+
IncreasedSpacing.args = generateProps();
|
|
88
|
+
|
|
80
89
|
export default {
|
|
81
90
|
title: 'base/broadcast message',
|
|
82
91
|
component: GlBroadcastMessage,
|
|
@@ -55,3 +55,22 @@
|
|
|
55
55
|
@include gl-py-4;
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
+
|
|
59
|
+
.slash-commands {
|
|
60
|
+
@include gl-mt-n2;
|
|
61
|
+
|
|
62
|
+
.active-command{
|
|
63
|
+
@include gl-bg-gray-50;
|
|
64
|
+
@include gl-rounded-base;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.gl-dropdown-item button.dropdown-item {
|
|
68
|
+
@include gl-font-sm;
|
|
69
|
+
@include gl-px-3;
|
|
70
|
+
@include gl-bg-none;
|
|
71
|
+
|
|
72
|
+
&:hover {
|
|
73
|
+
@include gl-bg-none;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -2,13 +2,23 @@ import { nextTick } from 'vue';
|
|
|
2
2
|
import { shallowMount } from '@vue/test-utils';
|
|
3
3
|
import GlEmptyState from '../../../regions/empty_state/empty_state.vue';
|
|
4
4
|
import GlExperimentBadge from '../../experiment_badge/experiment_badge.vue';
|
|
5
|
+
import GlCard from '../../../base/card/card.vue';
|
|
6
|
+
import GlDropdownItem from '../../../base/dropdown/dropdown_item.vue';
|
|
5
7
|
import DuoChatLoader from './components/duo_chat_loader/duo_chat_loader.vue';
|
|
6
8
|
import DuoChatPredefinedPrompts from './components/duo_chat_predefined_prompts/duo_chat_predefined_prompts.vue';
|
|
7
9
|
import DuoChatConversation from './components/duo_chat_conversation/duo_chat_conversation.vue';
|
|
8
|
-
import GlDuoChat from './duo_chat.vue';
|
|
10
|
+
import GlDuoChat, { slashCommands } from './duo_chat.vue';
|
|
9
11
|
|
|
10
12
|
import { MESSAGE_MODEL_ROLES, CHAT_RESET_MESSAGE } from './constants';
|
|
11
13
|
|
|
14
|
+
const generatePartialSlashCommands = () => {
|
|
15
|
+
const res = [];
|
|
16
|
+
slashCommands.forEach((command) => {
|
|
17
|
+
res.push(command.name.slice(0, command.name.length - 1));
|
|
18
|
+
});
|
|
19
|
+
return res;
|
|
20
|
+
};
|
|
21
|
+
|
|
12
22
|
describe('GlDuoChat', () => {
|
|
13
23
|
let wrapper;
|
|
14
24
|
|
|
@@ -43,6 +53,9 @@ describe('GlDuoChat', () => {
|
|
|
43
53
|
const findChatInput = () => wrapper.find('[data-testid="chat-prompt-input"]');
|
|
44
54
|
const findCloseChatButton = () => wrapper.find('[data-testid="chat-close-button"]');
|
|
45
55
|
const findLegalDisclaimer = () => wrapper.find('[data-testid="chat-legal-disclaimer"]');
|
|
56
|
+
const findSlashCommandsCard = () => wrapper.findComponent(GlCard);
|
|
57
|
+
const findSlashCommands = () => wrapper.findAllComponents(GlDropdownItem);
|
|
58
|
+
const findSelectedSlashCommand = () => wrapper.find('.active-command');
|
|
46
59
|
|
|
47
60
|
beforeEach(() => {
|
|
48
61
|
createComponent();
|
|
@@ -207,13 +220,13 @@ describe('GlDuoChat', () => {
|
|
|
207
220
|
const ENTER = 'Enter';
|
|
208
221
|
|
|
209
222
|
it.each`
|
|
210
|
-
trigger
|
|
211
|
-
${() => clickSubmit()}
|
|
212
|
-
${() => findChatInput().trigger('
|
|
213
|
-
${() => findChatInput().trigger('
|
|
214
|
-
${() => findChatInput().trigger('
|
|
215
|
-
${() => findChatInput().trigger('
|
|
216
|
-
${() => findChatInput().trigger('
|
|
223
|
+
trigger | event | action | expectEmitted
|
|
224
|
+
${() => clickSubmit()} | ${'Submit button click'} | ${'submit'} | ${[[promptStr]]}
|
|
225
|
+
${() => findChatInput().trigger('keyup', { key: ENTER })} | ${`Clicking ${ENTER}`} | ${'submit'} | ${[[promptStr]]}
|
|
226
|
+
${() => findChatInput().trigger('keyup', { key: ENTER, metaKey: true })} | ${`Clicking ${ENTER} + ⌘`} | ${'not submit'} | ${undefined}
|
|
227
|
+
${() => findChatInput().trigger('keyup', { key: ENTER, altKey: true })} | ${`Clicking ${ENTER} + ⎇`} | ${'not submit'} | ${undefined}
|
|
228
|
+
${() => findChatInput().trigger('keyup', { key: ENTER, shiftKey: true })} | ${`Clicking ${ENTER} + ⬆︎`} | ${'not submit'} | ${undefined}
|
|
229
|
+
${() => findChatInput().trigger('keyup', { key: ENTER, ctrlKey: true })} | ${`Clicking ${ENTER} + CTRL`} | ${'not submit'} | ${undefined}
|
|
217
230
|
`('$event should $action the prompt form', ({ trigger, expectEmitted } = {}) => {
|
|
218
231
|
createComponent({
|
|
219
232
|
propsData: { messages: [], isChatAvailable: true },
|
|
@@ -401,4 +414,288 @@ describe('GlDuoChat', () => {
|
|
|
401
414
|
});
|
|
402
415
|
});
|
|
403
416
|
});
|
|
417
|
+
|
|
418
|
+
describe('slash commands', () => {
|
|
419
|
+
const slashCommandsNames = slashCommands.map((command) => command.name);
|
|
420
|
+
const slashCommandsOnly = (commands = []) =>
|
|
421
|
+
slashCommandsNames.filter((name) => commands.includes(name));
|
|
422
|
+
|
|
423
|
+
describe('rendering', () => {
|
|
424
|
+
describe('without the `withSlashCommands` enabled', () => {
|
|
425
|
+
it('does not render slash commands by default', () => {
|
|
426
|
+
createComponent({
|
|
427
|
+
propsData: {
|
|
428
|
+
withSlashCommands: false,
|
|
429
|
+
},
|
|
430
|
+
});
|
|
431
|
+
expect(findSlashCommandsCard().exists()).toBe(false);
|
|
432
|
+
});
|
|
433
|
+
|
|
434
|
+
it('does not render slash commands when prompt is "/"', async () => {
|
|
435
|
+
createComponent({
|
|
436
|
+
propsData: {
|
|
437
|
+
withSlashCommands: false,
|
|
438
|
+
},
|
|
439
|
+
data: {
|
|
440
|
+
prompt: '/',
|
|
441
|
+
},
|
|
442
|
+
});
|
|
443
|
+
|
|
444
|
+
await nextTick();
|
|
445
|
+
expect(findSlashCommandsCard().exists()).toBe(false);
|
|
446
|
+
});
|
|
447
|
+
});
|
|
448
|
+
|
|
449
|
+
describe('with the `withSlashCommands` enabled', () => {
|
|
450
|
+
it('does not render slash commands by default', async () => {
|
|
451
|
+
createComponent({
|
|
452
|
+
propsData: {
|
|
453
|
+
withSlashCommands: true,
|
|
454
|
+
},
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
await nextTick();
|
|
458
|
+
expect(findSlashCommandsCard().exists()).toBe(false);
|
|
459
|
+
});
|
|
460
|
+
|
|
461
|
+
it('renders all slash commands when prompt is "/"', async () => {
|
|
462
|
+
createComponent({
|
|
463
|
+
propsData: {
|
|
464
|
+
withSlashCommands: true,
|
|
465
|
+
},
|
|
466
|
+
data: {
|
|
467
|
+
prompt: '/',
|
|
468
|
+
},
|
|
469
|
+
});
|
|
470
|
+
|
|
471
|
+
await nextTick();
|
|
472
|
+
expect(findSlashCommandsCard().exists()).toBe(true);
|
|
473
|
+
expect(findSlashCommands()).toHaveLength(slashCommands.length);
|
|
474
|
+
|
|
475
|
+
slashCommands.forEach((command, index) => {
|
|
476
|
+
expect(findSlashCommands().at(index).text()).toContain(command.name);
|
|
477
|
+
expect(findSlashCommands().at(index).text()).toContain(command.description);
|
|
478
|
+
});
|
|
479
|
+
});
|
|
480
|
+
|
|
481
|
+
describe('when the prompt includes the "/" character or no characters', () => {
|
|
482
|
+
it.each(['', '//', '\\', 'foo', '/foo'])(
|
|
483
|
+
'does not render the slash commands if prompt is "$prompt"',
|
|
484
|
+
async (prompt) => {
|
|
485
|
+
createComponent({
|
|
486
|
+
propsData: {
|
|
487
|
+
withSlashCommands: true,
|
|
488
|
+
},
|
|
489
|
+
data: {
|
|
490
|
+
prompt,
|
|
491
|
+
},
|
|
492
|
+
});
|
|
493
|
+
|
|
494
|
+
await nextTick();
|
|
495
|
+
expect(findSlashCommandsCard().exists()).toBe(false);
|
|
496
|
+
}
|
|
497
|
+
);
|
|
498
|
+
});
|
|
499
|
+
|
|
500
|
+
describe('when prompt presents a partial match to an existing slash command', () => {
|
|
501
|
+
it.each(generatePartialSlashCommands())(
|
|
502
|
+
'renders the slash commands when prompt is "%s" and is a partial match',
|
|
503
|
+
async (prompt) => {
|
|
504
|
+
createComponent({
|
|
505
|
+
propsData: {
|
|
506
|
+
withSlashCommands: true,
|
|
507
|
+
},
|
|
508
|
+
data: {
|
|
509
|
+
prompt,
|
|
510
|
+
},
|
|
511
|
+
});
|
|
512
|
+
|
|
513
|
+
await nextTick();
|
|
514
|
+
expect(findSlashCommandsCard().exists()).toBe(true);
|
|
515
|
+
}
|
|
516
|
+
);
|
|
517
|
+
});
|
|
518
|
+
|
|
519
|
+
describe('when the prompt matches a complete slash command', () => {
|
|
520
|
+
it.each(slashCommands.map((command) => command.name))(
|
|
521
|
+
'does not render the slash commands when prompt is "%s"',
|
|
522
|
+
async (prompt) => {
|
|
523
|
+
createComponent({
|
|
524
|
+
propsData: {
|
|
525
|
+
withSlashCommands: true,
|
|
526
|
+
},
|
|
527
|
+
data: {
|
|
528
|
+
prompt,
|
|
529
|
+
},
|
|
530
|
+
});
|
|
531
|
+
|
|
532
|
+
await nextTick();
|
|
533
|
+
expect(findSlashCommandsCard().exists()).toBe(false);
|
|
534
|
+
}
|
|
535
|
+
);
|
|
536
|
+
});
|
|
537
|
+
});
|
|
538
|
+
});
|
|
539
|
+
|
|
540
|
+
describe('interaction', () => {
|
|
541
|
+
describe('filtering when user types in partial slash command', () => {
|
|
542
|
+
it.each`
|
|
543
|
+
prompt | expectedCommands
|
|
544
|
+
${'/'} | ${slashCommandsNames}
|
|
545
|
+
${'/t'} | ${slashCommandsOnly(['/test'])}
|
|
546
|
+
${'/tes'} | ${slashCommandsOnly(['/test'])}
|
|
547
|
+
${'/e'} | ${slashCommandsOnly(['/explain'])}
|
|
548
|
+
${'/explai'} | ${slashCommandsOnly(['/explain'])}
|
|
549
|
+
${'/r'} | ${slashCommandsOnly(['/reset', '/refactor'])}
|
|
550
|
+
${'/re'} | ${slashCommandsOnly(['/reset', '/refactor'])}
|
|
551
|
+
${'/res'} | ${slashCommandsOnly(['/reset'])}
|
|
552
|
+
${'/ref'} | ${slashCommandsOnly(['/refactor'])}
|
|
553
|
+
${'/foo'} | ${[]}
|
|
554
|
+
`(
|
|
555
|
+
'shows $expectedCommands when prompt is $prompt',
|
|
556
|
+
async ({ prompt, expectedCommands } = {}) => {
|
|
557
|
+
createComponent({
|
|
558
|
+
propsData: {
|
|
559
|
+
withSlashCommands: true,
|
|
560
|
+
},
|
|
561
|
+
data: {
|
|
562
|
+
prompt,
|
|
563
|
+
},
|
|
564
|
+
});
|
|
565
|
+
|
|
566
|
+
await nextTick();
|
|
567
|
+
expect(findSlashCommands()).toHaveLength(expectedCommands.length);
|
|
568
|
+
expectedCommands.forEach((command) => {
|
|
569
|
+
expect(findSlashCommandsCard().text()).toContain(command);
|
|
570
|
+
});
|
|
571
|
+
}
|
|
572
|
+
);
|
|
573
|
+
});
|
|
574
|
+
|
|
575
|
+
describe('keyboard navigation', () => {
|
|
576
|
+
beforeEach(() => {
|
|
577
|
+
createComponent({
|
|
578
|
+
propsData: {
|
|
579
|
+
withSlashCommands: true,
|
|
580
|
+
messages,
|
|
581
|
+
},
|
|
582
|
+
data: {
|
|
583
|
+
prompt: '/',
|
|
584
|
+
},
|
|
585
|
+
});
|
|
586
|
+
});
|
|
587
|
+
|
|
588
|
+
it('toggles through commands on ArrowDown', async () => {
|
|
589
|
+
for (const command of slashCommandsNames) {
|
|
590
|
+
expect(findSelectedSlashCommand().text()).toContain(command);
|
|
591
|
+
findChatInput().trigger('keyup', { key: 'ArrowDown' });
|
|
592
|
+
// eslint-disable-next-line no-await-in-loop
|
|
593
|
+
await nextTick();
|
|
594
|
+
}
|
|
595
|
+
});
|
|
596
|
+
|
|
597
|
+
it('toggles through commands on ArrowUp', async () => {
|
|
598
|
+
const arr = [...slashCommandsNames].reverse();
|
|
599
|
+
arr.unshift(slashCommandsNames[0]); // it still has the top most command selected on the first run
|
|
600
|
+
for (const command of arr) {
|
|
601
|
+
expect(findSelectedSlashCommand().text()).toContain(command);
|
|
602
|
+
findChatInput().trigger('keyup', { key: 'ArrowUp' });
|
|
603
|
+
// eslint-disable-next-line no-await-in-loop
|
|
604
|
+
await nextTick();
|
|
605
|
+
}
|
|
606
|
+
});
|
|
607
|
+
|
|
608
|
+
describe('on Enter', () => {
|
|
609
|
+
const navigateToCommand = async (index) => {
|
|
610
|
+
const command = slashCommandsNames[index];
|
|
611
|
+
if (index) {
|
|
612
|
+
for (let i = 0; i < index; i += 1) {
|
|
613
|
+
findChatInput().trigger('keyup', { key: 'ArrowDown' });
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
await nextTick();
|
|
617
|
+
return command;
|
|
618
|
+
};
|
|
619
|
+
|
|
620
|
+
it('selects correct command and updates input if command should not submit right away', async () => {
|
|
621
|
+
const commandIndex = slashCommands.findIndex((cmd) => !cmd.shouldSubmit);
|
|
622
|
+
const command = await navigateToCommand(commandIndex);
|
|
623
|
+
|
|
624
|
+
expect(findSelectedSlashCommand().text()).toContain(command);
|
|
625
|
+
findChatInput().trigger('keyup', { key: 'Enter' });
|
|
626
|
+
await nextTick();
|
|
627
|
+
expect(findChatInput().props('value')).toBe(`${command} `);
|
|
628
|
+
expect(wrapper.emitted('send-chat-prompt')).toBe(undefined);
|
|
629
|
+
});
|
|
630
|
+
|
|
631
|
+
it('selects correct command and submits the prompt if command should submit right away', async () => {
|
|
632
|
+
const commandIndex = slashCommands.findIndex((cmd) => cmd.shouldSubmit);
|
|
633
|
+
const command = await navigateToCommand(commandIndex);
|
|
634
|
+
|
|
635
|
+
expect(findSelectedSlashCommand().text()).toContain(command);
|
|
636
|
+
findChatInput().trigger('keyup', { key: 'Enter' });
|
|
637
|
+
await nextTick();
|
|
638
|
+
expect(findChatInput().props('value')).toBe(`${command}`);
|
|
639
|
+
expect(wrapper.emitted('send-chat-prompt')).toEqual([[command]]);
|
|
640
|
+
});
|
|
641
|
+
});
|
|
642
|
+
});
|
|
643
|
+
|
|
644
|
+
describe('mouse navigation', () => {
|
|
645
|
+
beforeEach(() => {
|
|
646
|
+
createComponent({
|
|
647
|
+
propsData: {
|
|
648
|
+
withSlashCommands: true,
|
|
649
|
+
messages,
|
|
650
|
+
},
|
|
651
|
+
data: {
|
|
652
|
+
prompt: '/',
|
|
653
|
+
},
|
|
654
|
+
});
|
|
655
|
+
});
|
|
656
|
+
|
|
657
|
+
it('updates the selected command when hovering over it', async () => {
|
|
658
|
+
expect(findSelectedSlashCommand().text()).toContain(slashCommandsNames[0]);
|
|
659
|
+
findSlashCommands().at(2).trigger('mouseenter');
|
|
660
|
+
await nextTick();
|
|
661
|
+
expect(findSelectedSlashCommand().text()).toContain(slashCommandsNames[2]);
|
|
662
|
+
expect(findSelectedSlashCommand().text()).not.toContain(slashCommandsNames[0]);
|
|
663
|
+
});
|
|
664
|
+
|
|
665
|
+
describe('click', () => {
|
|
666
|
+
it('selects correct command and updates input if command should not submit right away', async () => {
|
|
667
|
+
const commandIndex = slashCommands.findIndex((cmd) => !cmd.shouldSubmit);
|
|
668
|
+
|
|
669
|
+
findSlashCommands().at(commandIndex).trigger('mouseenter');
|
|
670
|
+
await nextTick();
|
|
671
|
+
|
|
672
|
+
expect(findSelectedSlashCommand().text()).toContain(slashCommandsNames[commandIndex]);
|
|
673
|
+
|
|
674
|
+
findSelectedSlashCommand().vm.$emit('click');
|
|
675
|
+
await nextTick();
|
|
676
|
+
|
|
677
|
+
expect(findChatInput().props('value')).toBe(`${slashCommandsNames[commandIndex]} `);
|
|
678
|
+
expect(wrapper.emitted('send-chat-prompt')).toBe(undefined);
|
|
679
|
+
});
|
|
680
|
+
|
|
681
|
+
it('selects correct command and submits the prompt if command should submit right away', async () => {
|
|
682
|
+
const commandIndex = slashCommands.findIndex((cmd) => cmd.shouldSubmit);
|
|
683
|
+
|
|
684
|
+
findSlashCommands().at(commandIndex).trigger('mouseenter');
|
|
685
|
+
await nextTick();
|
|
686
|
+
|
|
687
|
+
expect(findSelectedSlashCommand().text()).toContain(slashCommandsNames[commandIndex]);
|
|
688
|
+
|
|
689
|
+
findSelectedSlashCommand().vm.$emit('click');
|
|
690
|
+
await nextTick();
|
|
691
|
+
|
|
692
|
+
expect(findChatInput().props('value')).toBe(slashCommandsNames[commandIndex]);
|
|
693
|
+
expect(wrapper.emitted('send-chat-prompt')).toEqual([
|
|
694
|
+
[slashCommandsNames[commandIndex]],
|
|
695
|
+
]);
|
|
696
|
+
});
|
|
697
|
+
});
|
|
698
|
+
});
|
|
699
|
+
});
|
|
700
|
+
});
|
|
404
701
|
});
|
|
@@ -27,6 +27,7 @@ const generateProps = ({
|
|
|
27
27
|
badgeHelpPageUrl = defaultValue('badgeHelpPageUrl'),
|
|
28
28
|
badgeType = defaultValue('badgeType'),
|
|
29
29
|
toolName = defaultValue('toolName'),
|
|
30
|
+
withSlashCommands = defaultValue('withSlashCommands'),
|
|
30
31
|
} = {}) => ({
|
|
31
32
|
title,
|
|
32
33
|
messages,
|
|
@@ -37,6 +38,7 @@ const generateProps = ({
|
|
|
37
38
|
badgeHelpPageUrl,
|
|
38
39
|
badgeType,
|
|
39
40
|
toolName,
|
|
41
|
+
withSlashCommands,
|
|
40
42
|
});
|
|
41
43
|
|
|
42
44
|
export const Default = (args, { argTypes }) => ({
|
|
@@ -57,6 +59,7 @@ export const Default = (args, { argTypes }) => ({
|
|
|
57
59
|
:badge-help-page-url="badgeHelpPageUrl"
|
|
58
60
|
:badge-type="badgeType"
|
|
59
61
|
:tool-name="toolName"
|
|
62
|
+
:with-slash-commands="withSlashCommands"
|
|
60
63
|
/>`,
|
|
61
64
|
});
|
|
62
65
|
Default.args = generateProps({
|
|
@@ -151,6 +154,7 @@ export const Interactive = (args, { argTypes }) => ({
|
|
|
151
154
|
:badge-help-page-url="badgeHelpPageUrl"
|
|
152
155
|
:badge-type="badgeType"
|
|
153
156
|
:tool-name="toolName"
|
|
157
|
+
:with-slash-commands="withSlashCommands"
|
|
154
158
|
@send-chat-prompt="onSendChatPrompt"
|
|
155
159
|
@chat-hidden="onChatHidden"
|
|
156
160
|
/>
|
|
@@ -176,7 +180,8 @@ export const Slots = (args, { argTypes }) => ({
|
|
|
176
180
|
:predefined-prompts="predefinedPrompts"
|
|
177
181
|
:badge-help-page-url="badgeHelpPageUrl"
|
|
178
182
|
:badge-type="badgeType"
|
|
179
|
-
:tool-name="toolName"
|
|
183
|
+
:tool-name="toolName"
|
|
184
|
+
:with-slash-commands="withSlashCommands">
|
|
180
185
|
|
|
181
186
|
<template #hero>
|
|
182
187
|
<pre class="code-block rounded code highlight gl-border-b gl-rounded-0! gl-mb-0 gl-overflow-y-auto solarized-light" style="max-height: 20rem; overflow-y: auto;">
|