Skip to content
This repository has been archived by the owner on Aug 9, 2021. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/mattb-cypress-test-updates' into…
Browse files Browse the repository at this point in the history
… monitoring
  • Loading branch information
Clare McLennan committed May 17, 2021
2 parents 018d4be + 6666a18 commit b6c272f
Show file tree
Hide file tree
Showing 5 changed files with 3,377 additions and 19 deletions.
127 changes: 127 additions & 0 deletions test-cypress/cypress/integration/recordings/monitoring_performance.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
/// <reference path="../../support/index.d.ts" />

import { addSeconds } from "../../commands/api/recording";

describe("Monitoring : times and recording groupings", () => {
const Dexter = "Dexter";
const group = "Monitoring_visits";
const max_page_length=100

before(() => {
cy.apiCreateUserGroup(Dexter, group);
});

it("can handle maximum number of visits per page", () => {
const camera = "visits-per-page";
var visits=[]
// add 1000 recordings
cy.apiCreateCamera(camera, group);
cy.uploadRecording(camera, { time: "20:55", duration: 10 });
for (let i = 0; i < (max_page_length*10)-1; i++) {
cy.uploadRecording(camera, { minsLater: 11 });
};

for (let i = 0; i < max_page_length; i++) {
visits.push({ recordings: 1});
};

const filter = {"page-size": max_page_length, page: 1};
// check first page
var t1=performance.now();
cy.checkMonitoringWithFilter(Dexter, camera, filter, visits);
var t2=performance.now();
cy.log(`Page 1 load duration: ${(t2-t1)} ms`);
// check last page
const filter10 = {"page-size": max_page_length, page: 10};
cy.checkMonitoringWithFilter(Dexter, camera, filter10, visits);
var t3=performance.now();
cy.log(`Page 10 load duration: ${(t3-t2)} ms`);
// check nothing beyond last page
const filter11 = {"page-size": max_page_length, page: 11};
cy.checkMonitoringWithFilter(Dexter, camera, filter11, []);
var t4=performance.now();
cy.log(`Page 11 load duration: ${(t4-t3)} ms`);

});

it("applies max page length by default", () => {
const camera = "default_page_size";
var visits=[]
// add 1 page plus 1 worth of recordings
cy.apiCreateCamera(camera, group);
cy.uploadRecording(camera, { time: "20:55", duration: 10 });
for (let i = 0; i < max_page_length; i++) {
cy.uploadRecording(camera, { minsLater: 11 });
};

// expected visits on 1st page is array of max_page_length of visits
for (let i = 0; i < max_page_length; i++) {
visits.push({ recordings: 1});
};

var visits2=[{recordings: 1}];

//check first page
const filter = {"page-size": max_page_length, page: 1};
cy.checkMonitoringWithFilter(Dexter, camera, filter, visits);
//check second page
const filter2 = {"page-size": max_page_length, page: 2};
cy.checkMonitoringWithFilter(Dexter, camera, filter2, visits2);

});


it("can handle large number of recordings per visit", () => {
const camera = "recordings-per-visit";
var visits=[]
// add 1000 recordings
cy.apiCreateCamera(camera, group);
cy.uploadRecording(camera, { time: "20:55", duration: 10 });
for (let i = 0; i < 999; i++) {
cy.uploadRecording(camera, { minsLater: 9 });
};

var visits=[{ recordings: 1000}];

const filter = {page: 1};
var t1=performance.now()
cy.checkMonitoringWithFilter(Dexter, camera, filter, visits);
var t2=performance.now();
cy.log(`Page 1 load duration: ${(t2-t1)} ms`);

});

it("can handle large number of pages", () => {
const camera = "pages";
var visits=[]
// add 1000 recordings
cy.apiCreateCamera(camera, group);
cy.uploadRecording(camera, { time: "20:55", duration: 10 });
for (let i = 0; i < 999; i++) {
cy.uploadRecording(camera, { minsLater: 11 });
};

var visits=[{ recordings: 1}];

//check first page
const filter1 = {"page-size": 1, page: 1};
var t1=performance.now();
cy.checkMonitoringWithFilter(Dexter, camera, filter1, visits);
var t2=performance.now();
cy.log(`Page 1 load duration: ${(t2-t1)} ms`);

//check last page
const filter1000 = {"page-size": 1, page: 1000};
cy.checkMonitoringWithFilter(Dexter, camera, filter1000, visits);
var t3=performance.now();
cy.log(`Page 1000 load duration: ${(t3-t2)} ms`);


//check nothing beyond last page
const filter1001 = {"page-size": 1, page: 1001};
cy.checkMonitoringWithFilter(Dexter, camera, filter1001, []);
});

});


16 changes: 16 additions & 0 deletions test-cypress/cypress/integration/recordings/monitoring_tags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,20 @@ describe("Monitoring : tracks and tags", () => {
});
cy.checkMonitoringTags(Damian, camera, ["conflicting tags"]);
});
it("User tags conflict on one of many tracks majority wins", () => {
const camera = "conflicter-multiple";
cy.apiCreateCamera(camera, group);
const recording = cy.uploadRecording(camera, {
tags: ["possum", "rabbit"]
});
recording.then((recID: number) => {
cy.userTagRecording(recID, 0, Damian, "possum");
cy.userTagRecording(recID, 0, Gerry, "rat");
});
cy.uploadRecording(camera, { tags: ["possum", "rat"] }).thenUserTagAs(Damian, "possum");
cy.uploadRecording(camera, { tags: ["cat"] }).thenUserTagAs(Damian, "possum");

cy.checkMonitoringTags(Damian, camera, ["possum"]);
});

});
74 changes: 72 additions & 2 deletions test-cypress/cypress/integration/recordings/monitoring_times.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,40 @@ describe("Monitoring : times and recording groupings", () => {
cy.uploadRecordingsAtTimes(camera, ["21:04", "21:15"]);
cy.checkMonitoring(Dexter, camera, [{ recordings: 1 }, { recordings: 1 }]);
});


it("recordings exactly 10 mins apart end to start are different visits", () => {
const camera = "cam-exactly-10-apart";
cy.apiCreateCamera(camera, group);
cy.uploadRecording(camera, { duration: 60 });
cy.uploadRecording(camera, { minsLater: 11 });
cy.checkMonitoring(Dexter, camera, [{ recordings: 1 }, { recordings: 1 }]);
});

it("recordings can start more than 10 mins apart so long as gap between one finishing and the next starting is less than 10 mins", () => {
const camera = "cam-just-close";
cy.apiCreateCamera(camera, group);
cy.uploadRecording(camera, { duration: 90 });
cy.uploadRecording(camera, { duration: 61 });
cy.uploadRecording(camera, { minsLater: 11 });
cy.checkMonitoring(Dexter, camera, [{ recordings: 2 }]);
});

// This feature has been disabled by Clare
// it("recordings with no tracks are not visits", () => {
// const camera = "cam-notracks";
// cy.apiCreateCamera(camera, group);
// cy.uploadRecording(camera, { tracks:[]});
// cy.checkMonitoring(Dexter, camera, []);
// });

// it("recordings with no tracks are not included in visits the fall within", () => {
// const camera = "cam-notracks-within-visit-timespan";
// cy.apiCreateCamera(camera, group);
// cy.uploadRecording(camera, { });
// cy.uploadRecording(camera, { minsLater: 5, tracks:[]});
// cy.uploadRecording(camera, { minsLater: 10});
// cy.checkMonitoring(Dexter, camera, [{ recordings: 2 }]);
// });

it("Visits where the first recording is before the start time, but overlap with search period are marked as incomplete", () => {
const camera = "cam-start-before";
cy.apiCreateCamera(camera, group);
Expand Down Expand Up @@ -59,6 +84,51 @@ describe("Monitoring : times and recording groupings", () => {
cy.checkMonitoringWithFilter(Dexter, camera, filter, [{ start:"21:22" }]);
});

//bounday cases

it("Visits where the last recording starts on period start time boundary is not included.", () => {
const camera = "cam-start-boundary-case";
cy.apiCreateCamera(camera, group);
cy.uploadRecording(camera, { time: "20:40" });
cy.uploadRecording(camera, { time: "20:50" });
cy.uploadRecording(camera, { time: "21:00" });

const filter = {
from: "21:00"
};

cy.checkMonitoringWithFilter(Dexter, camera, filter, []);
});


it("Visits where the last recording ends on period end time boundary is included and complete.", () => {
const camera = "cam-end-boundary-case";
cy.apiCreateCamera(camera, group);
cy.uploadRecording(camera, { time: "20:40" });
cy.uploadRecording(camera, { time: "20:50" });
cy.uploadRecording(camera, { time: "21:00" });

const filter = {
until: "21:00"
};


cy.checkMonitoringWithFilter(Dexter, camera, filter, [{ recordings: 3, start:"20:40", incomplete: "false" }]);
});

it("Visits which span the end-time but fall withing the collection window are included and marked as complete", () => {
const camera = "cam-start-justbefore";
cy.apiCreateCamera(camera, group);
cy.uploadRecording(camera, { time: "20:59", duration: 300 });
cy.uploadRecording(camera, { time: "21:05" });

const filter = {
until: "21:00"
};

cy.checkMonitoringWithFilter(Dexter, camera, filter, [{recordings: 2, start: "20:59", incomplete: "false"}]);
});

it("Visits where the first recording is after the end time are ignored", () => {
const camera = "cam-start-after";
cy.apiCreateCamera(camera, group);
Expand Down
3 changes: 2 additions & 1 deletion test-cypress/cypress/integration/recordings/visit_tags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,5 @@ describe("Visits : tracks and tags", () => {
});
cy.checkVisitTags(Dee, camera, ["conflicting tags"]);
});
});

});
Loading

0 comments on commit b6c272f

Please sign in to comment.