Merge branch 'master' into fix/13177
This commit is contained in:
commit
8fb38e85ca
|
@ -13,7 +13,7 @@ describe("/api/keys", () => {
|
||||||
|
|
||||||
describe("fetch", () => {
|
describe("fetch", () => {
|
||||||
it("should allow fetching", async () => {
|
it("should allow fetching", async () => {
|
||||||
await setup.switchToSelfHosted(async () => {
|
await config.withEnv({ SELF_HOSTED: "true" }, async () => {
|
||||||
const res = await request
|
const res = await request
|
||||||
.get(`/api/keys`)
|
.get(`/api/keys`)
|
||||||
.set(config.defaultHeaders())
|
.set(config.defaultHeaders())
|
||||||
|
@ -34,7 +34,7 @@ describe("/api/keys", () => {
|
||||||
|
|
||||||
describe("update", () => {
|
describe("update", () => {
|
||||||
it("should allow updating a value", async () => {
|
it("should allow updating a value", async () => {
|
||||||
await setup.switchToSelfHosted(async () => {
|
await config.withEnv({ SELF_HOSTED: "true" }, async () => {
|
||||||
const res = await request
|
const res = await request
|
||||||
.put(`/api/keys/TEST`)
|
.put(`/api/keys/TEST`)
|
||||||
.send({
|
.send({
|
||||||
|
|
|
@ -248,4 +248,13 @@ describe("/applications", () => {
|
||||||
expect(devLogs.data.length).toBe(0)
|
expect(devLogs.data.length).toBe(0)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe("permissions", () => {
|
||||||
|
it("should only return apps a user has access to", async () => {
|
||||||
|
const user = await config.createUser()
|
||||||
|
|
||||||
|
const apps = await config.api.application.fetch()
|
||||||
|
expect(apps.length).toBeGreaterThan(0)
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -157,7 +157,7 @@ describe("/queries", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should find a query in cloud", async () => {
|
it("should find a query in cloud", async () => {
|
||||||
await setup.switchToSelfHosted(async () => {
|
await config.withEnv({ SELF_HOSTED: "true" }, async () => {
|
||||||
const query = await config.createQuery()
|
const query = await config.createQuery()
|
||||||
const res = await request
|
const res = await request
|
||||||
.get(`/api/queries/${query._id}`)
|
.get(`/api/queries/${query._id}`)
|
||||||
|
|
|
@ -882,8 +882,7 @@ describe.each([
|
||||||
],
|
],
|
||||||
tableId: table._id,
|
tableId: table._id,
|
||||||
})
|
})
|
||||||
// the environment needs configured for this
|
await config.withEnv({ SELF_HOSTED: "true" }, async () => {
|
||||||
await setup.switchToSelfHosted(async () => {
|
|
||||||
return context.doInAppContext(config.getAppId(), async () => {
|
return context.doInAppContext(config.getAppId(), async () => {
|
||||||
const enriched = await outputProcessing(table, [row])
|
const enriched = await outputProcessing(table, [row])
|
||||||
expect((enriched as Row[])[0].attachment[0].url).toBe(
|
expect((enriched as Row[])[0].attachment[0].url).toBe(
|
||||||
|
|
|
@ -77,21 +77,3 @@ export function getConfig() {
|
||||||
}
|
}
|
||||||
return config!
|
return config!
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function switchToSelfHosted(func: any) {
|
|
||||||
// self hosted stops any attempts to Dynamo
|
|
||||||
env._set("NODE_ENV", "production")
|
|
||||||
env._set("SELF_HOSTED", true)
|
|
||||||
let error
|
|
||||||
try {
|
|
||||||
await func()
|
|
||||||
} catch (err) {
|
|
||||||
error = err
|
|
||||||
}
|
|
||||||
env._set("NODE_ENV", "jest")
|
|
||||||
env._set("SELF_HOSTED", false)
|
|
||||||
// don't throw error until after reset
|
|
||||||
if (error) {
|
|
||||||
throw error
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue