@n24q02m/workspace 0.9.0 → 0.9.1-beta.1
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/NOTICE +11 -5
- package/bin/cli.mjs +52 -52
- package/build/src/cli/tools.integration.test.js +26 -5
- package/build/src/cli/tools.integration.test.js.map +1 -1
- package/build/src/docs/docs.md +5 -1
- package/build/src/docs/overview.md +14 -0
- package/build/src/services/FormsService.d.ts +4 -4
- package/build/src/services/FormsService.js +4 -4
- package/build/src/services/FormsService.test.js +3 -3
- package/build/src/services/FormsService.test.js.map +1 -1
- package/build/src/tools/domains/error-payload.test.d.ts +2 -0
- package/build/src/tools/domains/error-payload.test.d.ts.map +1 -0
- package/build/src/tools/domains/error-payload.test.js +94 -0
- package/build/src/tools/domains/error-payload.test.js.map +1 -0
- package/build/src/tools/domains/factory.d.ts.map +1 -1
- package/build/src/tools/domains/factory.js +27 -1
- package/build/src/tools/domains/factory.js.map +1 -1
- package/build/src/tools/domains/factory.test.js +41 -0
- package/build/src/tools/domains/factory.test.js.map +1 -1
- package/build/src/vendored/services/CalendarService.d.ts.map +1 -1
- package/build/src/vendored/services/CalendarService.js +19 -15
- package/build/src/vendored/services/CalendarService.js.map +1 -1
- package/build/src/vendored/services/CalendarService.test.d.ts +2 -0
- package/build/src/vendored/services/CalendarService.test.d.ts.map +1 -0
- package/build/src/vendored/services/CalendarService.test.js +1227 -0
- package/build/src/vendored/services/CalendarService.test.js.map +1 -0
- package/build/src/vendored/services/CalendarValidation.test.d.ts +2 -0
- package/build/src/vendored/services/CalendarValidation.test.d.ts.map +1 -0
- package/build/src/vendored/services/CalendarValidation.test.js +312 -0
- package/build/src/vendored/services/CalendarValidation.test.js.map +1 -0
- package/build/src/vendored/services/ChatService.test.d.ts +2 -0
- package/build/src/vendored/services/ChatService.test.d.ts.map +1 -0
- package/build/src/vendored/services/ChatService.test.js +505 -0
- package/build/src/vendored/services/ChatService.test.js.map +1 -0
- package/build/src/vendored/services/DocsService.d.ts.map +1 -1
- package/build/src/vendored/services/DocsService.js +6 -1
- package/build/src/vendored/services/DocsService.js.map +1 -1
- package/build/src/vendored/services/DocsService.test.js +943 -5
- package/build/src/vendored/services/DocsService.test.js.map +1 -1
- package/build/src/vendored/services/DriveService.test.js +797 -9
- package/build/src/vendored/services/DriveService.test.js.map +1 -1
- package/build/src/vendored/services/SheetsService.test.js +328 -0
- package/build/src/vendored/services/SheetsService.test.js.map +1 -1
- package/build/src/vendored/utils/MimeHelper.test.js +329 -0
- package/build/src/vendored/utils/MimeHelper.test.js.map +1 -1
- package/build/src/vendored/utils/validation.d.ts.map +1 -1
- package/build/src/vendored/utils/validation.js +10 -1
- package/build/src/vendored/utils/validation.js.map +1 -1
- package/build/src/vendored/utils/validation.test.d.ts +2 -0
- package/build/src/vendored/utils/validation.test.d.ts.map +1 -0
- package/build/src/vendored/utils/validation.test.js +260 -0
- package/build/src/vendored/utils/validation.test.js.map +1 -0
- package/build/tsconfig.tsbuildinfo +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
|
@@ -1,16 +1,33 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
2
|
+
const mocks = vi.hoisted(() => {
|
|
3
|
+
const authClient = { marker: 'oauth-client' };
|
|
4
|
+
return {
|
|
5
|
+
authClient,
|
|
6
|
+
getAuthenticatedClient: vi.fn(async () => authClient),
|
|
7
|
+
docsFactory: vi.fn(),
|
|
8
|
+
documentsCreate: vi.fn(),
|
|
9
|
+
documentsBatchUpdate: vi.fn()
|
|
10
|
+
};
|
|
11
|
+
});
|
|
2
12
|
// Mock the auth shim so no real credentials are needed.
|
|
3
13
|
vi.mock('../../auth/credential-state.js', () => ({
|
|
4
|
-
getAuth: () => ({ getAuthenticatedClient: async () => (
|
|
14
|
+
getAuth: () => ({ getAuthenticatedClient: async () => mocks.getAuthenticatedClient() })
|
|
5
15
|
}));
|
|
6
|
-
// Mock googleapis to intercept the Docs API
|
|
16
|
+
// Mock googleapis to intercept the Docs API calls DocsService makes.
|
|
7
17
|
const documentsGet = vi.fn().mockResolvedValue({ data: { title: 'Untitled', body: { content: [] }, tabs: [] } });
|
|
8
18
|
vi.mock('googleapis', () => ({
|
|
9
|
-
google: {
|
|
19
|
+
google: {
|
|
20
|
+
docs: (options) => {
|
|
21
|
+
mocks.docsFactory(options);
|
|
22
|
+
return {
|
|
23
|
+
documents: { get: documentsGet, create: mocks.documentsCreate, batchUpdate: mocks.documentsBatchUpdate }
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
10
27
|
// keep the Auth type import happy (type-only, erased at runtime)
|
|
11
28
|
}));
|
|
12
|
-
import { DocsService, boundDocsText, DEFAULT_DOCS_TEXT_LIMIT, PREVIEW_DOCS_TEXT_LIMIT } from './DocsService.js';
|
|
13
29
|
import { AuthManager } from '../auth/AuthManager.js';
|
|
30
|
+
import { boundDocsText, DEFAULT_DOCS_TEXT_LIMIT, DocsService, MAX_DOCS_TEXT_LIMIT, PREVIEW_DOCS_TEXT_LIMIT, TABS_FIELD_MASK } from './DocsService.js';
|
|
14
31
|
describe('vendored DocsService over the shim', () => {
|
|
15
32
|
it('getText routes through the shim to docs.documents.get', async () => {
|
|
16
33
|
const svc = new DocsService(new AuthManager(['scope']));
|
|
@@ -74,4 +91,925 @@ describe('vendored DocsService over the shim', () => {
|
|
|
74
91
|
expect(mod.DocsService).toBeTypeOf('function');
|
|
75
92
|
});
|
|
76
93
|
});
|
|
94
|
+
const textOf = (res) => res.content[0].text;
|
|
95
|
+
const jsonOf = (res) => JSON.parse(res.content[0].text);
|
|
96
|
+
const newService = () => new DocsService(new AuthManager(['scope']));
|
|
97
|
+
const para = (...runs) => ({ paragraph: { elements: runs.map((content) => ({ textRun: { content } })) } });
|
|
98
|
+
const tab = (tabId, title, content, childTabs) => ({
|
|
99
|
+
tabProperties: { tabId, title },
|
|
100
|
+
documentTab: content ? { body: { content } } : undefined,
|
|
101
|
+
childTabs
|
|
102
|
+
});
|
|
103
|
+
const truncated = (kept, total) => `[Content truncated: showing ${kept} of ${total} characters (${total - kept} omitted). Request a larger limit, up to ${MAX_DOCS_TEXT_LIMIT}.]`;
|
|
104
|
+
describe('DocsService (behavior over a mocked Docs API)', () => {
|
|
105
|
+
beforeEach(() => {
|
|
106
|
+
documentsGet.mockReset();
|
|
107
|
+
mocks.documentsCreate.mockReset();
|
|
108
|
+
mocks.documentsBatchUpdate.mockReset();
|
|
109
|
+
mocks.documentsBatchUpdate.mockResolvedValue({ data: {} });
|
|
110
|
+
mocks.docsFactory.mockReset();
|
|
111
|
+
mocks.getAuthenticatedClient.mockReset();
|
|
112
|
+
mocks.getAuthenticatedClient.mockResolvedValue(mocks.authClient);
|
|
113
|
+
});
|
|
114
|
+
describe('boundDocsText', () => {
|
|
115
|
+
it('returns the text untouched when its length equals the limit', () => {
|
|
116
|
+
expect(boundDocsText('abc', 3)).toEqual({ text: 'abc', truncated: false, totalCharacters: 3 });
|
|
117
|
+
});
|
|
118
|
+
it('cuts one character over the limit and names the true size in the marker', () => {
|
|
119
|
+
expect(boundDocsText('ab', 1)).toEqual({
|
|
120
|
+
text: `a\n\n${truncated(1, 2)}`,
|
|
121
|
+
truncated: true,
|
|
122
|
+
totalCharacters: 2
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
it('treats an empty string as not truncated', () => {
|
|
126
|
+
expect(boundDocsText('', 1)).toEqual({ text: '', truncated: false, totalCharacters: 0 });
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
describe('Docs client construction', () => {
|
|
130
|
+
it('builds the Docs v1 client with the authenticated client and the shared retry/timeout options', async () => {
|
|
131
|
+
documentsGet.mockResolvedValue({ data: { title: 'Doc', tabs: [] } });
|
|
132
|
+
await newService().getText({ documentId: 'doc1' });
|
|
133
|
+
expect(mocks.docsFactory).toHaveBeenCalledTimes(1);
|
|
134
|
+
expect(mocks.docsFactory).toHaveBeenCalledWith(expect.objectContaining({
|
|
135
|
+
version: 'v1',
|
|
136
|
+
auth: mocks.authClient,
|
|
137
|
+
timeout: 30000,
|
|
138
|
+
retryConfig: expect.objectContaining({ retry: 3 })
|
|
139
|
+
}));
|
|
140
|
+
});
|
|
141
|
+
it('returns the error JSON when authentication fails, without calling the Docs API', async () => {
|
|
142
|
+
mocks.getAuthenticatedClient.mockRejectedValue(new Error('no credentials for account'));
|
|
143
|
+
const res = await newService().getText({ documentId: 'doc1' });
|
|
144
|
+
expect(jsonOf(res)).toEqual({ error: 'no credentials for account' });
|
|
145
|
+
expect(documentsGet).not.toHaveBeenCalled();
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
describe('getText (BOUNDS fork)', () => {
|
|
149
|
+
const bodyOf = (text) => [tab('t1', 'Main', [para(text)])];
|
|
150
|
+
it('requests the document with the tab field mask, tab content and no suggestions', async () => {
|
|
151
|
+
documentsGet.mockResolvedValue({ data: { title: 'Doc', tabs: bodyOf('hello') } });
|
|
152
|
+
await newService().getText({ documentId: 'doc1' });
|
|
153
|
+
expect(documentsGet).toHaveBeenCalledWith({
|
|
154
|
+
documentId: 'doc1',
|
|
155
|
+
fields: `title,${TABS_FIELD_MASK}`,
|
|
156
|
+
includeTabsContent: true,
|
|
157
|
+
suggestionsViewMode: 'PREVIEW_WITHOUT_SUGGESTIONS'
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
it('returns the title and body of a single-tab document', async () => {
|
|
161
|
+
documentsGet.mockResolvedValue({ data: { title: 'Doc', tabs: bodyOf('hello') } });
|
|
162
|
+
const res = await newService().getText({ documentId: 'doc1' });
|
|
163
|
+
expect(textOf(res)).toBe('Document Title: Doc\n\nhello');
|
|
164
|
+
});
|
|
165
|
+
it('omits the title prefix when the document has no title', async () => {
|
|
166
|
+
documentsGet.mockResolvedValue({ data: { tabs: bodyOf('hello') } });
|
|
167
|
+
const res = await newService().getText({ documentId: 'doc1' });
|
|
168
|
+
expect(textOf(res)).toBe('hello');
|
|
169
|
+
});
|
|
170
|
+
it('returns only the title prefix for a single tab without a body', async () => {
|
|
171
|
+
documentsGet.mockResolvedValue({ data: { title: 'Doc', tabs: [tab('t1', 'Main')] } });
|
|
172
|
+
const res = await newService().getText({ documentId: 'doc1' });
|
|
173
|
+
expect(textOf(res)).toBe('Document Title: Doc\n\n');
|
|
174
|
+
});
|
|
175
|
+
it('returns an empty string when the document has no tabs', async () => {
|
|
176
|
+
documentsGet.mockResolvedValue({ data: { title: 'Doc', tabs: [] } });
|
|
177
|
+
expect(textOf(await newService().getText({ documentId: 'doc1' }))).toBe('');
|
|
178
|
+
});
|
|
179
|
+
it('returns an empty string when the response carries no tabs field', async () => {
|
|
180
|
+
documentsGet.mockResolvedValue({ data: { title: 'Doc' } });
|
|
181
|
+
expect(textOf(await newService().getText({ documentId: 'doc1' }))).toBe('');
|
|
182
|
+
});
|
|
183
|
+
it('extracts the document id from a Docs URL before calling the API', async () => {
|
|
184
|
+
documentsGet.mockResolvedValue({ data: { tabs: bodyOf('x') } });
|
|
185
|
+
await newService().getText({ documentId: 'https://docs.google.com/document/d/AbC_123-x/edit' });
|
|
186
|
+
expect(documentsGet).toHaveBeenCalledWith(expect.objectContaining({ documentId: 'AbC_123-x' }));
|
|
187
|
+
});
|
|
188
|
+
it('rejects an id that is neither a valid id nor a Docs URL without calling the API', async () => {
|
|
189
|
+
const res = await newService().getText({ documentId: 'not a valid id!' });
|
|
190
|
+
expect(jsonOf(res)).toEqual({ error: 'Invalid document ID or URL' });
|
|
191
|
+
expect(documentsGet).not.toHaveBeenCalled();
|
|
192
|
+
});
|
|
193
|
+
describe('default, preview and explicit limits', () => {
|
|
194
|
+
it('cuts a long body at 20,000 characters and ends it with the shared marker naming the true size', async () => {
|
|
195
|
+
documentsGet.mockResolvedValue({ data: { tabs: bodyOf('y'.repeat(20_030)) } });
|
|
196
|
+
const res = await newService().getText({ documentId: 'doc1' });
|
|
197
|
+
expect(textOf(res)).toBe(`${'y'.repeat(DEFAULT_DOCS_TEXT_LIMIT)}\n\n${truncated(20_000, 20_030)}`);
|
|
198
|
+
expect(textOf(res)).toContain('[Content truncated: showing 20000 of 20030 characters (30 omitted). Request a larger limit, up to 100000.]');
|
|
199
|
+
});
|
|
200
|
+
it('returns a body of exactly 20,000 characters whole, with no marker', async () => {
|
|
201
|
+
documentsGet.mockResolvedValue({ data: { tabs: bodyOf('z'.repeat(DEFAULT_DOCS_TEXT_LIMIT)) } });
|
|
202
|
+
const res = await newService().getText({ documentId: 'doc1' });
|
|
203
|
+
expect(textOf(res)).toBe('z'.repeat(DEFAULT_DOCS_TEXT_LIMIT));
|
|
204
|
+
});
|
|
205
|
+
it('uses the 2,000-character preview budget when preview is set', async () => {
|
|
206
|
+
documentsGet.mockResolvedValue({ data: { tabs: bodyOf('p'.repeat(2_500)) } });
|
|
207
|
+
const res = await newService().getText({ documentId: 'doc1', preview: true });
|
|
208
|
+
expect(textOf(res)).toBe(`${'p'.repeat(PREVIEW_DOCS_TEXT_LIMIT)}\n\n${truncated(2_000, 2_500)}`);
|
|
209
|
+
});
|
|
210
|
+
it('lets an explicit limit win over preview', async () => {
|
|
211
|
+
documentsGet.mockResolvedValue({ data: { tabs: bodyOf('q'.repeat(3_000)) } });
|
|
212
|
+
const res = await newService().getText({ documentId: 'doc1', preview: true, limit: 5_000 });
|
|
213
|
+
expect(textOf(res)).toBe('q'.repeat(3_000));
|
|
214
|
+
});
|
|
215
|
+
it('counts the title prefix against the limit for a single-tab document', async () => {
|
|
216
|
+
documentsGet.mockResolvedValue({ data: { title: 'Doc', tabs: bodyOf('abcdefghij') } });
|
|
217
|
+
const res = await newService().getText({ documentId: 'doc1', limit: 25 });
|
|
218
|
+
// 'Document Title: Doc\n\n' is 21 characters, the full text 31.
|
|
219
|
+
expect(textOf(res)).toBe(`Document Title: Doc\n\nabcd\n\n${truncated(25, 31)}`);
|
|
220
|
+
});
|
|
221
|
+
it('accepts the smallest limit, 1', async () => {
|
|
222
|
+
documentsGet.mockResolvedValue({ data: { tabs: bodyOf('abc') } });
|
|
223
|
+
const res = await newService().getText({ documentId: 'doc1', limit: 1 });
|
|
224
|
+
expect(textOf(res)).toBe(`a\n\n${truncated(1, 3)}`);
|
|
225
|
+
});
|
|
226
|
+
it('accepts the largest limit, 100,000', async () => {
|
|
227
|
+
documentsGet.mockResolvedValue({ data: { tabs: bodyOf('abc') } });
|
|
228
|
+
const res = await newService().getText({ documentId: 'doc1', limit: MAX_DOCS_TEXT_LIMIT });
|
|
229
|
+
expect(textOf(res)).toBe('abc');
|
|
230
|
+
expect(documentsGet).toHaveBeenCalledTimes(1);
|
|
231
|
+
});
|
|
232
|
+
it.each([0, -1, 1.5, 100_001, Number.NaN])('rejects limit %s before touching auth or the Docs API', async (limit) => {
|
|
233
|
+
const res = await newService().getText({ documentId: 'doc1', limit });
|
|
234
|
+
expect(jsonOf(res)).toEqual({ error: 'limit must be an integer from 1 to 100000.' });
|
|
235
|
+
expect(mocks.docsFactory).not.toHaveBeenCalled();
|
|
236
|
+
expect(documentsGet).not.toHaveBeenCalled();
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
describe('reading one tab by tabId', () => {
|
|
240
|
+
const tabs = [tab('parent', 'Parent', [para('parent body')], [tab('child', 'Child', [para('child body')])])];
|
|
241
|
+
it('returns the title and the body of a top-level tab', async () => {
|
|
242
|
+
documentsGet.mockResolvedValue({ data: { title: 'Doc', tabs } });
|
|
243
|
+
const res = await newService().getText({ documentId: 'doc1', tabId: 'parent' });
|
|
244
|
+
expect(textOf(res)).toBe('Document Title: Doc\n\nparent body');
|
|
245
|
+
});
|
|
246
|
+
it('finds a nested child tab', async () => {
|
|
247
|
+
documentsGet.mockResolvedValue({ data: { title: 'Doc', tabs } });
|
|
248
|
+
const res = await newService().getText({ documentId: 'doc1', tabId: 'child' });
|
|
249
|
+
expect(textOf(res)).toBe('Document Title: Doc\n\nchild body');
|
|
250
|
+
});
|
|
251
|
+
it('omits the title prefix when the document has no title', async () => {
|
|
252
|
+
documentsGet.mockResolvedValue({ data: { tabs } });
|
|
253
|
+
const res = await newService().getText({ documentId: 'doc1', tabId: 'child' });
|
|
254
|
+
expect(textOf(res)).toBe('child body');
|
|
255
|
+
});
|
|
256
|
+
it('returns an error naming the tab when the tabId does not exist', async () => {
|
|
257
|
+
documentsGet.mockResolvedValue({ data: { title: 'Doc', tabs } });
|
|
258
|
+
const res = await newService().getText({ documentId: 'doc1', tabId: 'nope' });
|
|
259
|
+
expect(jsonOf(res)).toEqual({ error: 'Tab with ID nope not found.' });
|
|
260
|
+
});
|
|
261
|
+
it('returns an empty string for a tab without a body', async () => {
|
|
262
|
+
documentsGet.mockResolvedValue({ data: { title: 'Doc', tabs: [tab('empty', 'Empty')] } });
|
|
263
|
+
const res = await newService().getText({ documentId: 'doc1', tabId: 'empty' });
|
|
264
|
+
expect(textOf(res)).toBe('');
|
|
265
|
+
});
|
|
266
|
+
it('bounds the tab text with the shared marker, counting the title prefix', async () => {
|
|
267
|
+
documentsGet.mockResolvedValue({ data: { title: 'Doc', tabs: [tab('t1', 'T', [para('abcdefghij')])] } });
|
|
268
|
+
const res = await newService().getText({ documentId: 'doc1', tabId: 't1', limit: 25 });
|
|
269
|
+
expect(textOf(res)).toBe(`Document Title: Doc\n\nabcd\n\n${truncated(25, 31)}`);
|
|
270
|
+
});
|
|
271
|
+
});
|
|
272
|
+
describe('reading a multi-tab document', () => {
|
|
273
|
+
it('returns JSON with every tab, parents before their children, in document order', async () => {
|
|
274
|
+
documentsGet.mockResolvedValue({
|
|
275
|
+
data: {
|
|
276
|
+
title: 'Doc',
|
|
277
|
+
tabs: [
|
|
278
|
+
tab('t1', 'One', [para('one')], [tab('c1', 'Child', [para('child')], [tab('g1', 'Grand', [para('grand')])])]),
|
|
279
|
+
tab('t2', 'Two', [para('two')])
|
|
280
|
+
]
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
const res = await newService().getText({ documentId: 'doc1' });
|
|
284
|
+
expect(jsonOf(res)).toEqual({
|
|
285
|
+
title: 'Doc',
|
|
286
|
+
tabs: [
|
|
287
|
+
{ tabId: 't1', title: 'One', content: 'one', truncated: false, totalCharacters: 3, index: 0 },
|
|
288
|
+
{ tabId: 'c1', title: 'Child', content: 'child', truncated: false, totalCharacters: 5, index: 1 },
|
|
289
|
+
{ tabId: 'g1', title: 'Grand', content: 'grand', truncated: false, totalCharacters: 5, index: 2 },
|
|
290
|
+
{ tabId: 't2', title: 'Two', content: 'two', truncated: false, totalCharacters: 3, index: 3 }
|
|
291
|
+
]
|
|
292
|
+
});
|
|
293
|
+
});
|
|
294
|
+
it('bounds each tab on its own and reports its true size, without the title in the content', async () => {
|
|
295
|
+
documentsGet.mockResolvedValue({
|
|
296
|
+
data: { title: 'Doc', tabs: [tab('t1', 'One', [para('abcdef')]), tab('t2', 'Two', [para('xy')])] }
|
|
297
|
+
});
|
|
298
|
+
const res = await newService().getText({ documentId: 'doc1', limit: 4 });
|
|
299
|
+
expect(jsonOf(res).tabs).toEqual([
|
|
300
|
+
{
|
|
301
|
+
tabId: 't1',
|
|
302
|
+
title: 'One',
|
|
303
|
+
content: `abcd\n\n${truncated(4, 6)}`,
|
|
304
|
+
truncated: true,
|
|
305
|
+
totalCharacters: 6,
|
|
306
|
+
index: 0
|
|
307
|
+
},
|
|
308
|
+
{ tabId: 't2', title: 'Two', content: 'xy', truncated: false, totalCharacters: 2, index: 1 }
|
|
309
|
+
]);
|
|
310
|
+
});
|
|
311
|
+
it('reports an empty, untruncated tab when a tab has no body or no properties', async () => {
|
|
312
|
+
documentsGet.mockResolvedValue({
|
|
313
|
+
data: { title: 'Doc', tabs: [tab('t1', 'One', [para('one')]), { childTabs: undefined }] }
|
|
314
|
+
});
|
|
315
|
+
const res = await newService().getText({ documentId: 'doc1' });
|
|
316
|
+
expect(jsonOf(res).tabs[1]).toEqual({ content: '', truncated: false, totalCharacters: 0, index: 1 });
|
|
317
|
+
});
|
|
318
|
+
it('leaves the title out of the JSON when the document has none', async () => {
|
|
319
|
+
documentsGet.mockResolvedValue({ data: { tabs: [tab('t1', 'One', [para('one')]), tab('t2', 'Two')] } });
|
|
320
|
+
const res = await newService().getText({ documentId: 'doc1' });
|
|
321
|
+
expect(jsonOf(res)).not.toHaveProperty('title');
|
|
322
|
+
expect(jsonOf(res).tabs).toHaveLength(2);
|
|
323
|
+
});
|
|
324
|
+
});
|
|
325
|
+
describe('rendering structural elements', () => {
|
|
326
|
+
const singleTabText = async (element) => {
|
|
327
|
+
documentsGet.mockResolvedValue({ data: { tabs: [tab('t1', 'T', [element])] } });
|
|
328
|
+
return textOf(await newService().getText({ documentId: 'doc1' }));
|
|
329
|
+
};
|
|
330
|
+
const inParagraph = (element) => ({ paragraph: { elements: [element] } });
|
|
331
|
+
it.each([
|
|
332
|
+
['a text run', { textRun: { content: 'Hello ' } }, 'Hello '],
|
|
333
|
+
['a text run without content', { textRun: {} }, ''],
|
|
334
|
+
['a text run with empty content', { textRun: { content: '' } }, ''],
|
|
335
|
+
['an element of an unknown kind', { somethingElse: {} }, ''],
|
|
336
|
+
[
|
|
337
|
+
'a person chip with name and email',
|
|
338
|
+
{ person: { personProperties: { name: 'Ann', email: 'ann@x.test' } } },
|
|
339
|
+
'[Ann](mailto:ann@x.test)'
|
|
340
|
+
],
|
|
341
|
+
[
|
|
342
|
+
'a person chip with only an email',
|
|
343
|
+
{ person: { personProperties: { email: 'ann@x.test' } } },
|
|
344
|
+
'[ann@x.test](mailto:ann@x.test)'
|
|
345
|
+
],
|
|
346
|
+
['a person chip with only a name', { person: { personProperties: { name: 'Bob' } } }, 'Bob'],
|
|
347
|
+
['a person chip with no properties set', { person: { personProperties: {} } }, ''],
|
|
348
|
+
['a person without personProperties', { person: {} }, ''],
|
|
349
|
+
[
|
|
350
|
+
'a rich link with title and uri',
|
|
351
|
+
{ richLink: { richLinkProperties: { title: 'Spec', uri: 'https://e.test/s' } } },
|
|
352
|
+
'[Spec](https://e.test/s)'
|
|
353
|
+
],
|
|
354
|
+
[
|
|
355
|
+
'a rich link with only a uri',
|
|
356
|
+
{ richLink: { richLinkProperties: { uri: 'https://e.test/u' } } },
|
|
357
|
+
'[https://e.test/u](https://e.test/u)'
|
|
358
|
+
],
|
|
359
|
+
['a rich link with only a title', { richLink: { richLinkProperties: { title: 'Only title' } } }, 'Only title'],
|
|
360
|
+
['a rich link with no properties set', { richLink: { richLinkProperties: {} } }, ''],
|
|
361
|
+
['a rich link without richLinkProperties', { richLink: {} }, ''],
|
|
362
|
+
[
|
|
363
|
+
'a date chip with display text and timestamp',
|
|
364
|
+
{ dateElement: { dateElementProperties: { displayText: 'Jan 1', timestamp: '2026-01-01T00:00:00Z' } } },
|
|
365
|
+
'Jan 1'
|
|
366
|
+
],
|
|
367
|
+
[
|
|
368
|
+
'a date chip with only a timestamp',
|
|
369
|
+
{ dateElement: { dateElementProperties: { timestamp: '2026-01-02T00:00:00Z' } } },
|
|
370
|
+
'2026-01-02T00:00:00Z'
|
|
371
|
+
],
|
|
372
|
+
['a date chip with no properties set', { dateElement: { dateElementProperties: {} } }, ''],
|
|
373
|
+
['a date element without dateElementProperties', { dateElement: {} }, '']
|
|
374
|
+
])('renders %s', async (_label, element, expected) => {
|
|
375
|
+
expect(await singleTabText(inParagraph(element))).toBe(expected);
|
|
376
|
+
});
|
|
377
|
+
it('concatenates every element of a paragraph in order', async () => {
|
|
378
|
+
const text = await singleTabText({
|
|
379
|
+
paragraph: {
|
|
380
|
+
elements: [
|
|
381
|
+
{ textRun: { content: 'Hi ' } },
|
|
382
|
+
{ person: { personProperties: { name: 'Ann', email: 'ann@x.test' } } },
|
|
383
|
+
{ textRun: { content: ' see ' } },
|
|
384
|
+
{ richLink: { richLinkProperties: { title: 'Spec', uri: 'https://e.test/s' } } }
|
|
385
|
+
]
|
|
386
|
+
}
|
|
387
|
+
});
|
|
388
|
+
expect(text).toBe('Hi [Ann](mailto:ann@x.test) see [Spec](https://e.test/s)');
|
|
389
|
+
});
|
|
390
|
+
it('renders a paragraph without elements as nothing', async () => {
|
|
391
|
+
expect(await singleTabText({ paragraph: {} })).toBe('');
|
|
392
|
+
});
|
|
393
|
+
it('renders an element that is neither a paragraph nor a table as nothing', async () => {
|
|
394
|
+
expect(await singleTabText({ sectionBreak: {} })).toBe('');
|
|
395
|
+
});
|
|
396
|
+
it('reads table cells row by row, including a nested table, and skips empty rows and cells', async () => {
|
|
397
|
+
const text = await singleTabText({
|
|
398
|
+
table: {
|
|
399
|
+
tableRows: [
|
|
400
|
+
{ tableCells: [{ content: [para('a1 ')] }, { content: [para('b1 ')] }] },
|
|
401
|
+
{ tableCells: [{ content: [para('a2 ')] }, {}] },
|
|
402
|
+
{},
|
|
403
|
+
{
|
|
404
|
+
tableCells: [
|
|
405
|
+
{ content: [{ table: { tableRows: [{ tableCells: [{ content: [para('inner ')] }] }] } }] }
|
|
406
|
+
]
|
|
407
|
+
}
|
|
408
|
+
]
|
|
409
|
+
}
|
|
410
|
+
});
|
|
411
|
+
expect(text).toBe('a1 b1 a2 inner ');
|
|
412
|
+
});
|
|
413
|
+
it('renders a table without rows as nothing', async () => {
|
|
414
|
+
expect(await singleTabText({ table: {} })).toBe('');
|
|
415
|
+
});
|
|
416
|
+
});
|
|
417
|
+
it('returns the error JSON when the Docs API rejects with an Error', async () => {
|
|
418
|
+
documentsGet.mockRejectedValue(new Error('Request failed with status code 404'));
|
|
419
|
+
const res = await newService().getText({ documentId: 'doc1' });
|
|
420
|
+
expect(jsonOf(res)).toEqual({ error: 'Request failed with status code 404' });
|
|
421
|
+
});
|
|
422
|
+
it('stringifies a non-Error rejection into the error JSON', async () => {
|
|
423
|
+
documentsGet.mockRejectedValue('quota exceeded');
|
|
424
|
+
const res = await newService().getText({ documentId: 'doc1' });
|
|
425
|
+
expect(jsonOf(res)).toEqual({ error: 'quota exceeded' });
|
|
426
|
+
});
|
|
427
|
+
});
|
|
428
|
+
describe('getSuggestions', () => {
|
|
429
|
+
const suggestionDoc = {
|
|
430
|
+
title: 'Plan',
|
|
431
|
+
body: {
|
|
432
|
+
content: [
|
|
433
|
+
{
|
|
434
|
+
startIndex: 1,
|
|
435
|
+
endIndex: 20,
|
|
436
|
+
paragraph: {
|
|
437
|
+
suggestedParagraphStyleChanges: { 'sg.para': { paragraphStyle: { namedStyleType: 'HEADING_1' } } },
|
|
438
|
+
elements: [
|
|
439
|
+
{ startIndex: 1, endIndex: 6, textRun: { content: 'added', suggestedInsertionIds: ['sg.ins'] } },
|
|
440
|
+
{ startIndex: 6, endIndex: 11, textRun: { content: 'gone ', suggestedDeletionIds: ['sg.del'] } },
|
|
441
|
+
{
|
|
442
|
+
startIndex: 11,
|
|
443
|
+
endIndex: 15,
|
|
444
|
+
textRun: {
|
|
445
|
+
content: 'bold',
|
|
446
|
+
textStyle: { bold: true },
|
|
447
|
+
suggestedTextStyleChanges: { 'sg.s1': {}, 'sg.s2': {} }
|
|
448
|
+
}
|
|
449
|
+
},
|
|
450
|
+
{ startIndex: 15, endIndex: 20, textRun: { content: 'plain' } },
|
|
451
|
+
{ startIndex: 20, endIndex: 21, pageBreak: {} }
|
|
452
|
+
]
|
|
453
|
+
}
|
|
454
|
+
},
|
|
455
|
+
{ sectionBreak: {} }
|
|
456
|
+
]
|
|
457
|
+
}
|
|
458
|
+
};
|
|
459
|
+
it('requests the document with inline suggestions and only the title and body fields', async () => {
|
|
460
|
+
documentsGet.mockResolvedValue({ data: suggestionDoc });
|
|
461
|
+
await newService().getSuggestions({ documentId: 'doc1' });
|
|
462
|
+
expect(documentsGet).toHaveBeenCalledWith({
|
|
463
|
+
documentId: 'doc1',
|
|
464
|
+
suggestionsViewMode: 'SUGGESTIONS_INLINE',
|
|
465
|
+
fields: 'title,body'
|
|
466
|
+
});
|
|
467
|
+
});
|
|
468
|
+
it('extracts paragraph, insertion, deletion and style suggestions with their ranges', async () => {
|
|
469
|
+
documentsGet.mockResolvedValue({ data: suggestionDoc });
|
|
470
|
+
const res = await newService().getSuggestions({ documentId: 'doc1' });
|
|
471
|
+
expect(res.isError).toBeUndefined();
|
|
472
|
+
expect(jsonOf(res)).toEqual({
|
|
473
|
+
title: 'Plan',
|
|
474
|
+
suggestions: [
|
|
475
|
+
{
|
|
476
|
+
type: 'paragraphStyleChange',
|
|
477
|
+
text: 'addedgone boldplain',
|
|
478
|
+
suggestionIds: ['sg.para'],
|
|
479
|
+
namedStyleType: 'HEADING_1',
|
|
480
|
+
startIndex: 1,
|
|
481
|
+
endIndex: 20
|
|
482
|
+
},
|
|
483
|
+
{ type: 'insertion', text: 'added', suggestionIds: ['sg.ins'], startIndex: 1, endIndex: 6 },
|
|
484
|
+
{ type: 'deletion', text: 'gone ', suggestionIds: ['sg.del'], startIndex: 6, endIndex: 11 },
|
|
485
|
+
{
|
|
486
|
+
type: 'styleChange',
|
|
487
|
+
text: 'bold',
|
|
488
|
+
suggestionIds: ['sg.s1', 'sg.s2'],
|
|
489
|
+
textStyle: { bold: true },
|
|
490
|
+
startIndex: 11,
|
|
491
|
+
endIndex: 15
|
|
492
|
+
}
|
|
493
|
+
]
|
|
494
|
+
});
|
|
495
|
+
});
|
|
496
|
+
it('extracts the document id from a Docs URL', async () => {
|
|
497
|
+
documentsGet.mockResolvedValue({ data: suggestionDoc });
|
|
498
|
+
await newService().getSuggestions({ documentId: 'https://docs.google.com/document/d/Doc-9_x/edit' });
|
|
499
|
+
expect(documentsGet).toHaveBeenCalledWith(expect.objectContaining({ documentId: 'Doc-9_x' }));
|
|
500
|
+
});
|
|
501
|
+
it('finds suggestions inside table cells and skips rows and cells that are empty', async () => {
|
|
502
|
+
documentsGet.mockResolvedValue({
|
|
503
|
+
data: {
|
|
504
|
+
title: 'Table',
|
|
505
|
+
body: {
|
|
506
|
+
content: [
|
|
507
|
+
{
|
|
508
|
+
table: {
|
|
509
|
+
tableRows: [
|
|
510
|
+
{
|
|
511
|
+
tableCells: [
|
|
512
|
+
{
|
|
513
|
+
content: [
|
|
514
|
+
{
|
|
515
|
+
paragraph: {
|
|
516
|
+
elements: [{ textRun: { content: 'cell', suggestedInsertionIds: ['sg.cell'] } }]
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
]
|
|
520
|
+
},
|
|
521
|
+
{}
|
|
522
|
+
]
|
|
523
|
+
},
|
|
524
|
+
{}
|
|
525
|
+
]
|
|
526
|
+
}
|
|
527
|
+
},
|
|
528
|
+
{ table: {} }
|
|
529
|
+
]
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
});
|
|
533
|
+
const res = await newService().getSuggestions({ documentId: 'doc1' });
|
|
534
|
+
expect(jsonOf(res).suggestions).toEqual([{ type: 'insertion', text: 'cell', suggestionIds: ['sg.cell'] }]);
|
|
535
|
+
});
|
|
536
|
+
it('uses empty text and no style name when the suggestion carries neither', async () => {
|
|
537
|
+
documentsGet.mockResolvedValue({
|
|
538
|
+
data: {
|
|
539
|
+
title: 'Sparse',
|
|
540
|
+
body: {
|
|
541
|
+
content: [
|
|
542
|
+
{
|
|
543
|
+
paragraph: {
|
|
544
|
+
suggestedParagraphStyleChanges: { 'sg.null': null },
|
|
545
|
+
elements: [{ textRun: { suggestedInsertionIds: ['sg.noText'] } }, { textRun: { content: 'x' } }]
|
|
546
|
+
}
|
|
547
|
+
},
|
|
548
|
+
{ paragraph: { suggestedParagraphStyleChanges: { 'sg.noElements': {} } } }
|
|
549
|
+
]
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
});
|
|
553
|
+
const res = await newService().getSuggestions({ documentId: 'doc1' });
|
|
554
|
+
expect(jsonOf(res).suggestions).toEqual([
|
|
555
|
+
{ type: 'paragraphStyleChange', text: 'x', suggestionIds: ['sg.null'] },
|
|
556
|
+
{ type: 'insertion', text: '', suggestionIds: ['sg.noText'] },
|
|
557
|
+
{ type: 'paragraphStyleChange', text: '', suggestionIds: ['sg.noElements'] }
|
|
558
|
+
]);
|
|
559
|
+
});
|
|
560
|
+
it.each([
|
|
561
|
+
['a document without a body', { title: 'Empty' }],
|
|
562
|
+
['a body without content', { title: 'Empty', body: {} }],
|
|
563
|
+
['a body with null content', { title: 'Empty', body: { content: null } }]
|
|
564
|
+
])('returns no suggestions for %s', async (_label, data) => {
|
|
565
|
+
documentsGet.mockResolvedValue({ data });
|
|
566
|
+
const res = await newService().getSuggestions({ documentId: 'doc1' });
|
|
567
|
+
expect(jsonOf(res)).toEqual({ title: 'Empty', suggestions: [] });
|
|
568
|
+
});
|
|
569
|
+
it('flags the result as an error when the Docs API rejects', async () => {
|
|
570
|
+
documentsGet.mockRejectedValue(new Error('The caller does not have permission'));
|
|
571
|
+
const res = await newService().getSuggestions({ documentId: 'doc1' });
|
|
572
|
+
expect(res.isError).toBe(true);
|
|
573
|
+
expect(jsonOf(res)).toEqual({ error: 'The caller does not have permission' });
|
|
574
|
+
});
|
|
575
|
+
it('stringifies a non-Error rejection into the error JSON', async () => {
|
|
576
|
+
documentsGet.mockRejectedValue({ code: 403 });
|
|
577
|
+
const res = await newService().getSuggestions({ documentId: 'doc1' });
|
|
578
|
+
expect(res.isError).toBe(true);
|
|
579
|
+
expect(jsonOf(res)).toEqual({ error: '[object Object]' });
|
|
580
|
+
});
|
|
581
|
+
});
|
|
582
|
+
describe('create', () => {
|
|
583
|
+
beforeEach(() => {
|
|
584
|
+
mocks.documentsCreate.mockResolvedValue({ data: { documentId: 'new1', title: 'Server Title' } });
|
|
585
|
+
});
|
|
586
|
+
it('creates a document with the given title and skips the content insert when no content is given', async () => {
|
|
587
|
+
const res = await newService().create({ title: 'Input Title' });
|
|
588
|
+
expect(mocks.documentsCreate).toHaveBeenCalledWith({ requestBody: { title: 'Input Title' } });
|
|
589
|
+
expect(mocks.documentsBatchUpdate).not.toHaveBeenCalled();
|
|
590
|
+
expect(jsonOf(res)).toEqual({ documentId: 'new1', title: 'Server Title' });
|
|
591
|
+
});
|
|
592
|
+
it('treats an empty content string as no content', async () => {
|
|
593
|
+
await newService().create({ title: 'T', content: '' });
|
|
594
|
+
expect(mocks.documentsBatchUpdate).not.toHaveBeenCalled();
|
|
595
|
+
});
|
|
596
|
+
it('inserts the content at index 1 of the new document', async () => {
|
|
597
|
+
const res = await newService().create({ title: 'T', content: 'hello world' });
|
|
598
|
+
expect(mocks.documentsBatchUpdate).toHaveBeenCalledWith({
|
|
599
|
+
documentId: 'new1',
|
|
600
|
+
requestBody: { requests: [{ insertText: { location: { index: 1 }, text: 'hello world' } }] }
|
|
601
|
+
});
|
|
602
|
+
expect(jsonOf(res)).toEqual({ documentId: 'new1', title: 'Server Title' });
|
|
603
|
+
});
|
|
604
|
+
it('returns the error JSON when the create call rejects, without inserting content', async () => {
|
|
605
|
+
mocks.documentsCreate.mockRejectedValue(new Error('Insufficient Permission'));
|
|
606
|
+
const res = await newService().create({ title: 'T', content: 'hello' });
|
|
607
|
+
expect(jsonOf(res)).toEqual({ error: 'Insufficient Permission' });
|
|
608
|
+
expect(mocks.documentsBatchUpdate).not.toHaveBeenCalled();
|
|
609
|
+
});
|
|
610
|
+
it('returns the error JSON when the content insert rejects', async () => {
|
|
611
|
+
mocks.documentsBatchUpdate.mockRejectedValue(new Error('Invalid requests[0].insertText'));
|
|
612
|
+
const res = await newService().create({ title: 'T', content: 'hello' });
|
|
613
|
+
expect(jsonOf(res)).toEqual({ error: 'Invalid requests[0].insertText' });
|
|
614
|
+
});
|
|
615
|
+
it('stringifies a non-Error rejection into the error JSON', async () => {
|
|
616
|
+
mocks.documentsCreate.mockRejectedValue('backend unavailable');
|
|
617
|
+
const res = await newService().create({ title: 'T' });
|
|
618
|
+
expect(jsonOf(res)).toEqual({ error: 'backend unavailable' });
|
|
619
|
+
});
|
|
620
|
+
});
|
|
621
|
+
describe('writeText', () => {
|
|
622
|
+
const sentRequests = () => mocks.documentsBatchUpdate.mock.calls[0][0].requestBody.requests;
|
|
623
|
+
it('appends to the main body without reading the document when position is the default end', async () => {
|
|
624
|
+
const res = await newService().writeText({ documentId: 'doc1', text: 'tail' });
|
|
625
|
+
expect(mocks.documentsBatchUpdate).toHaveBeenCalledWith({
|
|
626
|
+
documentId: 'doc1',
|
|
627
|
+
requestBody: { requests: [{ insertText: { text: 'tail' } }] }
|
|
628
|
+
});
|
|
629
|
+
expect(documentsGet).not.toHaveBeenCalled();
|
|
630
|
+
expect(textOf(res)).toBe('Successfully wrote text to document doc1 at position end');
|
|
631
|
+
});
|
|
632
|
+
it('inserts at index 1 for position beginning', async () => {
|
|
633
|
+
const res = await newService().writeText({ documentId: 'doc1', text: 'head', position: 'beginning' });
|
|
634
|
+
expect(sentRequests()).toEqual([{ insertText: { location: { index: 1, tabId: undefined }, text: 'head' } }]);
|
|
635
|
+
expect(documentsGet).not.toHaveBeenCalled();
|
|
636
|
+
expect(textOf(res)).toBe('Successfully wrote text to document doc1 at position beginning');
|
|
637
|
+
});
|
|
638
|
+
it('inserts at index 1 of the given tab for position beginning', async () => {
|
|
639
|
+
await newService().writeText({ documentId: 'doc1', text: 'head', position: 'beginning', tabId: 'tabX' });
|
|
640
|
+
expect(sentRequests()).toEqual([{ insertText: { location: { index: 1, tabId: 'tabX' }, text: 'head' } }]);
|
|
641
|
+
});
|
|
642
|
+
it('inserts at a numeric position', async () => {
|
|
643
|
+
await newService().writeText({ documentId: 'doc1', text: 'mid', position: '7' });
|
|
644
|
+
expect(sentRequests()).toEqual([{ insertText: { location: { index: 7, tabId: undefined }, text: 'mid' } }]);
|
|
645
|
+
});
|
|
646
|
+
it('inserts at a numeric position inside the given tab', async () => {
|
|
647
|
+
await newService().writeText({ documentId: 'doc1', text: 'mid', position: '7', tabId: 'tabX' });
|
|
648
|
+
expect(sentRequests()).toEqual([{ insertText: { location: { index: 7, tabId: 'tabX' }, text: 'mid' } }]);
|
|
649
|
+
});
|
|
650
|
+
it.each(['abc', '0', '-3', ''])('rejects the position %j without writing', async (position) => {
|
|
651
|
+
const res = await newService().writeText({ documentId: 'doc1', text: 'x', position });
|
|
652
|
+
expect(jsonOf(res)).toEqual({
|
|
653
|
+
error: `Invalid position: "${position}". Use "beginning", "end", or a positive integer index.`
|
|
654
|
+
});
|
|
655
|
+
expect(mocks.documentsBatchUpdate).not.toHaveBeenCalled();
|
|
656
|
+
});
|
|
657
|
+
it('extracts the document id from a Docs URL', async () => {
|
|
658
|
+
const res = await newService().writeText({
|
|
659
|
+
documentId: 'https://docs.google.com/document/d/Doc-9_x/edit',
|
|
660
|
+
text: 'tail'
|
|
661
|
+
});
|
|
662
|
+
expect(mocks.documentsBatchUpdate).toHaveBeenCalledWith(expect.objectContaining({ documentId: 'Doc-9_x' }));
|
|
663
|
+
expect(textOf(res)).toBe('Successfully wrote text to document Doc-9_x at position end');
|
|
664
|
+
});
|
|
665
|
+
describe('appending to a tab', () => {
|
|
666
|
+
const tabs = [
|
|
667
|
+
tab('t1', 'One', [para('one')]),
|
|
668
|
+
tab('t2', 'Two', [{ endIndex: 5 }, { endIndex: 12 }], [tab('child', 'Child', [{ endIndex: 30 }])])
|
|
669
|
+
];
|
|
670
|
+
it('reads the document with the tab field mask and inserts just before the last element of the tab', async () => {
|
|
671
|
+
documentsGet.mockResolvedValue({ data: { tabs } });
|
|
672
|
+
await newService().writeText({ documentId: 'doc1', text: 'tail', tabId: 't2' });
|
|
673
|
+
expect(documentsGet).toHaveBeenCalledWith({
|
|
674
|
+
documentId: 'doc1',
|
|
675
|
+
fields: TABS_FIELD_MASK,
|
|
676
|
+
includeTabsContent: true
|
|
677
|
+
});
|
|
678
|
+
expect(sentRequests()).toEqual([{ insertText: { location: { index: 11, tabId: 't2' }, text: 'tail' } }]);
|
|
679
|
+
});
|
|
680
|
+
it('finds a nested child tab', async () => {
|
|
681
|
+
documentsGet.mockResolvedValue({ data: { tabs } });
|
|
682
|
+
await newService().writeText({ documentId: 'doc1', text: 'tail', tabId: 'child', position: 'end' });
|
|
683
|
+
expect(sentRequests()).toEqual([{ insertText: { location: { index: 29, tabId: 'child' }, text: 'tail' } }]);
|
|
684
|
+
});
|
|
685
|
+
it('falls back to index 1 when the tab has no body', async () => {
|
|
686
|
+
documentsGet.mockResolvedValue({ data: { tabs: [tab('t1', 'One')] } });
|
|
687
|
+
await newService().writeText({ documentId: 'doc1', text: 'tail', tabId: 't1' });
|
|
688
|
+
expect(sentRequests()).toEqual([{ insertText: { location: { index: 1, tabId: 't1' }, text: 'tail' } }]);
|
|
689
|
+
});
|
|
690
|
+
it('falls back to index 1 when the last element has no endIndex', async () => {
|
|
691
|
+
documentsGet.mockResolvedValue({ data: { tabs: [tab('t1', 'One', [{}])] } });
|
|
692
|
+
await newService().writeText({ documentId: 'doc1', text: 'tail', tabId: 't1' });
|
|
693
|
+
expect(sentRequests()).toEqual([{ insertText: { location: { index: 1, tabId: 't1' }, text: 'tail' } }]);
|
|
694
|
+
});
|
|
695
|
+
it('returns an error naming the tab when the document has no tabs at all', async () => {
|
|
696
|
+
documentsGet.mockResolvedValue({ data: {} });
|
|
697
|
+
const res = await newService().writeText({ documentId: 'doc1', text: 'tail', tabId: 't1' });
|
|
698
|
+
expect(jsonOf(res)).toEqual({ error: 'Tab with ID t1 not found.' });
|
|
699
|
+
expect(mocks.documentsBatchUpdate).not.toHaveBeenCalled();
|
|
700
|
+
});
|
|
701
|
+
it('returns an error naming the tab when the tabId does not exist, without writing', async () => {
|
|
702
|
+
documentsGet.mockResolvedValue({ data: { tabs } });
|
|
703
|
+
const res = await newService().writeText({ documentId: 'doc1', text: 'tail', tabId: 'nope' });
|
|
704
|
+
expect(jsonOf(res)).toEqual({ error: 'Tab with ID nope not found.' });
|
|
705
|
+
expect(mocks.documentsBatchUpdate).not.toHaveBeenCalled();
|
|
706
|
+
});
|
|
707
|
+
});
|
|
708
|
+
it('returns the error JSON when the batch update rejects', async () => {
|
|
709
|
+
mocks.documentsBatchUpdate.mockRejectedValue(new Error('Invalid location'));
|
|
710
|
+
const res = await newService().writeText({ documentId: 'doc1', text: 'x' });
|
|
711
|
+
expect(jsonOf(res)).toEqual({ error: 'Invalid location' });
|
|
712
|
+
});
|
|
713
|
+
it('stringifies a non-Error rejection into the error JSON', async () => {
|
|
714
|
+
mocks.documentsBatchUpdate.mockRejectedValue(42);
|
|
715
|
+
const res = await newService().writeText({ documentId: 'doc1', text: 'x' });
|
|
716
|
+
expect(jsonOf(res)).toEqual({ error: '42' });
|
|
717
|
+
});
|
|
718
|
+
});
|
|
719
|
+
describe('formatText', () => {
|
|
720
|
+
const appliedRequests = () => mocks.documentsBatchUpdate.mock.calls[0][0].requestBody.requests;
|
|
721
|
+
it.each([
|
|
722
|
+
['heading1', 'HEADING_1'],
|
|
723
|
+
['heading2', 'HEADING_2'],
|
|
724
|
+
['Heading3', 'HEADING_3'],
|
|
725
|
+
['HEADING4', 'HEADING_4'],
|
|
726
|
+
['heading5', 'HEADING_5'],
|
|
727
|
+
['heading6', 'HEADING_6'],
|
|
728
|
+
['normalText', 'NORMAL_TEXT'],
|
|
729
|
+
['normaltext', 'NORMAL_TEXT']
|
|
730
|
+
])('maps the style %s to the paragraph style %s', async (style, namedStyleType) => {
|
|
731
|
+
const res = await newService().formatText({ documentId: 'doc1', formats: [{ startIndex: 2, endIndex: 9, style }] });
|
|
732
|
+
expect(mocks.documentsBatchUpdate).toHaveBeenCalledWith({
|
|
733
|
+
documentId: 'doc1',
|
|
734
|
+
requestBody: {
|
|
735
|
+
requests: [
|
|
736
|
+
{
|
|
737
|
+
updateParagraphStyle: {
|
|
738
|
+
range: { startIndex: 2, endIndex: 9, tabId: undefined },
|
|
739
|
+
paragraphStyle: { namedStyleType },
|
|
740
|
+
fields: 'namedStyleType'
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
]
|
|
744
|
+
}
|
|
745
|
+
});
|
|
746
|
+
expect(textOf(res)).toBe('Successfully applied 1 format(s) to document doc1');
|
|
747
|
+
});
|
|
748
|
+
it.each([
|
|
749
|
+
['bold', 'bold'],
|
|
750
|
+
['Italic', 'italic'],
|
|
751
|
+
['UNDERLINE', 'underline'],
|
|
752
|
+
['strikethrough', 'strikethrough']
|
|
753
|
+
])('maps the style %s to a text style with only %s set', async (style, field) => {
|
|
754
|
+
await newService().formatText({ documentId: 'doc1', formats: [{ startIndex: 1, endIndex: 4, style }] });
|
|
755
|
+
expect(appliedRequests()).toEqual([
|
|
756
|
+
{
|
|
757
|
+
updateTextStyle: {
|
|
758
|
+
range: { startIndex: 1, endIndex: 4, tabId: undefined },
|
|
759
|
+
textStyle: { [field]: true },
|
|
760
|
+
fields: field
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
]);
|
|
764
|
+
});
|
|
765
|
+
it('maps code to the Courier New font', async () => {
|
|
766
|
+
await newService().formatText({ documentId: 'doc1', formats: [{ startIndex: 1, endIndex: 4, style: 'CODE' }] });
|
|
767
|
+
expect(appliedRequests()).toEqual([
|
|
768
|
+
{
|
|
769
|
+
updateTextStyle: {
|
|
770
|
+
range: { startIndex: 1, endIndex: 4, tabId: undefined },
|
|
771
|
+
textStyle: { weightedFontFamily: { fontFamily: 'Courier New' } },
|
|
772
|
+
fields: 'weightedFontFamily'
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
]);
|
|
776
|
+
});
|
|
777
|
+
it('maps link with a url to a link text style', async () => {
|
|
778
|
+
await newService().formatText({
|
|
779
|
+
documentId: 'doc1',
|
|
780
|
+
formats: [{ startIndex: 1, endIndex: 4, style: 'Link', url: 'https://example.test/page' }]
|
|
781
|
+
});
|
|
782
|
+
expect(appliedRequests()).toEqual([
|
|
783
|
+
{
|
|
784
|
+
updateTextStyle: {
|
|
785
|
+
range: { startIndex: 1, endIndex: 4, tabId: undefined },
|
|
786
|
+
textStyle: { link: { url: 'https://example.test/page' } },
|
|
787
|
+
fields: 'link'
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
]);
|
|
791
|
+
});
|
|
792
|
+
it('puts the tabId on every range', async () => {
|
|
793
|
+
await newService().formatText({
|
|
794
|
+
documentId: 'doc1',
|
|
795
|
+
tabId: 'tab9',
|
|
796
|
+
formats: [
|
|
797
|
+
{ startIndex: 1, endIndex: 4, style: 'bold' },
|
|
798
|
+
{ startIndex: 5, endIndex: 8, style: 'heading1' }
|
|
799
|
+
]
|
|
800
|
+
});
|
|
801
|
+
expect(appliedRequests()[0].updateTextStyle.range).toEqual({ startIndex: 1, endIndex: 4, tabId: 'tab9' });
|
|
802
|
+
expect(appliedRequests()[1].updateParagraphStyle.range).toEqual({ startIndex: 5, endIndex: 8, tabId: 'tab9' });
|
|
803
|
+
});
|
|
804
|
+
it('applies the valid formats in order, skips the unknown ones and counts only the applied ones', async () => {
|
|
805
|
+
const res = await newService().formatText({
|
|
806
|
+
documentId: 'doc1',
|
|
807
|
+
formats: [
|
|
808
|
+
{ startIndex: 1, endIndex: 2, style: 'bold' },
|
|
809
|
+
{ startIndex: 3, endIndex: 4, style: 'sparkle' },
|
|
810
|
+
{ startIndex: 5, endIndex: 6, style: 'link' },
|
|
811
|
+
{ startIndex: 7, endIndex: 8, style: 'italic' }
|
|
812
|
+
]
|
|
813
|
+
});
|
|
814
|
+
expect(appliedRequests()).toHaveLength(2);
|
|
815
|
+
expect(appliedRequests()[0].updateTextStyle.fields).toBe('bold');
|
|
816
|
+
expect(appliedRequests()[1].updateTextStyle.fields).toBe('italic');
|
|
817
|
+
expect(textOf(res)).toBe('Successfully applied 2 format(s) to document doc1');
|
|
818
|
+
});
|
|
819
|
+
it.each([
|
|
820
|
+
['an unknown style', [{ startIndex: 1, endIndex: 2, style: 'sparkle' }]],
|
|
821
|
+
['a link without a url', [{ startIndex: 1, endIndex: 2, style: 'link' }]],
|
|
822
|
+
['an empty list', []]
|
|
823
|
+
])('applies nothing and never calls Google for %s', async (_label, formats) => {
|
|
824
|
+
const res = await newService().formatText({ documentId: 'doc1', formats });
|
|
825
|
+
expect(textOf(res)).toBe('No valid formatting requests to apply.');
|
|
826
|
+
expect(mocks.docsFactory).not.toHaveBeenCalled();
|
|
827
|
+
expect(mocks.documentsBatchUpdate).not.toHaveBeenCalled();
|
|
828
|
+
});
|
|
829
|
+
it('extracts the document id from a Docs URL', async () => {
|
|
830
|
+
const res = await newService().formatText({
|
|
831
|
+
documentId: 'https://docs.google.com/document/d/Doc-9_x/edit',
|
|
832
|
+
formats: [{ startIndex: 1, endIndex: 2, style: 'bold' }]
|
|
833
|
+
});
|
|
834
|
+
expect(mocks.documentsBatchUpdate).toHaveBeenCalledWith(expect.objectContaining({ documentId: 'Doc-9_x' }));
|
|
835
|
+
expect(textOf(res)).toBe('Successfully applied 1 format(s) to document Doc-9_x');
|
|
836
|
+
});
|
|
837
|
+
it('returns the error JSON when the batch update rejects', async () => {
|
|
838
|
+
mocks.documentsBatchUpdate.mockRejectedValue(new Error('Invalid range'));
|
|
839
|
+
const res = await newService().formatText({
|
|
840
|
+
documentId: 'doc1',
|
|
841
|
+
formats: [{ startIndex: 1, endIndex: 2, style: 'bold' }]
|
|
842
|
+
});
|
|
843
|
+
expect(jsonOf(res)).toEqual({ error: 'Invalid range' });
|
|
844
|
+
});
|
|
845
|
+
it('stringifies a non-Error rejection into the error JSON', async () => {
|
|
846
|
+
mocks.documentsBatchUpdate.mockRejectedValue('boom');
|
|
847
|
+
const res = await newService().formatText({
|
|
848
|
+
documentId: 'doc1',
|
|
849
|
+
formats: [{ startIndex: 1, endIndex: 2, style: 'bold' }]
|
|
850
|
+
});
|
|
851
|
+
expect(jsonOf(res)).toEqual({ error: 'boom' });
|
|
852
|
+
});
|
|
853
|
+
it('returns the error JSON when a format has no style', async () => {
|
|
854
|
+
const res = await newService().formatText({
|
|
855
|
+
documentId: 'doc1',
|
|
856
|
+
formats: [{ startIndex: 1, endIndex: 2 }]
|
|
857
|
+
});
|
|
858
|
+
expect(jsonOf(res).error).toMatch(/toLowerCase/);
|
|
859
|
+
expect(mocks.documentsBatchUpdate).not.toHaveBeenCalled();
|
|
860
|
+
});
|
|
861
|
+
});
|
|
862
|
+
describe('replaceText', () => {
|
|
863
|
+
const sentRequests = () => mocks.documentsBatchUpdate.mock.calls[0][0].requestBody.requests;
|
|
864
|
+
const del = (tabId, startIndex, endIndex) => ({
|
|
865
|
+
deleteContentRange: { range: { tabId, startIndex, endIndex } }
|
|
866
|
+
});
|
|
867
|
+
const ins = (tabId, index, text) => ({
|
|
868
|
+
insertText: { location: { tabId, index }, text }
|
|
869
|
+
});
|
|
870
|
+
it('reads the tab content with the tab field mask before replacing', async () => {
|
|
871
|
+
documentsGet.mockResolvedValue({ data: { tabs: [tab('t1', 'One', [para('foo')])] } });
|
|
872
|
+
await newService().replaceText({ documentId: 'doc1', findText: 'foo', replaceText: 'bar' });
|
|
873
|
+
expect(documentsGet).toHaveBeenCalledWith({
|
|
874
|
+
documentId: 'doc1',
|
|
875
|
+
fields: TABS_FIELD_MASK,
|
|
876
|
+
includeTabsContent: true
|
|
877
|
+
});
|
|
878
|
+
});
|
|
879
|
+
it('deletes then inserts at each occurrence and shifts later positions when the replacement is shorter', async () => {
|
|
880
|
+
documentsGet.mockResolvedValue({ data: { tabs: [tab('t1', 'One', [para('foo bar foo')])] } });
|
|
881
|
+
const res = await newService().replaceText({ documentId: 'doc1', findText: 'foo', replaceText: 'ba' });
|
|
882
|
+
expect(mocks.documentsBatchUpdate).toHaveBeenCalledTimes(1);
|
|
883
|
+
expect(mocks.documentsBatchUpdate.mock.calls[0][0].documentId).toBe('doc1');
|
|
884
|
+
expect(sentRequests()).toEqual([del('t1', 1, 4), ins('t1', 1, 'ba'), del('t1', 8, 11), ins('t1', 8, 'ba')]);
|
|
885
|
+
expect(textOf(res)).toBe('Successfully replaced text in document doc1');
|
|
886
|
+
});
|
|
887
|
+
it('shifts later positions forward when the replacement is longer', async () => {
|
|
888
|
+
documentsGet.mockResolvedValue({ data: { tabs: [tab('t1', 'One', [para('a-a')])] } });
|
|
889
|
+
await newService().replaceText({ documentId: 'doc1', findText: 'a', replaceText: 'xyz' });
|
|
890
|
+
expect(sentRequests()).toEqual([del('t1', 1, 2), ins('t1', 1, 'xyz'), del('t1', 5, 6), ins('t1', 5, 'xyz')]);
|
|
891
|
+
});
|
|
892
|
+
it('does not shift positions when the replacement has the same length', async () => {
|
|
893
|
+
documentsGet.mockResolvedValue({ data: { tabs: [tab('t1', 'One', [para('a-a')])] } });
|
|
894
|
+
await newService().replaceText({ documentId: 'doc1', findText: 'a', replaceText: 'b' });
|
|
895
|
+
expect(sentRequests()).toEqual([del('t1', 1, 2), ins('t1', 1, 'b'), del('t1', 3, 4), ins('t1', 3, 'b')]);
|
|
896
|
+
});
|
|
897
|
+
it('does not count overlapping matches twice', async () => {
|
|
898
|
+
documentsGet.mockResolvedValue({ data: { tabs: [tab('t1', 'One', [para('aaaa')])] } });
|
|
899
|
+
await newService().replaceText({ documentId: 'doc1', findText: 'aa', replaceText: 'b' });
|
|
900
|
+
expect(sentRequests()).toEqual([del('t1', 1, 3), ins('t1', 1, 'b'), del('t1', 2, 4), ins('t1', 2, 'b')]);
|
|
901
|
+
});
|
|
902
|
+
it('matches text that spans several runs of a paragraph and text inside tables', async () => {
|
|
903
|
+
documentsGet.mockResolvedValue({
|
|
904
|
+
data: {
|
|
905
|
+
tabs: [
|
|
906
|
+
tab('t1', 'One', [
|
|
907
|
+
para('fo', 'o '),
|
|
908
|
+
{ table: { tableRows: [{ tableCells: [{ content: [para('foo')] }] }] } }
|
|
909
|
+
])
|
|
910
|
+
]
|
|
911
|
+
}
|
|
912
|
+
});
|
|
913
|
+
await newService().replaceText({ documentId: 'doc1', findText: 'foo', replaceText: 'X' });
|
|
914
|
+
expect(sentRequests()).toEqual([del('t1', 1, 4), ins('t1', 1, 'X'), del('t1', 3, 6), ins('t1', 3, 'X')]);
|
|
915
|
+
});
|
|
916
|
+
it('replaces in every tab, nested ones included, each request carrying its own tabId', async () => {
|
|
917
|
+
documentsGet.mockResolvedValue({
|
|
918
|
+
data: {
|
|
919
|
+
tabs: [
|
|
920
|
+
tab('t1', 'One', [para('foo')], [tab('c1', 'Child', [para('x foo')])]),
|
|
921
|
+
tab('t2', 'Two', [para('nothing here')]),
|
|
922
|
+
tab('t3', 'Three')
|
|
923
|
+
]
|
|
924
|
+
}
|
|
925
|
+
});
|
|
926
|
+
await newService().replaceText({ documentId: 'doc1', findText: 'foo', replaceText: 'bar' });
|
|
927
|
+
expect(sentRequests()).toEqual([del('t1', 1, 4), ins('t1', 1, 'bar'), del('c1', 3, 6), ins('c1', 3, 'bar')]);
|
|
928
|
+
});
|
|
929
|
+
it('replaces only in the requested tab', async () => {
|
|
930
|
+
documentsGet.mockResolvedValue({
|
|
931
|
+
data: {
|
|
932
|
+
tabs: [tab('t1', 'One', [para('foo')]), tab('t2', 'Two', [para('foo')], [tab('c2', 'Child', [para('foo')])])]
|
|
933
|
+
}
|
|
934
|
+
});
|
|
935
|
+
await newService().replaceText({ documentId: 'doc1', findText: 'foo', replaceText: 'bar', tabId: 'c2' });
|
|
936
|
+
expect(sentRequests()).toEqual([del('c2', 1, 4), ins('c2', 1, 'bar')]);
|
|
937
|
+
});
|
|
938
|
+
it('returns an error naming the tab when the tabId does not exist, without writing', async () => {
|
|
939
|
+
documentsGet.mockResolvedValue({ data: { tabs: [tab('t1', 'One', [para('foo')])] } });
|
|
940
|
+
const res = await newService().replaceText({
|
|
941
|
+
documentId: 'doc1',
|
|
942
|
+
findText: 'foo',
|
|
943
|
+
replaceText: 'bar',
|
|
944
|
+
tabId: 'nope'
|
|
945
|
+
});
|
|
946
|
+
expect(jsonOf(res)).toEqual({ error: 'Tab with ID nope not found.' });
|
|
947
|
+
expect(mocks.documentsBatchUpdate).not.toHaveBeenCalled();
|
|
948
|
+
});
|
|
949
|
+
it('sends no update and still reports success when nothing matches', async () => {
|
|
950
|
+
documentsGet.mockResolvedValue({ data: { tabs: [tab('t1', 'One', [para('nothing')])] } });
|
|
951
|
+
const res = await newService().replaceText({ documentId: 'doc1', findText: 'foo', replaceText: 'bar' });
|
|
952
|
+
expect(mocks.documentsBatchUpdate).not.toHaveBeenCalled();
|
|
953
|
+
expect(textOf(res)).toBe('Successfully replaced text in document doc1');
|
|
954
|
+
});
|
|
955
|
+
it('sends no update when the requested tab has no body', async () => {
|
|
956
|
+
documentsGet.mockResolvedValue({ data: { tabs: [tab('t1', 'One')] } });
|
|
957
|
+
await newService().replaceText({ documentId: 'doc1', findText: 'foo', replaceText: 'bar', tabId: 't1' });
|
|
958
|
+
expect(mocks.documentsBatchUpdate).not.toHaveBeenCalled();
|
|
959
|
+
});
|
|
960
|
+
it('sends no update when the document has no tabs', async () => {
|
|
961
|
+
documentsGet.mockResolvedValue({ data: {} });
|
|
962
|
+
const res = await newService().replaceText({ documentId: 'doc1', findText: 'foo', replaceText: 'bar' });
|
|
963
|
+
expect(mocks.documentsBatchUpdate).not.toHaveBeenCalled();
|
|
964
|
+
expect(textOf(res)).toBe('Successfully replaced text in document doc1');
|
|
965
|
+
});
|
|
966
|
+
it('extracts the document id from a Docs URL', async () => {
|
|
967
|
+
documentsGet.mockResolvedValue({ data: { tabs: [tab('t1', 'One', [para('foo')])] } });
|
|
968
|
+
const res = await newService().replaceText({
|
|
969
|
+
documentId: 'https://docs.google.com/document/d/Doc-9_x/edit',
|
|
970
|
+
findText: 'foo',
|
|
971
|
+
replaceText: 'bar'
|
|
972
|
+
});
|
|
973
|
+
expect(documentsGet).toHaveBeenCalledWith(expect.objectContaining({ documentId: 'Doc-9_x' }));
|
|
974
|
+
expect(mocks.documentsBatchUpdate).toHaveBeenCalledWith(expect.objectContaining({ documentId: 'Doc-9_x' }));
|
|
975
|
+
expect(textOf(res)).toBe('Successfully replaced text in document Doc-9_x');
|
|
976
|
+
});
|
|
977
|
+
it('builds the request list with a loop, so a very large number of matches does not overflow the stack', async () => {
|
|
978
|
+
const matches = 150_000;
|
|
979
|
+
documentsGet.mockResolvedValue({ data: { tabs: [tab('t1', 'One', [para('a'.repeat(matches))])] } });
|
|
980
|
+
const res = await newService().replaceText({ documentId: 'doc1', findText: 'a', replaceText: 'b' });
|
|
981
|
+
expect(textOf(res)).toBe('Successfully replaced text in document doc1');
|
|
982
|
+
expect(sentRequests()).toHaveLength(matches * 2);
|
|
983
|
+
});
|
|
984
|
+
it('returns the error JSON when reading the document rejects', async () => {
|
|
985
|
+
documentsGet.mockRejectedValue(new Error('Requested entity was not found.'));
|
|
986
|
+
const res = await newService().replaceText({ documentId: 'doc1', findText: 'foo', replaceText: 'bar' });
|
|
987
|
+
expect(jsonOf(res)).toEqual({ error: 'Requested entity was not found.' });
|
|
988
|
+
expect(mocks.documentsBatchUpdate).not.toHaveBeenCalled();
|
|
989
|
+
});
|
|
990
|
+
it('returns the error JSON when the batch update rejects', async () => {
|
|
991
|
+
documentsGet.mockResolvedValue({ data: { tabs: [tab('t1', 'One', [para('foo')])] } });
|
|
992
|
+
mocks.documentsBatchUpdate.mockRejectedValue(new Error('Invalid range'));
|
|
993
|
+
const res = await newService().replaceText({ documentId: 'doc1', findText: 'foo', replaceText: 'bar' });
|
|
994
|
+
expect(jsonOf(res)).toEqual({ error: 'Invalid range' });
|
|
995
|
+
});
|
|
996
|
+
it('stringifies a non-Error rejection into the error JSON', async () => {
|
|
997
|
+
documentsGet.mockRejectedValue('offline');
|
|
998
|
+
const res = await newService().replaceText({ documentId: 'doc1', findText: 'foo', replaceText: 'bar' });
|
|
999
|
+
expect(jsonOf(res)).toEqual({ error: 'offline' });
|
|
1000
|
+
});
|
|
1001
|
+
it('refuses an empty findText before reading the document, since it matches at every index', async () => {
|
|
1002
|
+
documentsGet.mockResolvedValue({ data: { tabs: [tab('t1', 'One', [para('foo')])] } });
|
|
1003
|
+
const res = await newService().replaceText({ documentId: 'doc1', findText: '', replaceText: 'bar' });
|
|
1004
|
+
expect(jsonOf(res)).toEqual({ error: 'findText must not be empty.' });
|
|
1005
|
+
expect(documentsGet).not.toHaveBeenCalled();
|
|
1006
|
+
expect(mocks.documentsBatchUpdate).not.toHaveBeenCalled();
|
|
1007
|
+
});
|
|
1008
|
+
it('still replaces a findText made only of whitespace, which is not empty', async () => {
|
|
1009
|
+
documentsGet.mockResolvedValue({ data: { tabs: [tab('t1', 'One', [para('a b c')])] } });
|
|
1010
|
+
await newService().replaceText({ documentId: 'doc1', findText: ' ', replaceText: '_' });
|
|
1011
|
+
expect(sentRequests()).toEqual([del('t1', 2, 3), ins('t1', 2, '_'), del('t1', 4, 5), ins('t1', 4, '_')]);
|
|
1012
|
+
});
|
|
1013
|
+
});
|
|
1014
|
+
});
|
|
77
1015
|
//# sourceMappingURL=DocsService.test.js.map
|