@gitlab/ui 68.2.0 → 68.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.
- package/CHANGELOG.md +14 -0
- package/dist/components/experimental/duo/chat/duo_chat.js +93 -4
- package/dist/config.js +9 -1
- 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 +19 -17
- 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/config.js +8 -0
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.3.0",
|
|
4
4
|
"description": "GitLab UI Components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -29,8 +29,9 @@
|
|
|
29
29
|
"build-scss-variables": "make scss_to_js/scss_variables.js",
|
|
30
30
|
"build-tokens": "node ./bin/build_tokens.js",
|
|
31
31
|
"clean": "rm -r dist storybook scss_to_js/scss_variables.* src/scss/utilities.scss",
|
|
32
|
-
"cy:
|
|
33
|
-
"cy:
|
|
32
|
+
"cy:a11y": "cypress run --browser chrome --env grepTags=@a11y",
|
|
33
|
+
"cy:edge": "cypress run --browser edge --env grepTags=-@a11y",
|
|
34
|
+
"cy:run": "cypress run --browser firefox --env grepTags=-@a11y",
|
|
34
35
|
"start": "yarn storybook",
|
|
35
36
|
"storybook": "yarn storybook-prep && storybook dev --ci --host ${STORYBOOK_HOST:-localhost} --port 9001 -c .storybook",
|
|
36
37
|
"storybook-vue3": "yarn storybook-prep && VUE_VERSION=3 storybook dev --ci --host ${STORYBOOK_HOST:-localhost} --port 9001 -c .storybook",
|
|
@@ -38,7 +39,7 @@
|
|
|
38
39
|
"storybook-static": "yarn storybook-prep && storybook build -c .storybook -o storybook",
|
|
39
40
|
"pretest:unit": "yarn build-tokens build-scss-variables",
|
|
40
41
|
"test": "run-s test:unit test:visual",
|
|
41
|
-
"test:integration": "NODE_ENV=test start-server-and-test start http://${STORYBOOK_HOST:-localhost}:9001/iframe.html cy:run",
|
|
42
|
+
"test:integration": "NODE_ENV=test start-server-and-test start http://${STORYBOOK_HOST:-localhost}:9001/iframe.html 'yarn cy:run && yarn cy:a11y'",
|
|
42
43
|
"test:unit": "NODE_ENV=test jest --testPathIgnorePatterns storyshots.spec.js",
|
|
43
44
|
"test:unit:watch": "yarn test:unit --watch",
|
|
44
45
|
"test:unit:debug": "NODE_ENV=test node --inspect node_modules/.bin/jest --testPathIgnorePatterns storyshot.spec.js --watch --runInBand",
|
|
@@ -91,6 +92,7 @@
|
|
|
91
92
|
"@babel/core": "^7.23.2",
|
|
92
93
|
"@babel/preset-env": "^7.23.2",
|
|
93
94
|
"@babel/preset-react": "^7.22.15",
|
|
95
|
+
"@cypress/grep": "^4.0.1",
|
|
94
96
|
"@gitlab/eslint-plugin": "19.2.0",
|
|
95
97
|
"@gitlab/fonts": "^1.3.0",
|
|
96
98
|
"@gitlab/stylelint-config": "5.0.1",
|
|
@@ -98,18 +100,18 @@
|
|
|
98
100
|
"@rollup/plugin-commonjs": "^11.1.0",
|
|
99
101
|
"@rollup/plugin-node-resolve": "^7.1.3",
|
|
100
102
|
"@rollup/plugin-replace": "^2.3.2",
|
|
101
|
-
"@storybook/addon-a11y": "7.5.
|
|
102
|
-
"@storybook/addon-docs": "7.5.
|
|
103
|
-
"@storybook/addon-essentials": "7.5.
|
|
104
|
-
"@storybook/addon-storyshots": "7.5.
|
|
105
|
-
"@storybook/addon-storyshots-puppeteer": "7.5.
|
|
106
|
-
"@storybook/addon-viewport": "7.5.
|
|
107
|
-
"@storybook/builder-webpack5": "7.5.
|
|
108
|
-
"@storybook/theming": "7.5.
|
|
109
|
-
"@storybook/vue": "7.5.
|
|
110
|
-
"@storybook/vue-webpack5": "7.5.
|
|
111
|
-
"@storybook/vue3": "7.5.
|
|
112
|
-
"@storybook/vue3-webpack5": "7.5.
|
|
103
|
+
"@storybook/addon-a11y": "7.5.3",
|
|
104
|
+
"@storybook/addon-docs": "7.5.3",
|
|
105
|
+
"@storybook/addon-essentials": "7.5.3",
|
|
106
|
+
"@storybook/addon-storyshots": "7.5.3",
|
|
107
|
+
"@storybook/addon-storyshots-puppeteer": "7.5.3",
|
|
108
|
+
"@storybook/addon-viewport": "7.5.3",
|
|
109
|
+
"@storybook/builder-webpack5": "7.5.3",
|
|
110
|
+
"@storybook/theming": "7.5.3",
|
|
111
|
+
"@storybook/vue": "7.5.3",
|
|
112
|
+
"@storybook/vue-webpack5": "7.5.3",
|
|
113
|
+
"@storybook/vue3": "7.5.3",
|
|
114
|
+
"@storybook/vue3-webpack5": "7.5.3",
|
|
113
115
|
"@vue/compat": "^3.2.40",
|
|
114
116
|
"@vue/compiler-sfc": "^3.2.40",
|
|
115
117
|
"@vue/test-utils": "1.3.0",
|
|
@@ -161,7 +163,7 @@
|
|
|
161
163
|
"sass-loader": "^10.2.0",
|
|
162
164
|
"sass-true": "^6.1.0",
|
|
163
165
|
"start-server-and-test": "^1.10.6",
|
|
164
|
-
"storybook": "7.5.
|
|
166
|
+
"storybook": "7.5.3",
|
|
165
167
|
"storybook-dark-mode": "3.0.1",
|
|
166
168
|
"style-dictionary": "^3.8.0",
|
|
167
169
|
"stylelint": "15.10.2",
|
|
@@ -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;">
|