diff --git a/integration-tests/cypress/e2e/api/batch-1/devices/device_reregister.ts b/integration-tests/cypress/e2e/api/batch-1/devices/device_reregister.ts index 2d1a54ce..90d89eb1 100644 --- a/integration-tests/cypress/e2e/api/batch-1/devices/device_reregister.ts +++ b/integration-tests/cypress/e2e/api/batch-1/devices/device_reregister.ts @@ -2,7 +2,11 @@ import { NOT_NULL_STRING } from "@commands/constants"; import { getTestName } from "@commands/names"; import { getCreds } from "@commands/server"; import ApiDeviceResponse = Cypress.ApiDeviceResponse; -import { DeviceType, HttpStatusCode } from "@typedefs/api/consts"; +import { + DeviceType, + HttpStatusCode, + RecordingType, +} from "@typedefs/api/consts"; import { DeviceHistoryEntry } from "@commands/types"; import { TestCreateExpectedHistoryEntry } from "@commands/api/device"; @@ -38,6 +42,13 @@ describe("Device reregister", () => { groupId: getCreds("RR_group1").id, }; }); + cy.log("Add a recording so that old device isn't deleted when renamed"); + cy.apiRecordingAdd( + "RR_cam1", + { type: RecordingType.ThermalRaw }, + "oneframe.cptv", + "raRecording1" + ); //re-register camera & store device details cy.apiDeviceReregister("RR_cam1", "RR_cam1b", "RR_group1").then(() => { @@ -129,6 +140,14 @@ describe("Device reregister", () => { cy.log("create second group"); cy.testCreateUserAndGroup("RR_user2b", "RR_group2b"); + cy.log("Add a recording so that old device isn't deleted when renamed"); + cy.apiRecordingAdd( + "RR_cam2", + { type: RecordingType.ThermalRaw }, + "oneframe.cptv", + "raRecording1" + ); + cy.log("re-register camera to 2nd group & store device details"); cy.apiDeviceReregister("RR_cam2", "RR_cam2", "RR_group2b").then(() => { expectedDevice2b = { @@ -168,6 +187,14 @@ describe("Device reregister", () => { } ); + cy.log("Add a recording so that old device isn't deleted when renamed"); + cy.apiRecordingAdd( + "RR_cam3", + { type: RecordingType.ThermalRaw }, + "oneframe.cptv", + "raRecording1" + ); + cy.log("create second group"); cy.testCreateUserAndGroup("RR_user3b", "RR_group3b"); diff --git a/integration-tests/cypress/e2e/api/batch-1/devices/devices.ts b/integration-tests/cypress/e2e/api/batch-1/devices/devices.ts index 95551c72..af88ed6b 100644 --- a/integration-tests/cypress/e2e/api/batch-1/devices/devices.ts +++ b/integration-tests/cypress/e2e/api/batch-1/devices/devices.ts @@ -1,7 +1,7 @@ import { getTestName } from "@commands/names"; import { makeAuthorizedRequest, v1ApiPath, getCreds } from "@commands/server"; import ApiDeviceResponse = Cypress.ApiDeviceResponse; -import { DeviceType } from "@typedefs/api/consts"; +import { DeviceType, RecordingType } from "@typedefs/api/consts"; describe("Devices list", () => { const superuser = getCreds("superuser")["email"]; @@ -69,6 +69,12 @@ describe("Devices list", () => { //reregistered device cy.testCreateUserGroupAndDevice(user3, group3, camera3); + cy.log("Add a recording so that old device isn't deleted when renamed"); + cy.apiRecordingAdd( + camera3, + { type: RecordingType.ThermalRaw }, + "oneframe.cptv" + ); cy.apiDeviceReregister(camera3, camera4, group3).then(() => { expectedDevice3AdminView = { id: getCreds(camera3).id, diff --git a/integration-tests/cypress/e2e/api/batch-1/groups/groups_devices.ts b/integration-tests/cypress/e2e/api/batch-1/groups/groups_devices.ts index 01e1618b..7b56796b 100644 --- a/integration-tests/cypress/e2e/api/batch-1/groups/groups_devices.ts +++ b/integration-tests/cypress/e2e/api/batch-1/groups/groups_devices.ts @@ -3,7 +3,11 @@ import { getCreds } from "@commands/server"; import { NOT_NULL_STRING } from "@commands/constants"; import ApiDeviceResponse = Cypress.ApiDeviceResponse; -import { DeviceType, HttpStatusCode } from "@typedefs/api/consts"; +import { + DeviceType, + HttpStatusCode, + RecordingType, +} from "@typedefs/api/consts"; describe("Groups - get devices for group", () => { const NOT_ADMIN = false; @@ -126,6 +130,12 @@ describe("Groups - get devices for group", () => { }); cy.log("Reregister the camera, making the old camera inactive"); + cy.apiRecordingAdd( + "gdCam4a", + { type: RecordingType.ThermalRaw }, + "oneframe.cptv", + "raRecording1" + ); cy.apiDeviceReregister("gdCam4a", "gdCam4b", "gdGroup4").then(() => { expectedGroupDevice4b = { id: getCreds("gdCam4b").id, @@ -135,7 +145,7 @@ describe("Groups - get devices for group", () => { groupId: getCreds("gdGroup4").id, active: true, admin: true, - type: DeviceType.Unknown, + type: DeviceType.Thermal, lastConnectionTime: NOT_NULL_STRING, isHealthy: true, }; @@ -147,7 +157,7 @@ describe("Groups - get devices for group", () => { groupId: getCreds("gdGroup4").id, active: true, admin: true, - type: DeviceType.Unknown, + type: DeviceType.Thermal, lastConnectionTime: NOT_NULL_STRING, isHealthy: true, }; diff --git a/integration-tests/cypress/e2e/api/batch-2/recordings/recording_add_get_delete.ts b/integration-tests/cypress/e2e/api/batch-2/recordings/recording_add_get_delete.ts index 6c3960d5..a1e4c918 100644 --- a/integration-tests/cypress/e2e/api/batch-2/recordings/recording_add_get_delete.ts +++ b/integration-tests/cypress/e2e/api/batch-2/recordings/recording_add_get_delete.ts @@ -330,20 +330,88 @@ describe("Recordings (thermal): add, get, delete", () => { const recording1 = TestCreateRecordingData(templateRecording); let expectedRecording1: ApiThermalRecordingResponse; - cy.log("Rename/reregister device"); - cy.apiDeviceReregister("raCamera1", "raCamera1-renamed", "raGroup").then( - () => { + cy.log( + "Add a recording to device to be re-registered so that the old device is set inactive, not deleted" + ); + cy.apiRecordingAddOnBehalfUsingDevice( + "raGroupAdmin", + "raCamera1", + recording1, + "raRecording1" + ).then(() => { + cy.log("Rename/reregister device"); + cy.apiDeviceReregister("raCamera1", "raCamera1-renamed", "raGroup").then( + () => { + cy.log("Add recording as group member"); + cy.apiRecordingAddOnBehalfUsingDevice( + "raGroupAdmin", + "raCamera1", + recording1, + "raRecording1" + ).then(() => { + expectedRecording1 = TestCreateExpectedRecordingData( + templateExpectedRecording, + "raRecording1", + "raCamera1", + "raGroup", + null, + recording1 + ); + cy.log("Check recording can be viewed correctly"); + cy.apiRecordingCheck( + "raGroupMember", + "raRecording1", + expectedRecording1, + EXCLUDE_IDS + ); + }); + + cy.log("Delete recording"); + cy.apiRecordingDelete("raGroupMember", "raRecording1"); + + cy.log("Check recording no longer exists"); + cy.apiRecordingCheck( + "raGroupMember", + "raRecording1", + undefined, + [], + HttpStatusCode.Forbidden + ); + } + ); + }); + }); + + it("Group member can add recordings by device on behalf - for inactive device", () => { + // NOTE: This test requires the previous test to also pass. + const recording1 = TestCreateRecordingData(templateRecording); + let expectedRecording1: ApiThermalRecordingResponse; + cy.log( + "Add a recording to device to be re-registered so that the old device is set inactive, not deleted" + ); + cy.apiRecordingAddOnBehalfUsingDevice( + "raGroupAdmin", + "raCamera1-renamed", + recording1, + "raRecording1" + ).then(() => { + cy.log("Rename/reregister device"); + cy.apiDeviceReregister( + "raCamera1-renamed", + "raCamera1-renamed2", + "raGroup" + ).then(() => { cy.log("Add recording as group member"); cy.apiRecordingAddOnBehalfUsingDevice( - "raGroupAdmin", - "raCamera1", + "raGroupMember", + "raCamera1-renamed", recording1, "raRecording1" ).then(() => { expectedRecording1 = TestCreateExpectedRecordingData( templateExpectedRecording, "raRecording1", - "raCamera1", + "raCamera1-renamed", "raGroup", null, recording1 @@ -368,55 +436,7 @@ describe("Recordings (thermal): add, get, delete", () => { [], HttpStatusCode.Forbidden ); - } - ); - }); - - it("Group member can add recordings by device on behalf - for inactive device", () => { - // NOTE: This test requires the previous test to also pass. - const recording1 = TestCreateRecordingData(templateRecording); - let expectedRecording1: ApiThermalRecordingResponse; - cy.log("Rename/reregister device"); - cy.apiDeviceReregister( - "raCamera1-renamed", - "raCamera1-renamed2", - "raGroup" - ).then(() => { - cy.log("Add recording as group member"); - cy.apiRecordingAddOnBehalfUsingDevice( - "raGroupMember", - "raCamera1-renamed", - recording1, - "raRecording1" - ).then(() => { - expectedRecording1 = TestCreateExpectedRecordingData( - templateExpectedRecording, - "raRecording1", - "raCamera1-renamed", - "raGroup", - null, - recording1 - ); - cy.log("Check recording can be viewed correctly"); - cy.apiRecordingCheck( - "raGroupMember", - "raRecording1", - expectedRecording1, - EXCLUDE_IDS - ); }); - - cy.log("Delete recording"); - cy.apiRecordingDelete("raGroupMember", "raRecording1"); - - cy.log("Check recording no longer exists"); - cy.apiRecordingCheck( - "raGroupMember", - "raRecording1", - undefined, - [], - HttpStatusCode.Forbidden - ); }); });