@jive-sh/workflow-platform 0.7.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +66 -435
- package/component/_generated/api.ts +72 -0
- package/component/_generated/component.ts +621 -0
- package/component/_generated/dataModel.ts +60 -0
- package/component/_generated/server.ts +169 -0
- package/component/convex.config.ts +3 -0
- package/component/engine.ts +755 -0
- package/component/errors.ts +66 -0
- package/component/events.ts +17 -0
- package/component/notes.ts +13 -0
- package/component/places.ts +136 -0
- package/component/retention.ts +205 -0
- package/component/runEngine.ts +25 -0
- package/component/schema.ts +132 -0
- package/component/steps.ts +188 -0
- package/component/store.ts +512 -0
- package/component/tasks.ts +289 -0
- package/component/worker.ts +109 -0
- package/component/workflows.ts +83 -0
- package/dist/definition/agent-runner.js +9 -0
- package/dist/definition/agent-runner.js.map +1 -0
- package/dist/definition/file-store.js +9 -0
- package/dist/definition/file-store.js.map +1 -0
- package/dist/definition/program-build.js +10 -0
- package/dist/definition/program-build.js.map +1 -0
- package/dist/definition/step.js +1 -0
- package/dist/definition/step.js.map +1 -0
- package/dist/definition/task-schema.js +5 -0
- package/dist/definition/task-schema.js.map +1 -0
- package/dist/definition/tasks.js +9 -0
- package/dist/definition/tasks.js.map +1 -0
- package/dist/definition/workflow.js +111 -0
- package/dist/definition/workflow.js.map +1 -0
- package/dist/graph.js +301 -9
- package/dist/graph.js.map +1 -1
- package/dist/index.js +7 -196
- package/dist/index.js.map +1 -1
- package/package.json +9 -4
- package/src/definition/agent-runner.ts +59 -0
- package/src/definition/file-store.ts +20 -0
- package/src/definition/program-build.ts +30 -0
- package/src/definition/step.ts +106 -0
- package/src/definition/task-schema.ts +15 -0
- package/src/definition/tasks.ts +43 -0
- package/src/definition/workflow.ts +255 -0
- package/src/graph.ts +341 -19
- package/src/index.ts +8 -238
- package/worker/directory-file-store.ts +42 -0
- package/worker/index.ts +12 -0
- package/worker/platform-client.ts +138 -0
- package/worker/step-meter.ts +80 -0
- package/worker/worker-tasks.ts +27 -0
- package/worker/worker.test.ts +200 -0
- package/worker/worker.ts +240 -0
- package/dist/budget-states.js +0 -30
- package/dist/budget-states.js.map +0 -1
- package/dist/cpu-limit/limiter.js +0 -839
- package/dist/cpu-limit/limiter.js.map +0 -1
- package/dist/cpu-limit/use.js +0 -139
- package/dist/cpu-limit/use.js.map +0 -1
- package/dist/dashboard/agent-usage.js +0 -25
- package/dist/dashboard/agent-usage.js.map +0 -1
- package/dist/dashboard/dashboard.css +0 -148
- package/dist/dashboard/drilldown.js +0 -47
- package/dist/dashboard/drilldown.js.map +0 -1
- package/dist/dashboard/queue-lines.js +0 -44
- package/dist/dashboard/queue-lines.js.map +0 -1
- package/dist/dashboard/queue-table.js +0 -16
- package/dist/dashboard/queue-table.js.map +0 -1
- package/dist/dashboard/run-doing-words.js +0 -29
- package/dist/dashboard/run-doing-words.js.map +0 -1
- package/dist/dashboard/setting-words.js +0 -18
- package/dist/dashboard/setting-words.js.map +0 -1
- package/dist/dashboard/spending-words.js +0 -24
- package/dist/dashboard/spending-words.js.map +0 -1
- package/dist/failure.js +0 -35
- package/dist/failure.js.map +0 -1
- package/dist/keep-running.js +0 -79
- package/dist/keep-running.js.map +0 -1
- package/dist/outside-failure.js +0 -31
- package/dist/outside-failure.js.map +0 -1
- package/dist/pick-wakes.js +0 -125
- package/dist/pick-wakes.js.map +0 -1
- package/dist/project.js +0 -1
- package/dist/project.js.map +0 -1
- package/dist/queue-counts.js +0 -51
- package/dist/queue-counts.js.map +0 -1
- package/dist/reasons.js +0 -33
- package/dist/reasons.js.map +0 -1
- package/dist/retention.js +0 -59
- package/dist/retention.js.map +0 -1
- package/dist/settings.js +0 -88
- package/dist/settings.js.map +0 -1
- package/dist/spending-limit.js +0 -82
- package/dist/spending-limit.js.map +0 -1
- package/dist/step-files.js +0 -200
- package/dist/step-files.js.map +0 -1
- package/dist/step-meter.js +0 -97
- package/dist/step-meter.js.map +0 -1
- package/dist/step-times.js +0 -114
- package/dist/step-times.js.map +0 -1
- package/dist/step-usage.js +0 -19
- package/dist/step-usage.js.map +0 -1
- package/dist/steps.js +0 -1205
- package/dist/steps.js.map +0 -1
- package/dist/storage/agent-claims.js +0 -3
- package/dist/storage/agent-claims.js.map +0 -1
- package/dist/storage/budgets.js +0 -121
- package/dist/storage/budgets.js.map +0 -1
- package/dist/storage/engine-records.js +0 -91
- package/dist/storage/engine-records.js.map +0 -1
- package/dist/storage/engine-storage.js +0 -67
- package/dist/storage/engine-storage.js.map +0 -1
- package/dist/storage/input-records.js +0 -12
- package/dist/storage/input-records.js.map +0 -1
- package/dist/storage/move-store.js +0 -251
- package/dist/storage/move-store.js.map +0 -1
- package/dist/storage/sqlite-store.js +0 -901
- package/dist/storage/sqlite-store.js.map +0 -1
- package/dist/storage/step-records.js +0 -11
- package/dist/storage/step-records.js.map +0 -1
- package/dist/storage/storage-error.js +0 -19
- package/dist/storage/storage-error.js.map +0 -1
- package/dist/storage/task-store.js +0 -30
- package/dist/storage/task-store.js.map +0 -1
- package/dist/system-workflows.js +0 -54
- package/dist/system-workflows.js.map +0 -1
- package/dist/tasks.js +0 -500
- package/dist/tasks.js.map +0 -1
- package/dist/views/format.js +0 -37
- package/dist/views/format.js.map +0 -1
- package/dist/views/runs-now.js +0 -117
- package/dist/views/runs-now.js.map +0 -1
- package/dist/views/step-funnel.js +0 -98
- package/dist/views/step-funnel.js.map +0 -1
- package/dist/views/step-graph.js +0 -39
- package/dist/views/step-graph.js.map +0 -1
- package/dist/views/workflows-view.js +0 -236
- package/dist/views/workflows-view.js.map +0 -1
- package/src/budget-states.ts +0 -54
- package/src/cpu-limit/limiter.ts +0 -935
- package/src/cpu-limit/use.ts +0 -166
- package/src/dashboard/agent-usage-line.tsx +0 -28
- package/src/dashboard/agent-usage.ts +0 -48
- package/src/dashboard/dashboard.css +0 -148
- package/src/dashboard/drilldown.ts +0 -70
- package/src/dashboard/index.tsx +0 -4
- package/src/dashboard/limits-and-runs.tsx +0 -191
- package/src/dashboard/machine-controls.tsx +0 -53
- package/src/dashboard/queue-bar.tsx +0 -62
- package/src/dashboard/queue-chart.tsx +0 -149
- package/src/dashboard/queue-lines.ts +0 -87
- package/src/dashboard/queue-table.ts +0 -37
- package/src/dashboard/run-doing-words.ts +0 -41
- package/src/dashboard/setting-words.ts +0 -30
- package/src/dashboard/spending-limit-control.tsx +0 -47
- package/src/dashboard/spending-words.ts +0 -32
- package/src/dashboard/time-distribution.tsx +0 -61
- package/src/dashboard/workflow-dag.tsx +0 -322
- package/src/dashboard/workflow-drilldown.tsx +0 -31
- package/src/dashboard/workflows-dashboard.tsx +0 -532
- package/src/failure.ts +0 -36
- package/src/keep-running.ts +0 -85
- package/src/outside-failure.ts +0 -39
- package/src/pick-wakes.ts +0 -182
- package/src/project.ts +0 -127
- package/src/queue-counts.ts +0 -64
- package/src/reasons.ts +0 -30
- package/src/retention.ts +0 -90
- package/src/settings.ts +0 -171
- package/src/spending-limit.ts +0 -139
- package/src/step-files.ts +0 -208
- package/src/step-meter.ts +0 -120
- package/src/step-times.ts +0 -151
- package/src/step-usage.ts +0 -23
- package/src/steps.ts +0 -1616
- package/src/storage/agent-claims.ts +0 -63
- package/src/storage/budgets.ts +0 -152
- package/src/storage/engine-records.ts +0 -119
- package/src/storage/engine-storage.ts +0 -82
- package/src/storage/input-records.ts +0 -43
- package/src/storage/move-store.ts +0 -265
- package/src/storage/sqlite-store.ts +0 -1022
- package/src/storage/step-records.ts +0 -358
- package/src/storage/storage-error.ts +0 -35
- package/src/storage/task-store.ts +0 -235
- package/src/system-workflows.ts +0 -70
- package/src/tasks.ts +0 -586
- package/src/views/format.ts +0 -40
- package/src/views/runs-now.ts +0 -188
- package/src/views/step-funnel.ts +0 -163
- package/src/views/step-graph.ts +0 -77
- package/src/views/workflows-view.ts +0 -484
- package/src/workflow-dag.test.tsx +0 -89
- package/src/workflow-page.test.tsx +0 -170
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ONE PAGE FOR EVERY WORKFLOW. Alex, 2026-11-21: "a workflow is a workflow. stop building bespoke pages", and "why does only
|
|
3
|
-
* the decompile workflow sub view have a graph?".
|
|
4
|
-
*
|
|
5
|
-
* 1. The top (made of workflows), a part (made of workflows, used as a step) and a leaf (on its queue) render the same
|
|
6
|
-
* sections in the same order, each with a box for every one of its steps, each box with its description in words.
|
|
7
|
-
* 2. A workflow that declares no graph still has one: its steps in their declared order, from the run's start to its end,
|
|
8
|
-
* and ELK lays every edge of it out.
|
|
9
|
-
*/
|
|
10
|
-
import { Database } from 'bun:sqlite';
|
|
11
|
-
import { afterAll, expect, test } from 'bun:test';
|
|
12
|
-
import { Effect, Schema } from 'effect';
|
|
13
|
-
import fs from 'node:fs';
|
|
14
|
-
import path from 'node:path';
|
|
15
|
-
import { renderToStaticMarkup } from 'react-dom/server';
|
|
16
|
-
import { createWorkflowPlatform, RUN_ENDS, RUN_STARTS, sqliteStorage, type WorkflowFigures } from './index';
|
|
17
|
-
import { layOut } from './dashboard/workflow-dag';
|
|
18
|
-
import { SYSTEM_WORKFLOW_WORDS, WorkflowPage, type WorkflowsPageData } from './dashboard/workflows-dashboard';
|
|
19
|
-
|
|
20
|
-
const scratch = path.join(import.meta.dir, '..', '.scratch', `workflow-page-${process.pid}`);
|
|
21
|
-
fs.mkdirSync(scratch, { recursive: true });
|
|
22
|
-
afterAll(() => fs.rmSync(scratch, { recursive: true, force: true }));
|
|
23
|
-
const budgetsFile = path.join(scratch, 'budgets.db');
|
|
24
|
-
new Database(budgetsFile, { create: true }).exec('CREATE TABLE workflow_budgets (workflow TEXT PRIMARY KEY, budget INTEGER NOT NULL, runs INTEGER, changed_at REAL NOT NULL)');
|
|
25
|
-
new Database(path.join(scratch, 'engine.db'), { create: true })
|
|
26
|
-
.exec('CREATE TABLE cluster_messages (request_id INTEGER, entity_type TEXT, entity_id TEXT, tag TEXT, processed INTEGER NOT NULL DEFAULT 0); CREATE TABLE cluster_replies (request_id INTEGER, payload TEXT);');
|
|
27
|
-
const processes = { thisProcess: () => ({ pid: process.pid, startedAt: 0 }), isAlive: () => true };
|
|
28
|
-
const platform = createWorkflowPlatform<never>({
|
|
29
|
-
project: {
|
|
30
|
-
sourceRoot: scratch, tree: { root: scratch, snapshots: path.join(scratch, 'snapshots'), notTree: [] },
|
|
31
|
-
texts: { write: () => '', read: () => '' },
|
|
32
|
-
runLightNow: () => ({ code: 0, stdout: '', stdoutBytes: new Uint8Array(), stderr: '' }),
|
|
33
|
-
processes, stepRecordVariable: 'TEST_STEP_RECORD', isTransientFailure: () => false, cpu: { limit: () => 1, newestUse: () => null },
|
|
34
|
-
},
|
|
35
|
-
storage: sqliteStorage({ stepRecordsFile: () => path.join(scratch, 'records.db'), engineFile: () => path.join(scratch, 'engine.db'), budgetsFile: () => budgetsFile, processes }),
|
|
36
|
-
});
|
|
37
|
-
const { defineStep, defineWorkflow, defineWorkflowStep, graphOfFeeds } = platform.steps;
|
|
38
|
-
const run = { payload: { run: Schema.String }, idempotencyKey: ({ run: r }: { readonly run: string }) => r, success: Schema.Void, error: Schema.String };
|
|
39
|
-
|
|
40
|
-
const PICK = defineStep({ name: 'Pick a page', runs: 'deterministic', description: 'Takes the first page of its queue.', at: import.meta.path, success: Schema.String });
|
|
41
|
-
const WRITE = defineStep({ name: 'Write the page', runs: 'agentic', model: 'test-model', description: 'An agent writes the page it took.', at: import.meta.path, success: Schema.String });
|
|
42
|
-
// The leaf: a workflow on its queue that declares no graph.
|
|
43
|
-
defineWorkflow({ item: 'page', finishedWord: 'done', at: import.meta.path, description: 'Writes pages.', steps: () => [PICK, WRITE], items: () => Effect.succeed(['a']), outcomes: () => [] })('Page writing', run);
|
|
44
|
-
const madeOf = (name: string, steps: ReadonlyArray<string>, mainStep?: string) =>
|
|
45
|
-
defineWorkflow({ item: null, at: import.meta.path, description: `${name}.`, steps: () => steps.map(defineWorkflowStep), graph: () => graphOfFeeds(steps), ...(mainStep === undefined ? {} : { mainStep }) })(name, run);
|
|
46
|
-
madeOf('Page part', ['Page writing'], 'Page writing');
|
|
47
|
-
madeOf('Page project', ['Page part']);
|
|
48
|
-
// A workflow on no item that a run of another starts as a step: its tasks are that workflow's, passing through it.
|
|
49
|
-
const CHECK = defineStep({ name: 'Check', runs: 'deterministic', description: 'Checks the page.', at: import.meta.path, success: Schema.String });
|
|
50
|
-
const Checking = defineWorkflow({ item: null, at: import.meta.path, description: 'Checks a page.', steps: () => [CHECK] })('Page check', run);
|
|
51
|
-
const CHECKING = platform.steps.defineSubWorkflow({ workflow: Checking, at: import.meta.path, success: Schema.Void });
|
|
52
|
-
defineWorkflow({ item: 'page', finishedWord: 'done', at: import.meta.path, description: 'Reviews pages.', steps: () => [CHECKING], items: () => Effect.succeed(['a']), outcomes: () => [] })('Page review', run);
|
|
53
|
-
|
|
54
|
-
const now = Date.now() / 1000;
|
|
55
|
-
const read = async () => {
|
|
56
|
-
const view = await Effect.runPromise(platform.view({ now, top: 'Page project' }));
|
|
57
|
-
const data: WorkflowsPageData = { view, runsNow: [], cpu: { limit: 1, use: null } };
|
|
58
|
-
const figuresOf = async (workflow: string): Promise<WorkflowFigures> => (await Effect.runPromise(platform.figures({ workflow, now, hours: 24 })))!;
|
|
59
|
-
return { data, figuresOf };
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
/** A page as a reader's browser gets it from the server, with its workflow's figures read. */
|
|
63
|
-
const page = async (at: ReadonlyArray<string>, workflow: string) => {
|
|
64
|
-
const { data, figuresOf } = await read();
|
|
65
|
-
const html = renderToStaticMarkup(<WorkflowPage data={data} figures={{ data: await figuresOf(workflow), error: null }} path={at} hrefOf={(p) => `/${p.join('/')}`} now={now} />);
|
|
66
|
-
return {
|
|
67
|
-
sections: [...html.matchAll(/data-section="([^"]+)"/g)].map((m) => m[1]),
|
|
68
|
-
boxes: [...html.matchAll(/data-step="([^"]+)" class="wp-node"/g)].map((m) => m[1]),
|
|
69
|
-
descriptions: [...html.matchAll(/<p class="wp-node-what">([^<]*)<\/p>/g)].map((m) => m[1]),
|
|
70
|
-
};
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
test('1. the top, a part and a leaf render the same sections in the same order, a box for each step with its description', async () => {
|
|
74
|
-
const top = await page([], 'Page project');
|
|
75
|
-
const part = await page(['Page part'], 'Page part');
|
|
76
|
-
const leaf = await page(['Page part', 'Page writing'], 'Page writing');
|
|
77
|
-
const sections = ['Tasks', 'Runs', 'Limits', 'Steps', 'Tasks over time', 'Blocked, by reason', 'Queued, needing an agent', 'What its runs gave', 'Where runs stopped'];
|
|
78
|
-
expect({ top: top.sections, part: part.sections, leaf: leaf.sections }).toEqual({ top: sections, part: sections, leaf: sections });
|
|
79
|
-
expect({ top: top.boxes, part: part.boxes, leaf: leaf.boxes }).toEqual({ top: ['Page part'], part: ['Page writing'], leaf: ['Pick a page', 'Write the page'] });
|
|
80
|
-
expect(leaf.descriptions).toEqual(['Takes the first page of its queue.', 'An agent writes the page it took.']);
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
test("1b. a top-level page shows the platform's own workflows apart, in words, with their run limits; a part's page does not; and one's own page says it is the platform's", async () => {
|
|
84
|
-
const { data, figuresOf } = await read();
|
|
85
|
-
const render = async (at: ReadonlyArray<string>, workflow: string) =>
|
|
86
|
-
renderToStaticMarkup(<WorkflowPage data={data} figures={{ data: await figuresOf(workflow), error: null }} path={at} hrefOf={(p) => `/${p.join('/')}`} now={now} />);
|
|
87
|
-
const top = await render([], 'Page project');
|
|
88
|
-
const block = top.slice(top.indexOf('data-platform-workflows'));
|
|
89
|
-
expect(block).toContain('<h3 class="wp-h3">Platform workflows</h3>');
|
|
90
|
-
expect(block).toContain('<a href="/Retention">Retention</a>');
|
|
91
|
-
expect(block).toContain(SYSTEM_WORKFLOW_WORDS);
|
|
92
|
-
expect(block).toContain('data-counts="runs"');
|
|
93
|
-
expect(block).toContain('no limit');
|
|
94
|
-
expect(block).toContain('10,000 runs');
|
|
95
|
-
expect(await render(['Page part'], 'Page part')).not.toContain('data-platform-workflows');
|
|
96
|
-
const own = await render(['Retention'], 'Retention');
|
|
97
|
-
expect({ words: own.includes(SYSTEM_WORKFLOW_WORDS), block: own.includes('data-platform-workflows') }).toEqual({ words: true, block: false });
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
test('2. a workflow that declares no graph has its steps in their declared order, and every edge of it is laid out', async () => {
|
|
101
|
-
const { figuresOf } = await read();
|
|
102
|
-
const figures = await figuresOf('Page writing');
|
|
103
|
-
expect({ declared: figures.graph.declared, edges: figures.graph.edges.map((e) => `${e.from} > ${e.to}`) })
|
|
104
|
-
.toEqual({ declared: false, edges: [`${RUN_STARTS} > Pick a page`, 'Pick a page > Write the page', `Write the page > ${RUN_ENDS}`] });
|
|
105
|
-
const laid = await layOut({ graph: figures.graph, heightOf: () => 80 });
|
|
106
|
-
expect({ boxes: [...laid.boxes.keys()], edges: laid.edges.filter((e) => e.points.length >= 2).length })
|
|
107
|
-
.toEqual({ boxes: [RUN_STARTS, 'Pick a page', 'Write the page', RUN_ENDS], edges: 3 });
|
|
108
|
-
// Down the page: each box below the one before it.
|
|
109
|
-
const ys = [RUN_STARTS, 'Pick a page', 'Write the page', RUN_ENDS].map((b) => laid.boxes.get(b)!.y);
|
|
110
|
-
expect(ys).toEqual([...ys].sort((a, b) => a - b));
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
/** Each addition of calls on a page, as its rows read: "1 in progress, 1 failed, 3 done, 5 calls, 24 h". */
|
|
114
|
-
const callsBars = (html: string): ReadonlyArray<string> =>
|
|
115
|
-
[...html.matchAll(/<table class="wp-sum" data-counts="calls">(.*?)<\/table>/g)]
|
|
116
|
-
.map((m) => [...m[1]!.matchAll(/class="wp-sum-n">([^<]*)<\/td><td class="wp-sum-label">([^<]*)</g)].map((x) => `${x[1]} ${x[2]}`).join(', '));
|
|
117
|
-
|
|
118
|
-
test('3. a workflow run as a step of another shows that workflow\'s calls of it as a bar, on its box there and on its own page alike', async () => {
|
|
119
|
-
const { data, figuresOf } = await read();
|
|
120
|
-
const cost = { calls: 5, failed: 1, open: 1, seconds: 10, inputTokens: 0, outputTokens: 0, cpuSeconds: 1, compiles: 0, items: 5 };
|
|
121
|
-
const parent = await figuresOf('Page review');
|
|
122
|
-
const onParent = renderToStaticMarkup(<WorkflowPage data={data} figures={{ data: { ...parent, steps: parent.steps.map((s) => (s.name === 'Page check' ? { ...s, cost } : s)) }, error: null }} path={['Page review']} hrefOf={(p) => `/${p.join('/')}`} now={now} />);
|
|
123
|
-
const own = await figuresOf('Page check');
|
|
124
|
-
expect(own.passingThrough).toEqual([{ workflow: 'Page review', step: 'Page check', cost: null }]);
|
|
125
|
-
const onItsOwn = renderToStaticMarkup(<WorkflowPage data={data} figures={{ data: { ...own, passingThrough: [{ ...own.passingThrough[0]!, cost }] }, error: null }} path={['Page review', 'Page check']} hrefOf={(p) => `/${p.join('/')}`} now={now} />);
|
|
126
|
-
const bar = '1 in progress, 1 failed, 3 done, 5 calls, 24 h';
|
|
127
|
-
expect({ onParent: callsBars(onParent), onItsOwn: callsBars(onItsOwn) }).toEqual({ onParent: [bar], onItsOwn: [bar] });
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
/** Where a page says it is: its path's links and its last part, its title, and the other top-level workflows it names. */
|
|
131
|
-
const whereItIs = async (at: ReadonlyArray<string>, workflow: string) => {
|
|
132
|
-
const { data, figuresOf } = await read();
|
|
133
|
-
const html = renderToStaticMarkup(<WorkflowPage data={data} figures={{ data: await figuresOf(workflow), error: null }} path={at} hrefOf={(p) => `/${p.join('/')}`} now={now} />);
|
|
134
|
-
const nav = /<nav class="wp-crumbs"[^>]*>(.*?)<\/nav>/.exec(html)?.[1] ?? '';
|
|
135
|
-
return {
|
|
136
|
-
links: [...nav.matchAll(/<a href="([^"]*)">([^<]*)<\/a>/g)].map((m) => `${m[2]} ${m[1]}`),
|
|
137
|
-
here: /<span class="wp-crumb-here"[^>]*>([^<]*)<\/span>/.exec(nav)?.[1] ?? null,
|
|
138
|
-
title: /<h2 class="wp-title">Workflow: <!-- -->([^<]*)/.exec(html)?.[1] ?? /<h2 class="wp-title">Workflow: ([^<]*)/.exec(html)?.[1] ?? null,
|
|
139
|
-
others: /<p class="wp-line wp-others">Other top-level workflows: (.*?)<\/p>/.exec(html)?.[1]?.replace(/<[^>]*>/g, '') ?? null,
|
|
140
|
-
};
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
test('4. every page says its path from the top, every part a link but its own, then its title, and names no other workflow but other top-level ones', async () => {
|
|
144
|
-
expect(await whereItIs([], 'Page project')).toEqual({ links: [], here: 'Page project', title: 'Page project', others: 'Page review' });
|
|
145
|
-
expect(await whereItIs(['Page part'], 'Page part')).toEqual({ links: ['Page project /'], here: 'Page part', title: 'Page part', others: null });
|
|
146
|
-
expect(await whereItIs(['Page part', 'Page writing'], 'Page writing')).toEqual({ links: ['Page project /', 'Page part /Page part'], here: 'Page writing', title: 'Page writing', others: null });
|
|
147
|
-
// Another top-level workflow's page names the project's top among the others, never itself.
|
|
148
|
-
expect(await whereItIs(['Page review'], 'Page review')).toEqual({ links: [], here: 'Page review', title: 'Page review', others: 'Page project' });
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
/** Each addition of tasks on a page, as its rows read: "3 queued, 1 in progress, 0 blocked, 6 done, 10 tasks in Page writing". */
|
|
152
|
-
const tasksBars = (html: string): ReadonlyArray<string> =>
|
|
153
|
-
[...html.matchAll(/<table class="wp-sum" data-counts="tasks">(.*?)<\/table>/g)]
|
|
154
|
-
.map((m) => [...m[1]!.matchAll(/class="wp-sum-n">([^<]*)<\/td><td class="wp-sum-label">([^<]*)</g)].map((x) => `${x[1]} ${x[2]}`).join(', '));
|
|
155
|
-
|
|
156
|
-
test("5. a workflow made of workflows shows its main step's tasks, named as that step's, on its box and on its own page; one naming none says its tasks are its steps'", async () => {
|
|
157
|
-
const { data: read0, figuresOf } = await read();
|
|
158
|
-
const counted = { queued: 3, 'in progress': 1, blocked: 0, done: 6 };
|
|
159
|
-
const data: WorkflowsPageData = { ...read0, view: { ...read0.view, workflows: read0.view.workflows.map((w) => (w.name === 'Page writing' ? { ...w, queue: counted } : w)) } };
|
|
160
|
-
expect(data.view.workflows.find((w) => w.name === 'Page part')?.startsOn).toEqual({ kind: 'its steps', mainStep: 'Page writing' });
|
|
161
|
-
const render = async (at: ReadonlyArray<string>, workflow: string) =>
|
|
162
|
-
renderToStaticMarkup(<WorkflowPage data={data} figures={{ data: await figuresOf(workflow), error: null }} path={at} hrefOf={(p) => `/${p.join('/')}`} now={now} />);
|
|
163
|
-
const bar = '3 queued (0 need agent), 1 in progress, 0 blocked, 6 done, 10 tasks in Page writing';
|
|
164
|
-
const top = await render([], 'Page project');
|
|
165
|
-
const part = await render(['Page part'], 'Page part');
|
|
166
|
-
// The top's Tasks section (before its first box) names no main step; the part's box on it, and the part's own page, show Page writing's.
|
|
167
|
-
expect({ topOwn: top.slice(0, top.indexOf('data-step=')).includes('data-counts="tasks"'), top: tasksBars(top), part: tasksBars(part).slice(0, 1) })
|
|
168
|
-
.toEqual({ topOwn: false, top: [bar], part: [bar] });
|
|
169
|
-
expect(top).toContain("Its tasks are its steps', each counted under its own workflow.");
|
|
170
|
-
});
|