Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
0b0d9d3
Update vite to v8
Swaathik Apr 14, 2026
63e8315
Security audit.
dlrice Apr 16, 2026
25bb8af
Ignorecase in sanitizeUrl.
dlrice Apr 16, 2026
5765a23
Add security tests.
dlrice Apr 16, 2026
99ec716
Use native URL for the url sanitization.
dlrice Apr 16, 2026
411eb0f
Update gitignore for coverage. Remove CSP meta tag.
dlrice Apr 16, 2026
30d437d
Run CI tests on all branches.
dlrice Apr 16, 2026
ef6cf67
Flag unsafe DOM manipulation with error.
dlrice Apr 16, 2026
41dfdc7
Always build the sourcemap.
dlrice Apr 16, 2026
f628005
Remove unused deps.
dlrice Apr 16, 2026
20ed98b
Migrate jest→vitest, capture coverage baseline.
dlrice Apr 18, 2026
ace5e7f
Move testing config to vite.config.mjs.
dlrice Apr 20, 2026
82853de
Remove comments.
dlrice Apr 20, 2026
c77df6a
Merge pull request #128 from ebi-webcomponents/vite-update
Swaathik Apr 20, 2026
4e22876
Merge remote-tracking branch 'origin/main' into testing-baseline
dlrice Apr 20, 2026
1ec90cb
Update packages.
dlrice Apr 20, 2026
be8252d
Update tsconfig.json for latest TSC update.
dlrice Apr 20, 2026
13e53ac
Restore tsc build and coverage scope after TypeScript 6 / vitest 4 up…
dlrice Apr 20, 2026
a676368
Pin eslint-plugin-no-unsanitized to exact version.
dlrice Apr 20, 2026
fb0c5f1
Merge remote-tracking branch 'origin/main' into security-audit
dlrice Apr 20, 2026
2986015
Merge pull request #129 from ebi-webcomponents/security-audit
dlrice Apr 20, 2026
3a13fc6
Merge remote-tracking branch 'origin/main' into testing-baseline
dlrice Apr 20, 2026
7736151
Remove test:ui.
dlrice Apr 20, 2026
9615385
Merge pull request #130 from ebi-webcomponents/testing-baseline
dlrice Apr 20, 2026
945ca9f
Configuration-driven approach refactor.
dlrice Apr 20, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions .babelrc

This file was deleted.

17 changes: 16 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,19 @@ dist/
node_modules/
*.log
.yalc/
yalc.lock
yalc.lock
coverage/
demo/

# Security: prevent accidental commit of secrets and credentials
.env
.env.*
.env.local
.env.*.local
*.pem
*.key
*.pfx
*.p12
*.cert
.aws/
credentials.json
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,43 @@ yarn start

to install dependencies and start the local development server.

## Testing

Tests run under [Vitest](https://vitest.dev/) with a `jsdom` DOM environment. All APIs (`describe`, `it`, `expect`, `vi`, …) must be imported explicitly from `'vitest'` — `globals` is off.

A small setup file at `src/__spec__/setup.ts` filters out jsdom's benign "Could not parse CSS stylesheet" warnings; jsdom's CSS parser is CSS2-era and chokes on the nested-selector syntax used in `src/protvista-styles.ts`. The stylesheet still attaches correctly — it's log noise only. Every other `console.error` passes through untouched. Remove the filter if we ever migrate to happy-dom (which parses modern CSS natively) or jsdom gains native-nesting support.

```bash
# Run the full pipeline (lint + types + unit)
yarn test

# Unit tests only (CI-friendly, non-zero exit on failure)
yarn test:unit

# Watch mode
yarn test:watch

# Coverage (writes text + html + lcov to ./coverage/)
yarn test:coverage
```

Coverage output is for local use only and is not committed. Open `coverage/index.html` after `yarn test:coverage` to inspect.

### Continuous integration

Every push and pull request runs the same three steps as `yarn test` via [`.github/workflows/test-and-deploy.yml`](./.github/workflows/test-and-deploy.yml): `yarn test:lint`, `yarn test:types`, and `yarn test:unit`, under Node 24 on `ubuntu-latest`. A separate `build` job runs `yarn build` (and, on `main`, `yarn build:demo`) and deploys the demo to GitHub Pages. Coverage is not collected in CI today — run `yarn test:coverage` locally when you need a coverage signal.

### Coverage

Captured 2026-04-20 via `yarn test:coverage` (v8 instrumentation, 29 tests across 3 spec files):

| Metric | Coverage % |
| ---------- | ---------- |
| Statements | 71.41 |
| Branches | 70.77 |
| Functions | 68.63 |
| Lines | 71.78 |

## Configuration

You can pass your own configuration to the component using the `config` attribute/property.
Expand Down
11 changes: 8 additions & 3 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import js from '@eslint/js';
import ts from 'typescript-eslint';
import tsParser from '@typescript-eslint/parser';
import tsPlugin from '@typescript-eslint/eslint-plugin';
import noUnsanitized from 'eslint-plugin-no-unsanitized';
import prettier from 'eslint-config-prettier';
import globals from 'globals';

Expand All @@ -20,21 +21,25 @@ export default [
globals: {
...globals.browser,
...globals.es2021,
...globals.jest,
},
},

plugins: {
'@typescript-eslint': tsPlugin,
'no-unsanitized': noUnsanitized,
},

/* start with the plugins own recommended rules */
/* start with the plugin's own recommended rules... */
rules: {
...tsPlugin.configs.recommended.rules,

/* then apply your custom tweaks */
/* ...then apply your custom tweaks */
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',

/* Security: flag unsafe DOM manipulation */
'no-unsanitized/method': 'error',
'no-unsanitized/property': 'error',
},
},
];
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

<body>
<div>
<!-- NOTE: for all of the following with no config-src → falls back to bundled src/default-config.yaml -->
<!-- Good default -->
<protvista-uniprot accession="P05067"></protvista-uniprot>
<!-- Good multimer -->
Expand Down
61 changes: 29 additions & 32 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "protvista-uniprot",
"description": "ProtVista tool for the UniProt website",
"version": "4.7.2",
"version": "5.0.0",
"files": [
"dist",
"src"
Expand All @@ -13,8 +13,10 @@
"start": "vite",
"test:lint": "eslint src --ext .ts ",
"test:types": "tsc",
"test:unit": "jest",
"test": "npm-run-all --continue-on-error test:*",
"test:unit": "vitest run",
"test:watch": "vitest",
"test:coverage": "vitest run --coverage",
"test": "npm-run-all --continue-on-error test:lint test:types test:unit",
"clear-cdn-cache": "./scripts/clearCDNcaches.sh"
},
"main": "dist/protvista-uniprot.js",
Expand All @@ -41,53 +43,48 @@
"@nightingale-elements/nightingale-structure": "5.8.0",
"@nightingale-elements/nightingale-track-canvas": "5.6.0",
"@nightingale-elements/nightingale-variation": "5.6.0",
"@floating-ui/dom": "1.7.6",
"@markdoc/markdoc": "0.5.7",
"ajv": "8.18.0",
"color-hash": "2.0.2",
"core-js": "3.48.0",
"js-yaml": "4.1.0",
"lit": "3.3.2",
"lodash-es": "4.17.23",
"timing-functions": "2.0.1",
"url-join": "5.0.0"
"lodash-es": "4.18.1",
"timing-functions": "2.0.1"
},
"devDependencies": {
"@babel/core": "7.29.0",
"@babel/plugin-proposal-decorators": "7.29.0",
"@babel/plugin-transform-runtime": "7.29.0",
"@babel/preset-env": "7.29.0",
"@babel/preset-typescript": "7.28.5",
"@babel/runtime-corejs3": "7.29.0",
"@eslint/js": "10.0.1",
"@originjs/vite-plugin-commonjs": "1.0.3",
"@types/jest": "30.0.0",
"@typescript-eslint/eslint-plugin": "8.56.1",
"@typescript-eslint/parser": "8.56.1",
"babel-jest": "30.2.0",
"eslint": "10.0.2",
"@types/color-hash": "2.0.0",
"@types/js-yaml": "4.0.9",
"@types/lodash-es": "4.17.12",
"@typescript-eslint/eslint-plugin": "8.58.2",
"@typescript-eslint/parser": "8.58.2",
"@vitest/coverage-v8": "4.1.4",
"eslint": "10.2.1",
"eslint-config-prettier": "10.1.8",
"eslint-plugin-no-unsanitized": "4.1.5",
"eslint-plugin-prettier": "5.5.5",
"globals": "17.3.0",
"jest": "30.2.0",
"globals": "17.5.0",
"jsdom": "29.0.2",
"npm-run-all": "4.1.5",
"rollup-plugin-visualizer": "7.0.0",
"rollup-plugin-visualizer": "7.0.1",
"svg-inline-loader": "0.8.2",
"typescript": "5.9.3",
"typescript-eslint": "8.56.1",
"vite": "7.3.1",
"typescript": "6.0.3",
"typescript-eslint": "8.58.2",
"vega-expression": "6.1.0",
"vite": "8.0.9",
"vite-plugin-dts": "4.5.4",
"vite-plugin-env-compatible": "2.0.1",
"vite-plugin-html": "3.2.2",
"vite-plugin-svgo": "2.0.0"
"vite-plugin-svgo": "2.0.0",
"vitest": "4.1.4"
},
"browserslist": [
"chrome >= 92",
"edge >= 92",
"firefox >= 90",
"safari >= 15"
],
"jest": {
"testRegex": "(/__tests__/.*|(\\.|/))spec\\.ts$",
"testPathIgnorePatterns": [
"/__mocks__/",
"<rootDir>/dist/"
]
}
]
}
Empty file added scripts/_validate-default.mjs
Empty file.
2 changes: 1 addition & 1 deletion scripts/clearCDNcaches.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

curl -X POST \
http://purge.jsdelivr.net \
https://purge.jsdelivr.net \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-d '{
Expand Down
Loading
Loading