Linting and fixing client test case, have to mock getAppId as the location will never be set during testing.

This commit is contained in:
Michael Drury 2020-11-03 14:30:20 +00:00
parent d8da28502e
commit 19bcecf9f3
5 changed files with 12 additions and 7 deletions

View File

@ -1,5 +1,5 @@
import { authenticate } from "./authenticate"
import {getAppIdFromPath} from "../render/getAppId";
import { getAppIdFromPath } from "../render/getAppId"
const apiCall = method => async ({ url, body }) => {
const response = await fetch(url, {

View File

@ -1,5 +1,8 @@
import { load, makePage, makeScreen, walkComponentTree } from "./testAppDef"
import { isScreenSlot } from "../src/render/builtinComponents"
jest.mock("../src/render/getAppId", () => ({
getAppIdFromPath: () => "TEST_APP_ID"
}))
describe("screenRouting", () => {
it("should load correct screen, for initial URL", async () => {

View File

@ -1,15 +1,17 @@
import jsdom, { JSDOM } from "jsdom"
import { loadBudibase } from "../src/index"
export const APP_ID = "TEST_APP_ID"
export const load = async (page, screens, url, host = "test.com") => {
screens = screens || []
url = url || "/"
const fullUrl = `http://${host}${url}`
const cookieJar = new jsdom.CookieJar()
const cookie = `${btoa("{}")}.${btoa('{"appId":"TEST_APP_ID"}')}.signature`
const cookie = `${btoa("{}")}.${btoa(`{"appId":"${APP_ID}"}`)}.signature`
cookieJar.setCookie(
`budibase:TEST_APP_ID:local=${cookie};domain=${host};path=/`,
`budibase:${APP_ID}:local=${cookie};domain=${host};path=/`,
fullUrl,
{
looseMode: false,

View File

@ -33,7 +33,7 @@ exports.authenticate = async ctx => {
const payload = {
userId: dbUser._id,
accessLevelId: dbUser.accessLevelId,
version: app.version
version: app.version,
}
// if in cloud add the user api key
if (env.CLOUD) {