forked from lightningpixel/modly
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmockExtensions.test.mjs
More file actions
62 lines (57 loc) · 1.72 KB
/
Copy pathmockExtensions.test.mjs
File metadata and controls
62 lines (57 loc) · 1.72 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import test from 'node:test'
import assert from 'node:assert/strict'
import { buildSync } from 'esbuild'
import { createRequire } from 'node:module'
import { mkdtempSync, writeFileSync } from 'node:fs'
import { tmpdir } from 'node:os'
import { join, resolve } from 'node:path'
function loadModule() {
const outfile = join(mkdtempSync(join(tmpdir(), 'modly-workflow-ext-test-')), 'mockExtensions.cjs')
const require = createRequire(import.meta.url)
const result = buildSync({
entryPoints: [resolve('src/areas/workflows/mockExtensions.ts')],
bundle: true,
platform: 'node',
format: 'cjs',
write: false,
})
writeFileSync(outfile, result.outputFiles[0].text, 'utf8')
return require(outfile)
}
function extension(type, overrides = {}) {
return {
type,
id: `${type}-extension`,
name: `${type} extension`,
trusted: false,
builtin: false,
entry: type === 'process' ? 'processor.js' : undefined,
nodes: [{
id: 'generate',
name: 'Generate',
input: 'image',
output: 'mesh',
paramsSchema: [],
}],
...overrides,
}
}
test('workflow discovery excludes corrupted extensions with preserved nodes', () => {
const { buildAllWorkflowExtensions } = loadModule()
const healthyModel = extension('model', { id: 'healthy-model' })
const pendingModel = extension('model', {
id: 'pixal3d',
corrupted: true,
manifestError: 'incomplete',
})
const pendingProcess = extension('process', {
id: 'pending-process',
corrupted: true,
manifestError: 'incomplete',
})
const result = buildAllWorkflowExtensions(
[healthyModel, pendingModel],
[pendingProcess],
)
assert.deepEqual(result.map((entry) => entry.id), ['healthy-model/generate'])
})