migrate deleteRow from runStep to test builder
This commit is contained in:
parent
e8ade0caee
commit
b99d411cec
|
@ -1,52 +1,65 @@
|
|||
import { createAutomationBuilder } from "./utilities/AutomationTestBuilder"
|
||||
import * as setup from "./utilities"
|
||||
|
||||
describe("test the delete row action", () => {
|
||||
let table: any
|
||||
let row: any
|
||||
let inputs: any
|
||||
let config = setup.getConfig()
|
||||
let table: any,
|
||||
row: any,
|
||||
config = setup.getConfig()
|
||||
|
||||
beforeEach(async () => {
|
||||
beforeAll(async () => {
|
||||
await config.init()
|
||||
table = await config.createTable()
|
||||
row = await config.createRow()
|
||||
inputs = {
|
||||
tableId: table._id,
|
||||
id: row._id,
|
||||
revision: row._rev,
|
||||
}
|
||||
})
|
||||
|
||||
afterAll(setup.afterAll)
|
||||
|
||||
it("should be able to run the action", async () => {
|
||||
const res = await setup.runStep(
|
||||
config,
|
||||
setup.actions.DELETE_ROW.stepId,
|
||||
inputs
|
||||
)
|
||||
expect(res.success).toEqual(true)
|
||||
expect(res.response).toBeDefined()
|
||||
expect(res.row._id).toEqual(row._id)
|
||||
})
|
||||
it("should be able to run the delete row action", async () => {
|
||||
const builder = createAutomationBuilder({
|
||||
name: "Delete Row Automation",
|
||||
})
|
||||
|
||||
it("check usage quota attempts", async () => {
|
||||
await setup.runInProd(async () => {
|
||||
await setup.runStep(config, setup.actions.DELETE_ROW.stepId, inputs)
|
||||
await builder
|
||||
.appAction({ fields: {} })
|
||||
.deleteRow({
|
||||
tableId: table._id,
|
||||
id: row._id,
|
||||
revision: row._rev,
|
||||
})
|
||||
.run()
|
||||
|
||||
await config.api.row.get(table._id, row._id, {
|
||||
status: 404,
|
||||
})
|
||||
})
|
||||
|
||||
it("should check invalid inputs return an error", async () => {
|
||||
const res = await setup.runStep(config, setup.actions.DELETE_ROW.stepId, {})
|
||||
expect(res.success).toEqual(false)
|
||||
const builder = createAutomationBuilder({
|
||||
name: "Invalid Inputs Automation",
|
||||
})
|
||||
|
||||
const results = await builder
|
||||
.appAction({ fields: {} })
|
||||
.deleteRow({ tableId: "", id: "", revision: "" })
|
||||
.run()
|
||||
|
||||
expect(results.steps[0].outputs.success).toEqual(false)
|
||||
})
|
||||
|
||||
it("should return an error when table doesn't exist", async () => {
|
||||
const res = await setup.runStep(config, setup.actions.DELETE_ROW.stepId, {
|
||||
tableId: "invalid",
|
||||
id: "invalid",
|
||||
revision: "invalid",
|
||||
const builder = createAutomationBuilder({
|
||||
name: "Nonexistent Table Automation",
|
||||
})
|
||||
expect(res.success).toEqual(false)
|
||||
|
||||
const results = await builder
|
||||
.appAction({ fields: {} })
|
||||
.deleteRow({
|
||||
tableId: "invalid",
|
||||
id: "invalid",
|
||||
revision: "invalid",
|
||||
})
|
||||
.run()
|
||||
|
||||
expect(results.steps[0].outputs.success).toEqual(false)
|
||||
})
|
||||
})
|
||||
|
|
|
@ -15,7 +15,7 @@ import * as uuid from "uuid"
|
|||
|
||||
describe("test the update row action", () => {
|
||||
let table: Table,
|
||||
row: any,
|
||||
row: Row,
|
||||
config = setup.getConfig()
|
||||
|
||||
beforeAll(async () => {
|
||||
|
@ -34,7 +34,7 @@ describe("test the update row action", () => {
|
|||
const results = await builder
|
||||
.appAction({ fields: {} })
|
||||
.updateRow({
|
||||
rowId: row._id,
|
||||
rowId: row._id!,
|
||||
row: {
|
||||
...row,
|
||||
name: "Updated name",
|
||||
|
|
Loading…
Reference in New Issue