forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdevInstance.parity.test.ts
More file actions
68 lines (65 loc) · 2.62 KB
/
Copy pathdevInstance.parity.test.ts
File metadata and controls
68 lines (65 loc) · 2.62 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
63
64
65
66
67
68
import { describe, expect, it } from 'vitest'
import * as ts from './devInstance'
import * as mjs from '../../scripts/lib/dev-ports.mjs'
// scripts/lib/dev-ports.mjs mirrors the port math of devInstance.ts so the
// plain-Node helper scripts can resolve ports without a TS loader. This test
// fails the moment the two drift — edit both or neither.
describe('dev-ports.mjs parity with devInstance.ts', () => {
it('shares the same constants', () => {
expect(mjs.PRIMARY_RENDERER_PORT).toBe(ts.PRIMARY_RENDERER_PORT)
expect(mjs.PRIMARY_CDP_PORT).toBe(ts.PRIMARY_CDP_PORT)
expect(mjs.DEV_RENDERER_BASE).toBe(ts.DEV_RENDERER_BASE)
expect(mjs.DEV_RENDERER_SPAN).toBe(ts.DEV_RENDERER_SPAN)
expect(mjs.DEV_CDP_BASE).toBe(ts.DEV_CDP_BASE)
expect(mjs.DEV_CDP_SPAN).toBe(ts.DEV_CDP_SPAN)
})
it('derives identical ports + slugs across a name corpus', () => {
const names = [
'multi-worktree-dev',
'primary',
'Feat/My Branch!',
'fix-orb',
'a',
'///',
'UPPER_case.1',
'worktree-99'
]
for (const n of names) {
expect(mjs.deriveRendererPort(n)).toBe(ts.deriveRendererPort(n))
expect(mjs.deriveCdpPort(n)).toBe(ts.deriveCdpPort(n))
expect(mjs.sanitizeInstanceName(n)).toBe(ts.sanitizeInstanceName(n))
}
})
// The scripts (seed-auth / dev:instance) must resolve the SAME effective ports
// the app binds, or the documented "set OMI_DEV_PORT to move it" remedy silently
// targets the wrong port. computeInstance (mjs) mirrors computeDevInstance (TS)
// including env-override precedence.
it('resolves identical ports under env overrides (precedence parity)', () => {
const envs: Array<Record<string, string>> = [
{},
{ OMI_DEV_PORT: '5210' },
{ OMI_DEV_CDP_PORT: '9251' },
{ OMI_DEV_REMOTE_DEBUG: '9333' },
// OMI_DEV_REMOTE_DEBUG must win over OMI_DEV_CDP_PORT.
{ OMI_DEV_CDP_PORT: '9251', OMI_DEV_REMOTE_DEBUG: '9333' },
{ OMI_DEV_PORT: '70000', OMI_DEV_CDP_PORT: 'abc' }, // garbage → fall through
{ OMI_INSTANCE: 'primary' },
{ OMI_INSTANCE: 'other-wt', OMI_DEV_CDP_PORT: '9270' }
]
for (const base of [
{ name: 'multi-worktree-dev', isPrimary: false },
{ name: 'omi', isPrimary: true }
]) {
for (const env of envs) {
const a = ts.computeDevInstance(base.name, base.isPrimary, env)
const b = mjs.computeInstance(base.name, base.isPrimary, env)
expect({ n: b.name, p: b.isPrimary, r: b.rendererPort, c: b.cdpPort }).toEqual({
n: a.name,
p: a.isPrimary,
r: a.rendererPort,
c: a.cdpPort
})
}
}
})
})