Skip to content

Commit

Permalink
- Clean up test external type imports
Browse files Browse the repository at this point in the history
- Remove unused tests
- Use matrix strategy to run test batches
  • Loading branch information
hardiesoft committed Oct 8, 2024
1 parent dd84533 commit 16d18eb
Show file tree
Hide file tree
Showing 108 changed files with 126 additions and 495 deletions.
60 changes: 8 additions & 52 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ jobs:
cd api && npm install --loglevel=error @typescript-eslint/parser @typescript-eslint/eslint-plugin github:TheCacophonyProject/apidoc-plugin-ts#v1.1.0 && npm run lint && cd ..
cd integration-tests && npm install --loglevel=error @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-plugin-cypress eslint-plugin-no-only-tests && npm run lint && cd ..
test-batch-1:
test:
runs-on: ubuntu-20.04

strategy:
matrix:
batch: [ci-batch-1, ci-batch-2]
services:
docker:
image: docker:19.03.12
Expand Down Expand Up @@ -79,58 +81,12 @@ jobs:
docker-compose exec server /app/api/node_modules/.bin/sequelize db:migrate --config /app/api/config/app_test_default.js --migrations-path /app/api/migrations
- name: Run Cypress tests
run: |
cd integration-tests
npm install --loglevel=error
npm run ci-batch-1
test-batch-2:
runs-on: ubuntu-20.04

services:
docker:
image: docker:19.03.12
options: --privileged
ports:
- 2375:2375
env:
DOCKER_TLS_CERTDIR: ""

env:
IS_CI_ENV: true

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Install Docker Compose
BATCH: ${{ matrix.batch }}
run: |
sudo curl -L "https://github.com/docker/compose/releases/download/v2.21.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version # Verify installation
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 18

- name: Set up Docker environment
run: |
docker-compose build
docker-compose up --force-recreate &> dockerstart.log &
node ./api/waitForApi.js || { docker ps; docker-compose logs; exit 1; }
- name: Run Cypress tests
run: |
cd integration-tests
cd integration-tests
npm install --loglevel=error
npm run ci-batch-2
npm run $BATCH
build:
if: startsWith(github.ref, 'refs/tags/')
Expand All @@ -147,7 +103,7 @@ jobs:
node-version: 18

- name: Install global npm packages
run: npm install -g --loglevel=error npm [email protected] eslint prettier
run: npm install -g --loglevel=error npm [email protected]

- name: Generate API docs
run: |
Expand Down
5 changes: 3 additions & 2 deletions browse-next/src/components/ImageUpload.worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ import * as webpEncoder from "@jsquash/webp/codec/enc/webp_enc";

import { defaultOptions } from "@jsquash/webp/meta";
import { initEmscriptenModule } from "@jsquash/webp/utils";
let emscriptenModule: never;
async function initWebpEncode(module: never) {
import type { WebPModule } from "../../public/webp-enc/webp_enc";
let emscriptenModule: Promise<WebPModule>;
async function initWebpEncode(module: WebAssembly.Module) {
if (supportsFastBuild()) {
emscriptenModule = initEmscriptenModule(webpEncoderFast.default, module);
return emscriptenModule;
Expand Down
8 changes: 8 additions & 0 deletions integration-tests/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,12 @@ module.exports = {
"no-only-tests/no-only-tests": ["warn"],
"cypress/no-assigning-return-values": ["off"],
},
overrides: [
{
files: ["./**/*.d.ts"],
rules: {
"no-undef": "off",
},
},
],
};
9 changes: 0 additions & 9 deletions integration-tests/cypress-performance.json.TEMPLATE

This file was deleted.

3 changes: 1 addition & 2 deletions integration-tests/cypress/browse/users/group.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/// <reference path="../../support/index.d.ts" />
import { getTestName } from "../../commands/names";
import { getTestName } from "@commands/names";

describe("Group Admin Pages", () => {
const Anna = "Anna";
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/cypress/browse/users/new_user_and_camera.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/// <reference path="../../support/index.d.ts" />
import { RecordingType } from "@typedefs/api/consts";

context("Users can see footage from their cameras", () => {
const username = "integration";
Expand Down Expand Up @@ -29,7 +29,7 @@ context("Users can see footage from their cameras", () => {

it("A camera can trigger and upload a new recording", () => {
cy.apiSignInAs(username);
cy.apiRecordingAdd(camera, {});
cy.apiRecordingAdd(camera, { type: RecordingType.ThermalRaw });
// for video to be uploaded
cy.wait(3 * 1000);
cy.testCheckDeviceHasRecordings(username, camera, 1);
Expand Down
2 changes: 0 additions & 2 deletions integration-tests/cypress/browse/users/registeruser.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/// <reference path="../../support/index.d.ts" />

context("Register as new user", () => {
const username = "new";

Expand Down
8 changes: 1 addition & 7 deletions integration-tests/cypress/commands/api/alerts.d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
/// <reference types="../types" />

declare namespace Cypress {
type ApiAlertCondition = import("@typedefs/api/alerts").ApiAlertCondition;
type AlertId = import("@typedefs/api/common").AlertId;
type ApiAlertResponse = import("@typedefs/api/alerts").ApiAlertResponse;
type StationIdAlias2 = import("@typedefs/api/common").StationId;
interface Chainable {
/**
* Create an alert for a device. Optioanlly expect to fail with code: failCode
Expand Down Expand Up @@ -49,7 +43,7 @@ declare namespace Cypress {
*/
apiStationAlertCheck(
userName: string,
stationId: StationIdAlias2,
stationId: StationId,
expectedAlert: any,
statusCode?: number
): Cypress.Chainable<ApiAlertResponse>;
Expand Down
3 changes: 0 additions & 3 deletions integration-tests/cypress/commands/api/alerts.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// load the global Cypress types
/// <reference types="cypress" />

import {
v1ApiPath,
getCreds,
Expand Down
4 changes: 0 additions & 4 deletions integration-tests/cypress/commands/api/authenticate.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
// load the global Cypress types
/// <reference types="cypress" />

declare namespace Cypress {
type ApiAuthenticateAccess = import("../types").ApiAuthenticateAccess;
interface Chainable {
/**
* Sign is as user using supplied username and session-unique suffix.
Expand Down
3 changes: 0 additions & 3 deletions integration-tests/cypress/commands/api/authenticate.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// load the global Cypress types
/// <reference types="cypress" />

import { ApiAuthenticateAccess } from "@commands/types";
import { getTestEmail, getTestName } from "../names";
import {
Expand Down
12 changes: 0 additions & 12 deletions integration-tests/cypress/commands/api/device.d.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
// load the global Cypress types
/// <reference types="cypress" />

declare namespace Cypress {
type ApiDeviceResponse = import("@typedefs/api/device").ApiDeviceResponse;
type LatLng = import("@typedefs/api/common").LatLng;
type ApiGroupsUserRelationshipResponse =
import("@typedefs/api/group").ApiGroupUserResponse;
type DeviceType = import("@typedefs/api/consts").DeviceType;
type DeviceHistoryEntry = import("@commands/types").DeviceHistoryEntry;
type DeviceId = import("@typedefs/api/common").DeviceId;
type ApiMaskRegionsData = import("@typedefs/api/device").ApiMaskRegionsData;

interface Chainable {
/**
* create a device in the given group
Expand Down
3 changes: 0 additions & 3 deletions integration-tests/cypress/commands/api/device.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/// <reference types="cypress" />

import { getTestName } from "../names";
import {
v1ApiPath,
Expand All @@ -10,7 +8,6 @@ import {
sortArrayOn,
checkTreeStructuresAreEqualExcept,
checkMessages,
makeAuthorizedRequest,
} from "../server";
import { logTestDescription, prettyLog } from "../descriptions";
import { ApiDevicesDevice, DeviceHistoryEntry, TestNameAndId } from "../types";
Expand Down
7 changes: 0 additions & 7 deletions integration-tests/cypress/commands/api/events.d.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
/// <reference types="cypress" />

declare namespace Cypress {
type TestComparablePowerEvent = import("../types").TestComparablePowerEvent;
type ApiEventDetail = import("../types").ApiEventDetail;
type ApiEventReturned = import("../types").ApiEventReturned;
type ApiEventErrorCategory = import("../types").ApiEventErrorCategory;
type ApiPowerEventReturned = import("../types").ApiPowerEventReturned;
interface Chainable {
/**
* Record a event for this device using device's credentials
Expand Down
3 changes: 0 additions & 3 deletions integration-tests/cypress/commands/api/events.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// load the global Cypress types
/// <reference types="cypress" />

import {
v1ApiPath,
getCreds,
Expand Down
9 changes: 1 addition & 8 deletions integration-tests/cypress/commands/api/group-station.d.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
// load the global Cypress types
/// <reference types="cypress" />
declare namespace Cypress {
// @ts-ignore
type ApiStationResponse = import("@typedefs/api/station").ApiStationResponse;
// @ts-ignore
type ApiStationData = import("../types").ApiStationData;
type StationIdAlias = import("@typedefs/api/common").StationId;
interface Chainable {
/**
* POST to api/v1/groups/<groupidorname>/station to add a single station
Expand All @@ -22,7 +15,7 @@ declare namespace Cypress {
untilDate?: string,
statusCode?: number,
additionalChecks?: any
): Cypress.Chainable<StationIdAlias>;
): Cypress.Chainable<StationId>;

/**
* Call api/v1/groups/<groupidorname>/station and check that returned values match expectedS tation
Expand Down
3 changes: 0 additions & 3 deletions integration-tests/cypress/commands/api/group-station.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// load the global Cypress types
/// <reference types="cypress" />

import { checkRecording } from "./recording-tests";
import { ApiStationData } from "../types";
import { ApiStationResponse } from "@typedefs/api/station";
Expand Down
13 changes: 0 additions & 13 deletions integration-tests/cypress/commands/api/group.d.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
// load the global Cypress types
/// <reference types="cypress" />
type ApiStationResponse = import("@typedefs/api/station").ApiStationResponse;
declare namespace Cypress {
type ApiGroupReturned = import("../types").ApiGroupReturned;
type ApiDeviceIdAndName = import("../types").ApiDeviceIdAndName;
type ApiGroupsDevice = import("../types").ApiGroupsDevice;
type ApiStationDataAlias = import("../types").ApiStationData;
type ApiStationDataReturned = import("../types").ApiStationDataReturned;
type ApiDeviceResponseAlias =
import("@typedefs/api/device").ApiDeviceResponse;
type ApiGroupUserRelationshipResponse =
import("@typedefs/api/group").ApiGroupUserResponse;

interface Chainable {
/**
* create a group for the given user (who has already been referenced in the test)
Expand Down
3 changes: 0 additions & 3 deletions integration-tests/cypress/commands/api/group.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// load the global Cypress types
/// <reference types="cypress" />

import { getTestEmail, getTestName } from "../names";
import { logTestDescription } from "../descriptions";

Expand Down
5 changes: 0 additions & 5 deletions integration-tests/cypress/commands/api/monitoring.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
// load the global Cypress types
/// <reference types="cypress" />

declare namespace Cypress {
type TestVisitSearchParams = import("../types").TestVisitSearchParams;
type TestComparableVisit = import("../types").TestComparableVisit;
interface Chainable {
/**
* check the visits returned match the listed visits specified. Only the specified information will be checked.
Expand Down
4 changes: 0 additions & 4 deletions integration-tests/cypress/commands/api/monitoring.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
// load the global Cypress types
/// <reference types="cypress" />
/// <reference types="../types" />

import { v1ApiPath, getCreds, convertToDate } from "../server";
import { logTestDescription, prettyLog } from "../descriptions";
import { stripBackName } from "../names";
Expand Down
5 changes: 0 additions & 5 deletions integration-tests/cypress/commands/api/recording-tag.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
/// <reference types="../types" />

declare namespace Cypress {
type ApiRecordingTagRequest =
import("@typedefs/api/tag").ApiRecordingTagRequest;

interface Chainable {
/**
* Add a tag to a recording.
Expand Down
3 changes: 0 additions & 3 deletions integration-tests/cypress/commands/api/recording-tag.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// load the global Cypress types
/// <reference types="cypress" />

import {
v1ApiPath,
getCreds,
Expand Down
8 changes: 0 additions & 8 deletions integration-tests/cypress/commands/api/recording-tests.d.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
// load the global Cypress types
/// <reference types="cypress" />

declare namespace Cypress {
// Avoiding redefinition in this namespace
type TestThermalRecordingInfoAlias =
import("../types").TestThermalRecordingInfo;
type RecordingIdAlias = import("@typedefs/api/common").RecordingId;

interface Chainable {
/**
* Upload a single recording to for a particular camera using pre-rolled test metadata
Expand Down
3 changes: 0 additions & 3 deletions integration-tests/cypress/commands/api/recording-tests.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// load the global Cypress types
/// <reference types="cypress" />

import { getTestName } from "../names";
import {
convertToDate,
Expand Down
20 changes: 0 additions & 20 deletions integration-tests/cypress/commands/api/recording.d.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,4 @@
// load the global Cypress types
/// <reference types="cypress" />

declare namespace Cypress {
type ApiRecordingSet = import("../types").ApiRecordingSet;
type ApiRecordingReturned = import("../types").ApiRecordingReturned;
type ApiRecordingColumns = import("../types").ApiRecordingColumns;
type ApiRecordingNeedsTagReturned =
import("../types").ApiRecordingNeedsTagReturned;
type ApiRecordingDataMetadata = import("../types").ApiRecordingDataMetadata;
type Interception = import("cypress/types/net-stubbing").Interception;
type ApiRecordingResponse =
import("@typedefs/api/recording").ApiRecordingResponse;
type TestThermalRecordingInfo = import("../types").TestThermalRecordingInfo;
type RecordingId = number;

type ApiAudioRecordingResponse =
import("@typedefs/api/recording").ApiAudioRecordingResponse;
type ApiThermalRecordingResponse =
import("@typedefs/api/recording").ApiThermalRecordingResponse;

interface Chainable {
/** Check the values returned by /api/fileProcessing (get)
* specify type and processingState (state)
Expand Down
Loading

0 comments on commit 16d18eb

Please sign in to comment.