(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
messytables-requirements
Jarosław Sadziński 2 years ago
parent 364610c69d
commit 356090abae

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

@ -2794,7 +2794,7 @@ function testDocApi() {
describe("Allowed Origin", () => { describe("Allowed Origin", () => {
it('should allow only example.com', async () => { it('should allow only example.com', async () => {
async function checkOrigin(origin: string, status: number, error?: string) { 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}} {...chimpy, headers: {...chimpy.headers, "Origin": origin}}
); );
error && assert.deepEqual(resp.data, {error}); 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://bad.com/example.com/toto", 500, "Unrecognized origin");
await checkOrigin("https://example.com/path", 200); await checkOrigin("https://example.com/path", 200);
await checkOrigin("https://good.example.com/toto", 200); await checkOrigin("https://good.example.com/toto", 200);
}) });
}) });
// PLEASE ADD MORE TESTS HERE // PLEASE ADD MORE TESTS HERE
} }

Loading…
Cancel
Save