pr comments
This commit is contained in:
parent
c89cebbece
commit
44702bbfb6
packages/server/src/automations/tests/scenarios
|
@ -299,9 +299,7 @@ describe("Loop automations", () => {
|
||||||
{ name: "Row 3", value: 3, tableId: table._id },
|
{ name: "Row 3", value: 3, tableId: table._id },
|
||||||
]
|
]
|
||||||
|
|
||||||
for (const row of rows) {
|
await config.api.row.bulkImport(table._id!, { rows })
|
||||||
await config.createRow(row)
|
|
||||||
}
|
|
||||||
|
|
||||||
const builder = createAutomationBuilder({
|
const builder = createAutomationBuilder({
|
||||||
name: "Test Loop and Update Row",
|
name: "Test Loop and Update Row",
|
||||||
|
@ -385,9 +383,7 @@ describe("Loop automations", () => {
|
||||||
{ name: "Row 3", value: 3, tableId: table._id },
|
{ name: "Row 3", value: 3, tableId: table._id },
|
||||||
]
|
]
|
||||||
|
|
||||||
for (const row of rows) {
|
await config.api.row.bulkImport(table._id!, { rows })
|
||||||
await config.createRow(row)
|
|
||||||
}
|
|
||||||
|
|
||||||
const builder = createAutomationBuilder({
|
const builder = createAutomationBuilder({
|
||||||
name: "Test Loop and Delete Row",
|
name: "Test Loop and Delete Row",
|
||||||
|
|
|
@ -444,43 +444,48 @@ describe("Automation Scenarios", () => {
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
testCases.forEach(({ condition, value, rowValue, expectPass }) => {
|
it.each(testCases)(
|
||||||
it(`should ${
|
"should pass the filter when condition is %s",
|
||||||
expectPass ? "pass" : "fail"
|
async ({ condition, value, rowValue, expectPass }) => {
|
||||||
} the filter when condition is "${condition}" and value is ${value}`, async () => {
|
it(`should ${
|
||||||
const builder = createAutomationBuilder({
|
expectPass ? "pass" : "fail"
|
||||||
name: `Test ${condition}`,
|
} the filter when condition is "${condition}" and value is ${value}`, async () => {
|
||||||
|
const builder = createAutomationBuilder({
|
||||||
|
name: `Test ${condition}`,
|
||||||
|
})
|
||||||
|
|
||||||
|
const results = await builder
|
||||||
|
.appAction({ fields: {} })
|
||||||
|
.createRow({
|
||||||
|
row: {
|
||||||
|
name: `${condition} Test`,
|
||||||
|
value: rowValue,
|
||||||
|
tableId: table._id,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.queryRows({
|
||||||
|
tableId: table._id!,
|
||||||
|
})
|
||||||
|
.filter({
|
||||||
|
field: "{{ steps.2.rows.0.value }}",
|
||||||
|
condition,
|
||||||
|
value,
|
||||||
|
})
|
||||||
|
.serverLog({
|
||||||
|
text: `${condition} condition ${
|
||||||
|
expectPass ? "passed" : "failed"
|
||||||
|
}`,
|
||||||
|
})
|
||||||
|
.run()
|
||||||
|
|
||||||
|
expect(results.steps[2].outputs.result).toBe(expectPass)
|
||||||
|
if (expectPass) {
|
||||||
|
expect(results.steps[3].outputs.success).toBeTrue()
|
||||||
|
} else {
|
||||||
|
expect(results.steps[3]).toBeUndefined()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
}
|
||||||
const results = await builder
|
)
|
||||||
.appAction({ fields: {} })
|
|
||||||
.createRow({
|
|
||||||
row: {
|
|
||||||
name: `${condition} Test`,
|
|
||||||
value: rowValue,
|
|
||||||
tableId: table._id,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.queryRows({
|
|
||||||
tableId: table._id!,
|
|
||||||
})
|
|
||||||
.filter({
|
|
||||||
field: "{{ steps.2.rows.0.value }}",
|
|
||||||
condition,
|
|
||||||
value,
|
|
||||||
})
|
|
||||||
.serverLog({
|
|
||||||
text: `${condition} condition ${expectPass ? "passed" : "failed"}`,
|
|
||||||
})
|
|
||||||
.run()
|
|
||||||
|
|
||||||
expect(results.steps[2].outputs.result).toBe(expectPass)
|
|
||||||
if (expectPass) {
|
|
||||||
expect(results.steps[3].outputs.success).toBeTrue()
|
|
||||||
} else {
|
|
||||||
expect(results.steps[3]).toBeUndefined()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue