Adding to test case to retry looking for entries out of the triggered workflow in the case of slow machines.

This commit is contained in:
mike12345567 2020-09-22 09:13:19 +01:00
parent 1a1d09862a
commit cc35099ebd
1 changed files with 13 additions and 5 deletions

View File

@ -13,6 +13,7 @@ const {
const { delay } = require("./testUtils") const { delay } = require("./testUtils")
const MAX_RETRIES = 4
const TEST_WORKFLOW = { const TEST_WORKFLOW = {
_id: "Test Workflow", _id: "Test Workflow",
name: "My Workflow", name: "My Workflow",
@ -168,11 +169,18 @@ describe("/workflows", () => {
expect(res.body.message).toEqual(`Workflow ${workflow._id} has been triggered.`) expect(res.body.message).toEqual(`Workflow ${workflow._id} has been triggered.`)
expect(res.body.workflow.name).toEqual(TEST_WORKFLOW.name) expect(res.body.workflow.name).toEqual(TEST_WORKFLOW.name)
// wait for workflow to complete in background // wait for workflow to complete in background
await delay(500) for (let tries = 0; tries < MAX_RETRIES; tries++) {
let elements = await getAllFromModel(request, app._id, instance._id, model._id) await delay(500)
expect(elements.length).toEqual(1) let elements = await getAllFromModel(request, app._id, instance._id, model._id)
expect(elements[0].name).toEqual("Test") // don't test it unless there are values to test
expect(elements[0].description).toEqual("TEST") if (elements.length === 1) {
expect(elements.length).toEqual(1)
expect(elements[0].name).toEqual("Test")
expect(elements[0].description).toEqual("TEST")
return
}
}
throw "Failed to find the records"
}) })
}) })