diff --git a/src/mapeo-manager.js b/src/mapeo-manager.js index 544deffb..c15f5fc1 100644 --- a/src/mapeo-manager.js +++ b/src/mapeo-manager.js @@ -678,7 +678,7 @@ export class MapeoManager extends TypedEmitter { } /** - * @returns {Promise>} + * @returns {Promise<{ deviceId: string } & Partial>} */ async getDeviceInfo() { const row = this.#db @@ -686,7 +686,7 @@ export class MapeoManager extends TypedEmitter { .from(localDeviceInfoTable) .where(eq(localDeviceInfoTable.deviceId, this.#deviceId)) .get() - return row ? row.deviceInfo : {} + return { deviceId: this.#deviceId, ...row?.deviceInfo } } /** diff --git a/test-e2e/device-info.js b/test-e2e/device-info.js index ec0781cc..7e289788 100644 --- a/test-e2e/device-info.js +++ b/test-e2e/device-info.js @@ -26,11 +26,13 @@ test('write and read deviceInfo', async (t) => { const info1 = { name: 'my device' } await manager.setDeviceInfo(info1) const readInfo1 = await manager.getDeviceInfo() - t.alike(readInfo1, info1) + const expected1 = { ...info1, deviceId: manager.deviceId } + t.alike(readInfo1, expected1) const info2 = { name: 'new name' } await manager.setDeviceInfo(info2) const readInfo2 = await manager.getDeviceInfo() - t.alike(readInfo2, info2) + const expected2 = { ...info2, deviceId: manager.deviceId } + t.alike(readInfo2, expected2) }) test('device info written to projects', (t) => {