@bevel-software/platform-core-frontend 0.28.1 → 0.29.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/package.json +11 -4
- package/src/core/CoreAppShell.tsx +29 -11
- package/src/core/__tests__/ShellRoutes.test.tsx +43 -1
- package/src/core/events.ts +4 -2
- package/src/core/registry.ts +25 -3
- package/src/modules/embed/__tests__/EmbedView.test.tsx +560 -17
- package/src/modules/embed/__tests__/embed-config.test.ts +77 -1
- package/src/modules/embed/__tests__/mcp-app-view.test.ts +203 -1
- package/src/modules/embed/components/EmbedView.tsx +233 -47
- package/src/modules/embed/embed-config.ts +126 -2
- package/src/modules/embed/embed-host.ts +11 -2
- package/src/modules/embed/mount.tsx +1 -0
- package/src/modules/library/__tests__/LibraryRoutes.test.tsx +213 -4
- package/src/modules/library/__tests__/PluginPage.test.tsx +1 -1
- package/src/modules/library/__tests__/SkillPage.test.tsx +10 -0
- package/src/modules/library/components/LibraryLayout.tsx +2 -2
- package/src/modules/library/components/PluginPage.tsx +2 -1
- package/src/modules/library/components/skill-page/SkillPage.tsx +2 -2
- package/src/modules/library/components/tool-page/ToolPage.tsx +1 -1
- package/src/modules/library/index.ts +18 -0
- package/src/modules/library/routes/LibraryRoutes.tsx +17 -1
- package/src/modules/library/routes/library-paths.ts +16 -2
- package/src/modules/onboarding/__tests__/get-started-column.test.tsx +3 -3
- package/src/modules/secrets-vault/components/ConnectToolsPage.tsx +39 -32
- package/src/modules/secrets-vault/components/SecretsPage.tsx +9 -24
- package/src/modules/secrets-vault/components/__tests__/ConnectToolsPage.test.tsx +111 -8
- package/src/modules/secrets-vault/components/__tests__/connect-lists-what-the-banner-counted.test.tsx +1 -1
- package/src/modules/secrets-vault/index.ts +7 -0
- package/src/modules/settings/settings-nav-items.tsx +3 -3
- package/src/modules/toolbar/commands/__tests__/actions.test.tsx +20 -37
- package/src/modules/toolbar/commands/actions.tsx +62 -50
- package/src/modules/toolbar/commands/command-menu.ts +37 -3
- package/src/modules/toolbar/commands/useCommandShortcuts.ts +29 -76
- package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +4 -2
- package/src/modules/toolbar/components/SearchPalette.tsx +20 -21
- package/src/modules/toolbar/components/__tests__/ExternalAgentAccessPage.test.tsx +5 -2
- package/src/modules/toolbar/components/__tests__/SearchPalette.test.tsx +242 -103
- package/src/modules/toolbar/components/__tests__/Toolbar.test.tsx +51 -1
- package/src/modules/toolbar/search/__tests__/rank.test.ts +7 -3
- package/src/modules/workflow/hooks/__tests__/useFileLock.test.tsx +475 -0
- package/src/modules/workflow/hooks/__tests__/useFileLock.wire.test.tsx +115 -0
- package/src/modules/workflow/hooks/useFileLock.ts +321 -57
- package/src/modules/workflow/index.ts +8 -0
- package/src/modules/workflow/services/__tests__/lock.api.test.ts +4 -0
- package/src/modules/workflow/services/lock.api.ts +28 -9
- package/src/modules/workspace/components/FileViewer.tsx +30 -16
- package/src/modules/workspace/components/KbPageHeader.tsx +8 -1
- package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +107 -4
- package/src/modules/workspace/components/__tests__/KbPageHeader.test.tsx +12 -0
- package/src/modules/workspace/components/renderers/HtmlRenderer.tsx +118 -13
- package/src/modules/workspace/components/renderers/__tests__/HtmlRenderer.test.tsx +189 -0
- package/src/modules/workspace/components/renderers/__tests__/htmlSandbox.test.ts +9 -0
- package/src/modules/workspace/components/renderers/__tests__/kbGraphLoader.test.tsx +60 -0
- package/src/modules/workspace/components/renderers/frameResizeHandle.ts +116 -0
- package/src/modules/workspace/components/renderers/index.ts +6 -0
- package/src/modules/workspace/components/renderers/kbGraphLoader.ts +27 -0
- package/src/modules/workspace/components/renderers/lazyRenderer.tsx +1 -1
- package/src/modules/workspace/components/renderers/rendererSurface.ts +19 -0
- package/src/modules/workspace/index.ts +33 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
1
|
+
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
|
2
2
|
import { fireEvent, render, screen, waitFor, within } from '@testing-library/react';
|
|
3
3
|
import userEvent from '@testing-library/user-event';
|
|
4
4
|
import { act } from 'react';
|
|
@@ -41,10 +41,10 @@ vi.mock('../../../library/services/plugins.api', async (importOriginal) => ({
|
|
|
41
41
|
...(await importOriginal<typeof import('../../../library/services/plugins.api')>()),
|
|
42
42
|
listPlugins: api.listPlugins,
|
|
43
43
|
}));
|
|
44
|
-
//
|
|
44
|
+
// Create new page's own naming and retrying is `useCreatePage`'s, pinned by the Get
|
|
45
45
|
// set up column's suite; here it is the command that calls it.
|
|
46
46
|
const createPage = vi.hoisted(() => vi.fn<() => Promise<string | null>>());
|
|
47
|
-
// Where
|
|
47
|
+
// Where Create new page would write; null for someone who may write no Knowledge folder.
|
|
48
48
|
const pageTarget = vi.hoisted(() => ({ folder: 'knowledge-base/KnowledgeBase' as string | null }));
|
|
49
49
|
vi.mock('../../../workspace/hooks/useCreatePage', () => ({
|
|
50
50
|
useCreatePage: () => ({
|
|
@@ -380,10 +380,10 @@ describe('SearchPalette: commands', () => {
|
|
|
380
380
|
expect(groups[0]).toHaveAccessibleName('Actions');
|
|
381
381
|
expect(groups[1]).toHaveAccessibleName('Pages');
|
|
382
382
|
expect(groupRows('Actions')).toEqual([
|
|
383
|
-
'
|
|
384
|
-
'Invite
|
|
383
|
+
'Create new pageC (shortcut C)',
|
|
384
|
+
'Invite peopleShift I (shortcut Shift I)',
|
|
385
385
|
'Connect your agent',
|
|
386
|
-
'Go to Skills &
|
|
386
|
+
'Go to Skills & ToolsShift S (shortcut Shift S)',
|
|
387
387
|
]);
|
|
388
388
|
// Nothing is highlighted until a row is picked (see the next test).
|
|
389
389
|
expect(input()).not.toHaveAttribute('aria-activedescendant');
|
|
@@ -413,8 +413,9 @@ describe('SearchPalette: commands', () => {
|
|
|
413
413
|
const user = userEvent.setup();
|
|
414
414
|
renderPalette();
|
|
415
415
|
await user.click(trigger());
|
|
416
|
-
await user.hover(screen.getByRole('option', { name: 'Invite people' }));
|
|
417
|
-
|
|
416
|
+
await user.hover(screen.getByRole('option', { name: 'Invite people (shortcut Shift I)' }));
|
|
417
|
+
const invite = screen.getByRole('option', { name: 'Invite people (shortcut Shift I)' });
|
|
418
|
+
expect(invite).toHaveAttribute('aria-selected', 'true');
|
|
418
419
|
|
|
419
420
|
await user.type(input(), 'invite');
|
|
420
421
|
expect(input()).toHaveAttribute('aria-activedescendant', options()[0].id);
|
|
@@ -430,9 +431,9 @@ describe('SearchPalette: commands', () => {
|
|
|
430
431
|
renderPalette({ onboardingPending: false });
|
|
431
432
|
await user.click(trigger());
|
|
432
433
|
expect(groupRows('Actions')).toEqual([
|
|
433
|
-
'
|
|
434
|
-
'Invite
|
|
435
|
-
'Go to Skills &
|
|
434
|
+
'Create new pageC (shortcut C)',
|
|
435
|
+
'Invite peopleShift I (shortcut Shift I)',
|
|
436
|
+
'Go to Skills & ToolsShift S (shortcut Shift S)',
|
|
436
437
|
]);
|
|
437
438
|
// ...but it is still there to be typed for.
|
|
438
439
|
await user.type(input(), 'connect');
|
|
@@ -446,13 +447,13 @@ describe('SearchPalette: commands', () => {
|
|
|
446
447
|
|
|
447
448
|
await user.type(input(), 'go to');
|
|
448
449
|
expect(groupRows('Actions')).toEqual([
|
|
449
|
-
'Go to
|
|
450
|
-
'Go to Skills &
|
|
450
|
+
'Go to KnowledgeShift K (shortcut Shift K)',
|
|
451
|
+
'Go to Skills & ToolsShift S (shortcut Shift S)',
|
|
451
452
|
]);
|
|
452
453
|
|
|
453
454
|
await user.clear(input());
|
|
454
455
|
await user.type(input(), 'team');
|
|
455
|
-
expect(groupRows('Actions')).toEqual(['Invite
|
|
456
|
+
expect(groupRows('Actions')).toEqual(['Invite peopleShift I (shortcut Shift I)']);
|
|
456
457
|
|
|
457
458
|
await user.clear(input());
|
|
458
459
|
await user.type(input(), 'on');
|
|
@@ -465,7 +466,10 @@ describe('SearchPalette: commands', () => {
|
|
|
465
466
|
const user = userEvent.setup();
|
|
466
467
|
renderPalette({ admin: false });
|
|
467
468
|
await user.click(trigger());
|
|
468
|
-
expect(groupRows('Actions')).toEqual([
|
|
469
|
+
expect(groupRows('Actions')).toEqual([
|
|
470
|
+
'Create new pageC (shortcut C)',
|
|
471
|
+
'Go to Skills & ToolsShift S (shortcut Shift S)',
|
|
472
|
+
]);
|
|
469
473
|
await user.type(input(), 'invite');
|
|
470
474
|
expect(group('Actions')).toBeNull();
|
|
471
475
|
await user.clear(input());
|
|
@@ -473,7 +477,7 @@ describe('SearchPalette: commands', () => {
|
|
|
473
477
|
expect(group('Actions')).toBeNull();
|
|
474
478
|
});
|
|
475
479
|
|
|
476
|
-
it('
|
|
480
|
+
it('Create new page creates the page through the shared hook and closes the palette', async () => {
|
|
477
481
|
const user = userEvent.setup();
|
|
478
482
|
renderPalette();
|
|
479
483
|
await user.click(trigger());
|
|
@@ -483,12 +487,24 @@ describe('SearchPalette: commands', () => {
|
|
|
483
487
|
expect(screen.queryByRole('combobox')).toBeNull();
|
|
484
488
|
});
|
|
485
489
|
|
|
490
|
+
it('calls the page command "Create new page", and finds it by "new", "create" or "new page"', async () => {
|
|
491
|
+
const user = userEvent.setup();
|
|
492
|
+
renderPalette();
|
|
493
|
+
await user.click(trigger());
|
|
494
|
+
expect(screen.queryByRole('option', { name: /^New page/ })).toBeNull();
|
|
495
|
+
for (const query of ['new', 'create', 'new page']) {
|
|
496
|
+
await user.clear(input());
|
|
497
|
+
await user.type(input(), query);
|
|
498
|
+
expect(groupRows('Actions')[0]).toBe('Create new pageC (shortcut C)');
|
|
499
|
+
}
|
|
500
|
+
});
|
|
501
|
+
|
|
486
502
|
it('says why a command failed, in the palette it reopens', async () => {
|
|
487
503
|
createPage.mockRejectedValue(new Error('Couldn’t create the page: refused'));
|
|
488
504
|
const user = userEvent.setup();
|
|
489
505
|
renderPalette();
|
|
490
506
|
await user.click(trigger());
|
|
491
|
-
await user.click(screen.getByRole('option', { name: /^
|
|
507
|
+
await user.click(screen.getByRole('option', { name: /^Create new page/ }));
|
|
492
508
|
expect(await screen.findByRole('alert')).toHaveTextContent('Couldn’t create the page: refused');
|
|
493
509
|
expect(input()).toHaveFocus();
|
|
494
510
|
await user.keyboard('{Escape}');
|
|
@@ -500,7 +516,7 @@ describe('SearchPalette: commands', () => {
|
|
|
500
516
|
const user = userEvent.setup();
|
|
501
517
|
renderPalette();
|
|
502
518
|
await user.click(trigger());
|
|
503
|
-
await user.click(screen.getByRole('option', { name: 'Invite people' }));
|
|
519
|
+
await user.click(screen.getByRole('option', { name: 'Invite people (shortcut Shift I)' }));
|
|
504
520
|
expect(inviteOpen).toHaveBeenCalledTimes(1);
|
|
505
521
|
expect(screen.queryByRole('combobox')).toBeNull();
|
|
506
522
|
});
|
|
@@ -613,7 +629,7 @@ describe('SearchPalette: commands', () => {
|
|
|
613
629
|
id: 'new-ontology',
|
|
614
630
|
label: 'New ontology',
|
|
615
631
|
group: 'Graph',
|
|
616
|
-
shortcut:
|
|
632
|
+
shortcut: { key: 'o' },
|
|
617
633
|
visible: (ctx) => ctx.isAdmin,
|
|
618
634
|
run,
|
|
619
635
|
},
|
|
@@ -625,11 +641,11 @@ describe('SearchPalette: commands', () => {
|
|
|
625
641
|
renderPalette({ commandActions });
|
|
626
642
|
await user.click(trigger());
|
|
627
643
|
await user.type(input(), 'new');
|
|
628
|
-
expect(groupRows('Actions')).toEqual(['New
|
|
644
|
+
expect(groupRows('Actions')).toEqual(['New ontologyGraphO (shortcut O)', 'Create new pageC (shortcut C)']);
|
|
629
645
|
expect(screen.queryByText('Impostor page')).toBeNull();
|
|
630
646
|
|
|
631
647
|
const row = screen.getByRole('option', { name: /new ontology/i });
|
|
632
|
-
expect(within(row).getByText('O', { selector: 'kbd' })
|
|
648
|
+
expect(within(row).getByText('O', { selector: 'kbd' })).toHaveAttribute('aria-hidden');
|
|
633
649
|
await user.click(row);
|
|
634
650
|
expect(run).toHaveBeenCalledWith(expect.objectContaining({ isAdmin: true, activeAppId: 'knowledge' }));
|
|
635
651
|
error.mockRestore();
|
|
@@ -668,21 +684,25 @@ describe('SearchPalette: commands', () => {
|
|
|
668
684
|
});
|
|
669
685
|
|
|
670
686
|
/**
|
|
671
|
-
* C,
|
|
672
|
-
*
|
|
687
|
+
* C, ⇧I, ⇧K, ⇧S: the commonest commands without the palette — and never at
|
|
688
|
+
* the expense of somebody typing.
|
|
673
689
|
*/
|
|
674
|
-
describe('SearchPalette:
|
|
690
|
+
describe('SearchPalette: shortcuts', () => {
|
|
675
691
|
const press = (key: string, init: KeyboardEventInit = {}, target: Element = document.body) =>
|
|
676
692
|
fireEvent.keyDown(target, { key, ...init });
|
|
693
|
+
/** A Shift key as the browser reports it: the capital, with `shiftKey`. */
|
|
694
|
+
const shift = (letter: string, init: KeyboardEventInit = {}, target?: Element) =>
|
|
695
|
+
press(letter.toUpperCase(), { shiftKey: true, ...init }, target);
|
|
696
|
+
const location = () => screen.getByTestId('location').textContent;
|
|
677
697
|
|
|
678
698
|
it('C creates a new page', () => {
|
|
679
699
|
renderPalette();
|
|
680
|
-
press('c');
|
|
700
|
+
expect(press('c')).toBe(false); // handled: its default is prevented
|
|
681
701
|
expect(createPage).toHaveBeenCalledTimes(1);
|
|
682
702
|
expect(screen.queryByRole('combobox')).toBeNull();
|
|
683
703
|
});
|
|
684
704
|
|
|
685
|
-
it('C does nothing, and the menu offers no
|
|
705
|
+
it('C does nothing, and the menu offers no Create new page, for someone who may write no Knowledge folder', async () => {
|
|
686
706
|
pageTarget.folder = null;
|
|
687
707
|
const user = userEvent.setup();
|
|
688
708
|
renderPalette();
|
|
@@ -690,9 +710,9 @@ describe('SearchPalette: single-key shortcuts', () => {
|
|
|
690
710
|
expect(createPage).not.toHaveBeenCalled();
|
|
691
711
|
expect(screen.queryByRole('combobox')).toBeNull();
|
|
692
712
|
await user.click(trigger());
|
|
693
|
-
expect(screen.queryByRole('option', { name: /^
|
|
713
|
+
expect(screen.queryByRole('option', { name: /^Create new page/ })).toBeNull();
|
|
694
714
|
await user.type(input(), 'new page');
|
|
695
|
-
expect(screen.queryByRole('option', { name: /^
|
|
715
|
+
expect(screen.queryByRole('option', { name: /^Create new page/ })).toBeNull();
|
|
696
716
|
});
|
|
697
717
|
|
|
698
718
|
it('closes quietly when a refused write found nowhere left to write', async () => {
|
|
@@ -700,61 +720,153 @@ describe('SearchPalette: single-key shortcuts', () => {
|
|
|
700
720
|
const user = userEvent.setup();
|
|
701
721
|
renderPalette();
|
|
702
722
|
await user.click(trigger());
|
|
703
|
-
await user.click(screen.getByRole('option', { name: /^
|
|
723
|
+
await user.click(screen.getByRole('option', { name: /^Create new page/ }));
|
|
704
724
|
expect(createPage).toHaveBeenCalledTimes(1);
|
|
705
725
|
expect(screen.queryByRole('combobox')).toBeNull();
|
|
706
726
|
expect(screen.queryByRole('alert')).toBeNull();
|
|
707
727
|
});
|
|
708
728
|
|
|
709
|
-
it('
|
|
729
|
+
it('⇧I opens Invite', () => {
|
|
710
730
|
renderPalette();
|
|
711
|
-
|
|
731
|
+
shift('i');
|
|
732
|
+
expect(inviteOpen).toHaveBeenCalledTimes(1);
|
|
733
|
+
});
|
|
734
|
+
|
|
735
|
+
it('⇧S goes to Skills & Tools, ⇧K to Knowledge', () => {
|
|
736
|
+
renderPalette();
|
|
737
|
+
shift('s');
|
|
738
|
+
expect(location()).toBe('/skills-and-tools');
|
|
739
|
+
shift('k');
|
|
740
|
+
expect(location()).toBe('/workspace');
|
|
741
|
+
});
|
|
742
|
+
|
|
743
|
+
it('runs C only without Shift, and the Shift keys only with it', () => {
|
|
744
|
+
renderPalette();
|
|
745
|
+
expect(shift('c')).toBe(true); // let through: a capital C
|
|
746
|
+
press('i');
|
|
747
|
+
press('k');
|
|
712
748
|
press('s');
|
|
713
|
-
expect(
|
|
749
|
+
expect(createPage).not.toHaveBeenCalled();
|
|
750
|
+
expect(inviteOpen).not.toHaveBeenCalled();
|
|
751
|
+
expect(location()).toBe('/workspace/main');
|
|
752
|
+
});
|
|
753
|
+
|
|
754
|
+
it('does nothing for G then K, G then S, ⇧E or ⇧A', () => {
|
|
755
|
+
publishEditablePage('knowledge-base/KnowledgeBase/Onboarding.md');
|
|
756
|
+
renderPalette({ openFilePath: 'knowledge-base/KnowledgeBase/Onboarding.md', onboardingPending: true });
|
|
714
757
|
press('g');
|
|
715
758
|
press('k');
|
|
716
|
-
|
|
759
|
+
press('g');
|
|
760
|
+
press('s');
|
|
761
|
+
shift('e');
|
|
762
|
+
shift('a');
|
|
763
|
+
expect(location()).toBe('/workspace/main');
|
|
764
|
+
expect(screen.getByTestId('location-state').textContent).toBe('null');
|
|
717
765
|
});
|
|
718
766
|
|
|
719
|
-
it('shows
|
|
767
|
+
it('shows each key as one keycap on the command it runs, all of one width, and says it as words', async () => {
|
|
720
768
|
const user = userEvent.setup();
|
|
721
769
|
renderPalette();
|
|
722
770
|
await user.click(trigger());
|
|
723
|
-
const
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
//
|
|
727
|
-
|
|
771
|
+
const row = (name: string) => screen.getByRole('option', { name });
|
|
772
|
+
const keycap = (name: string) => row(name).querySelector('kbd')!;
|
|
773
|
+
|
|
774
|
+
// Not an Apple device under jsdom: "Shift K", not "⇧K".
|
|
775
|
+
// Said, not declared: in the open menu the key types into the search.
|
|
776
|
+
for (const option of screen.getAllByRole('option')) expect(option).not.toHaveAttribute('aria-keyshortcuts');
|
|
777
|
+
expect(keycap('Create new page (shortcut C)').textContent).toBe('C');
|
|
778
|
+
expect(keycap('Invite people (shortcut Shift I)').textContent).toBe('Shift I');
|
|
779
|
+
expect(keycap('Go to Skills & Tools (shortcut Shift S)').textContent).toBe('Shift S');
|
|
780
|
+
const caps = screen.getAllByRole('option').flatMap((o) => [...o.querySelectorAll('kbd')]);
|
|
781
|
+
expect(caps).toHaveLength(3);
|
|
782
|
+
for (const cap of caps) {
|
|
783
|
+
expect(cap).toHaveAttribute('aria-hidden', 'true');
|
|
784
|
+
expect(cap).toHaveClass('w-14', 'inline-flex', 'justify-center');
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
await user.type(input(), 'knowledge');
|
|
788
|
+
expect(keycap('Go to Knowledge (shortcut Shift K)').textContent).toBe('Shift K');
|
|
728
789
|
});
|
|
729
790
|
|
|
730
|
-
|
|
791
|
+
describe('on an Apple device', () => {
|
|
792
|
+
afterEach(() => vi.unstubAllGlobals());
|
|
793
|
+
|
|
794
|
+
it('draws a Shift key as ⇧ and the capital in the narrow cap, and still says "Shift"', async () => {
|
|
795
|
+
vi.stubGlobal('navigator', {
|
|
796
|
+
...navigator,
|
|
797
|
+
userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 14_5) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.5 Safari/605.1.15',
|
|
798
|
+
});
|
|
799
|
+
const user = userEvent.setup();
|
|
800
|
+
renderPalette();
|
|
801
|
+
await user.click(trigger());
|
|
802
|
+
const keycap = (name: string) => screen.getByRole('option', { name }).querySelector('kbd')!;
|
|
803
|
+
// Drawn as the symbol, spoken as the word: the row's name carries "Shift".
|
|
804
|
+
expect(keycap('Create new page (shortcut C)').textContent).toBe('C');
|
|
805
|
+
expect(keycap('Invite people (shortcut Shift I)').textContent).toBe('⇧I');
|
|
806
|
+
expect(keycap('Go to Skills & Tools (shortcut Shift S)').textContent).toBe('⇧S');
|
|
807
|
+
// One width for the platform, not one per key: C sits in the same cap as ⇧S.
|
|
808
|
+
for (const cap of screen.getAllByRole('option').flatMap((o) => [...o.querySelectorAll('kbd')])) {
|
|
809
|
+
expect(cap).toHaveClass('w-7');
|
|
810
|
+
expect(cap).not.toHaveClass('w-14');
|
|
811
|
+
}
|
|
812
|
+
});
|
|
813
|
+
});
|
|
814
|
+
|
|
815
|
+
it('gives Edit this page, Connect your agent and the settings rows no key', async () => {
|
|
816
|
+
publishEditablePage('knowledge-base/KnowledgeBase/Onboarding.md');
|
|
817
|
+
const user = userEvent.setup();
|
|
818
|
+
renderPalette({
|
|
819
|
+
openFilePath: 'knowledge-base/KnowledgeBase/Onboarding.md',
|
|
820
|
+
adminMenuItems: [{ id: 'stub-path', label: 'Stub page', path: '/stub-page', order: 95 }],
|
|
821
|
+
});
|
|
822
|
+
await user.click(trigger());
|
|
823
|
+
for (const query of ['edit', 'connect', 'settings']) {
|
|
824
|
+
await user.clear(input());
|
|
825
|
+
await user.type(input(), query);
|
|
826
|
+
for (const option of within(screen.getByRole('group', { name: 'Actions' })).getAllByRole('option')) {
|
|
827
|
+
expect(option.querySelector('kbd')).toBeNull();
|
|
828
|
+
expect(option).not.toHaveAttribute('aria-keyshortcuts');
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
});
|
|
832
|
+
|
|
833
|
+
it('leaves keys alone in a field, a select or an editor', () => {
|
|
731
834
|
renderPalette();
|
|
732
835
|
const field = document.createElement('input');
|
|
836
|
+
const select = document.createElement('select');
|
|
733
837
|
const editor = document.createElement('div');
|
|
734
838
|
editor.setAttribute('contenteditable', 'true');
|
|
735
839
|
const line = document.createElement('p');
|
|
736
840
|
editor.appendChild(line);
|
|
737
|
-
document.body.append(field, editor);
|
|
841
|
+
document.body.append(field, select, editor);
|
|
738
842
|
try {
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
843
|
+
for (const target of [field, select, line]) {
|
|
844
|
+
expect(press('c', {}, target)).toBe(true);
|
|
845
|
+
expect(shift('i', {}, target)).toBe(true);
|
|
846
|
+
expect(shift('k', {}, target)).toBe(true);
|
|
847
|
+
expect(shift('s', {}, target)).toBe(true);
|
|
848
|
+
}
|
|
743
849
|
expect(createPage).not.toHaveBeenCalled();
|
|
744
|
-
expect(
|
|
850
|
+
expect(inviteOpen).not.toHaveBeenCalled();
|
|
851
|
+
expect(location()).toBe('/workspace/main');
|
|
745
852
|
} finally {
|
|
746
853
|
field.remove();
|
|
854
|
+
select.remove();
|
|
747
855
|
editor.remove();
|
|
748
856
|
}
|
|
749
857
|
});
|
|
750
858
|
|
|
751
|
-
it('leaves keys alone with
|
|
859
|
+
it('leaves keys alone with Ctrl, ⌘ or Alt held', () => {
|
|
752
860
|
renderPalette();
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
861
|
+
for (const modifier of ['ctrlKey', 'metaKey', 'altKey'] as const) {
|
|
862
|
+
press('c', { [modifier]: true });
|
|
863
|
+
shift('i', { [modifier]: true });
|
|
864
|
+
shift('k', { [modifier]: true });
|
|
865
|
+
shift('s', { [modifier]: true });
|
|
866
|
+
}
|
|
757
867
|
expect(createPage).not.toHaveBeenCalled();
|
|
868
|
+
expect(inviteOpen).not.toHaveBeenCalled();
|
|
869
|
+
expect(location()).toBe('/workspace/main');
|
|
758
870
|
});
|
|
759
871
|
|
|
760
872
|
it('leaves keys alone while a modal dialog is up', () => {
|
|
@@ -764,101 +876,128 @@ describe('SearchPalette: single-key shortcuts', () => {
|
|
|
764
876
|
document.body.appendChild(modal);
|
|
765
877
|
try {
|
|
766
878
|
press('c');
|
|
879
|
+
shift('i');
|
|
880
|
+
shift('k');
|
|
881
|
+
shift('s');
|
|
767
882
|
expect(createPage).not.toHaveBeenCalled();
|
|
883
|
+
expect(inviteOpen).not.toHaveBeenCalled();
|
|
884
|
+
expect(location()).toBe('/workspace/main');
|
|
768
885
|
} finally {
|
|
769
886
|
modal.remove();
|
|
770
887
|
}
|
|
771
888
|
});
|
|
772
889
|
|
|
773
|
-
it('leaves
|
|
890
|
+
it('leaves every key to the query while the palette is open', async () => {
|
|
774
891
|
const user = userEvent.setup();
|
|
775
892
|
renderPalette();
|
|
776
893
|
await user.click(trigger());
|
|
777
|
-
await user.type(input(), '
|
|
894
|
+
await user.type(input(), 'cSIK');
|
|
895
|
+
expect(input()).toHaveValue('cSIK');
|
|
778
896
|
expect(createPage).not.toHaveBeenCalled();
|
|
779
|
-
expect(
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
try {
|
|
785
|
-
renderPalette();
|
|
786
|
-
press('g');
|
|
787
|
-
act(() => {
|
|
788
|
-
vi.advanceTimersByTime(1001);
|
|
789
|
-
});
|
|
790
|
-
press('k');
|
|
791
|
-
expect(screen.getByTestId('location')).toHaveTextContent('/workspace/main');
|
|
792
|
-
} finally {
|
|
793
|
-
vi.useRealTimers();
|
|
794
|
-
}
|
|
795
|
-
});
|
|
796
|
-
|
|
797
|
-
it('tries the second key on its own when it did not complete a sequence: G then C makes a page', () => {
|
|
798
|
-
renderPalette();
|
|
799
|
-
press('g');
|
|
800
|
-
press('c');
|
|
801
|
-
expect(createPage).toHaveBeenCalledTimes(1);
|
|
802
|
-
// And G then G re-arms: the second G is the first key of a new sequence.
|
|
803
|
-
press('g');
|
|
804
|
-
press('g');
|
|
805
|
-
press('s');
|
|
806
|
-
expect(screen.getByTestId('location')).toHaveTextContent('/skills-and-tools');
|
|
897
|
+
expect(inviteOpen).not.toHaveBeenCalled();
|
|
898
|
+
expect(location()).toBe('/workspace/main');
|
|
899
|
+
// A key on the panel around the input is the query's too, not a command's.
|
|
900
|
+
shift('s', {}, screen.getByRole('listbox'));
|
|
901
|
+
expect(location()).toBe('/workspace/main');
|
|
807
902
|
});
|
|
808
903
|
|
|
809
|
-
it('
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
await user.click(trigger());
|
|
814
|
-
await user.keyboard('{Escape}');
|
|
815
|
-
press('k');
|
|
816
|
-
expect(screen.getByTestId('location')).toHaveTextContent('/workspace/main');
|
|
904
|
+
it('lets the key through where its command is not on offer: ⇧I for someone who is not an admin', () => {
|
|
905
|
+
renderPalette({ admin: false });
|
|
906
|
+
expect(shift('i')).toBe(true);
|
|
907
|
+
expect(inviteOpen).not.toHaveBeenCalled();
|
|
817
908
|
});
|
|
818
909
|
|
|
819
910
|
// A distribution's command gets a working key for the `shortcut` it set,
|
|
820
911
|
// under the same guards: the hint on its row is never a key that does
|
|
821
912
|
// nothing.
|
|
822
|
-
it('binds a registry command’s
|
|
823
|
-
const
|
|
913
|
+
it('binds a registry command’s letter, with or without Shift, and leaves it alone in a field', () => {
|
|
914
|
+
const plain = vi.fn();
|
|
915
|
+
const shifted = vi.fn();
|
|
824
916
|
renderPalette({
|
|
825
|
-
commandActions: [
|
|
917
|
+
commandActions: [
|
|
918
|
+
{ id: 'new-ontology', label: 'New ontology', shortcut: { key: 'o' }, visible: () => true, run: plain },
|
|
919
|
+
{ id: 'open-graph', label: 'Open graph', shortcut: { key: 'O', shift: true }, visible: () => true, run: shifted },
|
|
920
|
+
],
|
|
826
921
|
});
|
|
827
922
|
press('o');
|
|
828
|
-
expect(
|
|
923
|
+
expect(plain).toHaveBeenCalledTimes(1);
|
|
924
|
+
expect(shifted).not.toHaveBeenCalled();
|
|
925
|
+
shift('o');
|
|
926
|
+
expect(shifted).toHaveBeenCalledTimes(1);
|
|
927
|
+
expect(plain).toHaveBeenCalledTimes(1);
|
|
829
928
|
const field = document.createElement('input');
|
|
830
929
|
document.body.appendChild(field);
|
|
831
930
|
try {
|
|
832
931
|
press('o', {}, field);
|
|
932
|
+
shift('o', {}, field);
|
|
833
933
|
} finally {
|
|
834
934
|
field.remove();
|
|
835
935
|
}
|
|
836
|
-
expect(
|
|
936
|
+
expect(plain).toHaveBeenCalledTimes(1);
|
|
937
|
+
expect(shifted).toHaveBeenCalledTimes(1);
|
|
837
938
|
});
|
|
838
939
|
|
|
839
|
-
it('drops a registry shortcut that
|
|
940
|
+
it('drops a registry shortcut that is taken or not one letter, hint and all, and keeps the core key', async () => {
|
|
840
941
|
const error = vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
841
942
|
const run = vi.fn();
|
|
842
943
|
const user = userEvent.setup();
|
|
944
|
+
const shiftC = vi.fn();
|
|
945
|
+
const command = (id: string, label: string, shortcut: CommandAction['shortcut'], fn = run): CommandAction => ({
|
|
946
|
+
id,
|
|
947
|
+
label,
|
|
948
|
+
shortcut,
|
|
949
|
+
visible: () => true,
|
|
950
|
+
run: fn,
|
|
951
|
+
});
|
|
843
952
|
renderPalette({
|
|
844
953
|
commandActions: [
|
|
845
|
-
// The same key as
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
954
|
+
// The same key as Create new page, and as Go to Knowledge — whatever the letter's case.
|
|
955
|
+
command('clash', 'Clash', { key: 'C' }),
|
|
956
|
+
command('clash-shift', 'Clash shift', { key: 'k', shift: true }),
|
|
957
|
+
// Not one letter: two keys, a digit, a symbol, nothing.
|
|
958
|
+
command('two-keys', 'Two keys', { key: 'gk' }),
|
|
959
|
+
command('digit', 'Digit', { key: '1' }),
|
|
960
|
+
command('symbol', 'Symbol', { key: '⇧' }),
|
|
961
|
+
command('empty', 'Empty', { key: '' }),
|
|
962
|
+
// The old shape, a list of keys, as a distribution not yet migrated gives it.
|
|
963
|
+
command('old-shape', 'Old shape', ['G', 'K'] as unknown as CommandAction['shortcut']),
|
|
964
|
+
// ⇧C is free: C is bound without Shift.
|
|
965
|
+
command('shift-c', 'Shift C', { key: 'c', shift: true }, shiftC),
|
|
849
966
|
],
|
|
850
967
|
});
|
|
851
968
|
press('c');
|
|
852
969
|
expect(createPage).toHaveBeenCalledTimes(1);
|
|
970
|
+
shift('s');
|
|
971
|
+
shift('k');
|
|
972
|
+
expect(location()).toBe('/workspace');
|
|
853
973
|
press('g');
|
|
854
974
|
press('k');
|
|
855
|
-
|
|
975
|
+
press('1');
|
|
856
976
|
expect(run).not.toHaveBeenCalled();
|
|
857
|
-
|
|
977
|
+
shift('c');
|
|
978
|
+
expect(shiftC).toHaveBeenCalledTimes(1);
|
|
979
|
+
expect(createPage).toHaveBeenCalledTimes(1);
|
|
980
|
+
// The rows stay, with no key shown — except ⇧C's, which is bound.
|
|
858
981
|
await user.click(trigger());
|
|
859
982
|
await user.type(input(), 'clash');
|
|
860
|
-
expect(groupRows('Actions')).toEqual(['Clash']);
|
|
861
|
-
|
|
983
|
+
expect(groupRows('Actions')).toEqual(['Clash', 'Clash shift']);
|
|
984
|
+
for (const q of ['two keys', 'digit', 'symbol', 'empty', 'old shape']) {
|
|
985
|
+
await user.clear(input());
|
|
986
|
+
await user.type(input(), q);
|
|
987
|
+
expect(screen.getAllByRole('option').flatMap((o) => [...o.querySelectorAll('kbd')])).toHaveLength(0);
|
|
988
|
+
}
|
|
989
|
+
await user.clear(input());
|
|
990
|
+
await user.type(input(), 'shift c');
|
|
991
|
+
expect(screen.getByRole('option', { name: 'Shift C (shortcut Shift C)' })).toBeInTheDocument();
|
|
992
|
+
// Each dropped shortcut is said once, naming its command; the old shape
|
|
993
|
+
// shows what was given.
|
|
994
|
+
expect(error).toHaveBeenCalledTimes(7);
|
|
995
|
+
expect(error.mock.calls.map(([message]) => String(message))).toEqual(
|
|
996
|
+
['clash', 'clash-shift', 'two-keys', 'digit', 'symbol', 'empty', 'old-shape'].map((id) =>
|
|
997
|
+
expect.stringContaining(` of ${id} `),
|
|
998
|
+
),
|
|
999
|
+
);
|
|
1000
|
+
expect(String(error.mock.calls[6][0])).toContain('["G","K"]');
|
|
862
1001
|
error.mockRestore();
|
|
863
1002
|
});
|
|
864
1003
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, it, expect, vi, afterEach, beforeEach } from 'vitest';
|
|
2
2
|
import { setSidebarCollapsed } from '../../../layout/state/sidebar';
|
|
3
|
-
import { render, screen, within } from '@testing-library/react';
|
|
3
|
+
import { cleanup, render, screen, within } from '@testing-library/react';
|
|
4
4
|
import userEvent from '@testing-library/user-event';
|
|
5
5
|
import { MemoryRouter, useLocation } from 'react-router-dom';
|
|
6
6
|
import { Toolbar } from '../Toolbar';
|
|
@@ -24,8 +24,10 @@ import { AdminContext } from '../../../admin/state/admin.context';
|
|
|
24
24
|
import {
|
|
25
25
|
ActiveAppIdContext,
|
|
26
26
|
AppRegistryContext,
|
|
27
|
+
activeAppId as activeAppIdFor,
|
|
27
28
|
makeRegistry,
|
|
28
29
|
type AdminMenuItem,
|
|
30
|
+
type AppDef,
|
|
29
31
|
type ToolbarItemDef,
|
|
30
32
|
} from '../../../../core/registry';
|
|
31
33
|
import { GIT_MENU_ITEMS } from '../../../git';
|
|
@@ -81,6 +83,8 @@ function renderToolbar(overrides?: {
|
|
|
81
83
|
/** The shell-provided active app (see ActiveAppIdContext); the Library
|
|
82
84
|
* sidebar toggle follows this, not the path. */
|
|
83
85
|
activeAppId?: string;
|
|
86
|
+
/** The switcher's apps; none by default. */
|
|
87
|
+
apps?: AppDef[];
|
|
84
88
|
}) {
|
|
85
89
|
const toggleExplorer = vi.fn();
|
|
86
90
|
const toggleChat = vi.fn();
|
|
@@ -181,6 +185,7 @@ function renderToolbar(overrides?: {
|
|
|
181
185
|
// rows ahead of the registry's.
|
|
182
186
|
adminMenuItems: [...GIT_MENU_ITEMS, ...stubAdminMenuItems],
|
|
183
187
|
toolbarItems: overrides?.toolbarItems ?? [],
|
|
188
|
+
apps: overrides?.apps ?? [],
|
|
184
189
|
})}
|
|
185
190
|
>
|
|
186
191
|
<Toolbar />
|
|
@@ -390,6 +395,51 @@ describe('Toolbar', () => {
|
|
|
390
395
|
});
|
|
391
396
|
});
|
|
392
397
|
|
|
398
|
+
// "Connect your tools" is a Skills & Tools page. At `/connect` it belonged to
|
|
399
|
+
// no app, so the toggle vanished, the brand jumped left and no tab was
|
|
400
|
+
// selected. The active app here comes from the shell's own rule
|
|
401
|
+
// (`activeAppId`), not the harness's guess, so the test fails if the page
|
|
402
|
+
// ever leaves the app's path again.
|
|
403
|
+
describe('on Connect your tools', () => {
|
|
404
|
+
beforeEach(() => setSidebarCollapsed(false));
|
|
405
|
+
|
|
406
|
+
const apps: AppDef[] = [
|
|
407
|
+
{ id: 'knowledge', label: 'Knowledge', path: '/workspace', order: 10, element: <div /> },
|
|
408
|
+
{ id: 'skills-tools', label: 'Skills & Tools', path: '/skills-and-tools', order: 20, element: <div /> },
|
|
409
|
+
];
|
|
410
|
+
const renderAt = (route: string) =>
|
|
411
|
+
renderToolbar({
|
|
412
|
+
route,
|
|
413
|
+
apps,
|
|
414
|
+
activeAppId: activeAppIdFor(apps, route),
|
|
415
|
+
layout: { canToggleExplorer: false, canToggleChat: false },
|
|
416
|
+
});
|
|
417
|
+
|
|
418
|
+
it('shows the sidebar toggle, and it hides and shows the sidebar', async () => {
|
|
419
|
+
renderAt('/skills-and-tools/connect');
|
|
420
|
+
await userEvent.click(screen.getByRole('button', { name: 'Hide sidebar' }));
|
|
421
|
+
await userEvent.click(screen.getByRole('button', { name: 'Show sidebar' }));
|
|
422
|
+
expect(screen.getByRole('button', { name: 'Hide sidebar' })).toHaveAttribute('aria-expanded', 'true');
|
|
423
|
+
});
|
|
424
|
+
|
|
425
|
+
it('selects Skills & Tools', () => {
|
|
426
|
+
renderAt('/skills-and-tools/connect');
|
|
427
|
+
const appsNav = screen.getByRole('navigation', { name: 'Apps' });
|
|
428
|
+
expect(within(appsNav).getByRole('link', { name: 'Skills & Tools' })).toHaveAttribute('aria-current', 'page');
|
|
429
|
+
expect(within(appsNav).getByRole('link', { name: 'Knowledge' })).not.toHaveAttribute('aria-current');
|
|
430
|
+
});
|
|
431
|
+
|
|
432
|
+
it('renders the same top bar as /skills-and-tools, element for element', () => {
|
|
433
|
+
const markup = (route: string) => {
|
|
434
|
+
renderAt(route);
|
|
435
|
+
const html = document.querySelector('header')!.outerHTML;
|
|
436
|
+
cleanup();
|
|
437
|
+
return html;
|
|
438
|
+
};
|
|
439
|
+
expect(markup('/skills-and-tools/connect')).toBe(markup('/skills-and-tools'));
|
|
440
|
+
});
|
|
441
|
+
});
|
|
442
|
+
|
|
393
443
|
// The "Reconciling with the team…" status pill is gone with the
|
|
394
444
|
// pending-commits queue refactor — push failures are handled silently
|
|
395
445
|
// by the background recovery agent now, so there's nothing user-facing
|