1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
| import { describe, expect, it } from 'vitest';
|
| import { parsePluginContext } from '../../src/domain/plugin-context';
|
| const valid = {
| apiBaseUrl: 'http://localhost:30000',
| ticket: 'opaque-ticket',
| scope: 'onlyoffice:eln-template-fill',
| documentId: 'file-1',
| bizDataId: 'record-1',
| bizModule: 'eln.template',
| bizScene: 'eln.template.fill',
| pluginVersion: '0.1.0',
| canFill: true,
| };
|
| describe('parsePluginContext', () => {
| it('parses the flattened ONLYOFFICE options', () => {
| expect(parsePluginContext(valid)).toEqual(valid);
| });
|
| it.each([
| { ...valid, ticket: '' },
| { ...valid, scope: 'other' },
| { ...valid, apiBaseUrl: 'javascript:alert(1)' },
| { ...valid, bizScene: 'eln.template.annotate' },
| { ...valid, pluginVersion: '0.2.0' },
| ])('rejects invalid context', (value) => {
| expect(() => parsePluginContext(value)).toThrow('插件运行上下文无效');
| });
| });
|
|