(core) Fix for tests failures

Summary:
- DocApi test for Allowed Origin was using a home server endpoint
- Fixing waitForServer, as gristApp can be unavailable for a moment when browser is refreshed
- Fixing MergedOrgs tests typing issue

Test Plan: Updated

Reviewers: cyprien, paulfitz

Reviewed By: cyprien, paulfitz

Subscribers: paulfitz

Differential Revision: https://phab.getgrist.com/D3648
This commit is contained in:
Jarosław Sadziński 2022-10-03 14:49:58 +02:00
parent 364610c69d
commit 356090abae
2 changed files with 4 additions and 4 deletions

View File

@ -831,7 +831,7 @@ export async function waitAppFocus(yesNo: boolean = true): Promise<void> {
*/
export async function waitForServer(optTimeout: number = 2000) {
await driver.wait(() => driver.executeScript(
"return (!window.gristApp.comm || !window.gristApp.comm.hasActiveRequests())"
"return window.gristApp && (!window.gristApp.comm || !window.gristApp.comm.hasActiveRequests())"
+ " && window.gristApp.testNumPendingApiRequests() === 0",
optTimeout,
"Timed out waiting for server requests to complete"

View File

@ -2794,7 +2794,7 @@ function testDocApi() {
describe("Allowed Origin", () => {
it('should allow only example.com', async () => {
async function checkOrigin(origin: string, status: number, error?: string) {
const resp = await axios.get(`${serverUrl}/api/docs/${docIds.Timesheets}/`,
const resp = await axios.get(`${serverUrl}/api/docs/${docIds.Timesheets}/tables/Table1/data`,
{...chimpy, headers: {...chimpy.headers, "Origin": origin}}
);
error && assert.deepEqual(resp.data, {error});
@ -2805,8 +2805,8 @@ function testDocApi() {
await checkOrigin("https://bad.com/example.com/toto", 500, "Unrecognized origin");
await checkOrigin("https://example.com/path", 200);
await checkOrigin("https://good.example.com/toto", 200);
})
})
});
});
// PLEASE ADD MORE TESTS HERE
}