Skip to content
This repository has been archived by the owner on Dec 30, 2024. It is now read-only.

Commit

Permalink
Merge branch 'testing'
Browse files Browse the repository at this point in the history
  • Loading branch information
electroly committed Feb 16, 2024
2 parents 396d1ca + cf645f2 commit c25c6bc
Show file tree
Hide file tree
Showing 46 changed files with 1,573 additions and 999 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ node_modules
dist
dist-firefox
artifacts
results
seccomp_profile.json
40 changes: 40 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Playwright Tests
on:
push:
branches:
- master

jobs:
playwright:
name: "Playwright Tests"
if: false # disable for now
runs-on: ubuntu-latest
container:
# make sure to match this version to what's in package.json
image: mcr.microsoft.com/playwright:v1.40.1-jammy
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
with:
version: 8.15.1
- uses: actions/setup-node@v4
with:
node-version: 21
cache: 'pnpm'
- name: Install project dependencies
run: pnpm install
- name: Install test dependencies
run: pnpm test:deps
- name: Build in prod mode
run: pnpm build
- name: Run the test suite against Chromium
run: pnpm test
env:
HOME: /root
CI: true
E2E_SHACKLI: ${{ secrets.E2E_SHACKLI }}
- name: Upload test report
uses: actions/upload-artifact@v2
with:
name: test-report
path: results/*
11 changes: 1 addition & 10 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@
.idea*
node_modules
coverage-ts
dist
dist-chrome
dist-firefox
artifacts
# make sure to use --id option when signing!
.web-extension-id
Session.vim
dist.crx
dist.pem
tsconfig.tsbuildinfo
mochawesome-report
/cypress/screenshots/
/cypress/fixtures/_shack_li_.txt
debug.log
.DS_Store
.envrc
.env
.direnv
/test-results/
/playwright-report/
/playwright/.cache/
results
_shack_li_.json
11 changes: 6 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,23 @@ If you're interested in contributing a new content script or feature suggestion:
- The WinChatty notifications' `processNotifyEvent` exposes the latest event message retrieved from the server (see: [WinChatty API](http://winchatty.com/v2/readme)).
- Content scripts have to be registered in `content.ts`. Make sure to put event-dependent handlers **_before_** the `ChromeShack.install()` line.

## Running integration tests
## Running integration tests locally

The E2E integration test suite requires a login cookie fixture in order to run all tests successfully. To setup the local testing environment do the following:
The E2E integration test suite requires a valid Shacknews login cookie fixture loaded into the environment var `E2E_SHACKLI` in order to run all tests successfully. This variable can be loaded from a `.env` file placed in the project root or exported from your shell. To setup the local testing environment and generate the fixture from scratch do the following:

- If you haven't already, make sure to do: `pnpm install`
- **STRONGLY RECOMMENDED**: Use the included `test.sh` in the project root to leverage Docker/Podman for containerized testing!
- Make sure you're running on a supported OS version, see [this doc](https://playwright.dev/docs/intro#system-requirements) for details. Typically Windows, MacOS, or an LTS version of Ubuntu are supported.
- Verify that Cypress and Chrome are installed and can run: `pnpm exec playwright install --with-deps chromium`
- Verify that Playwright and Chromium are installed with: `pnpm test:deps`
- Put your test credentials in an `.env` file in the project root in the following format:

```text
TESTUSR=username
TESTPW=password
```

- Create the login cookie fixture: `pnpm generate-cookie`
- Run the test suite (NOTE: this can take significant machine resources): `pnpm test`
- Authenticate your credentials and create the login cookie fixture in `.env`: `pnpm testlogin`
- Run the test suite (NOTE: this can take significant machine resources): `pnpm build && pnpm test` or `./test.sh` in the project root.

## Release procedure

Expand Down
20 changes: 20 additions & 0 deletions Dockerfile.e2etest
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Pull the base image
FROM mcr.microsoft.com/playwright:v1.40.1-jammy

ARG SCOOKIE
ARG CI

ENV CI=$CI
ENV E2E_SHACKLI=$SCOOKIE
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable

WORKDIR /code/
COPY . /code/

RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
RUN pnpm test:deps
RUN pnpm build

CMD ["/bin/bash"]
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ NOTE: See the `ThirdPartyLicenses.txt` in the `public/` folder that is generated

- [Preact](https://github.com/preactjs/preact)
- [Embla](https://github.com/davidcetinkaya/embla-carousel)
- [jQuery](https://github.com/jquery/jquery)
- [DOMPurify](https://github.com/cure53/DOMPurify)
- [ts-debounce](https://github.com/chodorowicz/ts-debounce)
- [react-fontawesome](https://github.com/FortAwesome/react-fontawesome)
Expand Down
2 changes: 1 addition & 1 deletion biome.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://biomejs.dev/schemas/1.4.1/schema.json",
"files": {
"ignore": ["node_modules", "dist", "dist-firefox"]
"ignore": ["node_modules", "dist", "dist-firefox", "results"]
},
"organizeImports": {
"enabled": true
Expand Down
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chromeshack",
"version": "1.75.0",
"version": "1.76.0",
"description": "Collection of scripts for Shacknews.",
"repository": "https://github.com/latestchatty/chromeshack",
"type": "module",
Expand All @@ -13,14 +13,15 @@
"build:popup": "vite build --config vite.popup.config.ts",
"build:permissions": "vite build --config vite.permissions.config.ts",
"build:js": "run-p build:serviceWorker build:content build:popup build:permissions",
"clean": "rm -rf dist-firefox/* dist/* artifacts/dist/* artifacts/dist-firefox/* playwright-report/ test-results/",
"clean": "rm -rf dist-firefox/* dist/* artifacts/dist/* artifacts/dist-firefox/*",
"dev:crxjs": "vite dev",
"dev:firefoxjs": "NODE_ENV=development run-p build:js",
"dev": "run-s clean lint && tsc && run-p dev:crxjs dev:firefoxjs",
"build:crxjs": "vite build",
"build:ffxcrxjs": "run-s build:js",
"build": "run-s clean lint && tsc && run-p build:crxjs build:ffxcrxjs",
"build:pkg": "run-s build pkgsrc",
"test:deps": "playwright install chromium --with-deps",
"test": "playwright test",
"pretty": "prettier -w ./src/*.html ./src/styles/*.css ./public/*.html",
"lint": "biome lint .",
Expand All @@ -35,10 +36,9 @@
"dompurify": "^3.0.8",
"embla-carousel-react": "8.0.0-rc19",
"html-react-parser": "^4.2.10",
"jquery": "^3.7.1",
"lodash.isequal": "^4.5.0",
"lz-string": "^1.5.0",
"preact": "^10.19.3",
"preact": "^10.19.4",
"prop-types": "15.8.1",
"text-field-edit": "^4.0.0",
"ts-debounce": "^4.0.0",
Expand All @@ -54,18 +54,18 @@
"@types/dompurify": "^3.0.5",
"@types/jquery": "^3.5.29",
"@types/lodash.isequal": "^4.5.8",
"@types/node": "^20.11.16",
"@types/react": "^18.2.51",
"@types/react-dom": "^18.2.18",
"@types/node": "^20.11.17",
"@types/react": "^18.2.55",
"@types/react-dom": "^18.2.19",
"adm-zip": "^0.5.10",
"dotenv": "^16.4.1",
"dotenv": "^16.4.4",
"embla-carousel": "8.0.0-rc19",
"glob": "^10.3.10",
"jest": "^29.7.0",
"license-checker": "^25.0.1",
"npm-run-all": "^4.1.5",
"prettier": "^3.2.4",
"prettier": "^3.2.5",
"typescript": "^5.3.3",
"vite": "^5.0.12"
"vite": "^5.1.1"
}
}
31 changes: 7 additions & 24 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,47 +1,30 @@
import { defineConfig, devices } from "@playwright/test";

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// require('dotenv').config();

/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: "./tests/e2e",
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 0 : 1,
/* Opt out of parallel tests on CI */
workers: process.env.CI ? 1 : 2,
workers: process.env.CI ? 2 : 4,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: [["html"], ["list"]],
reporter: [
["list", { printSteps: true, outputFolder: "results/reports" }],
["html", { open: "never", outputFolder: "results/reports" }],
],
outputDir: "results/tests",

/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
// baseURL: 'http://127.0.0.1:3000',
screenshot: "only-on-failure",
trace: "retain-on-failure",
video: "retain-on-failure",
headless: true,
},

/* Configure projects for major browsers */
projects: [
{
name: "chromium",
use: { ...devices["Desktop Chrome"] },
},
],

/* Run your local dev server before starting the tests */
// webServer: {
// command: 'npm run start',
// url: 'http://127.0.0.1:3000',
// reuseExistingServer: !process.env.CI,
// },
});
Loading

0 comments on commit c25c6bc

Please sign in to comment.