Skip to content

Commit 68f8045

Browse files
committed
test(e2e): ensure model is present in DB
1 parent 51de6e1 commit 68f8045

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

devices/getModelForDevice.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ export const getModelForDevice =
2727
}),
2828
)
2929

30-
const model = Items?.[0] !== undefined && unmarshall(Items[0]).model
30+
const model =
31+
Items?.[0] !== undefined ? unmarshall(Items[0]).model : undefined
3132

3233
if (model === undefined)
3334
return {

feature-runner/steps/device.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import path from 'node:path'
1414
import { setTimeout } from 'node:timers/promises'
1515
import pRetry from 'p-retry'
1616
import { getDevice as getDeviceFromIndex } from '../../devices/getDevice.js'
17+
import { getModelForDevice } from '../../devices/getModelForDevice.js'
1718
import { registerDevice } from '../../devices/registerDevice.js'
1819
import type { Settings } from '../../nrfcloud/settings.js'
1920
import type { World } from '../run-features.js'
@@ -62,6 +63,22 @@ const createDevice =
6263
},
6364
)
6465

66+
await pRetry(
67+
async () => {
68+
const res = await getModelForDevice({
69+
db,
70+
DevicesTableName: devicesTable,
71+
})(id)
72+
if ('error' in res)
73+
throw new Error(`Failed to get model for device ${id}!`)
74+
},
75+
{
76+
retries: 5,
77+
minTimeout: 500,
78+
maxTimeout: 1000,
79+
},
80+
)
81+
6582
progress(`Device registered: ${id}`)
6683
}
6784
const getDevice =

0 commit comments

Comments
 (0)