Fix Emberwake downloads by appending blob anchors before click.
Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled

ZIP exports and public download links silently failed because blob saves skipped document.body appendChild (unlike Builds DownloadButton) and public links pointed at the command-deck URL instead of same-origin paths.
This commit is contained in:
AetherForge
2026-06-07 15:54:28 -07:00
parent ab3c4e087d
commit b0240abecc
9 changed files with 156 additions and 76 deletions

View File

@@ -322,6 +322,32 @@ describe('api client', () => {
expect(lastFetch().init.method).toBe('DELETE');
});
it('exportSpreadKit POSTs and triggers blob download', async () => {
setStoredAuth('user', 'pass');
fetchMock.mockResolvedValueOnce(new Response(new Blob(['zip']), { status: 200 }));
const appendChildSpy = vi.spyOn(document.body, 'appendChild');
const clickMock = vi.fn();
vi.spyOn(HTMLAnchorElement.prototype, 'click').mockImplementation(clickMock);
await api.exportSpreadKit({
build_id: 'build-1',
server_url: 'http://localhost:8989',
campaign: 'linkedin-bait',
});
const { url, init } = lastFetch();
expect(url).toBe('/api/v1/builder/spread-kit-export');
expect(init.method).toBe('POST');
expectAuthHeaders(init);
expect(JSON.parse(init.body as string)).toEqual({
build_id: 'build-1',
server_url: 'http://localhost:8989',
campaign: 'linkedin-bait',
});
expect(appendChildSpy).toHaveBeenCalled();
expect(clickMock).toHaveBeenCalled();
});
it('getDashboardStats and listBuilds', async () => {
fetchMock
.mockResolvedValueOnce(