Fixing issues with automation test cases running steps outside of a tenant.
This commit is contained in:
parent
ca7d532443
commit
3258aead45
2 changed files with 57 additions and 51 deletions
|
@ -43,53 +43,55 @@ describe("run misc tests", () => {
|
||||||
|
|
||||||
describe("test table utilities", () => {
|
describe("test table utilities", () => {
|
||||||
it("should be able to import a CSV", async () => {
|
it("should be able to import a CSV", async () => {
|
||||||
const table = await config.createTable({
|
return config.doInContext(null, async () => {
|
||||||
name: "table",
|
const table = await config.createTable({
|
||||||
type: "table",
|
name: "table",
|
||||||
key: "name",
|
type: "table",
|
||||||
schema: {
|
key: "name",
|
||||||
a: {
|
schema: {
|
||||||
type: "string",
|
a: {
|
||||||
constraints: {
|
|
||||||
type: "string",
|
type: "string",
|
||||||
|
constraints: {
|
||||||
|
type: "string",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
b: {
|
||||||
|
type: "string",
|
||||||
|
constraints: {
|
||||||
|
type: "string",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
c: {
|
||||||
|
type: "string",
|
||||||
|
constraints: {
|
||||||
|
type: "string",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
d: {
|
||||||
|
type: "string",
|
||||||
|
constraints: {
|
||||||
|
type: "string",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
b: {
|
})
|
||||||
type: "string",
|
const dataImport = {
|
||||||
constraints: {
|
csvString: "a,b,c,d\n1,2,3,4",
|
||||||
type: "string",
|
schema: {},
|
||||||
},
|
}
|
||||||
},
|
for (let col of ["a", "b", "c", "d"]) {
|
||||||
c: {
|
dataImport.schema[col] = { type: "string" }
|
||||||
type: "string",
|
}
|
||||||
constraints: {
|
await tableUtils.handleDataImport(
|
||||||
type: "string",
|
{ userId: "test" },
|
||||||
},
|
table,
|
||||||
},
|
dataImport
|
||||||
d: {
|
)
|
||||||
type: "string",
|
const rows = await config.getRows()
|
||||||
constraints: {
|
expect(rows[0].a).toEqual("1")
|
||||||
type: "string",
|
expect(rows[0].b).toEqual("2")
|
||||||
},
|
expect(rows[0].c).toEqual("3")
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
const dataImport = {
|
|
||||||
csvString: "a,b,c,d\n1,2,3,4",
|
|
||||||
schema: {},
|
|
||||||
}
|
|
||||||
for (let col of ["a", "b", "c", "d"]) {
|
|
||||||
dataImport.schema[col] = { type: "string" }
|
|
||||||
}
|
|
||||||
await tableUtils.handleDataImport(
|
|
||||||
{ userId: "test" },
|
|
||||||
table,
|
|
||||||
dataImport
|
|
||||||
)
|
|
||||||
const rows = await config.getRows()
|
|
||||||
expect(rows[0].a).toEqual("1")
|
|
||||||
expect(rows[0].b).toEqual("2")
|
|
||||||
expect(rows[0].c).toEqual("3")
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
|
@ -1,4 +1,6 @@
|
||||||
const TestConfig = require("../../../tests/utilities/TestConfiguration")
|
const TestConfig = require("../../../tests/utilities/TestConfiguration")
|
||||||
|
const { TENANT_ID } = require("../../../tests/utilities/structures")
|
||||||
|
const { doInTenant } = require("@budibase/backend-core/tenancy")
|
||||||
const actions = require("../../actions")
|
const actions = require("../../actions")
|
||||||
const emitter = require("../../../events/index")
|
const emitter = require("../../../events/index")
|
||||||
const env = require("../../../environment")
|
const env = require("../../../environment")
|
||||||
|
@ -31,14 +33,16 @@ exports.runInProd = async fn => {
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.runStep = async function runStep(stepId, inputs) {
|
exports.runStep = async function runStep(stepId, inputs) {
|
||||||
let step = await actions.getAction(stepId)
|
return doInTenant(TENANT_ID, async () => {
|
||||||
expect(step).toBeDefined()
|
let step = await actions.getAction(stepId)
|
||||||
return step({
|
expect(step).toBeDefined()
|
||||||
inputs,
|
return step({
|
||||||
appId: config ? config.getAppId() : null,
|
inputs,
|
||||||
// don't really need an API key, mocked out usage quota, not being tested here
|
appId: config ? config.getAppId() : null,
|
||||||
apiKey: exports.apiKey,
|
// don't really need an API key, mocked out usage quota, not being tested here
|
||||||
emitter,
|
apiKey: exports.apiKey,
|
||||||
|
emitter,
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue