mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) updates from grist-core
This commit is contained in:
@@ -2138,6 +2138,62 @@ function testDocApi() {
|
||||
assert.deepEqual(resp.data, { error: 'tableId parameter should be a string: undefined' });
|
||||
});
|
||||
|
||||
it("GET /docs/{did}/download/table-schema serves table-schema-encoded document", async function() {
|
||||
const resp = await axios.get(`${serverUrl}/api/docs/${docIds.TestDoc}/download/table-schema?tableId=Foo`, chimpy);
|
||||
assert.equal(resp.status, 200);
|
||||
const expected = {
|
||||
format: "csv",
|
||||
mediatype: "text/csv",
|
||||
encoding: "utf-8",
|
||||
dialect: {
|
||||
delimiter: ",",
|
||||
doubleQuote: true,
|
||||
},
|
||||
name: 'foo',
|
||||
title: 'Foo',
|
||||
schema: {
|
||||
fields: [{
|
||||
name: 'A',
|
||||
type: 'string',
|
||||
format: 'default',
|
||||
}, {
|
||||
name: 'B',
|
||||
type: 'string',
|
||||
format: 'default',
|
||||
}]
|
||||
}
|
||||
};
|
||||
assert.deepInclude(resp.data, expected);
|
||||
|
||||
const resp2 = await axios.get(resp.data.path, chimpy);
|
||||
assert.equal(resp2.status, 200);
|
||||
assert.equal(resp2.data, 'A,B\nSanta,1\nBob,11\nAlice,2\nFelix,22\n');
|
||||
});
|
||||
|
||||
it("GET /docs/{did}/download/table-schema respects permissions", async function() {
|
||||
// kiwi has no access to TestDoc
|
||||
const resp = await axios.get(`${serverUrl}/api/docs/${docIds.TestDoc}/download/table-schema?tableId=Table1`, kiwi);
|
||||
assert.equal(resp.status, 403);
|
||||
assert.deepEqual(resp.data, {"error":"No view access"});
|
||||
});
|
||||
|
||||
it("GET /docs/{did}/download/table-schema returns 404 if tableId is invalid", async function() {
|
||||
const resp = await axios.get(
|
||||
`${serverUrl}/api/docs/${docIds.TestDoc}/download/table-schema?tableId=MissingTableId`,
|
||||
chimpy,
|
||||
);
|
||||
assert.equal(resp.status, 404);
|
||||
assert.deepEqual(resp.data, { error: 'Table MissingTableId not found.' });
|
||||
});
|
||||
|
||||
it("GET /docs/{did}/download/table-schema returns 400 if tableId is missing", async function() {
|
||||
const resp = await axios.get(
|
||||
`${serverUrl}/api/docs/${docIds.TestDoc}/download/table-schema`, chimpy);
|
||||
assert.equal(resp.status, 400);
|
||||
assert.deepEqual(resp.data, { error: 'tableId parameter should be a string: undefined' });
|
||||
});
|
||||
|
||||
|
||||
it("GET /docs/{did}/download/xlsx serves XLSX-encoded document", async function() {
|
||||
const resp = await axios.get(`${serverUrl}/api/docs/${docIds.Timesheets}/download/xlsx?tableId=Table1`, chimpy);
|
||||
assert.equal(resp.status, 200);
|
||||
|
||||
Reference in New Issue
Block a user