From 764487e9ca895d573d05791f7d6b21d5d9c91719 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 21 Nov 2026 11:10:58 +0000 Subject: [PATCH 1/2] build(deps-dev): bump jsdom from 30.1.3 to 31.0.1 Bumps [jsdom](https://github.com/jsdom/jsdom) from 30.1.3 to 31.0.1. - [Release notes](https://github.com/jsdom/jsdom/releases) - [Commits](https://github.com/jsdom/jsdom/compare/v30.1.3...v31.0.1) --- updated-dependencies: - dependency-name: jsdom dependency-version: 31.0.0 dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- package-lock.json | 330 +++++++++++++--------------------------------- package.json | 2 +- 2 files changed, 95 insertions(+), 237 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4badf885..6e78597d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,7 +16,7 @@ "@typescript/native": "npm:typescript@7.0.2", "acorn": "^8.19.0", "eslint-plugin-obsidianmd": "^0.4.2", - "jsdom": "^30.1.3", + "jsdom": "^31.0.1", "obsidian": "1.14.4", "obsidian-e2e": "^0.15.0", "oxfmt": "^0.76.0", @@ -42,39 +42,6 @@ "dev": true, "license": "MIT" }, - "node_modules/@asamuzakjp/css-color": { - "version": "7.1.6", - "resolved": "https://registry.npmjs.org/@asamuzakjp/css-color/-/css-color-7.1.6.tgz", - "integrity": "sha512-jZJUZX0mR6JqnjQGb79yTYbR5WXmACmcLoFSgZk+7W+0qMJ8jWGRp9ncYvE1ihwL3dwbmfeCe6/O0rRwWTko4g==", - "dev": true, - "license": "MIT", - "dependencies": { - "@csstools/css-calc": "^3.4.3", - "@csstools/css-color-parser": "^4.2.6", - "@csstools/css-parser-algorithms": "^4.0.2", - "@csstools/css-tokenizer": "^4.0.2", - "lru-cache": "^11.5.3" - }, - "engines": { - "node": "^22.22.2 || ^24.15.0 || >=26.0.0" - } - }, - "node_modules/@asamuzakjp/dom-selector": { - "version": "10.0.3", - "resolved": "https://registry.npmjs.org/@asamuzakjp/dom-selector/-/dom-selector-10.0.3.tgz", - "integrity": "sha512-3+777rEPsOOjoy5/sRmIzHnoRDaLpm3XWY2dmWn/N7f/XwDG0bcpnFaKL3X9FYJUbNwLmpcJC1bUYexJRxsFlw==", - "dev": true, - "license": "MIT", - "dependencies": { - "bidi-js": "^1.1.0", - "css-tree": "^3.2.1", - "is-potential-custom-element-name": "^1.0.1", - "lru-cache": "^11.5.3" - }, - "engines": { - "node": "^22.22.2 || ^24.15.0 || >=26.0.0" - } - }, "node_modules/@babel/code-frame": { "version": "7.29.7", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.29.7.tgz", @@ -110,19 +77,6 @@ "node": ">=6.9.0" } }, - "node_modules/@bramus/specificity": { - "version": "2.4.3", - "resolved": "https://registry.npmjs.org/@bramus/specificity/-/specificity-2.4.3.tgz", - "integrity": "sha512-0GEz8qJWokkUVYQYRukmkSHIFNoBH8QTreeHrAFbvz1XFYc3Y+puhMs8PQ5x8GNugiC2l5jvDBXKLbBIByeSBw==", - "dev": true, - "license": "MIT", - "dependencies": { - "css-tree": "^3.2.1" - }, - "bin": { - "specificity": "bin/cli.js" - } - }, "node_modules/@codemirror/state": { "version": "6.7.6", "resolved": "https://registry.npmjs.org/@codemirror/state/-/state-6.7.6.tgz", @@ -148,146 +102,6 @@ "w3c-keyname": "^2.2.4" } }, - "node_modules/@csstools/color-helpers": { - "version": "6.1.2", - "resolved": "https://registry.npmjs.org/@csstools/color-helpers/-/color-helpers-6.1.2.tgz", - "integrity": "sha512-grhRy3OKmniaAEKXMjua5z/EODX0MSqBGjunw8+j/3HQjOnahs2AGhvEOIYVUWcU6ScApbhLhVrQTX8XqrMrow==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/csstools" - }, - { - "type": "opencollective", - "url": "https://opencollective.com/csstools" - } - ], - "license": "MIT-0", - "engines": { - "node": ">=20.19.0" - } - }, - "node_modules/@csstools/css-calc": { - "version": "3.4.3", - "resolved": "https://registry.npmjs.org/@csstools/css-calc/-/css-calc-3.4.3.tgz", - "integrity": "sha512-iex20d8CHVkyvg6B7UKV7uHnI2Bqo9g+EFfT9E0y+GvTvhZ/DwONJ+9aKb1dlqm0ZiGsL5RXjp0fCoJYnkeDjA==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/csstools" - }, - { - "type": "opencollective", - "url": "https://opencollective.com/csstools" - } - ], - "license": "MIT", - "engines": { - "node": ">=20.19.0" - }, - "peerDependencies": { - "@csstools/css-parser-algorithms": "^4.0.2", - "@csstools/css-tokenizer": "^4.0.2" - } - }, - "node_modules/@csstools/css-color-parser": { - "version": "4.2.6", - "resolved": "https://registry.npmjs.org/@csstools/css-color-parser/-/css-color-parser-4.2.6.tgz", - "integrity": "sha512-iiPQ3iRWwnJkeEn6RIu6SJPr7hYrLz6XZ9s/QZl+2/LI5KQVjpl2fdmDSZKuD4xP6GMmMPgHFFXg6k1Wkz0Trg==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/csstools" - }, - { - "type": "opencollective", - "url": "https://opencollective.com/csstools" - } - ], - "license": "MIT", - "dependencies": { - "@csstools/color-helpers": "^6.1.2", - "@csstools/css-calc": "^3.4.3" - }, - "engines": { - "node": ">=20.19.0" - }, - "peerDependencies": { - "@csstools/css-parser-algorithms": "^4.0.2", - "@csstools/css-tokenizer": "^4.0.2" - } - }, - "node_modules/@csstools/css-parser-algorithms": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/@csstools/css-parser-algorithms/-/css-parser-algorithms-4.0.2.tgz", - "integrity": "sha512-40cSKyMvK+tq4qz6Awrlye2WGuOKt3FwPgtGg6KTfbHOWNw+Rk1rzbAtZnZ6IBhsY491HLRnDXwoyBAijmmILA==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/csstools" - }, - { - "type": "opencollective", - "url": "https://opencollective.com/csstools" - } - ], - "license": "MIT", - "engines": { - "node": ">=20.19.0" - }, - "peerDependencies": { - "@csstools/css-tokenizer": "^4.0.2" - } - }, - "node_modules/@csstools/css-syntax-patches-for-csstree": { - "version": "1.1.15", - "resolved": "https://registry.npmjs.org/@csstools/css-syntax-patches-for-csstree/-/css-syntax-patches-for-csstree-1.1.15.tgz", - "integrity": "sha512-J0u7HkVl2nzSlhsiTOp4AmwcUQ3D+mGEEKfBy/7To5/y7F2OHwyLrXfrhR0SMgr4p5Lo+eaMVSeai24zUcBIxA==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/csstools" - }, - { - "type": "opencollective", - "url": "https://opencollective.com/csstools" - } - ], - "license": "MIT-0", - "peerDependencies": { - "css-tree": "^3.2.1" - }, - "peerDependenciesMeta": { - "css-tree": { - "optional": true - } - } - }, - "node_modules/@csstools/css-tokenizer": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/@csstools/css-tokenizer/-/css-tokenizer-4.0.2.tgz", - "integrity": "sha512-OoKoR0f76dCY666JlcbhmVTs2drYj1GUXZTYTcbUgJjh9Nv41aFfZ21bPQTERm5+L5cBDo466NltB2lplS5GBw==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/csstools" - }, - { - "type": "opencollective", - "url": "https://opencollective.com/csstools" - } - ], - "license": "MIT", - "engines": { - "node": ">=20.19.0" - } - }, "node_modules/@eslint-community/eslint-plugin-eslint-comments": { "version": "4.8.1", "resolved": "https://registry.npmjs.org/@eslint-community/eslint-plugin-eslint-comments/-/eslint-plugin-eslint-comments-4.8.1.tgz", @@ -2901,14 +2715,31 @@ "node": "18 || 20 || >=22" } }, - "node_modules/bidi-js": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/bidi-js/-/bidi-js-1.1.0.tgz", - "integrity": "sha512-fX1Onk0tdVPC7obPWB5EbJ1z7NVhLq4m2xZLq2YXBkxzMXIGRpNMU88n0EPgWseKl12J7zXs7qrDxPK4sRs2fg==", + "node_modules/bcp-47": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/bcp-47/-/bcp-47-2.1.2.tgz", + "integrity": "sha512-wsv86UuNFuPnVieKLyECTT+CP1WSAHeoIg5P3xu2kA9Z+7fVPoKt7dxzSeEhtJel0AI+NW3fIW3KtTKQKUCngg==", "dev": true, "license": "MIT", "dependencies": { - "require-from-string": "^2.0.2" + "is-alphabetical": "^2.0.0", + "is-alphanumerical": "^2.0.0", + "is-decimal": "^2.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/bcp-47-match": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/bcp-47-match/-/bcp-47-match-2.0.3.tgz", + "integrity": "sha512-JtTezzbAibu8G0R9op9zb3vcWZd9JF6M0xOYGPn0fNCd7wOpRB1mU2mH9T8gaBGbAAyIIVgB2G7xG0GP98zMAQ==", + "dev": true, + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" } }, "node_modules/brace-expansion": { @@ -3101,20 +2932,6 @@ "node": ">= 8" } }, - "node_modules/css-tree": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/css-tree/-/css-tree-3.2.1.tgz", - "integrity": "sha512-X7sjQzceUhu1u7Y/ylrRZFU2FS6LRiFVp6rKLPg23y3x3c3DOKAwuXGDp+PAGjh6CSnCjYeAul8pcT8bAl+lSA==", - "dev": true, - "license": "MIT", - "dependencies": { - "mdn-data": "2.27.1", - "source-map-js": "^1.2.1" - }, - "engines": { - "node": "^10 || ^12.20.0 || ^14.13.0 || >=15.0.0" - } - }, "node_modules/css.escape": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/css.escape/-/css.escape-1.5.1.tgz", @@ -3355,9 +3172,9 @@ } }, "node_modules/entities": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/entities/-/entities-8.1.0.tgz", - "integrity": "sha512-kxL7msIffSuh9aaFAMD7rxAIuTRMAHMeBtgHW2yUdWw732ZNh4MehkF2gdjvtdmikkaIP9bFDDJOPlsvm7avrA==", + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-9.0.0.tgz", + "integrity": "sha512-oJFNDJg3kTPwAD1cNn2+WmUq4wFoo09npc3Ydf1D7ED4smRiWrsKnaLxykrTWgyGEcusc87P5dxlAleol9kpkg==", "dev": true, "license": "BSD-2-Clause", "engines": { @@ -4907,6 +4724,32 @@ "node": ">= 0.4" } }, + "node_modules/is-alphabetical": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-alphabetical/-/is-alphabetical-2.0.1.tgz", + "integrity": "sha512-FWyyY60MeTNyeSRpkM2Iry0G9hpr7/9kD40mD/cGQEuilcZYS4okz8SN2Q6rLCJ8gbCt6fN+rC+6tMGS99LaxQ==", + "dev": true, + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/is-alphanumerical": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-alphanumerical/-/is-alphanumerical-2.0.1.tgz", + "integrity": "sha512-hmbYhX/9MUMF5uh7tOXyK/n0ZvWpad5caBA17GsC6vyuCqaWliRG5K1qS9inmUhEMaOBIW7/whAnSwveW/LtZw==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-alphabetical": "^2.0.0", + "is-decimal": "^2.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, "node_modules/is-array-buffer": { "version": "3.0.5", "resolved": "https://registry.npmjs.org/is-array-buffer/-/is-array-buffer-3.0.5.tgz", @@ -5042,6 +4885,17 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/is-decimal": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-decimal/-/is-decimal-2.0.1.tgz", + "integrity": "sha512-AAB9hiomQs5DXWcRB1rqsxGUstbRroFOPPVAomNk/3XHR5JyEZChOyTWe2oayKnsSsr/kcGqF+z6yuH6HHpN0A==", + "dev": true, + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, "node_modules/is-document.all": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-document.all/-/is-document.all-1.0.0.tgz", @@ -5385,41 +5239,39 @@ } }, "node_modules/jsdom": { - "version": "30.1.3", - "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-30.1.3.tgz", - "integrity": "sha512-hQMUPvRgN7KxsfIytDQji7bimuJeRQa6Qo5+iuiZQk5CafeRxLIA10/cG5YCBFNpD9RO3oqIiN4CO1Y44kxqXg==", + "version": "31.0.1", + "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-31.0.1.tgz", + "integrity": "sha512-CbhJL8ZQg3eKswxSZth4QO9tW0jPIhmR0vtSXQSbKSfWbwIT6hoRc17wdHIVTQ43KI0mdV5iTJr3281IDgVZ5g==", "dev": true, "license": "MIT", "dependencies": { - "@asamuzakjp/css-color": "^7.1.3", - "@asamuzakjp/dom-selector": "^10.0.3", - "@bramus/specificity": "^2.4.2", - "@csstools/css-syntax-patches-for-csstree": "^1.1.15", "@exodus/bytes": "^1.16.0", - "css-tree": "^3.2.1", + "bcp-47": "^2.1.2", + "bcp-47-match": "^2.0.3", "data-urls": "^8.0.0", "decimal.js": "^10.6.0", "html-encoding-sniffer": "^7.0.0", "is-potential-custom-element-name": "^1.0.1", "lru-cache": "^11.5.3", - "parse5": "^8.0.1", + "parse5": "^8.1.0", + "parse5-parser-stream": "^8.1.0", "saxes": "^6.0.0", "tough-cookie": "^6.0.2", - "undici": "^8.12.1", + "undici": "^8.12.3", "w3c-xmlserializer": "^6.0.0", "webidl-conversions": "^8.0.1", "whatwg-mimetype": "^5.0.0", - "whatwg-url": "^17.2.0", + "whatwg-url": "^17.3.0", "xml-name-validator": "^5.0.0" }, "engines": { "node": "^22.22.2 || ^24.15.0 || >=26.0.0" }, "peerDependencies": { - "canvas": "^3.2.3" + "@napi-rs/canvas": "^1.0.13" }, "peerDependenciesMeta": { - "canvas": { + "@napi-rs/canvas": { "optional": true } } @@ -5925,13 +5777,6 @@ "node": ">= 0.4" } }, - "node_modules/mdn-data": { - "version": "2.27.1", - "resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.27.1.tgz", - "integrity": "sha512-9Yubnt3e8A0OKwxYSXyhLymGW4sCufcLG6VdiDdUGVkPhpqLxlvP5vl1983gQjJl3tqbrM731mjaZaP68AgosQ==", - "dev": true, - "license": "CC0-1.0" - }, "node_modules/min-indent": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/min-indent/-/min-indent-1.0.1.tgz", @@ -6421,13 +6266,26 @@ } }, "node_modules/parse5": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/parse5/-/parse5-8.0.1.tgz", - "integrity": "sha512-z1e/HMG90obSGeidlli3hj7cbocou0/wa5HacvI3ASx34PecNjNQeaHNo5WIZpWofN9kgkqV1q5YvXe3F0FoPw==", + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-8.1.1.tgz", + "integrity": "sha512-EcR/6WDcU7b2N3vQSxKALCk9lXGtUMQxXio008OEMBE0kavu/7JLfBEeFPzi43nMqVDSbEn3QCK+BMCc9zO//w==", + "dev": true, + "license": "MIT", + "dependencies": { + "entities": "^9.0.0" + }, + "funding": { + "url": "https://github.com/inikulin/parse5?sponsor=1" + } + }, + "node_modules/parse5-parser-stream": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/parse5-parser-stream/-/parse5-parser-stream-8.1.1.tgz", + "integrity": "sha512-hMcVbbUJcQmP8rURWUdYrT1flRiBiBVjq/RYGguJpDUgIXSqdYKlE0CxthmdMWoSlBAuL5bUBa73g0pttSy7Hw==", "dev": true, "license": "MIT", "dependencies": { - "entities": "^8.0.0" + "parse5": "^8.1.1" }, "funding": { "url": "https://github.com/inikulin/parse5?sponsor=1" @@ -7712,9 +7570,9 @@ } }, "node_modules/undici": { - "version": "8.12.2", - "resolved": "https://registry.npmjs.org/undici/-/undici-8.12.2.tgz", - "integrity": "sha512-XtuDWVdqTLr3NAxm2ly9/hU6kUsJOgGh1RASzMBbsw6aWCOaQzHdW+QQDfdERjfJ2V5vL5pRPa4RetO9UfivDg==", + "version": "8.12.4", + "resolved": "https://registry.npmjs.org/undici/-/undici-8.12.4.tgz", + "integrity": "sha512-8Mx+uNKKER2bA4AdtedkqRbwUCIJFr2nJckXRe5yrDqzePqwLP7VNcctN8/XdmDSbF7mS+jJKIszlL+vbam1VA==", "dev": true, "license": "MIT", "engines": { diff --git a/package.json b/package.json index c2d1822b..572df7bd 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "@typescript/native": "npm:typescript@7.0.2", "acorn": "^8.19.0", "eslint-plugin-obsidianmd": "^0.4.2", - "jsdom": "^30.1.3", + "jsdom": "^31.0.1", "obsidian": "1.14.4", "obsidian-e2e": "^0.15.0", "oxfmt": "^0.76.0", From 18d9f46be0c9e1c9580fe375dc95bf2019e33f13 Mon Sep 17 00:00:00 2001 From: Christian Bager Bach Houmann Date: Sat, 21 Nov 2026 12:35:27 +0100 Subject: [PATCH 2/2] test(ui): adapt the view's style tests to jsdom 31's CSS engine jsdom 31 replaced its CSS implementation. It now evaluates media queries as a desktop that hovers with no motion preference, substitutes var() as a browser does (an undefined variable falls back to the initial value, and var() in shorthands works), and applies a UA stylesheet. - componentCss settles every query itself: listed queries match, others become `not all`, so jsdom's emulated device cannot leak in. - The tests define the Obsidian theme variables they read and assert the resolved values; the shorthand stand-ins jsdom 30 needed are gone. - Test markup carries the real `pn-bare` class, which undoes the UA button background as it does Obsidian's. - An absolutely positioned label computes `display: block`, as CSS Display's blockification requires. - Transition and animation shorthands use jsdom 31's serialization. --- src/ui/PodcastView/styles.test.ts | 59 ++++++++++++++++++------------- tests/mocks/componentCss.ts | 10 +++--- 2 files changed, 40 insertions(+), 29 deletions(-) diff --git a/src/ui/PodcastView/styles.test.ts b/src/ui/PodcastView/styles.test.ts index 65310d3d..9f9a24cc 100644 --- a/src/ui/PodcastView/styles.test.ts +++ b/src/ui/PodcastView/styles.test.ts @@ -9,6 +9,23 @@ import { componentCss, styled } from "../../../tests/mocks/componentCss"; const REDUCE = "(prefers-reduced-motion: reduce)"; const UI = path.resolve(import.meta.dirname, ".."); +/** + * Obsidian's theme variables that the tested declarations read. jsdom substitutes var() as a + * browser does, so a declaration whose variable is undefined falls back to its initial value. + */ +const theme = { + "--interactive-accent": "rgb(124, 58, 237)", + "--background-modifier-hover": "rgba(0, 0, 0, 0.075)", + "--background-modifier-border": "rgb(224, 224, 224)", + "--shadow-s": "rgba(0, 0, 0, 0.1) 0px 1px 2px", + "--size-4-1": "4px", + "--size-4-2": "8px", + "--size-4-5": "20px", +}; +const THEME = `body { ${Object.entries(theme) + .map(([name, value]) => `${name}: ${value};`) + .join(" ")} }`; + /** `html` in the view, with `{}` standing for the component's own scoping class. */ const inView = (component: string, html: string) => `
${html.replaceAll("{}", `pn-${component}`)}
`; @@ -20,21 +37,21 @@ describe("reduced motion", () => { "Deck", '
', ".pn-play", - ["transform 120ms ease", ""], + ["transform 0.12s", "none"], ], [ "a podcast card", "LibraryPage", '
', ".pn-gridcard", - ["transform 120ms ease", ""], + ["transform 0.12s", "none"], ], [ "a playing row's bars", "EpisodeRow", '
', ".pn-eq i", - ["", "pn-eq 1s ease-in-out infinite"], + ["all", "1s ease-in-out -0.8s infinite pn-eq"], ], ])( "%s stops moving when the user prefers reduced motion", @@ -56,7 +73,7 @@ describe("focus ring", () => { test("draws the video's play button ring inside the frame that clips it, and others outside", () => { const css = componentCss(["PodcastView", "Player"], { states: ["focus-visible"] }); styled( - css, + THEME + css, inView( "Player", '
', @@ -69,8 +86,8 @@ describe("focus ring", () => { }; expect([ring(".pn-vplay"), ring(".pn-iconbtn")]).toEqual([ - ["2px solid var(--interactive-accent)", "-2px"], - ["2px solid var(--interactive-accent)", "1px"], + [`2px solid ${theme["--interactive-accent"]}`, "-2px"], + [`2px solid ${theme["--interactive-accent"]}`, "1px"], ]); }); }); @@ -108,34 +125,30 @@ describe("hover", () => { [ "the skip button", "Deck", - '
', + '
', ".pn-skip", "rgba(0, 0, 0, 0)", ], [ "the panel switch that is on", "Player", - '
', + '
', ".pn-sw", - "var(--background-modifier-border)", + theme["--background-modifier-border"], ], ])( "%s keeps its resting background after a tap", (_name, component, html, selector, resting) => { const background = (hovered: boolean, media: string[] = []) => { - // jsdom drops a var() in a shorthand, so each background stands in as its color. - const css = componentCss(["PodcastView", component], { - media, - states: ["hover"], - }).replaceAll("background: var(", "background-color: var("); + const css = componentCss(["PodcastView", component], { media, states: ["hover"] }); const markup = inView(component, html.replace("%", hovered ? " hover" : "")); - return getComputedStyle(styled(css, markup, selector)).backgroundColor; + return getComputedStyle(styled(THEME + css, markup, selector)).backgroundColor; }; expect([background(false), background(true), background(true, [HOVER])]).toEqual([ resting, resting, - "var(--background-modifier-hover)", + theme["--background-modifier-hover"], ]); }, ); @@ -162,7 +175,7 @@ describe("the transcript's note button", () => { expect([label("pn-panel-head"), label("pn-panel-empty")]).toEqual([ { - display: "inline", + display: "block", visibility: "visible", position: "absolute", clipPath: "inset(50%)", @@ -176,11 +189,7 @@ describe("on a tablet", () => { test("the rail's add button keeps its own padding over Obsidian's for every button", () => { const obsidian = ".is-tablet button:not(.clickable-icon) { padding: var(--size-4-1) var(--size-4-5); }"; - // jsdom drops a var() in a shorthand, so Obsidian's 4 px spacing steps stand in. - const css = (obsidian + componentCss(["PodcastView", "Rail"])).replace( - /var\(--size-4-(\d)\)/g, - (_, step: string) => `${Number(step) * 4}px`, - ); + const css = THEME + obsidian + componentCss(["PodcastView", "Rail"]); const { padding } = getComputedStyle( styled( css, @@ -195,7 +204,7 @@ describe("on a tablet", () => { describe("the player's stage", () => { test("dresses its own artwork, not the covers of a panel's rows shown in it", () => { - const css = componentCss(["PodcastView", "Player", "EpisodeRow"]); + const css = THEME + componentCss(["PodcastView", "Player", "EpisodeRow"]); const tile = (id: string) => ``; styled( css, @@ -208,8 +217,8 @@ describe("the player's stage", () => { }; expect([look("art"), look("row")]).toEqual([ - { shadow: "var(--shadow-s)", icon: "25cqw" }, - { shadow: expect.not.stringContaining("--shadow-s"), icon: "18px" }, + { shadow: theme["--shadow-s"], icon: "25cqw" }, + { shadow: expect.not.stringContaining(theme["--shadow-s"]), icon: "18px" }, ]); }); }); diff --git a/tests/mocks/componentCss.ts b/tests/mocks/componentCss.ts index 2e090fa9..e6018673 100644 --- a/tests/mocks/componentCss.ts +++ b/tests/mocks/componentCss.ts @@ -8,9 +8,11 @@ const COMPONENTS = path.resolve(import.meta.dirname, "../../src/ui/PodcastView") /** * The CSS of the view's components as jsdom cascades it. Each component is scoped by the * class `pn-`, so markup takes that class where its own sheet scopes an element. - * Nesting is flattened, which jsdom lacks, and sheets keep the order given: shell first, as - * it mounts first. jsdom applies no media or container query but `all`, so `media` names the - * queries that match, as the user's device, setting or the container's size would make them. + * Nesting is flattened, and sheets keep the order given: shell first, as it mounts first. + * jsdom evaluates media queries as a desktop that hovers and has no motion preference, and + * container queries become media queries here, so the helper settles every query itself: + * `media` names the queries that match, as the user's device, setting or the container's + * size would make them, and every other query matches nothing. * `states` turns pseudo-classes such as `:focus-visible` into classes a test can set. */ export function componentCss( @@ -36,7 +38,7 @@ export function componentCss( ); for (const child of node.nodes) if (child.type !== "decl") visit(child, own, within); } else if (node.type === "atrule" && (node.name === "media" || node.name === "container")) { - const query = media.includes(node.params) ? "all" : node.params; + const query = media.includes(node.params) ? "all" : "not all"; const copy = postcss.atRule({ name: "media", params: query }); within.append(copy); for (const child of (node as AtRule).nodes ?? []) visit(child, selectors, copy);