@datagrok/hit-triage 1.10.9 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/.grokignore +2 -0
  2. package/.turbo/turbo-build.log +25 -3
  3. package/CHANGELOG.md +78 -0
  4. package/CLAUDE.md +87 -10
  5. package/README_HD.md +14 -14
  6. package/README_HT.md +6 -6
  7. package/README_PH.md +110 -0
  8. package/bdd/bdd.config.json +3 -1
  9. package/bdd/bindings/campaign.ts +626 -0
  10. package/bdd/bindings/hit-design.ts +36 -42
  11. package/bdd/bindings/landing.ts +839 -0
  12. package/bdd/bindings/pepti-hit.ts +35 -0
  13. package/bdd/features/campaign/crumbs.feature +22 -0
  14. package/bdd/features/campaign/grid.feature +56 -0
  15. package/bdd/features/campaign/merge.feature +105 -0
  16. package/bdd/features/campaign/molecule-vid.feature +40 -0
  17. package/bdd/features/campaign/permissions.feature +46 -0
  18. package/bdd/features/campaign/progress-tracker.feature +89 -0
  19. package/bdd/features/campaign/refresh-hint.feature +33 -0
  20. package/bdd/features/campaign/ribbon.feature +49 -0
  21. package/bdd/features/campaign/stage-choices.feature +39 -0
  22. package/bdd/features/campaign/submit.feature +135 -0
  23. package/bdd/features/campaign/tracker-cards.feature +46 -0
  24. package/bdd/features/campaign/view-only.feature +37 -0
  25. package/bdd/features/landing/campaign-deep-links.feature +61 -0
  26. package/bdd/features/landing/hit-design-campaigns-fixes.feature +116 -0
  27. package/bdd/features/landing/hit-design-campaigns.feature +153 -0
  28. package/bdd/features/landing/hit-triage-campaigns.feature +99 -0
  29. package/bdd/features/landing/new-campaign.feature +69 -0
  30. package/bdd/features/landing/pep-triage-campaigns.feature +41 -0
  31. package/bdd/features/landing/pepti-hit-landing.feature +132 -0
  32. package/bdd/features/pepti-hit/helm-edit.feature +47 -0
  33. package/bdd/features/templates/template-editor.feature +130 -0
  34. package/bdd/features/templates/template-picker.feature +112 -0
  35. package/bdd/features/templates/triage-forms.feature +59 -0
  36. package/bdd/fixtures/bar-chart.layout +1 -0
  37. package/bdd/fixtures/merge-local.csv +2 -0
  38. package/bdd/generated/campaign/crumbs.test.ts +33 -0
  39. package/bdd/generated/campaign/grid.test.ts +79 -0
  40. package/bdd/generated/campaign/merge.test.ts +134 -0
  41. package/bdd/generated/campaign/molecule-vid.test.ts +52 -0
  42. package/bdd/generated/campaign/permissions.test.ts +58 -0
  43. package/bdd/generated/campaign/progress-tracker.test.ts +129 -0
  44. package/bdd/generated/campaign/refresh-hint.test.ts +44 -0
  45. package/bdd/generated/campaign/ribbon.test.ts +65 -0
  46. package/bdd/generated/campaign/stage-choices.test.ts +55 -0
  47. package/bdd/generated/campaign/submit.test.ts +167 -0
  48. package/bdd/generated/campaign/tracker-cards.test.ts +49 -0
  49. package/bdd/generated/campaign/view-only.test.ts +51 -0
  50. package/bdd/generated/hit-design/campaign-column-metadata.test.ts +1 -0
  51. package/bdd/generated/landing/campaign-deep-links.test.ts +68 -0
  52. package/bdd/generated/landing/hit-design-campaigns-fixes.test.ts +99 -0
  53. package/bdd/generated/landing/hit-design-campaigns.test.ts +160 -0
  54. package/bdd/generated/landing/hit-triage-campaigns.test.ts +107 -0
  55. package/bdd/generated/landing/new-campaign.test.ts +78 -0
  56. package/bdd/generated/landing/pep-triage-campaigns.test.ts +52 -0
  57. package/bdd/generated/landing/pepti-hit-landing.test.ts +130 -0
  58. package/bdd/generated/pepti-hit/helm-edit.test.ts +64 -0
  59. package/bdd/generated/templates/template-editor.test.ts +137 -0
  60. package/bdd/generated/templates/template-picker.test.ts +119 -0
  61. package/bdd/generated/templates/triage-forms.test.ts +68 -0
  62. package/css/hit-triage.css +27 -23
  63. package/dist/package-test.js +690 -4
  64. package/dist/package-test.js.map +1 -1
  65. package/dist/package.js +318 -73
  66. package/dist/package.js.map +1 -1
  67. package/package.json +11 -7
  68. package/queries/locks.sql +37 -0
  69. package/src/app/accordeons/layout-input.ts +52 -44
  70. package/src/app/accordeons/new-campaign-accordeon.ts +91 -54
  71. package/src/app/accordeons/new-hit-design-campaign-accordeon.ts +3 -67
  72. package/src/app/accordeons/new-pep-triage-template-accordeon.ts +39 -41
  73. package/src/app/accordeons/new-template-accordeon.ts +41 -24
  74. package/src/app/ai/view-functions.ts +22 -19
  75. package/src/app/base-view.ts +99 -8
  76. package/src/app/consts.ts +8 -5
  77. package/src/app/dialogs/functions-dialog.ts +14 -9
  78. package/src/app/dialogs/merge-table-dialog.ts +181 -325
  79. package/src/app/hit-app-base.ts +61 -90
  80. package/src/app/hit-design-app.ts +481 -886
  81. package/src/app/hit-design-views/info-view.ts +57 -407
  82. package/src/app/hit-design-views/submit-view.ts +216 -111
  83. package/src/app/hit-design-views/tiles-view.ts +168 -123
  84. package/src/app/hit-design-views/utils.css +0 -8
  85. package/src/app/hit-triage-app.ts +69 -38
  86. package/src/app/hit-triage-views/info-view.ts +70 -371
  87. package/src/app/pep-triage-app.ts +2 -2
  88. package/src/app/pep-triage-views/info-view.ts +42 -83
  89. package/src/app/pepti-hit-app.ts +32 -183
  90. package/src/app/pepti-hits-views/info-view.ts +15 -37
  91. package/src/app/shared/campaign-catalog.ts +408 -0
  92. package/src/app/shared/campaign-session.ts +557 -0
  93. package/src/app/shared/compute-editor.ts +274 -0
  94. package/src/app/shared/hit-home.ts +45 -0
  95. package/src/app/shared/new-campaign-form.ts +90 -0
  96. package/src/app/shared/permissions-editor.ts +93 -0
  97. package/src/app/shared/template-editor.ts +331 -0
  98. package/src/app/shared/template-picker.ts +154 -0
  99. package/src/app/utils/merge-table.ts +183 -78
  100. package/src/app/utils.ts +34 -325
  101. package/src/package-api.ts +29 -8
  102. package/src/package-test.ts +17 -2
  103. package/src/package.g.ts +12 -8
  104. package/src/package.ts +19 -7
  105. package/src/tests/ai.ts +244 -0
  106. package/src/tests/campaign-layout.ts +82 -0
  107. package/src/tests/campaign-session.ts +168 -0
  108. package/src/tests/campaigns.ts +23 -0
  109. package/src/tests/catalog.ts +156 -0
  110. package/src/tests/compat.ts +482 -0
  111. package/src/tests/compute.ts +165 -0
  112. package/src/tests/fixtures.ts +359 -0
  113. package/src/tests/merge.ts +149 -0
  114. package/src/tests/owners.ts +11 -0
  115. package/src/tests/save-lock.ts +932 -0
  116. package/src/tests/storage.ts +106 -0
  117. package/src/tests/template-editor.ts +538 -0
  118. package/src/tests/templates.ts +143 -0
  119. package/src/tests/triage-start.ts +81 -0
  120. package/src/tests/u2-guards.ts +384 -0
  121. package/src/tests/vid.ts +77 -0
  122. package/src/app/accordeons/new-hit-design-template-accordeon.ts +0 -238
  123. package/src/app/dialogs/permissions-dialog.ts +0 -66
@@ -0,0 +1,106 @@
1
+ /* eslint-disable max-len */
2
+ import {category, expect, test} from '@datagrok-libraries/test/src/test';
3
+ import {CampaignGrouping, HDCampaignsCollapsedLSKey, HDCampaignsGroupingLSKey, HDCampaignsTableSortingLSKey,
4
+ HDCampaignTableColumnsLSKey, HDDefaultCampaignTableColumns, HTCampaignsCollapsedLSKey, HTCampaignsGroupingLSKey,
5
+ HTCampaignsTableSortingLSKey, HTCampaignTableColumnsLSKey, HTDefaultCampaignTableColumns, HTFunctionOrderingLSKey} from '../app/consts';
6
+ import {getSavedFunctionOrdering, setSavedFunctionOrdering} from '../app/utils';
7
+ import {catalogPersistence} from '../app/shared/campaign-catalog';
8
+ import {expectSame} from './fixtures';
9
+
10
+ /** Runs [body] with [keys] cleared, then puts the viewer's own values back. */
11
+ async function withKeys(keys: string[], body: () => Promise<void> | void): Promise<void> {
12
+ const saved = keys.map((k) => localStorage.getItem(k));
13
+ try {
14
+ for (const k of keys)
15
+ localStorage.removeItem(k);
16
+ await body();
17
+ } finally {
18
+ for (const [i, k] of keys.entries())
19
+ saved[i] === null ? localStorage.removeItem(k) : localStorage.setItem(k, saved[i]!);
20
+ }
21
+ }
22
+
23
+ const HD_KEYS = [HDCampaignsGroupingLSKey, HDCampaignTableColumnsLSKey, HDCampaignsTableSortingLSKey, HDCampaignsCollapsedLSKey];
24
+ const HT_KEYS = [HTCampaignsGroupingLSKey, HTCampaignTableColumnsLSKey, HTCampaignsTableSortingLSKey, HTCampaignsCollapsedLSKey];
25
+ const state = (patch: object) => ({columns: [], sort: '', groupBy: null, collapsed: {}, ...patch});
26
+ const groupKey = (key: string) => `Accordion:Hit-Design-campaigns-group-${key}`;
27
+
28
+ category('Storage', () => {
29
+ test('the grouping keys hold the grouping as plain text', () => withKeys([...HD_KEYS, ...HT_KEYS], () => {
30
+ const hd = catalogPersistence('HD');
31
+ const ht = catalogPersistence('HT');
32
+ expect(hd.load().groupBy, null, 'Hit Design default');
33
+ expect(ht.load().groupBy, null, 'Hit Triage default');
34
+ hd.save(state({groupBy: CampaignGrouping.LastModifiedUser}));
35
+ expect(localStorage.getItem('HDCampaignsGrouping'), 'Last Modified User', 'HDCampaignsGrouping');
36
+ ht.save(state({groupBy: 'campaignFields.Chemist'}));
37
+ expect(localStorage.getItem('HTCampaignsGrouping'), 'campaignFields.Chemist', 'HTCampaignsGrouping');
38
+ localStorage.setItem('HDCampaignsGrouping', 'campaignFields.Target MW');
39
+ expect(hd.load().groupBy, 'campaignFields.Target MW', 'a stored field grouping reads back');
40
+ expect(ht.load().groupBy, 'campaignFields.Chemist', 'the two apps keep separate keys');
41
+ hd.save(state({}));
42
+ expect(localStorage.getItem('HDCampaignsGrouping'), CampaignGrouping.None, 'no grouping is "None"');
43
+ expect(hd.load().groupBy, null, '"None" reads back as no grouping');
44
+ }));
45
+
46
+ test('the column keys hold a JSON list of column names in display order', () => withKeys([...HD_KEYS, ...HT_KEYS], () => {
47
+ const hd = catalogPersistence('HD');
48
+ expectSame(HDDefaultCampaignTableColumns, ['Code', 'Created', 'Author', 'Last Modified by', 'Molecules', 'Status'], 'Hit Design default');
49
+ expectSame(HTDefaultCampaignTableColumns, ['Created', 'Author', 'Total', 'Selected', 'Status'], 'Hit Triage default');
50
+ expect(hd.load().columns === undefined, true, 'nothing kept: the defaults');
51
+ hd.save(state({columns: ['Status', 'Code', 'campaignFields.Chemist']}));
52
+ expect(localStorage.getItem('HDCampaignTableColumns'), '["Status","Code","campaignFields.Chemist"]', 'HDCampaignTableColumns');
53
+ catalogPersistence('HT').save(state({columns: ['Selected', 'Total']}));
54
+ expect(localStorage.getItem('HTCampaignTableColumns'), '["Selected","Total"]', 'HTCampaignTableColumns');
55
+ expectSame(hd.load().columns, ['Status', 'Code', 'campaignFields.Chemist'], 'read back in order');
56
+ for (const bad of ['{not json', '[1,2]', '"Code"', '{"a":1}']) {
57
+ localStorage.setItem('HDCampaignTableColumns', bad);
58
+ expect(hd.load().columns === undefined, true, `${bad} falls back to the default`);
59
+ }
60
+ }));
61
+
62
+ test('the sorting keys hold columnName and ascending, or nothing', () => withKeys([...HD_KEYS, ...HT_KEYS], () => {
63
+ const hd = catalogPersistence('HD');
64
+ const ht = catalogPersistence('HT');
65
+ expect(hd.load().sort, '', 'Hit Design default');
66
+ expect(ht.load().sort, '', 'Hit Triage default');
67
+ hd.save(state({sort: '!Created'}));
68
+ expect(localStorage.getItem('HDCampaignsTableSorting'), '{"columnName":"Created","ascending":false}', 'HDCampaignsTableSorting');
69
+ localStorage.setItem('HTCampaignsTableSorting', '{"columnName":"campaignFields.Chemist","ascending":true}');
70
+ expect(ht.load().sort, 'campaignFields.Chemist', 'HTCampaignsTableSorting read back');
71
+ hd.save(state({sort: ''}));
72
+ expect(localStorage.getItem('HDCampaignsTableSorting'), null, 'no sorting removes the key');
73
+ }));
74
+
75
+ test('a save writes only the choice that changed: the default columns are not frozen', () => withKeys(HD_KEYS, () => {
76
+ const hd = catalogPersistence('HD');
77
+ hd.load();
78
+ hd.save(state({columns: HDDefaultCampaignTableColumns, sort: '!Created'}));
79
+ expect(localStorage.getItem('HDCampaignsTableSorting'), '{"columnName":"Created","ascending":false}', 'the sort chosen is kept');
80
+ expect(localStorage.getItem('HDCampaignTableColumns'), null, 'the default columns are not written');
81
+ expect(localStorage.getItem('HDCampaignsGrouping'), null, 'nor the grouping nobody chose');
82
+ expect(localStorage.getItem(HDCampaignsCollapsedLSKey), null, 'nor the folds');
83
+ }));
84
+
85
+ test('the compute tab order key holds order and hidden lists', () => withKeys([HTFunctionOrderingLSKey], () => {
86
+ expectSame(getSavedFunctionOrdering(), {order: [], hidden: []}, 'default');
87
+ setSavedFunctionOrdering({order: ['Chem:addChemPropertiesColumns', 'descriptors'], hidden: ['Chembl:chemblMolregno']});
88
+ expectSame(JSON.parse(localStorage.getItem('HTFunctionOrderingLS')!),
89
+ {order: ['Chem:addChemPropertiesColumns', 'descriptors'], hidden: ['Chembl:chemblMolregno']}, 'HTFunctionOrderingLS');
90
+ localStorage.setItem('HTFunctionOrderingLS', '{"order":["a"]}');
91
+ expectSame(getSavedFunctionOrdering(), {order: ['a'], hidden: []}, 'a partial value reads with an empty hidden list');
92
+ }));
93
+
94
+ test('folded groups are kept per grouping; the accordion\'s own folds are read once', () =>
95
+ withKeys([...HD_KEYS, ...Object.keys(localStorage).filter((k) => k.startsWith(groupKey(''))), groupKey('ZZB3 A'),
96
+ groupKey('ZZB3 B')], () => {
97
+ const hd = catalogPersistence('HD');
98
+ localStorage.setItem('HDCampaignsGrouping', CampaignGrouping.Status);
99
+ localStorage.setItem(groupKey('ZZB3 A'), '{"ZZB3 A":false}');
100
+ localStorage.setItem(groupKey('ZZB3 B'), '{"ZZB3 B":true}');
101
+ expectSame(hd.load().collapsed, {Status: ['ZZB3 A']}, 'only a group the accordion kept closed starts folded');
102
+ hd.save(state({groupBy: CampaignGrouping.Status, collapsed: {Status: ['ZZB3 B'], Template: ['KHL']}}));
103
+ expect(localStorage.getItem(HDCampaignsCollapsedLSKey), '{"Status":["ZZB3 B"],"Template":["KHL"]}', 'HDCampaignsCollapsed');
104
+ expectSame(hd.load().collapsed, {Status: ['ZZB3 B'], Template: ['KHL']}, 'kept folds win over the accordion\'s');
105
+ }));
106
+ });
@@ -0,0 +1,538 @@
1
+ /* eslint-disable max-len */
2
+ import * as grok from 'datagrok-api/grok';
3
+ import * as DG from 'datagrok-api/dg';
4
+ import {category, expect, test, waitUntil} from '@datagrok-libraries/test/src/test';
5
+ import {_package} from '../package';
6
+ import {loadTemplate} from '../app/utils';
7
+ import {openTemplateEditor} from '../app/shared/template-editor';
8
+ import {createTemplateAccordeon} from '../app/accordeons/new-template-accordeon';
9
+ import {createPepTriageTemplateAccordeon} from '../app/accordeons/new-pep-triage-template-accordeon';
10
+ import {HitAppBase} from '../app/hit-app-base';
11
+ import {HitDesignTemplate, IComputeDialogResult, TemplateCompute} from '../app/types';
12
+ import {ComputeEditorOptions, computeEditor, templateCompute} from '../app/shared/compute-editor';
13
+ import {chemFunctionsDialog, descriptorsTree, rerunOnOpenOption} from '../app/dialogs/functions-dialog';
14
+ import {HTFunctionOrderingLSKey} from '../app/consts';
15
+ import {expectSame, noComputeTemplate, pepTriageTemplate, Sandbox, triageTemplate} from './fixtures';
16
+ import {onRoot} from './owners';
17
+
18
+ /** A name the server refuses as a file name (a NUL in it: 400, on any storage): the write fails, as a full disk or a
19
+ * lost connection would make it. */
20
+ const unwritable = (app: string) => `ZZB3 ${app} \u0000`;
21
+ const saveFailed = (app: string) => `Could not save template ZZB3 ${app}`;
22
+
23
+ const openViews = () => Array.from(grok.shell.views).map((v) => v.name);
24
+
25
+ const computeEditorOnRoot = (options: ComputeEditorOptions) => onRoot('compute editor test', () => computeEditor(options));
26
+
27
+ /** A compute function, script and query found by name; a stand without one fails the test rather than checks less. */
28
+ function required<T>(found: T | undefined, what: string): T {
29
+ if (found === undefined)
30
+ throw new Error(`the stand has no ${what}`);
31
+ return found;
32
+ }
33
+
34
+ interface OpenEditor<T> {
35
+ root: HTMLElement;
36
+ /** What the editor handed to the landing after writing it. */
37
+ created: Promise<T>;
38
+ /** Whether it did. */
39
+ isCreated: () => boolean;
40
+ }
41
+
42
+ /** The Hit Design editor opened as the template picker opens it, once its Compute section has its descriptors. */
43
+ async function openEditor<T extends HitDesignTemplate>(app: HitAppBase<unknown>, preset?: T): Promise<OpenEditor<T>> {
44
+ let created!: (t: T) => void;
45
+ let isCreated = false;
46
+ const done = new Promise<T>((resolve) => created = resolve);
47
+ await openTemplateEditor<T>({app, preset, onCreated: (t) => {
48
+ isCreated = true;
49
+ created(t);
50
+ }});
51
+ await waitUntil(() => grok.shell.v?.name === 'New Template', 'the template editor did not open', 15000);
52
+ const root = grok.shell.v.root.querySelector<HTMLElement>('[data-u2-name="template-editor"]')!;
53
+ await waitUntil(() => root.querySelector('.hit-triage-compute-descriptors .u2-tree:not([hidden])') !== null,
54
+ 'the Compute section never listed the descriptors', 30000);
55
+ return {root, created: done, isCreated: () => isCreated};
56
+ }
57
+
58
+ function typeInto(input: HTMLInputElement, text: string): void {
59
+ input.value = text;
60
+ input.dispatchEvent(new Event('input', {bubbles: true}));
61
+ }
62
+
63
+ const editorInput = (root: HTMLElement, name: string) => root.querySelector<HTMLInputElement>(`[data-u2-name="${name}"] input`)!;
64
+ const createButton = (root: HTMLElement) => Array.from(root.querySelectorAll<HTMLButtonElement>('button'))
65
+ .find((b) => b.textContent?.trim().toLowerCase() === 'create')!;
66
+ const disabled = (button: HTMLButtonElement) => button.getAttribute('aria-disabled') === 'true' || button.classList.contains('d4-disabled');
67
+ const balloonShown = (text: string) => Array.from(document.querySelectorAll('.d4-balloon')).some((b) => b.textContent?.includes(text));
68
+
69
+ async function closeEditor(): Promise<void> {
70
+ if (grok.shell.v?.name === 'New Template')
71
+ grok.shell.v.close();
72
+ }
73
+
74
+ /** An input of the Hit Triage / PepTriage editor by its caption, set as typing sets it. */
75
+ function typeTriage(root: HTMLElement, caption: string, text: string): void {
76
+ typeInto(root.querySelector<HTMLInputElement>(`[name="input-host-${caption}"] input, ` +
77
+ `[name="input-host-${caption.replace(/ /g, '-')}"] input`)!, text);
78
+ }
79
+
80
+ /** The Hit Triage editor reads and writes the app's own folder, not a sandbox's: what a test puts there goes after it. */
81
+ const TRIAGE_TEMPLATES = 'Hit Triage/templates';
82
+
83
+ async function removeTriageTemplate(name: string): Promise<void> {
84
+ const path = `${TRIAGE_TEMPLATES}/${name}.json`;
85
+ if (await _package.files.exists(path).catch(() => false))
86
+ await _package.files.delete(path);
87
+ }
88
+
89
+ category('Template editor', () => {
90
+ test('Hit Design: a clone proposes a free name and key and keeps the fields, stages, compute, submit function and layout', async () => {
91
+ const sb = await Sandbox.create('editor');
92
+ try {
93
+ const viewState = DG.ViewLayout.fromJson(await _package.files.readAsText('Hit Design/HD-template-layout.layout')).viewState;
94
+ const script = required(DG.Func.find({package: 'ApiSamples', name: 'Pearson'})[0] as DG.Script | undefined,
95
+ 'script ApiSamples:Pearson (a table and a column, as compute scripts take them)');
96
+ const query = required(DG.Func.find({package: 'Chembl', name: 'NamesToSmiles'})[0] as DG.DataQuery | undefined,
97
+ 'query Chembl:NamesToSmiles (a list first, as compute queries take it)');
98
+ const t: HitDesignTemplate = {...noComputeTemplate('ZZB3 Source', 'ZZB3'), layoutViewState: viewState,
99
+ compute: {descriptors: {enabled: true, args: ['MolWt']}, functions: [],
100
+ scripts: [{name: script.name, id: script.id, args: {}, rerunOnOpen: true}],
101
+ queries: [{name: query.name, id: query.id, args: {}}]}};
102
+ await sb.writeTemplate(t);
103
+ const app = await sb.hitDesign();
104
+ // the stand tags no script or query as a compute function: the app is told of these two
105
+ app.computeFunctions.scripts.push(script);
106
+ app.computeFunctions.queries.push(query);
107
+ const editor = await openEditor(app, t);
108
+ expect(editorInput(editor.root, 'name').value, 'ZZB3 Source (copy)', 'the proposed name');
109
+ expect(editorInput(editor.root, 'key').value, 'ZZB4', 'the proposed key');
110
+ expect(editor.root.querySelector<HTMLSelectElement>('[data-u2-name="submit-function"] select')!.selectedOptions[0]?.textContent,
111
+ 'Demo File Submit', 'the submit function, by its friendly name');
112
+ expect(editorInput(editor.root, 'layout').value, 'ZZB3 Source.layout', 'the layout, shown by its file name');
113
+ await waitUntil(() => !disabled(createButton(editor.root)), 'CREATE stayed disabled for the clone', 10000);
114
+ createButton(editor.root).click();
115
+ const saved = await editor.created;
116
+ const expected = {...t, name: 'ZZB3 Source (copy)', key: 'ZZB4',
117
+ campaignFields: t.campaignFields.map((f) => ({...f, required: !!f.required}))};
118
+ // the arguments of a script or a query are what their forms hold, every input past the molecules
119
+ const withoutArgs = (x: HitDesignTemplate) => ({...x, compute: {...x.compute,
120
+ scripts: x.compute.scripts?.map((s) => ({...s, args: null})),
121
+ queries: x.compute.queries?.map((q) => ({...q, args: null}))}});
122
+ const expectedCompute = {...expected.compute, scripts: [{...t.compute.scripts![0]}], queries: [{...t.compute.queries![0], rerunOnOpen: false}]};
123
+ expectSame(withoutArgs(saved), withoutArgs({...expected, compute: expectedCompute}), 'the clone, its script and query included');
124
+ expectSame(withoutArgs(await loadTemplate(`${sb.appName}/templates/ZZB3 Source (copy).json`)),
125
+ withoutArgs({...expected, compute: expectedCompute}), 'the clone on the share');
126
+ expectSame(Object.keys(saved), ['name', 'key', 'campaignFields', 'stages', 'layoutViewState', 'compute', 'submit'],
127
+ 'the keys, in the order the editor has always written them');
128
+ } finally {
129
+ await closeEditor();
130
+ await sb.dispose();
131
+ }
132
+ }, {timeout: 120000});
133
+
134
+ test('Hit Design: a clone of a template whose layout is a file on a share keeps that file\'s path', async () => {
135
+ const sb = await Sandbox.create('editor');
136
+ try {
137
+ const json = await _package.files.readAsText('Hit Design/HD-template-layout.layout');
138
+ await _package.files.writeAsText(`${sb.appName}/layouts/zz.layout`, json);
139
+ const share = `System:AppData/HitTriage/${sb.appName}/layouts/zz.layout`;
140
+ const t: HitDesignTemplate = {...noComputeTemplate('ZZB3 Shared Layout', 'ZZBS'),
141
+ layoutViewState: DG.ViewLayout.fromJson(json).viewState, localLayoutPath: share};
142
+ await sb.writeTemplate(t);
143
+ const app = await sb.hitDesign();
144
+ const editor = await openEditor(app, t);
145
+ expect(editorInput(editor.root, 'layout').value.endsWith('zz.layout'), true, 'the layout, shown by its file');
146
+ await waitUntil(() => !disabled(createButton(editor.root)), 'CREATE stayed disabled for the clone', 10000);
147
+ createButton(editor.root).click();
148
+ const saved = await editor.created;
149
+ expect(saved.localLayoutPath, share, 'the share path, re-read by "Apply template layout"');
150
+ expect(saved.layoutViewState, t.layoutViewState, 'the layout');
151
+ } finally {
152
+ await closeEditor();
153
+ await sb.dispose();
154
+ }
155
+ }, {timeout: 120000});
156
+
157
+ test('Hit Design: the crumb back to the landing closes the editor, and asks first once something was typed', async () => {
158
+ const sb = await Sandbox.create('editor');
159
+ try {
160
+ const app = await sb.hitDesign();
161
+ const discard = () => document.querySelector<HTMLElement>('[data-u2-name="discard-template"]');
162
+ const press = (caption: string) => Array.from(discard()!.querySelectorAll<HTMLButtonElement>('button'))
163
+ .find((b) => b.textContent?.trim().toLowerCase() === caption)!.click();
164
+ await openEditor(app);
165
+ grok.shell.v = app.multiView;
166
+ await waitUntil(() => !openViews().includes('New Template'), 'the untouched editor stayed open', 10000);
167
+ expect(discard(), null, 'a question about an untouched editor');
168
+
169
+ const editor = await openEditor(app);
170
+ typeInto(editorInput(editor.root, 'name'), 'ZZB3 Typed');
171
+ grok.shell.v = app.multiView;
172
+ await waitUntil(() => discard() !== null, 'nothing asked before the typed name went', 10000);
173
+ press('cancel');
174
+ await waitUntil(() => grok.shell.v?.name === 'New Template', 'CANCEL did not bring the editor back', 10000);
175
+ expect(editorInput(editor.root, 'name').value, 'ZZB3 Typed', 'the typed name, kept');
176
+ grok.shell.v = app.multiView;
177
+ await waitUntil(() => discard() !== null, 'nothing asked the second time', 10000);
178
+ press('discard');
179
+ await waitUntil(() => !openViews().includes('New Template'), 'DISCARD left the editor open', 10000);
180
+ expect(grok.shell.v?.name, app.multiView.name, 'the landing, current');
181
+ } finally {
182
+ await closeEditor();
183
+ await sb.dispose();
184
+ }
185
+ }, {timeout: 120000});
186
+
187
+ test('Hit Design: with no template at all, the landing\'s editor creates the first one and offers it', async () => {
188
+ const sb = await Sandbox.create('editor');
189
+ try {
190
+ const app = await sb.hitDesign();
191
+ const picker = () => app.infoView.root.querySelector<HTMLElement>('[data-u2-name="template-picker"]');
192
+ const offer = Array.from(picker()?.querySelectorAll<HTMLButtonElement>('[data-u2="empty-state"] button') ?? [])
193
+ .find((b) => b.textContent?.trim() === 'Create template');
194
+ expect(offer !== undefined, true, 'the picker\'s Create template');
195
+ offer!.click();
196
+ await waitUntil(() => grok.shell.v?.name === 'New Template', 'the template editor did not open', 15000);
197
+ const root = grok.shell.v.root.querySelector<HTMLElement>('[data-u2-name="template-editor"]')!;
198
+ typeInto(editorInput(root, 'name'), 'ZZB3 First');
199
+ typeInto(editorInput(root, 'key'), 'ZZBF');
200
+ await waitUntil(() => !disabled(createButton(root)), 'CREATE stayed disabled', 30000);
201
+ createButton(root).click();
202
+ await waitUntil(() => grok.shell.v?.name !== 'New Template' &&
203
+ picker()?.querySelector<HTMLSelectElement>('select')?.value === 'ZZB3 First', 'the landing never offered the first template', 15000);
204
+ expect((await loadTemplate<HitDesignTemplate>(`${sb.appName}/templates/ZZB3 First.json`)).key, 'ZZBF', 'the key on the share');
205
+ } finally {
206
+ await closeEditor();
207
+ await sb.dispose();
208
+ }
209
+ }, {timeout: 120000});
210
+
211
+ test('Hit Design: CREATE is disabled while the name or the key is empty or taken', async () => {
212
+ const sb = await Sandbox.create('editor');
213
+ try {
214
+ await sb.writeTemplate(noComputeTemplate('ZZB3 Taken', 'ZZBT'));
215
+ const app = await sb.hitDesign();
216
+ const {root} = await openEditor(app);
217
+ expect(disabled(createButton(root)), true, 'CREATE with nothing filled in');
218
+ typeInto(editorInput(root, 'name'), ' ');
219
+ typeInto(editorInput(root, 'key'), 'ZZBF');
220
+ await waitUntil(() => disabled(createButton(root)), 'CREATE enabled for a name of spaces', 5000);
221
+ typeInto(editorInput(root, 'name'), 'ZZB3 Free');
222
+ typeInto(editorInput(root, 'key'), ' ');
223
+ await waitUntil(() => disabled(createButton(root)), 'CREATE enabled for a key of spaces', 5000);
224
+ typeInto(editorInput(root, 'key'), 'ZZBF');
225
+ typeInto(editorInput(root, 'name'), 'zzb3 taken ');
226
+ await waitUntil(() => disabled(createButton(root)), 'CREATE enabled for a taken name (another case, a space after)', 5000);
227
+ typeInto(editorInput(root, 'name'), 'ZZB3 Free');
228
+ await waitUntil(() => !disabled(createButton(root)), 'CREATE stayed disabled with a free name and key', 5000);
229
+ typeInto(editorInput(root, 'key'), 'zzbt');
230
+ await waitUntil(() => disabled(createButton(root)), 'CREATE enabled for a taken key', 5000);
231
+ } finally {
232
+ await closeEditor();
233
+ await sb.dispose();
234
+ }
235
+ }, {timeout: 120000});
236
+
237
+ test('Hit Design: a name or a key another session took meanwhile is refused, nothing overwritten or duplicated', async () => {
238
+ const sb = await Sandbox.create('editor');
239
+ try {
240
+ const app = await sb.hitDesign();
241
+ const editor = await openEditor(app);
242
+ typeInto(editorInput(editor.root, 'name'), 'ZZB3 Late');
243
+ typeInto(editorInput(editor.root, 'key'), 'ZZBL');
244
+ await waitUntil(() => !disabled(createButton(editor.root)), 'CREATE stayed disabled', 5000);
245
+ const other = noComputeTemplate('ZZB3 Late', 'ZZBO');
246
+ await sb.writeTemplate(other);
247
+ createButton(editor.root).click();
248
+ await waitUntil(() => disabled(createButton(editor.root)) && editor.root.querySelector('[data-u2-name="name"] [data-u2-part="error"]')
249
+ ?.textContent === 'A template with this name already exists', 'the name was not refused', 10000);
250
+ expect(editor.isCreated(), false, 'the editor reported a template created');
251
+ expect(grok.shell.v.name, 'New Template', 'the view after CREATE');
252
+ expectSame(await loadTemplate(`${sb.appName}/templates/ZZB3 Late.json`), other, 'the other session\'s template');
253
+
254
+ typeInto(editorInput(editor.root, 'name'), 'ZZB3 Later');
255
+ await waitUntil(() => !disabled(createButton(editor.root)), 'CREATE stayed disabled with a free name', 5000);
256
+ await sb.writeTemplate(noComputeTemplate('ZZB3 Other', 'ZZBL'));
257
+ createButton(editor.root).click();
258
+ await waitUntil(() => disabled(createButton(editor.root)) && editor.root.querySelector('[data-u2-name="key"] [data-u2-part="error"]')
259
+ ?.textContent === 'ZZBL is used by ZZB3 Other', 'the key was not refused', 10000);
260
+ expect(editor.isCreated(), false, 'the editor reported a template created');
261
+ expect(await _package.files.exists(`${sb.appName}/templates/ZZB3 Later.json`), false, 'a second template with the key');
262
+ } finally {
263
+ await closeEditor();
264
+ await sb.dispose();
265
+ }
266
+ }, {timeout: 120000});
267
+
268
+ test('Hit Design: a template the share refuses keeps the editor open and says why', async () => {
269
+ const sb = await Sandbox.create('editor');
270
+ try {
271
+ const app = await sb.hitDesign();
272
+ const editor = await openEditor(app);
273
+ typeInto(editorInput(editor.root, 'name'), unwritable('design'));
274
+ typeInto(editorInput(editor.root, 'key'), 'ZZBU');
275
+ await waitUntil(() => !disabled(createButton(editor.root)), 'CREATE stayed disabled', 5000);
276
+ DG.Balloon.closeAll();
277
+ createButton(editor.root).click();
278
+ await waitUntil(() => balloonShown(saveFailed('design')), 'no balloon said the save failed', 15000);
279
+ expect(editor.isCreated(), false, 'the editor reported a template created');
280
+ expect(balloonShown('Template created successfully'), false, 'a success balloon');
281
+ expect(grok.shell.v.name, 'New Template', 'the view after the failed save');
282
+ await waitUntil(() => !disabled(createButton(editor.root)), 'CREATE stayed busy after the failure', 5000);
283
+ } finally {
284
+ await closeEditor();
285
+ await sb.dispose();
286
+ }
287
+ }, {timeout: 120000});
288
+
289
+ test('Compute: the editor reads a template\'s compute back as the compute dialog does', async () => {
290
+ const sb = await Sandbox.create('editor');
291
+ try {
292
+ const app = await sb.hitDesign();
293
+ const toxicity = required(app.computeFunctions.functions.find((f) => f.name === 'addChemRisksColumns'),
294
+ 'compute function Chem:addChemRisksColumns (Toxicity Risks)');
295
+ const compute: TemplateCompute = {descriptors: {enabled: true, args: ['MolWt', 'NumHDonors']},
296
+ functions: [{name: toxicity.name, package: toxicity.package.name,
297
+ args: {mutagenicity: false, tumorigenicity: true}, rerunOnOpen: true}], scripts: [], queries: []};
298
+ let answered: IComputeDialogResult | undefined;
299
+ const dialog = await chemFunctionsDialog(app, (r) => answered = r, () => {}, {compute}, false, true);
300
+ await waitUntil(() => dialog.root.querySelector('.statistics-compute-dialog-descriptors-group') !== null,
301
+ 'the compute dialog never listed the descriptors', 30000);
302
+ dialog.okProxy();
303
+ const editor = computeEditorOnRoot({functions: app.computeFunctions, value: compute, descriptors: descriptorsTree,
304
+ orderKey: HTFunctionOrderingLSKey, rerunOnOpen: rerunOnOpenOption});
305
+ try {
306
+ await editor.ready;
307
+ expectSame(editor.read(), templateCompute(answered!), 'the editor\'s compute against the dialog\'s');
308
+ expectSame(editor.read().descriptors, compute.descriptors, 'the descriptors');
309
+ } finally {
310
+ editor.dispose();
311
+ }
312
+ } finally {
313
+ await sb.dispose();
314
+ }
315
+ }, {timeout: 120000});
316
+
317
+ test('Compute: a descriptor picked in the tree turns the descriptors on, and its group counts it', async () => {
318
+ const sb = await Sandbox.create('editor');
319
+ const host = document.body.appendChild(document.createElement('div'));
320
+ host.style.cssText = 'position: fixed; left: 0; top: 0; width: 900px; height: 400px; z-index: 10000; background: white';
321
+ try {
322
+ const app = await sb.hitDesign();
323
+ const editor = computeEditorOnRoot({functions: app.computeFunctions, descriptors: descriptorsTree,
324
+ orderKey: HTFunctionOrderingLSKey, value: {descriptors: {enabled: false, args: []}, functions: []}});
325
+ host.append(editor.root);
326
+ try {
327
+ await editor.ready;
328
+ typeInto(editor.root.querySelector<HTMLInputElement>('[data-u2-name="descriptor-search"] input')!, 'MolWt');
329
+ const molWt = () => Array.from(editor.root.querySelectorAll<HTMLElement>('.u2-tree-row'))
330
+ .find((r) => r.querySelector('.u2-tree-label')?.textContent === 'MolWt');
331
+ await waitUntil(() => molWt() !== undefined, 'the search never showed MolWt', 10000);
332
+ molWt()!.querySelector<HTMLElement>('.u2-tree-check')!.click();
333
+ await waitUntil(() => editor.read().descriptors.args.includes('MolWt'), 'MolWt was not picked', 5000);
334
+ expect(editor.read().descriptors.enabled, true, 'the descriptors calculated');
335
+ // the rows are flat: MolWt's group is the last group row above it, its shown descriptors the rows down to the next
336
+ const label = (r: HTMLElement) => r.querySelector('.u2-tree-label')?.textContent ?? '';
337
+ const isGroup = (r: HTMLElement) => / · \d+ of \d+$/.test(label(r));
338
+ const rows = Array.from(editor.root.querySelectorAll<HTMLElement>('.u2-tree-row'));
339
+ const groupAt = rows.slice(0, rows.indexOf(molWt()!)).map(isGroup).lastIndexOf(true);
340
+ const next = rows.findIndex((r, i) => i > groupAt && isGroup(r));
341
+ const shown = rows.slice(groupAt + 1, next < 0 ? rows.length : next).map(label);
342
+ const groupName = label(rows[groupAt]).split(' · ')[0];
343
+ const groupRow = () => Array.from(editor.root.querySelectorAll<HTMLElement>('.u2-tree-row'))
344
+ .find((r) => label(r).startsWith(`${groupName} · `));
345
+ await waitUntil(() => / · 1 of \d+$/.test(label(groupRow()!)), 'the group label did not count the pick', 5000);
346
+ groupRow()!.querySelector<HTMLElement>('.u2-tree-check')!.click();
347
+ await waitUntil(() => editor.read().descriptors.args.length === 0, 'the group\'s checkbox did not drop its pick', 5000);
348
+ groupRow()!.querySelector<HTMLElement>('.u2-tree-check')!.click();
349
+ await waitUntil(() => editor.read().descriptors.args.length > 0, 'the group\'s checkbox picked nothing', 5000);
350
+ expectSame([...editor.read().descriptors.args].sort(), [...shown].sort(),
351
+ 'a group picks the descriptors the search shows, not all of its own');
352
+ } finally {
353
+ editor.dispose();
354
+ }
355
+ } finally {
356
+ host.remove();
357
+ await sb.dispose();
358
+ }
359
+ }, {timeout: 120000});
360
+
361
+ test('Compute: without descriptors to pick from there is no Descriptors row, and the descriptors stay as given', async () => {
362
+ const sb = await Sandbox.create('editor');
363
+ try {
364
+ const app = await sb.hitDesign();
365
+ const given = {enabled: true, args: ['MolWt']};
366
+ const editor = computeEditorOnRoot({functions: app.computeFunctions, orderKey: HTFunctionOrderingLSKey,
367
+ value: {descriptors: given, functions: []}});
368
+ try {
369
+ await editor.ready;
370
+ const rows = Array.from(editor.root.querySelectorAll('[role="option"]')).map((r) => r.textContent);
371
+ expect(rows.includes('Descriptors'), false, `a Descriptors row among ${rows.join(', ')}`);
372
+ expect(rows.length > 0, true, 'the functions listed');
373
+ expectSame(editor.read().descriptors, given, 'the descriptors');
374
+ } finally {
375
+ editor.dispose();
376
+ }
377
+ } finally {
378
+ await sb.dispose();
379
+ }
380
+ }, {timeout: 120000});
381
+
382
+ test('Compute: the list is named "Functions", and a function\'s check says what it toggles', async () => {
383
+ const sb = await Sandbox.create('editor');
384
+ try {
385
+ const app = await sb.hitDesign();
386
+ const editor = computeEditorOnRoot({functions: app.computeFunctions, orderKey: HTFunctionOrderingLSKey,
387
+ value: noComputeTemplate('ZZB3 Named', 'ZZB3').compute});
388
+ document.body.append(editor.root);
389
+ try {
390
+ expect(editor.root.querySelector('[role="listbox"]')?.getAttribute('aria-label'), 'Functions', 'the list\'s name');
391
+ const box = editor.root.querySelector('[role="option"] input[type="checkbox"]');
392
+ expect(box != null, true, 'a function\'s check');
393
+ box!.dispatchEvent(new PointerEvent('pointerenter'));
394
+ const tip = 'Toggle calculation of this function';
395
+ await waitUntil(() => Array.from(document.querySelectorAll('[role="tooltip"]')).some((t) => t.textContent === tip),
396
+ `the check's tooltip is not "${tip}"`, 5000);
397
+ box!.dispatchEvent(new PointerEvent('pointerleave'));
398
+ } finally {
399
+ editor.root.remove();
400
+ editor.dispose();
401
+ }
402
+ } finally {
403
+ await sb.dispose();
404
+ }
405
+ }, {timeout: 120000});
406
+
407
+ test('Compute: a function hidden by "Reorder…" is not calculated, as in the compute dialog', async () => {
408
+ const sb = await Sandbox.create('editor');
409
+ const orderKey = `ZZB3 order ${DG.Utils.randomString(6)}`;
410
+ try {
411
+ const app = await sb.hitDesign();
412
+ const f = app.computeFunctions.functions.find((f) => f.inputs.length >= 2 && f.inputs[0].propertyType === 'dataframe');
413
+ if (!f)
414
+ throw new Error('the stand has no compute function');
415
+ localStorage.setItem(orderKey, JSON.stringify({order: [], hidden: [f.friendlyName ?? f.name]}));
416
+ const compute: TemplateCompute = {descriptors: {enabled: false, args: []}, scripts: [], queries: [],
417
+ functions: [{name: f.name, package: f.package.name, args: {}}]};
418
+ const editor = computeEditorOnRoot({functions: app.computeFunctions, value: compute, descriptors: descriptorsTree,
419
+ orderKey});
420
+ try {
421
+ await editor.ready;
422
+ expectSame(editor.read().functions, [], 'the functions calculated');
423
+ } finally {
424
+ editor.dispose();
425
+ }
426
+ } finally {
427
+ localStorage.removeItem(orderKey);
428
+ await sb.dispose();
429
+ }
430
+ }, {timeout: 120000});
431
+
432
+ test('Hit Triage: CREATE is disabled while the name or the key is empty or taken', async () => {
433
+ const sb = await Sandbox.create('editor');
434
+ const taken = triageTemplate(`ZZB3 Taken ${DG.Utils.randomString(6)}`, `ZZBT${DG.Utils.randomString(6)}`);
435
+ try {
436
+ await _package.files.writeAsText(`${TRIAGE_TEMPLATES}/${taken.name}.json`, JSON.stringify(taken));
437
+ const app = await sb.hitTriage();
438
+ const editor = await createTemplateAccordeon(app, {});
439
+ const create = createButton(editor.root);
440
+ expect(disabled(create), true, 'CREATE with nothing filled in');
441
+ typeTriage(editor.root, 'Name', taken.name);
442
+ typeTriage(editor.root, 'Key', 'ZZBF');
443
+ expect(disabled(create), true, 'CREATE with a taken name');
444
+ typeTriage(editor.root, 'Name', 'ZZB3 Free');
445
+ expect(disabled(create), false, 'CREATE with a free name and key');
446
+ typeTriage(editor.root, 'Key', taken.key);
447
+ expect(disabled(create), true, 'CREATE with a taken key');
448
+ } finally {
449
+ await removeTriageTemplate(taken.name);
450
+ await sb.dispose();
451
+ }
452
+ }, {timeout: 120000});
453
+
454
+ test('Hit Triage, PepTriage: a clone proposes the key\'s next free number, as Hit Design does (KHL, KHL2 taken → KHL3)', async () => {
455
+ const sb = await Sandbox.create('editor');
456
+ const tag = DG.Utils.randomString(6);
457
+ const key = `ZZK${tag}K`;
458
+ const triage = [triageTemplate(`ZZB3 Clone ${tag}`, key), triageTemplate(`ZZB3 Clone ${tag} 2`, `${key}2`)];
459
+ const keyOf = (root: HTMLElement) => root.querySelector<HTMLInputElement>('[name="input-host-Key"] input')!.value;
460
+ try {
461
+ for (const t of triage)
462
+ await _package.files.writeAsText(`${TRIAGE_TEMPLATES}/${t.name}.json`, JSON.stringify(t));
463
+ const ht = await createTemplateAccordeon(await sb.hitTriage(), {}, triage[0]);
464
+ expect(keyOf(ht.root), `${key}3`, 'the Hit Triage clone\'s key');
465
+
466
+ const peptides = [pepTriageTemplate(`ZZB3 Peptides ${tag}`, key), pepTriageTemplate(`ZZB3 Peptides ${tag} 2`, `${key}2`)];
467
+ for (const t of peptides)
468
+ await sb.writeTemplate(t);
469
+ const pt = await createPepTriageTemplateAccordeon(await sb.pepTriage(), {}, peptides[0]);
470
+ expect(keyOf(pt.root), `${key}3`, 'the PepTriage clone\'s key');
471
+ } finally {
472
+ for (const t of triage)
473
+ await removeTriageTemplate(t.name);
474
+ await sb.dispose();
475
+ }
476
+ }, {timeout: 150000});
477
+
478
+ test('Hit Triage, PepTriage: a clone proposes a name no template has, as Hit Design does ("(copy)" taken → "(copy 2)")', async () => {
479
+ const sb = await Sandbox.create('editor');
480
+ const tag = DG.Utils.randomString(6);
481
+ const name = `ZZB3 Copy ${tag}`;
482
+ const triage = [triageTemplate(name, `ZZC${tag}A`), triageTemplate(`${name} (copy)`, `ZZC${tag}B`)];
483
+ const nameOf = (root: HTMLElement) => root.querySelector<HTMLInputElement>('[name="input-host-Name"] input')!.value;
484
+ try {
485
+ for (const t of triage)
486
+ await _package.files.writeAsText(`${TRIAGE_TEMPLATES}/${t.name}.json`, JSON.stringify(t));
487
+ const ht = await createTemplateAccordeon(await sb.hitTriage(), {}, triage[0]);
488
+ expect(nameOf(ht.root), `${name} (copy 2)`, 'the Hit Triage clone\'s name');
489
+
490
+ const peptides = [pepTriageTemplate(name, `ZZC${tag}A`), pepTriageTemplate(`${name} (copy)`, `ZZC${tag}B`)];
491
+ for (const t of peptides)
492
+ await sb.writeTemplate(t);
493
+ const pt = await createPepTriageTemplateAccordeon(await sb.pepTriage(), {}, peptides[0]);
494
+ expect(nameOf(pt.root), `${name} (copy 2)`, 'the PepTriage clone\'s name');
495
+ } finally {
496
+ for (const t of triage)
497
+ await removeTriageTemplate(t.name);
498
+ await sb.dispose();
499
+ }
500
+ }, {timeout: 150000});
501
+
502
+ test('Hit Triage: a template the share refuses is reported, not announced as created', async () => {
503
+ const sb = await Sandbox.create('editor');
504
+ try {
505
+ const app = await sb.hitTriage();
506
+ const editor = await createTemplateAccordeon(app, {});
507
+ let created = false;
508
+ void editor.template.then(() => created = true);
509
+ typeTriage(editor.root, 'Name', unwritable('triage'));
510
+ typeTriage(editor.root, 'Key', 'ZZBU');
511
+ DG.Balloon.closeAll();
512
+ createButton(editor.root).click();
513
+ await waitUntil(() => balloonShown(saveFailed('triage')), 'no balloon said the save failed', 15000);
514
+ expect(created, false, 'the editor reported a template created');
515
+ expect(balloonShown('Template created successfully'), false, 'a success balloon');
516
+ } finally {
517
+ await removeTriageTemplate(unwritable('triage'));
518
+ await sb.dispose();
519
+ }
520
+ }, {timeout: 120000});
521
+
522
+ test('PepTriage: CREATE waits for the name, the key and the sequence column', async () => {
523
+ const sb = await Sandbox.create('editor');
524
+ try {
525
+ await sb.writeTemplate(pepTriageTemplate('ZZB3 Peptide Template', 'ZZBQ'));
526
+ const app = await sb.pepTriage();
527
+ const editor = await createPepTriageTemplateAccordeon(app, {});
528
+ const create = createButton(editor.root);
529
+ typeTriage(editor.root, 'Name', 'ZZB3 Peptides');
530
+ typeTriage(editor.root, 'Key', 'ZZBP');
531
+ expect(disabled(create), true, 'CREATE with no sequence column');
532
+ typeTriage(editor.root, 'Sequence Column', 'Helm');
533
+ expect(disabled(create), false, 'CREATE with a name, a key and a sequence column');
534
+ } finally {
535
+ await sb.dispose();
536
+ }
537
+ }, {timeout: 150000});
538
+ });