feat(audit): Batch 25 — project reorg (CC12), leading DI args (CC7), CC10 by-design
CC12: renderer views/ (5 screens + Onboarding + settings cards) + lib/ (theme/thumb/datetime/id/qualityOptions/useClipboardLink/queueStats); main core/ (buildArgs/validation/indexerCore/ytdlpPolicy). git mv preserved history; all src+test imports updated. Build emits view chunks from views/, 344 tests + typecheck green, live probe rendered all screens. CC7: wc/onProgress is the leading arg everywhere — downloadAppUpdate(wc,url), indexSource(onProgress,url,signal), indexSourceCancelable(onProgress,url). CC10: closed by-design — jsonStore backs all records; settings stay in electron-store for DPAPI secret encryption (a deliberate two-store split). Also closes the UI24/W4 context-menu cross-reference. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -138,7 +138,7 @@ afterAll(() => {
|
||||
describe('downloadAppUpdate (CL4 behavior pins)', () => {
|
||||
it('refuses an untrusted initial URL without making any request', async () => {
|
||||
const { wc } = fakeWc()
|
||||
const r = await downloadAppUpdate('https://evil.example/x.exe', wc)
|
||||
const r = await downloadAppUpdate(wc, 'https://evil.example/x.exe')
|
||||
expect(r.ok).toBe(false)
|
||||
expect(r.error).toMatch(/untrusted/i)
|
||||
expect(madeRequests.length).toBe(0)
|
||||
@@ -154,7 +154,7 @@ describe('downloadAppUpdate (CL4 behavior pins)', () => {
|
||||
res.emit('end')
|
||||
})
|
||||
const { wc, sends } = fakeWc()
|
||||
const r = await downloadAppUpdate(ASSET, wc)
|
||||
const r = await downloadAppUpdate(wc, ASSET)
|
||||
expect(r).toEqual({ ok: true, filePath: installerPath })
|
||||
expect(readFileSync(installerPath).equals(INSTALLER)).toBe(true)
|
||||
expect(sends.length).toBeGreaterThan(0)
|
||||
@@ -171,7 +171,7 @@ describe('downloadAppUpdate (CL4 behavior pins)', () => {
|
||||
res.emit('end')
|
||||
})
|
||||
const { wc } = fakeWc()
|
||||
const r = await downloadAppUpdate(ASSET, wc)
|
||||
const r = await downloadAppUpdate(wc, ASSET)
|
||||
expect(r.ok).toBe(false)
|
||||
expect(r.error).toMatch(/checksum/i)
|
||||
await expectGone(installerPath)
|
||||
@@ -186,7 +186,7 @@ describe('downloadAppUpdate (CL4 behavior pins)', () => {
|
||||
res.emit('end')
|
||||
})
|
||||
const { wc } = fakeWc()
|
||||
const r = await downloadAppUpdate(ASSET, wc)
|
||||
const r = await downloadAppUpdate(wc, ASSET)
|
||||
expect(r.ok).toBe(false)
|
||||
expect(r.error).toMatch(/incomplete/i)
|
||||
await expectGone(installerPath)
|
||||
@@ -198,7 +198,7 @@ describe('downloadAppUpdate (CL4 behavior pins)', () => {
|
||||
req.emit('redirect', 302, 'GET', 'https://evil.example/attachments/x.exe')
|
||||
})
|
||||
const { wc } = fakeWc()
|
||||
const r = await downloadAppUpdate(ASSET, wc)
|
||||
const r = await downloadAppUpdate(wc, ASSET)
|
||||
expect(r.ok).toBe(false)
|
||||
expect(r.error).toMatch(/redirect.*untrusted/i)
|
||||
const installerReq = madeRequests[1]!
|
||||
@@ -216,7 +216,7 @@ describe('downloadAppUpdate (CL4 behavior pins)', () => {
|
||||
res.emit('end')
|
||||
})
|
||||
const { wc } = fakeWc()
|
||||
const r = await downloadAppUpdate(ASSET, wc)
|
||||
const r = await downloadAppUpdate(wc, ASSET)
|
||||
expect(r.ok).toBe(true)
|
||||
expect(madeRequests[1]!.redirectsFollowed).toBe(1)
|
||||
})
|
||||
@@ -226,7 +226,7 @@ describe('downloadAppUpdate (CL4 behavior pins)', () => {
|
||||
req.emit('redirect', 302, 'GET', 'https://evil.example/x.sha256')
|
||||
})
|
||||
const { wc } = fakeWc()
|
||||
const r = await downloadAppUpdate(ASSET, wc)
|
||||
const r = await downloadAppUpdate(wc, ASSET)
|
||||
expect(r.ok).toBe(false)
|
||||
expect(r.error).toMatch(/checksum/i)
|
||||
expect(madeRequests.length).toBe(1) // never reached the installer request
|
||||
@@ -237,7 +237,7 @@ describe('downloadAppUpdate (CL4 behavior pins)', () => {
|
||||
req.emit('response', new FakeResponse(404))
|
||||
})
|
||||
const { wc } = fakeWc()
|
||||
const r = await downloadAppUpdate(ASSET, wc)
|
||||
const r = await downloadAppUpdate(wc, ASSET)
|
||||
expect(r.ok).toBe(false)
|
||||
expect(r.error).toMatch(/no checksum/i)
|
||||
expect(madeRequests.length).toBe(1)
|
||||
@@ -246,7 +246,7 @@ describe('downloadAppUpdate (CL4 behavior pins)', () => {
|
||||
it('refuses a malformed checksum file (no 64-hex digest)', async () => {
|
||||
requestScripts.push(checksumOk('not a digest at all\n'))
|
||||
const { wc } = fakeWc()
|
||||
const r = await downloadAppUpdate(ASSET, wc)
|
||||
const r = await downloadAppUpdate(wc, ASSET)
|
||||
expect(r.ok).toBe(false)
|
||||
expect(r.error).toMatch(/malformed/i)
|
||||
expect(madeRequests.length).toBe(1)
|
||||
@@ -262,7 +262,7 @@ describe('downloadAppUpdate (CL4 behavior pins)', () => {
|
||||
res.emit('end')
|
||||
})
|
||||
const { wc } = fakeWc()
|
||||
const r = await downloadAppUpdate(ASSET, wc)
|
||||
const r = await downloadAppUpdate(wc, ASSET)
|
||||
expect(r.ok).toBe(false)
|
||||
expect(r.error).toMatch(/canceled/i)
|
||||
expect(madeRequests.length).toBe(1)
|
||||
@@ -277,7 +277,7 @@ describe('downloadAppUpdate (CL4 behavior pins)', () => {
|
||||
cancelAppUpdate()
|
||||
})
|
||||
const { wc } = fakeWc()
|
||||
const r = await downloadAppUpdate(ASSET, wc)
|
||||
const r = await downloadAppUpdate(wc, ASSET)
|
||||
expect(r.ok).toBe(false)
|
||||
expect(r.error).toMatch(/canceled/i)
|
||||
expect(madeRequests[1]!.aborted).toBe(true)
|
||||
@@ -294,7 +294,7 @@ describe('downloadAppUpdate (CL4 behavior pins)', () => {
|
||||
// …and then nothing: the stream stalls.
|
||||
})
|
||||
const { wc } = fakeWc()
|
||||
const pending = downloadAppUpdate(ASSET, wc)
|
||||
const pending = downloadAppUpdate(wc, ASSET)
|
||||
await vi.advanceTimersByTimeAsync(61_000)
|
||||
const r = await pending
|
||||
expect(r.ok).toBe(false)
|
||||
@@ -310,7 +310,7 @@ describe('downloadAppUpdate (CL4 behavior pins)', () => {
|
||||
req.emit('response', new FakeResponse(503))
|
||||
})
|
||||
const { wc } = fakeWc()
|
||||
const r = await downloadAppUpdate(ASSET, wc)
|
||||
const r = await downloadAppUpdate(wc, ASSET)
|
||||
expect(r.ok).toBe(false)
|
||||
expect(r.error).toMatch(/503/)
|
||||
})
|
||||
@@ -327,7 +327,7 @@ describe('downloadAppUpdate (CL4 behavior pins)', () => {
|
||||
res.emit('end')
|
||||
})
|
||||
const { wc } = fakeWc()
|
||||
const r = await downloadAppUpdate(ASSET, wc)
|
||||
const r = await downloadAppUpdate(wc, ASSET)
|
||||
expect(r.ok).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user