Skip to content

Commit

Permalink
test(video): add record video option
Browse files Browse the repository at this point in the history
  • Loading branch information
j-mendez committed Sep 21, 2023
1 parent c4beff5 commit 502cf2d
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 10 deletions.
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ COPY . .

RUN cargo install --no-default-features --path .

FROM node:20.2-alpine3.17 AS BUILD_IMAGE
FROM node:20.6.1-alpine3.17 AS BUILD_IMAGE

ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD="true"

Expand All @@ -27,11 +27,13 @@ RUN rm -R ./node_modules
RUN npm install --production

# final image
FROM node:20.2-alpine3.17
FROM node:20.6.1-alpine3.17

RUN apk upgrade --update-cache --available && \
apk add openssl

RUN npx playwright install ffmpeg

ENV GRPC_HOST_MAV="mav:50053" \
NODE_ENV=production

Expand Down
4 changes: 3 additions & 1 deletion Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ COPY . .

RUN cargo install --no-default-features --path .

FROM node:20.2-alpine3.17
FROM node:20.6.1-alpine3.17

ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD="true" \
NODE_ENV="development" \
Expand All @@ -22,6 +22,8 @@ ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD="true" \
RUN apk upgrade --update-cache --available && \
apk add openssl

RUN npx playwright install ffmpeg

WORKDIR /usr/src/app

COPY package*.json ./
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ In order to enable firefox use the `FIREFOX_ENABLED` env var. You also need to r
AI_DISABLED=false
CHROME_LB=
FIREFOX_ENABLED=false
PAGEMIND_RECORD=true
```

## Healthcheck
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@a11ywatch/pagemind",
"version": "0.9.43",
"version": "0.9.44",
"description": "Get metrics on your web page with inclusion",
"main": "./server.js",
"author": "Jeff Mendez",
Expand Down
18 changes: 14 additions & 4 deletions src/core/controllers/audit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ import { getWsEndPoint } from "../../config";
// manage shared connections
const sharedContext = new Map<string, { ctx: BrowserContext; size: number }>();

// record the video
const RECORD = process.env.PAGEMIND_RECORD;
const RECORDING_BASE_DIR = RECORD === "true" ? "./recordings" : RECORD;

// get the shared contextID
const getSharedContextID = (
params: Partial<ScanRpcParams> & { domain?: string }
Expand Down Expand Up @@ -74,6 +78,12 @@ export const auditWebsite = async (params, retry?: boolean) => {
{}
)
: undefined,
recordVideo:
RECORD && RECORD !== "false"
? {
dir: `${RECORDING_BASE_DIR}/${sharedContextID}`,
}
: undefined,
});

// set the initial context
Expand Down Expand Up @@ -172,11 +182,11 @@ export const auditWebsite = async (params, retry?: boolean) => {

if (context) {
try {
await page.close()
} catch(e) {
console.error(e)
await page.close();
} catch (e) {
console.error(e);
}

context.size--;

// if context is empty cleanup
Expand Down

0 comments on commit 502cf2d

Please sign in to comment.