|
|
|
@ -2990,7 +2990,6 @@ function testDocApi() {
|
|
|
|
|
|
|
|
|
|
before(async function() {
|
|
|
|
|
this.timeout(30000);
|
|
|
|
|
if (!process.env.TEST_REDIS_URL) { this.skip(); }
|
|
|
|
|
requests = {
|
|
|
|
|
"add,update": [],
|
|
|
|
|
"add": [],
|
|
|
|
@ -3059,6 +3058,22 @@ function testDocApi() {
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}, webhooksTestPort);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
after(async function() {
|
|
|
|
|
await serving.shutdown();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('table endpoints', function() {
|
|
|
|
|
before(async function() {
|
|
|
|
|
this.timeout(30000);
|
|
|
|
|
// We rely on the REDIS server in this test.
|
|
|
|
|
if (!process.env.TEST_REDIS_URL) { this.skip(); }
|
|
|
|
|
requests = {
|
|
|
|
|
"add,update": [],
|
|
|
|
|
"add": [],
|
|
|
|
|
"update": [],
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
redisCalls = [];
|
|
|
|
|
redisMonitor = createClient(process.env.TEST_REDIS_URL);
|
|
|
|
@ -3070,7 +3085,6 @@ function testDocApi() {
|
|
|
|
|
|
|
|
|
|
after(async function() {
|
|
|
|
|
if (!process.env.TEST_REDIS_URL) { this.skip(); }
|
|
|
|
|
await serving.shutdown();
|
|
|
|
|
await redisMonitor.quitAsync();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -3204,6 +3218,28 @@ function testDocApi() {
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe("/webhooks endpoint", function() {
|
|
|
|
|
let docId: string;
|
|
|
|
|
let doc: DocAPI;
|
|
|
|
|
let stats: WebhookSummary[];
|
|
|
|
|
before(async function() {
|
|
|
|
|
// Create a test document.
|
|
|
|
|
const ws1 = (await userApi.getOrgWorkspaces('current'))[0].id;
|
|
|
|
|
docId = await userApi.newDoc({name: 'testdoc2'}, ws1);
|
|
|
|
|
doc = userApi.getDocAPI(docId);
|
|
|
|
|
await axios.post(`${serverUrl}/api/docs/${docId}/apply`, [
|
|
|
|
|
['ModifyColumn', 'Table1', 'B', {type: 'Bool'}],
|
|
|
|
|
], chimpy);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const waitForQueue = async (length: number) => {
|
|
|
|
|
await waitForIt(async () => {
|
|
|
|
|
stats = await readStats(docId);
|
|
|
|
|
assert.equal(length, _.sum(stats.map(x => x.usage?.numWaiting ?? 0)));
|
|
|
|
|
}, 1000, 200);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
it("should clear the outgoing queue", async() => {
|
|
|
|
|
// Create a test document.
|
|
|
|
@ -3406,27 +3442,6 @@ function testDocApi() {
|
|
|
|
|
await webhook1();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe("/webhooks endpoint", function() {
|
|
|
|
|
let docId: string;
|
|
|
|
|
let doc: DocAPI;
|
|
|
|
|
let stats: WebhookSummary[];
|
|
|
|
|
before(async() => {
|
|
|
|
|
// Create a test document.
|
|
|
|
|
const ws1 = (await userApi.getOrgWorkspaces('current'))[0].id;
|
|
|
|
|
docId = await userApi.newDoc({name: 'testdoc2'}, ws1);
|
|
|
|
|
doc = userApi.getDocAPI(docId);
|
|
|
|
|
await axios.post(`${serverUrl}/api/docs/${docId}/apply`, [
|
|
|
|
|
['ModifyColumn', 'Table1', 'B', {type: 'Bool'}],
|
|
|
|
|
], chimpy);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const waitForQueue = async (length: number) => {
|
|
|
|
|
await waitForIt(async () => {
|
|
|
|
|
stats = await readStats(docId);
|
|
|
|
|
assert.equal(length, _.sum(stats.map(x => x.usage?.numWaiting ?? 0)));
|
|
|
|
|
}, 1000, 200);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
it("should return statistics", async() => {
|
|
|
|
|
await clearQueue(docId);
|
|
|
|
|
// Read stats, it should be empty.
|
|
|
|
@ -3757,7 +3772,6 @@ function testDocApi() {
|
|
|
|
|
await unsubscribe(docId, webhook4);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe("Allowed Origin", () => {
|
|
|
|
|