@promptbook/cli 0.112.0-103 → 0.112.0-105
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/apps/agents-server/src/app/AddAgentButton.tsx +0 -5
- package/apps/agents-server/src/app/actions.ts +50 -0
- package/apps/agents-server/src/app/admin/image-generator-test/ImageAttachmentsEditor.tsx +19 -3
- package/apps/agents-server/src/app/admin/limits/LimitsClient.tsx +11 -12
- package/apps/agents-server/src/app/admin/metadata/MetadataClient.tsx +34 -2
- package/apps/agents-server/src/app/admin/servers/CreateServerDialog.tsx +6 -1
- package/apps/agents-server/src/app/admin/servers/useCreateServerWizard.ts +13 -1
- package/apps/agents-server/src/app/agents/[agentName]/AgentChatWrapper.tsx +11 -2
- package/apps/agents-server/src/app/agents/[agentName]/AgentProfileChat.tsx +14 -5
- package/apps/agents-server/src/app/agents/[agentName]/book/BookEditorWrapper.tsx +7 -1
- package/apps/agents-server/src/app/agents/[agentName]/chat/CanonicalAgentChatSurface.tsx +11 -1
- package/apps/agents-server/src/app/agents/[agentName]/images/default-avatar.png/route.ts +6 -2
- package/apps/agents-server/src/app/api/health/route.ts +18 -0
- package/apps/agents-server/src/app/api/images/[filename]/route.ts +6 -2
- package/apps/agents-server/src/app/api/internal/agent-runner-limits/route.ts +51 -0
- package/apps/agents-server/src/app/api/upload/route.ts +48 -12
- package/apps/agents-server/src/app/layout.tsx +13 -0
- package/apps/agents-server/src/components/AgentProfile/AgentProfile.tsx +1 -4
- package/apps/agents-server/src/components/FileUploadAvailability/FileUploadAvailabilityContext.tsx +50 -0
- package/apps/agents-server/src/components/FileUploadAvailability/FileUploadUnavailableNotice.tsx +45 -0
- package/apps/agents-server/src/components/Header/Header.tsx +0 -11
- package/apps/agents-server/src/components/Header/useHeaderAgentMenus.tsx +0 -5
- package/apps/agents-server/src/components/LayoutWrapper/LayoutWrapper.tsx +85 -76
- package/apps/agents-server/src/components/NewAgentDialog/NewAgentDialog.tsx +7 -3
- package/apps/agents-server/src/components/NewAgentDialog/NewAgentWizardKnowledgeStep.tsx +6 -0
- package/apps/agents-server/src/components/NewAgentDialog/useNewAgentDialog.tsx +39 -16
- package/apps/agents-server/src/components/NewAgentDialog/useNewAgentWizardKnowledgeState.ts +8 -1
- package/apps/agents-server/src/constants/defaultAgentAvatarVisual.ts +1 -1
- package/apps/agents-server/src/constants/serverLimits.ts +22 -2
- package/apps/agents-server/src/database/migrations/2026-06-0200-default-agent-avatar-visual-octopus3d3.sql +16 -0
- package/apps/agents-server/src/database/seedDefaultAgents.ts +218 -0
- package/apps/agents-server/src/middleware.ts +2 -1
- package/apps/agents-server/src/tools/$provideCdnForServer.ts +114 -9
- package/apps/agents-server/src/utils/agentRouting/resolveAgentRouteTarget.ts +27 -4
- package/apps/agents-server/src/utils/defaultAgents/loadDefaultAgentBooks.ts +103 -0
- package/apps/agents-server/src/utils/knowledge/createInlineKnowledgeSourceUploader.ts +24 -5
- package/apps/agents-server/src/utils/serverLimits.ts +26 -1
- package/apps/agents-server/src/utils/serverManagement/createManagedServer/seedServerDefaultAgents.ts +1 -85
- package/apps/agents-server/src/utils/shareTargetPayloads.ts +20 -2
- package/apps/agents-server/src/utils/upload/fileUploadAvailability.ts +91 -0
- package/apps/agents-server/src/utils/upload/uploadFileToServer.ts +46 -2
- package/esm/apps/agents-server/src/constants/federatedAgentImport.d.ts +42 -0
- package/esm/apps/agents-server/src/constants/serverLimits.d.ts +207 -0
- package/esm/apps/agents-server/src/constants/toolUsageLimits.d.ts +55 -0
- package/esm/index.es.js +1109 -35
- package/esm/index.es.js.map +1 -1
- package/esm/scripts/run-agent-messages/main/AgentMessageFailureTracker.d.ts +27 -0
- package/esm/scripts/run-agent-messages/main/handleAgentWatchError.d.ts +4 -0
- package/esm/scripts/run-agent-messages/main/runAgentMessages.d.ts +1 -0
- package/esm/scripts/run-agent-messages/messages/moveAgentMessageToFailed.d.ts +17 -0
- package/esm/src/avatars/types/AvatarVisualDefinition.d.ts +1 -1
- package/esm/src/avatars/visuals/octopus3d3AvatarVisual.d.ts +7 -0
- package/esm/src/book-components/BookEditor/BookEditor.d.ts +5 -4
- package/esm/src/book-components/BookEditor/BookEditorTheme.d.ts +24 -0
- package/esm/src/book-components/BookEditor/useBookEditorMonacoLanguage.d.ts +1 -6
- package/esm/src/book-components/BookEditor/useBookEditorMonacoLifecycle.d.ts +1 -4
- package/esm/src/book-components/BookEditor/useBookEditorMonacoStyles.d.ts +2 -1
- package/esm/src/cli/cli-commands/agent-folder/agentProjectPaths.d.ts +6 -0
- package/esm/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/avatars/types/AvatarVisualDefinition.ts +1 -0
- package/src/avatars/visuals/avatarVisualRegistry.ts +2 -0
- package/src/avatars/visuals/octopus3d3AvatarVisual.ts +902 -0
- package/src/book-components/BookEditor/BookEditor.tsx +10 -7
- package/src/book-components/BookEditor/BookEditorMonaco.tsx +3 -1
- package/src/book-components/BookEditor/BookEditorTheme.ts +32 -0
- package/src/book-components/BookEditor/useBookEditorMonacoLanguage.ts +12 -15
- package/src/book-components/BookEditor/useBookEditorMonacoLifecycle.ts +1 -5
- package/src/book-components/BookEditor/useBookEditorMonacoStyles.ts +2 -1
- package/src/cli/cli-commands/agent-folder/agentProjectPaths.ts +7 -0
- package/src/cli/cli-commands/agents-server/buildAgentsServer.ts +109 -9
- package/src/cli/cli-commands/agents-server/startAgentsServer.ts +132 -4
- package/src/other/templates/getTemplatesPipelineCollection.ts +690 -747
- package/src/utils/agents/resolveAgentAvatarImageUrl.ts +1 -1
- package/src/version.ts +2 -2
- package/src/versions.txt +2 -1
- package/umd/apps/agents-server/src/constants/federatedAgentImport.d.ts +42 -0
- package/umd/apps/agents-server/src/constants/serverLimits.d.ts +207 -0
- package/umd/apps/agents-server/src/constants/toolUsageLimits.d.ts +55 -0
- package/umd/index.umd.js +1109 -35
- package/umd/index.umd.js.map +1 -1
- package/umd/scripts/run-agent-messages/main/AgentMessageFailureTracker.d.ts +27 -0
- package/umd/scripts/run-agent-messages/main/handleAgentWatchError.d.ts +4 -0
- package/umd/scripts/run-agent-messages/main/runAgentMessages.d.ts +1 -0
- package/umd/scripts/run-agent-messages/messages/moveAgentMessageToFailed.d.ts +17 -0
- package/umd/src/avatars/types/AvatarVisualDefinition.d.ts +1 -1
- package/umd/src/avatars/visuals/octopus3d3AvatarVisual.d.ts +7 -0
- package/umd/src/book-components/BookEditor/BookEditor.d.ts +5 -4
- package/umd/src/book-components/BookEditor/BookEditorTheme.d.ts +24 -0
- package/umd/src/book-components/BookEditor/useBookEditorMonacoLanguage.d.ts +1 -6
- package/umd/src/book-components/BookEditor/useBookEditorMonacoLifecycle.d.ts +1 -4
- package/umd/src/book-components/BookEditor/useBookEditorMonacoStyles.d.ts +2 -1
- package/umd/src/cli/cli-commands/agent-folder/agentProjectPaths.d.ts +6 -0
- package/umd/src/version.d.ts +1 -1
- package/apps/agents-server/src/message-providers/email/_common/utils/parseEmailAddress.test.ts.todo +0 -108
- package/apps/agents-server/src/message-providers/email/_common/utils/parseEmailAddresses.test.ts.todo +0 -117
- package/apps/agents-server/src/message-providers/email/_common/utils/stringifyEmailAddress.test.ts.todo +0 -119
- package/apps/agents-server/src/message-providers/email/_common/utils/stringifyEmailAddresses.test.ts.todo +0 -74
- package/apps/agents-server/tests/e2e/authentication-and-navigation.spec.ts.todo +0 -178
- package/src/_packages/browser.index.ts +0 -31
- package/src/_packages/browser.readme.md +0 -43
- package/src/book-2.0/agent-source/parseAgentSourceWithCommitments.test.ts.todo +0 -265
- package/src/book-components/BookEditor/BookEditorMonaco.test.tsx.todo +0 -115
- package/src/book-components/Chat/utils/renderMarkdown.test.ts.tmp +0 -199
- package/src/collection/agent-collection/constructors/agent-collection-in-directory/AgentCollectionInDirectory.test.ts.todo +0 -131
- package/src/commands/_common/parseCommand.test.ts.todo +0 -48
- package/src/commitments/META_LINK/META_LINK.test.ts.todo +0 -75
- package/src/conversion/validation/pipelineStringToJson-errors.test.ts.todo +0 -33
- package/src/dialogs/simple-prompt/SimplePromptInterfaceTools.ts +0 -51
- package/src/executables/browsers/locateSafari.test.ts.tmp +0 -15
- package/src/execution/PromptbookFetch.test-type.ts +0 -14
- package/src/execution/createPipelineExecutor/00-createPipelineExecutor.test.ts.todo +0 -0
- package/src/execution/execution-report/executionReportJsonToString.test.ts.todo +0 -83
- package/src/execution/utils/usageToHuman.test.ts.todo +0 -80
- package/src/llm-providers/_common/register/$provideLlmToolsForTestingAndScriptsAndPlayground.ts +0 -76
- package/src/llm-providers/_common/utils/assertUniqueModels.ts +0 -27
- package/src/llm-providers/_multiple/playground/playground.ts +0 -141
- package/src/llm-providers/_multiple/playground/tsconfig.json +0 -19
- package/src/llm-providers/agent/playground/playground.ts +0 -190
- package/src/llm-providers/agent/playground/tsconfig.json +0 -19
- package/src/llm-providers/anthropic-claude/playground/playground.ts +0 -99
- package/src/llm-providers/anthropic-claude/playground/tsconfig.json +0 -19
- package/src/llm-providers/azure-openai/playground/playground.ts +0 -101
- package/src/llm-providers/azure-openai/playground/tsconfig.json +0 -19
- package/src/llm-providers/ollama/playground/playground.ts +0 -120
- package/src/llm-providers/ollama/playground/tsconfig.json +0 -19
- package/src/llm-providers/openai/playground/playground.ts +0 -406
- package/src/llm-providers/openai/playground/tsconfig.json +0 -19
- package/src/llm-providers/remote/playground/playground.ts +0 -144
- package/src/llm-providers/remote/playground/tsconfig.json +0 -19
- package/src/llm-providers/vercel/playground/playground.ts +0 -133
- package/src/llm-providers/vercel/playground/tsconfig.json +0 -19
- package/src/personas/preparePersona.test.ts.todo +0 -126
- package/src/playground/backup/_playground-boilerplate.ts.txt +0 -37
- package/src/playground/backup/playground-agent-os.txt +0 -62
- package/src/playground/backup/playground-brj-app.ts.txt +0 -302
- package/src/playground/backup/playground-browser-playwright.txt +0 -110
- package/src/playground/backup/playground-claude-mcp.txt +0 -43
- package/src/playground/backup/playground-document-conversion.txt +0 -84
- package/src/playground/backup/playground-glob.ts.txt +0 -42
- package/src/playground/backup/playground-mcp-server.txt +0 -1
- package/src/playground/backup/playground-openai-agent-kit.txt +0 -73
- package/src/playground/backup/playground-openai-function-calling.txt +0 -131
- package/src/playground/backup/playground-openai-streaming.ts.txt +0 -68
- package/src/playground/backup/playground-scrape-knowledge.txt +0 -65
- package/src/playground/backup/playground-scraperFetch.ts.txt +0 -44
- package/src/playground/backup/playground-using-openai-compatible-route-on-agents-server.ts.txt +0 -49
- package/src/playground/backup/playground-write-pavolhejny-bio.txt +0 -120
- package/src/playground/permanent/_boilerplate.ts +0 -54
- package/src/playground/permanent/agent-with-browser-playground.ts +0 -92
- package/src/playground/permanent/error-handling-playground.ts +0 -103
- package/src/playground/playground.ts +0 -36
- package/src/playground/tsconfig.json +0 -19
- package/src/scrapers/_boilerplate/BoilerplateScraper.test.ts.todo +0 -73
- package/src/scrapers/_boilerplate/playground/boilerplate-scraper-playground.ts +0 -79
- package/src/scrapers/_boilerplate/playground/tsconfig.json +0 -19
- package/src/scrapers/_common/utils/files/blobToDataurl.test.ts.todo +0 -17
- package/src/scrapers/_common/utils/files/dataurlToBlob.test.ts.todo +0 -52
- package/src/scrapers/_common/utils/files/isValidDataurl.test.ts.todo +0 -42
- package/src/scrapers/_common/utils/files/shorten.test.ts.todo +0 -13
- package/src/scrapers/document/playground/document-scraper-playground.ts +0 -80
- package/src/scrapers/document/playground/tsconfig.json +0 -19
- package/src/scrapers/document-legacy/playground/legacy-document-scraper-playground.ts +0 -80
- package/src/scrapers/document-legacy/playground/tsconfig.json +0 -19
- package/src/scrapers/markdown/playground/markdown-scraper-playground.ts +0 -74
- package/src/scrapers/markdown/playground/tsconfig.json +0 -19
- package/src/scrapers/markitdown/MarkitdownScraper.test.ts.todo +0 -132
- package/src/scrapers/markitdown/playground/markitdown-scraper-playground.ts +0 -91
- package/src/scrapers/markitdown/playground/tsconfig.json +0 -19
- package/src/scrapers/pdf/PdfScraper.test.ts.todo +0 -52
- package/src/scrapers/pdf/playground/pdf-scraper-playground.ts +0 -75
- package/src/scrapers/pdf/playground/tsconfig.json +0 -19
- package/src/scrapers/website/playground/tsconfig.json +0 -19
- package/src/scrapers/website/playground/website-scraper-playground.ts +0 -82
- package/src/storage/_common/PromptbookStorage.test-type.ts +0 -14
- package/src/storage/local-storage/getIndexedDbStorage.ts +0 -36
- package/src/storage/local-storage/getLocalStorage.ts +0 -33
- package/src/storage/local-storage/getSessionStorage.ts +0 -33
- package/src/storage/local-storage/utils/IndexedDbStorageOptions.ts +0 -16
- package/src/storage/local-storage/utils/makePromptbookStorageFromIndexedDb.ts +0 -58
- package/src/storage/local-storage/utils/makePromptbookStorageFromWebStorage.ts +0 -45
- package/src/transpilers/formatted-book-in-markdown/FormattedBookInMarkdownTranspiler.test.ts.todo +0 -35
- package/src/transpilers/openai-sdk/playground/playground.ts +0 -85
- package/src/transpilers/openai-sdk/playground/tmp/chatbot-openaisdk-1.js +0 -194
- package/src/transpilers/openai-sdk/playground/tmp/package.json +0 -3
- package/src/transpilers/openai-sdk/playground/tsconfig.json +0 -18
- package/src/utils/editable/utils/findUsableParameters.test.ts.todo +0 -43
- package/src/utils/editable/utils/stringifyPipelineJson.test.ts.todo +0 -38
- package/src/utils/markdown/prettifyMarkdown.test.ts.tmp +0 -42
- package/src/utils/serialization/serializeToPromptbookJavascript.test.ts.todo +0 -116
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
import { expect, test, type Page } from 'playwright/test';
|
|
2
|
-
import { loginAsAdmin, logoutFromHeader } from './support/auth';
|
|
3
|
-
import { openHeaderMenu } from './support/navigation';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Emulates a coarse-pointer touch environment while keeping desktop viewport width.
|
|
7
|
-
*
|
|
8
|
-
* @param page - Current Playwright page.
|
|
9
|
-
*/
|
|
10
|
-
async function emulateTouchInput(page: Page) {
|
|
11
|
-
await page.addInitScript(() => {
|
|
12
|
-
const originalMatchMedia = window.matchMedia.bind(window);
|
|
13
|
-
|
|
14
|
-
Object.defineProperty(navigator, 'maxTouchPoints', {
|
|
15
|
-
configurable: true,
|
|
16
|
-
get: () => 5,
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
Object.defineProperty(window, 'ontouchstart', {
|
|
20
|
-
configurable: true,
|
|
21
|
-
value: null,
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
window.matchMedia = (query: string): MediaQueryList => {
|
|
25
|
-
if (query === '(hover: none) and (pointer: coarse)') {
|
|
26
|
-
return {
|
|
27
|
-
matches: true,
|
|
28
|
-
media: query,
|
|
29
|
-
onchange: null,
|
|
30
|
-
addListener: () => void 0,
|
|
31
|
-
removeListener: () => void 0,
|
|
32
|
-
addEventListener: () => void 0,
|
|
33
|
-
removeEventListener: () => void 0,
|
|
34
|
-
dispatchEvent: () => false,
|
|
35
|
-
} as MediaQueryList;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return originalMatchMedia(query);
|
|
39
|
-
};
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Creates a new agent through the homepage dialog and waits for its profile page.
|
|
45
|
-
*
|
|
46
|
-
* @param page - Current Playwright page.
|
|
47
|
-
*/
|
|
48
|
-
async function createAgentViaHomepageDialog(page: Page): Promise<void> {
|
|
49
|
-
const addAgentCard = page.getByText('Add New Agent');
|
|
50
|
-
await expect(addAgentCard).toBeVisible();
|
|
51
|
-
await addAgentCard.click();
|
|
52
|
-
|
|
53
|
-
await expect(page.getByRole('heading', { name: 'Create New Agent' })).toBeVisible();
|
|
54
|
-
await page.getByRole('button', { name: 'Create Agent' }).click();
|
|
55
|
-
await expect(page).toHaveURL(/\/agents\/[^/?#]+$/);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Opens the `System` menu and expands the `My Account` category.
|
|
60
|
-
*
|
|
61
|
-
* @param page - Current Playwright page.
|
|
62
|
-
*/
|
|
63
|
-
async function openSystemMyAccountMenu(page: Page): Promise<void> {
|
|
64
|
-
await openHeaderMenu(page, 'System');
|
|
65
|
-
const myAccountButton = page.getByRole('button', { name: 'My Account' });
|
|
66
|
-
await expect(myAccountButton).toBeVisible();
|
|
67
|
-
await myAccountButton.hover();
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Clicks one link inside the `System > My Account` nested submenu.
|
|
72
|
-
*
|
|
73
|
-
* @param page - Current Playwright page.
|
|
74
|
-
* @param linkName - Visible text of the destination link.
|
|
75
|
-
*/
|
|
76
|
-
async function clickSystemMyAccountLink(page: Page, linkName: string): Promise<void> {
|
|
77
|
-
await openSystemMyAccountMenu(page);
|
|
78
|
-
|
|
79
|
-
const nestedMenuPortal = page.locator('[data-header-dropdown-portal="true"]');
|
|
80
|
-
await expect(nestedMenuPortal).toBeAttached();
|
|
81
|
-
|
|
82
|
-
const nestedLink = nestedMenuPortal.getByRole('link', { name: linkName });
|
|
83
|
-
await expect(nestedLink).toBeVisible();
|
|
84
|
-
await nestedLink.click();
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Core authentication and navigation integration flows for Agents Server.
|
|
89
|
-
*/
|
|
90
|
-
test.describe('Agents Server authentication and navigation', () => {
|
|
91
|
-
test('shows forbidden state for protected System page when anonymous', async ({ page }) => {
|
|
92
|
-
await page.goto('/system/profile');
|
|
93
|
-
await expect(page.getByRole('heading', { name: '403 Forbidden' })).toBeVisible();
|
|
94
|
-
await expect(page.getByLabel('Username')).toBeVisible();
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
test('allows admin to sign in, navigate major menus, and sign out', async ({ page }) => {
|
|
98
|
-
await page.goto('/');
|
|
99
|
-
await expect(page.getByRole('link', { name: 'Promptbook Agents Server' })).toBeVisible();
|
|
100
|
-
|
|
101
|
-
await loginAsAdmin(page);
|
|
102
|
-
await expect(page.getByRole('button', { name: 'System' })).toBeVisible();
|
|
103
|
-
|
|
104
|
-
await openHeaderMenu(page, 'Documentation');
|
|
105
|
-
await page.getByRole('link', { name: 'Overview' }).click();
|
|
106
|
-
await expect(page).toHaveURL(/\/docs$/);
|
|
107
|
-
await expect(page.getByRole('heading', { name: 'Documentation' })).toBeVisible();
|
|
108
|
-
|
|
109
|
-
await page.goto('/docs/PERSONA');
|
|
110
|
-
await expect(page.getByRole('heading', { name: 'PERSONA', exact: true })).toBeVisible();
|
|
111
|
-
|
|
112
|
-
await clickSystemMyAccountLink(page, 'Profile');
|
|
113
|
-
await expect(page).toHaveURL(/\/system\/profile$/);
|
|
114
|
-
await expect(page.getByRole('heading', { name: 'Profile' })).toBeVisible();
|
|
115
|
-
|
|
116
|
-
await clickSystemMyAccountLink(page, 'User Memory');
|
|
117
|
-
await expect(page).toHaveURL(/\/system\/user-memory$/);
|
|
118
|
-
await expect(page.getByRole('heading', { name: 'User Memory' })).toBeVisible();
|
|
119
|
-
|
|
120
|
-
await logoutFromHeader(page);
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
test('keeps nested header submenu items tappable on touch devices', async ({ page }) => {
|
|
124
|
-
await emulateTouchInput(page);
|
|
125
|
-
await page.goto('/');
|
|
126
|
-
|
|
127
|
-
await loginAsAdmin(page);
|
|
128
|
-
await openHeaderMenu(page, 'Documentation');
|
|
129
|
-
|
|
130
|
-
const allSubmenuButton = page.getByRole('button', { name: /^All$/ });
|
|
131
|
-
await expect(allSubmenuButton).toBeVisible();
|
|
132
|
-
await allSubmenuButton.click();
|
|
133
|
-
|
|
134
|
-
const personaLink = page.getByRole('link', { name: /^PERSONA\b/ });
|
|
135
|
-
await expect(personaLink).toBeVisible();
|
|
136
|
-
await personaLink.click();
|
|
137
|
-
|
|
138
|
-
await expect(page).toHaveURL(/\/docs\/PERSONA$/);
|
|
139
|
-
await expect(page.getByRole('heading', { name: 'PERSONA', exact: true })).toBeVisible();
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
test('protects clone prompt against accidental close when the input is dirty', async ({ page }) => {
|
|
143
|
-
await page.goto('/');
|
|
144
|
-
await loginAsAdmin(page);
|
|
145
|
-
await createAgentViaHomepageDialog(page);
|
|
146
|
-
|
|
147
|
-
await page.getByRole('button', { name: 'More options' }).click();
|
|
148
|
-
await page.getByRole('button', { name: 'Clone agent' }).click();
|
|
149
|
-
const cloneHeading = page.getByRole('heading', { name: 'Clone agent' });
|
|
150
|
-
const cloneInput = page.getByLabel('Agent name');
|
|
151
|
-
|
|
152
|
-
await expect(cloneHeading).toBeVisible();
|
|
153
|
-
await cloneInput.fill('Clone name draft');
|
|
154
|
-
|
|
155
|
-
let dismissedDiscardDialog = false;
|
|
156
|
-
page.once('dialog', async (dialog) => {
|
|
157
|
-
dismissedDiscardDialog = true;
|
|
158
|
-
expect(dialog.type()).toBe('confirm');
|
|
159
|
-
await dialog.dismiss();
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
await page.mouse.click(8, 8);
|
|
163
|
-
await expect.poll(() => dismissedDiscardDialog).toBe(true);
|
|
164
|
-
await expect(cloneHeading).toBeVisible();
|
|
165
|
-
await expect(cloneInput).toHaveValue('Clone name draft');
|
|
166
|
-
|
|
167
|
-
let acceptedDiscardDialog = false;
|
|
168
|
-
page.once('dialog', async (dialog) => {
|
|
169
|
-
acceptedDiscardDialog = true;
|
|
170
|
-
expect(dialog.type()).toBe('confirm');
|
|
171
|
-
await dialog.accept();
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
await page.keyboard.press('Escape');
|
|
175
|
-
await expect.poll(() => acceptedDiscardDialog).toBe(true);
|
|
176
|
-
await expect(cloneHeading).toBeHidden();
|
|
177
|
-
});
|
|
178
|
-
});
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
// ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten
|
|
2
|
-
// `@promptbook/browser`
|
|
3
|
-
|
|
4
|
-
import { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION } from '../version';
|
|
5
|
-
import { getAllCommitmentsToolFunctionsForBrowser } from '../commitments/_common/getAllCommitmentsToolFunctionsForBrowser';
|
|
6
|
-
import { SimplePromptInterfaceTools } from '../dialogs/simple-prompt/SimplePromptInterfaceTools';
|
|
7
|
-
import { $provideScrapersForBrowser } from '../scrapers/_common/register/$provideScrapersForBrowser';
|
|
8
|
-
import { BrowserSpeechRecognition } from '../speech-recognition/BrowserSpeechRecognition';
|
|
9
|
-
import { getIndexedDbStorage } from '../storage/local-storage/getIndexedDbStorage';
|
|
10
|
-
import { getLocalStorage } from '../storage/local-storage/getLocalStorage';
|
|
11
|
-
import { getSessionStorage } from '../storage/local-storage/getSessionStorage';
|
|
12
|
-
import { $induceBookDownload } from '../utils/files/$induceBookDownload';
|
|
13
|
-
import { $induceFileDownload } from '../utils/files/$induceFileDownload';
|
|
14
|
-
import { ObjectUrl } from '../utils/files/ObjectUrl';
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
// Note: Exporting version from each package
|
|
18
|
-
export { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION };
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
// Note: Entities of the `@promptbook/browser`
|
|
22
|
-
export { getAllCommitmentsToolFunctionsForBrowser };
|
|
23
|
-
export { SimplePromptInterfaceTools };
|
|
24
|
-
export { $provideScrapersForBrowser };
|
|
25
|
-
export { BrowserSpeechRecognition };
|
|
26
|
-
export { getIndexedDbStorage };
|
|
27
|
-
export { getLocalStorage };
|
|
28
|
-
export { getSessionStorage };
|
|
29
|
-
export { $induceBookDownload };
|
|
30
|
-
export { $induceFileDownload };
|
|
31
|
-
export { ObjectUrl };
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
The browser package provides browser-specific functionality for Promptbook, including localStorage integration, IndexedDB storage, and browser-compatible scrapers. It enables Promptbook to run efficiently in web browser environments.
|
|
2
|
-
|
|
3
|
-
## 🎯 Purpose and Motivation
|
|
4
|
-
|
|
5
|
-
This package extends Promptbook's core functionality with browser-specific features that are essential for web applications. It provides browser storage APIs, user interface tools, and browser-compatible scrapers that enable full-featured Promptbook applications in web environments.
|
|
6
|
-
|
|
7
|
-
## 🔧 High-Level Functionality
|
|
8
|
-
|
|
9
|
-
The package provides browser-specific integrations and utilities:
|
|
10
|
-
- **Browser Storage**: Integration with localStorage, sessionStorage, and IndexedDB
|
|
11
|
-
- **User Interface Tools**: Simple prompt interface for browser interactions
|
|
12
|
-
- **Browser Scrapers**: Browser-compatible content scrapers
|
|
13
|
-
- **Web Compatibility**: Ensures Promptbook works seamlessly in browser environments
|
|
14
|
-
- **Client-side Caching**: Efficient caching using browser storage APIs
|
|
15
|
-
|
|
16
|
-
## ✨ Key Features
|
|
17
|
-
|
|
18
|
-
- 💾 **Multiple Storage Options** - Support for localStorage, sessionStorage, and IndexedDB
|
|
19
|
-
- 🌐 **Browser-native APIs** - Leverage browser-specific capabilities and storage
|
|
20
|
-
- 🎨 **Simple UI Tools** - Basic interface tools for browser-based interactions
|
|
21
|
-
- 📱 **Cross-browser Compatibility** - Works across modern web browsers
|
|
22
|
-
- 🔒 **Client-side Security** - Secure storage and execution in browser sandbox
|
|
23
|
-
- ⚡ **Performance Optimized** - Efficient storage and caching for web applications
|
|
24
|
-
- 🛠️ **Web Scrapers** - Browser-compatible content scraping capabilities
|
|
25
|
-
|
|
26
|
-
## 📦 Exported Entities
|
|
27
|
-
|
|
28
|
-
### Version Information
|
|
29
|
-
- `BOOK_LANGUAGE_VERSION` - Current book language version
|
|
30
|
-
- `PROMPTBOOK_ENGINE_VERSION` - Current engine version
|
|
31
|
-
|
|
32
|
-
### User Interface Tools
|
|
33
|
-
- `SimplePromptInterfaceTools` - Simple prompt interface for browser interactions
|
|
34
|
-
|
|
35
|
-
### Browser Scrapers
|
|
36
|
-
- `$provideScrapersForBrowser` - Provide browser-compatible knowledge scrapers
|
|
37
|
-
|
|
38
|
-
### Storage APIs
|
|
39
|
-
- `getIndexedDbStorage` - Get IndexedDB storage implementation
|
|
40
|
-
- `getLocalStorage` - Get localStorage storage implementation
|
|
41
|
-
- `getSessionStorage` - Get sessionStorage storage implementation
|
|
42
|
-
|
|
43
|
-
> 💡 This package does not make sense on its own, look at [all promptbook packages](#-packages) or just install all by `npm i ptbk`
|
|
@@ -1,265 +0,0 @@
|
|
|
1
|
-
// TODO: Uncomment the test
|
|
2
|
-
|
|
3
|
-
import { describe, expect, it } from '@jest/globals';
|
|
4
|
-
import { spaceTrim } from 'spacetrim';
|
|
5
|
-
import { validateBook } from '../../agent-source/string_book';
|
|
6
|
-
import { parseAgentSourceWithCommitments } from './parseAgentSourceWithCommitments';
|
|
7
|
-
|
|
8
|
-
describe('parseAgentSourceWithCommitments with multiline support', () => {
|
|
9
|
-
it('should parse single-line commitments correctly', () => {
|
|
10
|
-
const agentSource = validateBook(
|
|
11
|
-
spaceTrim(`
|
|
12
|
-
Test Agent
|
|
13
|
-
PERSONA Some persona description
|
|
14
|
-
KNOWLEDGE https://example.com/knowledge.pdf
|
|
15
|
-
`),
|
|
16
|
-
);
|
|
17
|
-
|
|
18
|
-
const result = parseAgentSourceWithCommitments(agentSource);
|
|
19
|
-
|
|
20
|
-
expect(result.agentName).toBe('Test Agent');
|
|
21
|
-
expect(result.commitments).toHaveLength(2);
|
|
22
|
-
|
|
23
|
-
expect(result.commitments[0]).toEqual({
|
|
24
|
-
type: 'PERSONA',
|
|
25
|
-
content: 'Some persona description',
|
|
26
|
-
originalLine: 'PERSONA Some persona description',
|
|
27
|
-
lineNumber: 2,
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
expect(result.commitments[1]).toEqual({
|
|
31
|
-
type: 'KNOWLEDGE',
|
|
32
|
-
content: 'https://example.com/knowledge.pdf',
|
|
33
|
-
originalLine: 'KNOWLEDGE https://example.com/knowledge.pdf',
|
|
34
|
-
lineNumber: 3,
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('should parse multiline commitments correctly', () => {
|
|
39
|
-
const agentSource = validateBook(
|
|
40
|
-
spaceTrim(`
|
|
41
|
-
Test Agent
|
|
42
|
-
PERSONA Another persona description
|
|
43
|
-
which is continued on the next line
|
|
44
|
-
and also on the next line
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
and also on the next paragraph
|
|
48
|
-
PERSONA New persona description
|
|
49
|
-
KNOWLEDGE Some knowledge description
|
|
50
|
-
|
|
51
|
-
which is continued on the next line
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
PERSONA Yet another persona description
|
|
55
|
-
continued description of the PERSONA
|
|
56
|
-
and continued on the next line because the last keyword PERSONA was not at the start of the line
|
|
57
|
-
`),
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
const result = parseAgentSourceWithCommitments(agentSource);
|
|
61
|
-
|
|
62
|
-
expect(result.agentName).toBe('Test Agent');
|
|
63
|
-
expect(result.commitments).toHaveLength(3);
|
|
64
|
-
|
|
65
|
-
// First multiline PERSONA
|
|
66
|
-
expect(result.commitments[0]).toEqual({
|
|
67
|
-
type: 'PERSONA',
|
|
68
|
-
content: spaceTrim(`
|
|
69
|
-
Another persona description
|
|
70
|
-
which is continued on the next line
|
|
71
|
-
and also on the next line
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
and also on the next paragraph
|
|
75
|
-
`),
|
|
76
|
-
originalLine: 'PERSONA Another persona description',
|
|
77
|
-
lineNumber: 2,
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
// Second PERSONA (single line)
|
|
81
|
-
expect(result.commitments[1]).toEqual({
|
|
82
|
-
type: 'PERSONA',
|
|
83
|
-
content: 'New persona description',
|
|
84
|
-
originalLine: 'PERSONA New persona description',
|
|
85
|
-
lineNumber: 8,
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
// KNOWLEDGE with multiline content
|
|
89
|
-
expect(result.commitments[2]).toEqual({
|
|
90
|
-
type: 'KNOWLEDGE',
|
|
91
|
-
content: spaceTrim(`
|
|
92
|
-
Some knowledge description
|
|
93
|
-
|
|
94
|
-
which is continued on the next line
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
PERSONA Yet another persona description
|
|
98
|
-
continued description of the PERSONA
|
|
99
|
-
and continued on the next line because the last keyword PERSONA was not at the start of the line
|
|
100
|
-
`),
|
|
101
|
-
originalLine: 'KNOWLEDGE Some knowledge description',
|
|
102
|
-
lineNumber: 9,
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
it('should handle the exact example from the requirements', () => {
|
|
107
|
-
const agentSource = validateBook(`Test Agent
|
|
108
|
-
PERSONA Some persona description
|
|
109
|
-
PERSONA Another persona description
|
|
110
|
-
which is continued on the next line
|
|
111
|
-
and also on the next line
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
and also on the next paragraph
|
|
115
|
-
PERSONA New persona description
|
|
116
|
-
KNOWLEDGE https://example.com/knowledge.pdf
|
|
117
|
-
KNOWLEDGE Some knowledge description
|
|
118
|
-
|
|
119
|
-
which is continued on the next line
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
PERSONA Yet another persona description
|
|
123
|
-
continued description of the PERSONA
|
|
124
|
-
and continued on the next line because the last keyword PERSONA was not at the start of the line`);
|
|
125
|
-
|
|
126
|
-
const result = parseAgentSourceWithCommitments(agentSource);
|
|
127
|
-
|
|
128
|
-
expect(result.agentName).toBe('Test Agent');
|
|
129
|
-
expect(result.commitments).toHaveLength(6);
|
|
130
|
-
|
|
131
|
-
// First PERSONA (single line)
|
|
132
|
-
expect(result.commitments[0]).toEqual({
|
|
133
|
-
type: 'PERSONA',
|
|
134
|
-
content: 'Some persona description',
|
|
135
|
-
originalLine: 'PERSONA Some persona description',
|
|
136
|
-
lineNumber: 2,
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
// Second PERSONA (multiline)
|
|
140
|
-
expect(result.commitments[1]).toEqual({
|
|
141
|
-
type: 'PERSONA',
|
|
142
|
-
content: `Another persona description
|
|
143
|
-
which is continued on the next line
|
|
144
|
-
and also on the next line
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
and also on the next paragraph`,
|
|
148
|
-
originalLine: 'PERSONA Another persona description',
|
|
149
|
-
lineNumber: 3,
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
// Third PERSONA (single line)
|
|
153
|
-
expect(result.commitments[2]).toEqual({
|
|
154
|
-
type: 'PERSONA',
|
|
155
|
-
content: 'New persona description',
|
|
156
|
-
originalLine: 'PERSONA New persona description',
|
|
157
|
-
lineNumber: 9,
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
// First KNOWLEDGE (single line)
|
|
161
|
-
expect(result.commitments[3]).toEqual({
|
|
162
|
-
type: 'KNOWLEDGE',
|
|
163
|
-
content: 'https://example.com/knowledge.pdf',
|
|
164
|
-
originalLine: 'KNOWLEDGE https://example.com/knowledge.pdf',
|
|
165
|
-
lineNumber: 10,
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
// Second KNOWLEDGE (multiline)
|
|
169
|
-
expect(result.commitments[4]).toEqual({
|
|
170
|
-
type: 'KNOWLEDGE',
|
|
171
|
-
content: `Some knowledge description
|
|
172
|
-
|
|
173
|
-
which is continued on the next line
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
`,
|
|
177
|
-
originalLine: 'KNOWLEDGE Some knowledge description',
|
|
178
|
-
lineNumber: 11,
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
// Fourth PERSONA (multiline, continues until end)
|
|
182
|
-
expect(result.commitments[5]).toEqual({
|
|
183
|
-
type: 'PERSONA',
|
|
184
|
-
content: `Yet another persona description
|
|
185
|
-
continued description of the PERSONA
|
|
186
|
-
and continued on the next line because the last keyword PERSONA was not at the start of the line`,
|
|
187
|
-
originalLine: 'PERSONA Yet another persona description',
|
|
188
|
-
lineNumber: 15,
|
|
189
|
-
});
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
it('should handle empty lines and preserve spacing in multiline content', () => {
|
|
193
|
-
const agentSource = validateBook(`Test Agent
|
|
194
|
-
PERSONA First persona
|
|
195
|
-
|
|
196
|
-
with empty line above
|
|
197
|
-
PERSONA Second persona`);
|
|
198
|
-
|
|
199
|
-
const result = parseAgentSourceWithCommitments(agentSource);
|
|
200
|
-
|
|
201
|
-
expect(result.commitments).toHaveLength(2);
|
|
202
|
-
|
|
203
|
-
expect(result.commitments[0]).toEqual({
|
|
204
|
-
type: 'PERSONA',
|
|
205
|
-
content: `First persona
|
|
206
|
-
|
|
207
|
-
with empty line above`,
|
|
208
|
-
originalLine: 'PERSONA First persona',
|
|
209
|
-
lineNumber: 2,
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
expect(result.commitments[1]).toEqual({
|
|
213
|
-
type: 'PERSONA',
|
|
214
|
-
content: 'Second persona',
|
|
215
|
-
originalLine: 'PERSONA Second persona',
|
|
216
|
-
lineNumber: 5,
|
|
217
|
-
});
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
it('should handle commitments with no initial content on the same line', () => {
|
|
221
|
-
const agentSource = validateBook(`Test Agent
|
|
222
|
-
PERSONA
|
|
223
|
-
This is the content
|
|
224
|
-
that continues on multiple lines
|
|
225
|
-
KNOWLEDGE
|
|
226
|
-
https://example.com/knowledge.pdf`);
|
|
227
|
-
|
|
228
|
-
const result = parseAgentSourceWithCommitments(agentSource);
|
|
229
|
-
|
|
230
|
-
expect(result.commitments).toHaveLength(2);
|
|
231
|
-
|
|
232
|
-
expect(result.commitments[0]).toEqual({
|
|
233
|
-
type: 'PERSONA',
|
|
234
|
-
content: `This is the content
|
|
235
|
-
that continues on multiple lines`,
|
|
236
|
-
originalLine: 'PERSONA',
|
|
237
|
-
lineNumber: 2,
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
expect(result.commitments[1]).toEqual({
|
|
241
|
-
type: 'KNOWLEDGE',
|
|
242
|
-
content: 'https://example.com/knowledge.pdf',
|
|
243
|
-
originalLine: 'KNOWLEDGE',
|
|
244
|
-
lineNumber: 5,
|
|
245
|
-
});
|
|
246
|
-
});
|
|
247
|
-
|
|
248
|
-
it('should handle non-commitment lines correctly', () => {
|
|
249
|
-
const agentSource = validateBook(`Test Agent
|
|
250
|
-
This is not a commitment
|
|
251
|
-
PERSONA Some persona
|
|
252
|
-
Another line that is not a commitment
|
|
253
|
-
KNOWLEDGE Some knowledge
|
|
254
|
-
Final non-commitment line`);
|
|
255
|
-
|
|
256
|
-
const result = parseAgentSourceWithCommitments(agentSource);
|
|
257
|
-
|
|
258
|
-
expect(result.commitments).toHaveLength(2);
|
|
259
|
-
expect(result.nonCommitmentLines).toEqual([
|
|
260
|
-
'Test Agent',
|
|
261
|
-
'This is not a commitment',
|
|
262
|
-
'Final non-commitment line',
|
|
263
|
-
]);
|
|
264
|
-
});
|
|
265
|
-
});
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
/** @jest-environment jsdom */
|
|
2
|
-
|
|
3
|
-
import { describe, expect, it, jest } from '@jest/globals';
|
|
4
|
-
import { render } from '@testing-library/react';
|
|
5
|
-
import { string_book } from '../../book-2.0/agent-source/string_book';
|
|
6
|
-
import { BookEditorMonaco } from './BookEditorMonaco';
|
|
7
|
-
|
|
8
|
-
// Mock the monaco editor
|
|
9
|
-
const mockSetMonarchTokensProvider = jest.fn();
|
|
10
|
-
const mockDispose = jest.fn();
|
|
11
|
-
mockSetMonarchTokensProvider.mockReturnValue({ dispose: mockDispose });
|
|
12
|
-
|
|
13
|
-
jest.mock('@monaco-editor/react', () => ({
|
|
14
|
-
__esModule: true,
|
|
15
|
-
Editor: (props: { [key: string]: unknown }) => <div data-testid="mock-editor">{JSON.stringify(props)}</div>,
|
|
16
|
-
useMonaco: () => ({
|
|
17
|
-
languages: {
|
|
18
|
-
register: jest.fn(),
|
|
19
|
-
setMonarchTokensProvider: mockSetMonarchTokensProvider,
|
|
20
|
-
registerCompletionItemProvider: jest.fn(() => ({ dispose: jest.fn() })),
|
|
21
|
-
},
|
|
22
|
-
editor: {
|
|
23
|
-
defineTheme: jest.fn(),
|
|
24
|
-
setTheme: jest.fn(),
|
|
25
|
-
},
|
|
26
|
-
}),
|
|
27
|
-
}));
|
|
28
|
-
|
|
29
|
-
// Mock other dependencies
|
|
30
|
-
jest.mock('../../book-2.0/commitments', () => ({
|
|
31
|
-
getAllCommitmentDefinitions: () => [{ type: 'ASK' }, { type: 'TELL' }, { type: 'META' }],
|
|
32
|
-
}));
|
|
33
|
-
|
|
34
|
-
jest.mock('../../config', () => ({
|
|
35
|
-
PROMPTBOOK_SYNTAX_COLORS: {
|
|
36
|
-
TITLE: { toHex: () => '#000000' },
|
|
37
|
-
COMMITMENT: { toHex: () => '#000000' },
|
|
38
|
-
PARAMETER: { toHex: () => '#000000' },
|
|
39
|
-
},
|
|
40
|
-
}));
|
|
41
|
-
|
|
42
|
-
describe('BookEditorMonaco', () => {
|
|
43
|
-
it('should use a regex that supports international characters for parameters', () => {
|
|
44
|
-
render(<BookEditorMonaco value={'' as string_book} isReadonly={false} />);
|
|
45
|
-
|
|
46
|
-
expect(mockSetMonarchTokensProvider).toHaveBeenCalled();
|
|
47
|
-
|
|
48
|
-
const monarchTokensProvider = mockSetMonarchTokensProvider!.mock!.calls[0]![1]! as {
|
|
49
|
-
tokenizer: { body: [RegExp, string][] };
|
|
50
|
-
};
|
|
51
|
-
const bookRules = monarchTokensProvider.tokenizer.body;
|
|
52
|
-
|
|
53
|
-
const parameterRule = bookRules.find((rule) => rule[1] === 'parameter');
|
|
54
|
-
expect(parameterRule).toBeDefined();
|
|
55
|
-
|
|
56
|
-
const parameterRegex = parameterRule![0];
|
|
57
|
-
expect(parameterRegex).toBeInstanceOf(RegExp);
|
|
58
|
-
|
|
59
|
-
// Test the regex with various strings
|
|
60
|
-
const textWithParams = 'Tohle je @Slovník a také @мир.';
|
|
61
|
-
const matches = textWithParams.match(new RegExp(parameterRegex.source, 'g'));
|
|
62
|
-
expect(matches).toEqual(['@Slovník', '@мир']);
|
|
63
|
-
|
|
64
|
-
expect('@Slovník'.match(parameterRegex)?.[0]).toBe('@Slovník');
|
|
65
|
-
expect('@мир'.match(parameterRegex)?.[0]).toBe('@мир');
|
|
66
|
-
expect('@parameter123'.match(parameterRegex)?.[0]).toBe('@parameter123');
|
|
67
|
-
expect('@onlyAscii'.match(parameterRegex)?.[0]).toBe('@onlyAscii');
|
|
68
|
-
expect('not a parameter'.match(parameterRegex)).toBeNull();
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
describe('BookEditorMonaco padding', () => {
|
|
72
|
-
it('should add 5 empty lines to an empty book', () => {
|
|
73
|
-
const { getByTestId } = render(<BookEditorMonaco value={undefined} isReadonly={false} />);
|
|
74
|
-
const editor = getByTestId('mock-editor');
|
|
75
|
-
const props = JSON.parse(editor.textContent || '{}');
|
|
76
|
-
expect(props.value).toBe('\n\n\n\n\n');
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it('should add 5 empty lines to a book with no trailing newlines', () => {
|
|
80
|
-
const { getByTestId } = render(<BookEditorMonaco value={'Hello' as string_book} isReadonly={false} />);
|
|
81
|
-
const editor = getByTestId('mock-editor');
|
|
82
|
-
const props = JSON.parse(editor.textContent || '{}');
|
|
83
|
-
expect(props.value).toBe('Hello\n\n\n\n\n');
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it('should add remaining empty lines to a book with some trailing newlines', () => {
|
|
87
|
-
const { getByTestId } = render(<BookEditorMonaco value={'Hello\n\n' as string_book} isReadonly={false} />);
|
|
88
|
-
const editor = getByTestId('mock-editor');
|
|
89
|
-
const props = JSON.parse(editor.textContent || '{}');
|
|
90
|
-
expect(props.value).toBe('Hello\n\n\n\n\n');
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it('should not add empty lines to a book with 5 trailing newlines', () => {
|
|
94
|
-
const { getByTestId } = render(
|
|
95
|
-
<BookEditorMonaco value={'Hello\n\n\n\n\n' as string_book} isReadonly={false} />,
|
|
96
|
-
);
|
|
97
|
-
const editor = getByTestId('mock-editor');
|
|
98
|
-
const props = JSON.parse(editor.textContent || '{}');
|
|
99
|
-
expect(props.value).toBe('Hello\n\n\n\n\n');
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
it('should not add empty lines to a book with more than 5 trailing newlines', () => {
|
|
103
|
-
const { getByTestId } = render(
|
|
104
|
-
<BookEditorMonaco value={'Hello\n\n\n\n\n\n' as string_book} isReadonly={false} />,
|
|
105
|
-
);
|
|
106
|
-
const editor = getByTestId('mock-editor');
|
|
107
|
-
const props = JSON.parse(editor.textContent || '{}');
|
|
108
|
-
expect(props.value).toBe('Hello\n\n\n\n\n\n');
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* TODO: Make this test working, now it fails because css modules import doesn't work in the test env
|
|
115
|
-
*/
|