make some overall QoL improvements
This commit is contained in:
@@ -887,6 +887,30 @@ test("chat search, organization, and workspace export work", async () => {
|
||||
await server.close();
|
||||
});
|
||||
|
||||
test("archiving frees an active chat slot and restoring respects the limit", async () => {
|
||||
const server = await startTestServer({config: {chatLimit: 1}});
|
||||
try {
|
||||
const jar = new CookieJar();
|
||||
await request(server.baseUrl, "/register", {method: "POST", body: {username: "archiver", password: "password123"}});
|
||||
await request(server.baseUrl, "/login", {method: "POST", body: {username: "archiver", password: "password123"}, jar});
|
||||
const first = await request(server.baseUrl, "/chats", {method: "POST", body: {title: "First"}, jar});
|
||||
assert.equal(first.status, 200);
|
||||
assert.equal((await request(server.baseUrl, "/chats", {method: "POST", body: {title: "Blocked"}, jar})).status, 400);
|
||||
assert.equal((await request(server.baseUrl, `/chats/${first.json.chat.id}/organization`, {
|
||||
method: "PUT", body: {archived: true}, jar
|
||||
})).status, 200);
|
||||
const second = await request(server.baseUrl, "/chats", {method: "POST", body: {title: "Second"}, jar});
|
||||
assert.equal(second.status, 200);
|
||||
assert.equal((await request(server.baseUrl, `/chats/${first.json.chat.id}/organization`, {
|
||||
method: "PUT", body: {archived: false}, jar
|
||||
})).status, 400);
|
||||
await request(server.baseUrl, `/chats/${second.json.chat.id}/organization`, {method: "PUT", body: {archived: true}, jar});
|
||||
assert.equal((await request(server.baseUrl, `/chats/${first.json.chat.id}/organization`, {
|
||||
method: "PUT", body: {archived: false}, jar
|
||||
})).status, 200);
|
||||
} finally { await server.close(); }
|
||||
});
|
||||
|
||||
test("persona clone, version restore, and market feedback endpoints work", async () => {
|
||||
const server = await startTestServer();
|
||||
const jar = new CookieJar();
|
||||
|
||||
@@ -132,6 +132,37 @@ test("account rename retains ownership and account deletion removes pending file
|
||||
await assert.rejects(fs.access(path.join(s.directory, key)));
|
||||
});
|
||||
|
||||
test("workspace archive restores image bytes for another account", async t => {
|
||||
const s = await setup(t);
|
||||
const bytes = await s.image("png");
|
||||
const image = await (await s.upload(bytes)).json();
|
||||
const chatId = await s.chat();
|
||||
assert.equal((await s.api("/chat", {chatId, message: "What is in this image?", attachments: [image.id]})).status, 200);
|
||||
const exported = await s.api("/exports/workspace/archive");
|
||||
assert.equal(exported.status, 200);
|
||||
assert.match(exported.headers.get("content-disposition"), /workspace-backup\.tar\.gz/);
|
||||
const archive = await exported.blob();
|
||||
const destination = await s.register("destination");
|
||||
const form = () => {
|
||||
const data = new FormData();
|
||||
data.append("archive", archive, "workspace.tar.gz");
|
||||
return data;
|
||||
};
|
||||
const base = new URL("/", exported.url).origin;
|
||||
const preview = await fetch(base + "/imports/workspace/archive/preview", {method: "POST", headers: {Cookie: destination}, body: form()});
|
||||
assert.equal(preview.status, 200);
|
||||
assert.equal((await preview.json()).preview.chats, 1);
|
||||
const imported = await fetch(base + "/imports/workspace/archive", {method: "POST", headers: {Cookie: destination}, body: form()});
|
||||
assert.equal(imported.status, 200);
|
||||
const workspace = await (await s.api("/exports/workspace", null, "GET", destination)).json();
|
||||
const restored = workspace.workspace.chats[0].messages[0].attachments[0];
|
||||
assert.notEqual(restored.id, image.id);
|
||||
const download = await s.api(`/attachments/${restored.id}`, null, "GET", destination);
|
||||
assert.equal(download.status, 200);
|
||||
assert.deepEqual(Buffer.from(await download.arrayBuffer()), bytes);
|
||||
assert.equal((await s.api(`/attachments/${restored.id}`)).status, 404);
|
||||
});
|
||||
|
||||
test("images feed dedicated vision, cache, streamed reasoning, reload and shared branch lifecycle", async t => {
|
||||
const s = await setup(t);
|
||||
const uploads = [];
|
||||
|
||||
Reference in New Issue
Block a user