fix(embeds): address Phase 38 review findings across registry, Blog Editor, and docs

This commit is contained in:
Jakub Zych
2026-11-28 13:13:09 +01:00
parent 3fc656da0f
commit a047d4284f
9 changed files with 69 additions and 37 deletions

View File

@@ -18,7 +18,7 @@ WinterCMS theme components such as `journalPost` and `journalPosts` are a later
## Features ## Features
- **Posts.** `models.Post` maps `golem15_journal_posts`. Translatable fields are title, content, content_html, excerpt, metadata, and slug (indexed). Fillable does not include `redactor_id`, `content_html`, or `user_id`. Attachments `featured_images` and `content_images` use `system_files` under the same MorphName. YAML admin uses `mltext`, `mltextarea` and the plugin's own `mlblogeditor` field type for content (see [Admin: Blog Editor field types](#admin-blog-editor-field-types)); an admin save stores the sanitized HTML in both `content` and `content_html`. `classes.FormatHTML` regenerates `content_html` on the other write paths (`journal:import-posts`, Journal API writes). It renders markdown and passes raw HTML in `content` through the renderer (Winter parity), then sanitizes the result with a `bluemonday` allow-list: bluemonday's UGC policy plus `footer`, `class`, schema.org microdata, the `color`, `font-size`, `font-weight` and `text-align` styles, goldmark's footnote roles, `dir="auto"`, two pasted-transcript `data-message-*` attributes, and exactly five rules for the Blog Editor's own output (Phase 16.2, Phase 33): `data-embed` matching `^youtube$` and `data-id` matching `^[A-Za-z0-9_-]{11}$` on `figure` (the embed placeholder), `alt` with any text on `img`, `start` matching `^[0-9]+$` on `ol`, and `rel` on `a` holding only the tokens `nofollow`, `sponsored` and `ugc` (`^(nofollow|sponsored|ugc)( (nofollow|sponsored|ugc))*$`; any other `rel` value is removed). No iframe, other data attribute, style property or URL scheme is allowed for the editor; `TestEditorOutputPassesPolicy` checks every entry of the editor corpus against the policy. Like Winter's `Html::clean`, it strips what the policy does not allow instead of refusing the save: script, style, iframe, object, embed, form, base and meta elements, comments, event handler attributes, and URLs other than http, https, mailto and relative ones. HTML the policy keeps whole is stored byte for byte, so imported bodies survive a save. Admin saves strip the same way and name what they removed (`classes.SanitizeHTMLReport`). A tag that repeats an attribute is never kept whole: the sanitized output, which keeps the first value, is stored. On the API and import paths `content` itself is stored as submitted. Translated `content_html` goes through the same policy on the API and `journal:import-posts` write paths (`classes.FormatTranslation`): when the translation carries a non-blank `content`, `content_html` is rendered from it and a supplied `content_html` is replaced, as the host column is always derived; a translation with only `content_html` is sanitized with `classes.SanitizeHTML`. Winter stored a supplied translated `content_html` verbatim. The API response shapes and status codes are unchanged. - **Posts.** `models.Post` maps `golem15_journal_posts`. Translatable fields are title, content, content_html, excerpt, metadata, and slug (indexed). Fillable does not include `redactor_id`, `content_html`, or `user_id`. Attachments `featured_images` and `content_images` use `system_files` under the same MorphName. YAML admin uses `mltext`, `mltextarea` and the plugin's own `mlblogeditor` field type for content (see [Admin: Blog Editor field types](#admin-blog-editor-field-types)); an admin save stores the sanitized HTML in both `content` and `content_html`. `classes.FormatHTML` regenerates `content_html` on the other write paths (`journal:import-posts`, Journal API writes). It renders markdown and passes raw HTML in `content` through the renderer (Winter parity), then sanitizes the result with a `bluemonday` allow-list: bluemonday's UGC policy plus `footer`, `class`, schema.org microdata, the `color`, `font-size`, `font-weight` and `text-align` styles, goldmark's footnote roles, `dir="auto"`, two pasted-transcript `data-message-*` attributes, and rules for the Blog Editor's own output (Phase 16.2, Phase 33, Phase 38): pair-aware `data-embed` and `data-id` on `figure` against the app's `classes.EmbedRegistry` (`youtube` matching `^[A-Za-z0-9_-]{11}$` by default, plus app-registered providers) alongside validated `data-aspect` and `data-height` CLS hints, `alt` with any text on `img`, `start` matching `^[0-9]+$` on `ol`, and `rel` on `a` holding only the tokens `nofollow`, `sponsored` and `ugc` (`^(nofollow|sponsored|ugc)( (nofollow|sponsored|ugc))*$`; any other `rel` value is removed). No iframe, other data attribute, style property or URL scheme is allowed for the editor; `TestEditorOutputPassesPolicy` checks every entry of the editor corpus against the policy. Like Winter's `Html::clean`, it strips what the policy does not allow instead of refusing the save: script, style, iframe, object, embed, form, base and meta elements, comments, event handler attributes, and URLs other than http, https, mailto and relative ones. HTML the policy keeps whole is stored byte for byte, so imported bodies survive a save. Admin saves strip the same way and name what they removed (`classes.SanitizeHTMLReport`). A tag that repeats an attribute is never kept whole: the sanitized output, which keeps the first value, is stored. On the API and import paths `content` itself is stored as submitted. Translated `content_html` goes through the same policy on the API and `journal:import-posts` write paths (`classes.FormatTranslation`): when the translation carries a non-blank `content`, `content_html` is rendered from it and a supplied `content_html` is replaced, as the host column is always derived; a translation with only `content_html` is sanitized with `classes.SanitizeHTML`. Winter stored a supplied translated `content_html` verbatim. The API response shapes and status codes are unchanged.
- **Categories and tags.** `models.Category` is translatable (name, description, slug). It also stores `content`, an HTML host column that is not translatable, edited in the admin with the `blogeditor` field type. Fillable is name, slug, code, description, content and parent_id; nest_* columns exist in DDL and are not fillable. `models.Tag` is not translatable. Fillable is name, slug, description. Pivots are `golem15_journal_posts_categories` and `golem15_journal_posts_tags`. - **Categories and tags.** `models.Category` is translatable (name, description, slug). It also stores `content`, an HTML host column that is not translatable, edited in the admin with the `blogeditor` field type. Fillable is name, slug, code, description, content and parent_id; nest_* columns exist in DDL and are not fillable. `models.Tag` is not translatable. Fillable is name, slug, description. Pivots are `golem15_journal_posts_categories` and `golem15_journal_posts_tags`.
- **Menu and sitemap item types.** The plugin registers its five PHP menu item types (`journal-category`, `all-journal-categories`, `journal-post`, `all-journal-posts`, `category-journal-posts`), `journal-tag` and `journal-author` with the framework's menu item type registry, so menus and sitemaps can point at posts, categories, tags and author pages. Posts, categories, tags and authors carry content descriptors, so plugins that work on every content type (sitemaps, SEO, search) describe, page and match Journal records without the Journal importing them. See [menu item types](#menu-item-types) and [content descriptors](#content-descriptors). - **Menu and sitemap item types.** The plugin registers its five PHP menu item types (`journal-category`, `all-journal-categories`, `journal-post`, `all-journal-posts`, `category-journal-posts`), `journal-tag` and `journal-author` with the framework's menu item type registry, so menus and sitemaps can point at posts, categories, tags and author pages. Posts, categories, tags and authors carry content descriptors, so plugins that work on every content type (sitemaps, SEO, search) describe, page and match Journal records without the Journal importing them. See [menu item types](#menu-item-types) and [content descriptors](#content-descriptors).
- **Settings.** Singleton row ID=1 on `golem15_journal_settings`, not PHP `system_settings`. `search_use_typesense` defaults to false. A fresh save never contacts Typesense. The Headings and links tab holds the H1 setting `content_h1_to_h2` (on by default) and the generic link texts `generic_anchors`; see [headings and links](#headings-and-links). - **Settings.** Singleton row ID=1 on `golem15_journal_settings`, not PHP `system_settings`. `search_use_typesense` defaults to false. A fresh save never contacts Typesense. The Headings and links tab holds the H1 setting `content_h1_to_h2` (on by default) and the generic link texts `generic_anchors`; see [headings and links](#headings-and-links).
@@ -474,7 +474,7 @@ if reg := classes.EmbedRegistryFrom(app); reg != nil {
| `journal.Plugin` | Compiled plugin; `ID` is `golem15.journal`. | | `journal.Plugin` | Compiled plugin; `ID` is `golem15.journal`. |
| `journal.Plugin.Requires` | Returns `golem15.translate` only. | | `journal.Plugin.Requires` | Returns `golem15.translate` only. |
| `journal.Plugin.LangFS` | Embedded English and Polish UI phrasebooks. | | `journal.Plugin.LangFS` | Embedded English and Polish UI phrasebooks. |
| `journal.Plugin.ConfigFS` | Ships `config/config.yaml` (`golem15.journal.content_h1_to_h2`, `golem15.journal.related_mode`, `golem15.journal.related_count`, `golem15.journal.image_widths`). | | `journal.Plugin.ConfigFS` | Ships `config/config.yaml` (`golem15.journal.content_h1_to_h2`, `golem15.journal.related_mode`, `golem15.journal.related_count`, `golem15.journal.image_widths`, `golem15.journal.embed_providers`). |
| `journal.Plugin.Migrations` | gormigrate steps registered by this plugin. | | `journal.Plugin.Migrations` | gormigrate steps registered by this plugin. |
| `journal.Plugin.Models` | Models registered by this plugin. | | `journal.Plugin.Models` | Models registered by this plugin. |
| `journal.Plugin.Commands` | Registers `journal:export-posts`, `journal:import-posts`, `journal:reindex`, `journal:fix-headings` and `journal:image-variants`. | | `journal.Plugin.Commands` | Registers `journal:export-posts`, `journal:import-posts`, `journal:reindex`, `journal:fix-headings` and `journal:image-variants`. |

File diff suppressed because one or more lines are too long

View File

@@ -798,12 +798,12 @@ export class BlogEditorElement extends HTMLElement {
} }
const aspect = this.#inputOf(this.#embedForm, 'aspect') const aspect = this.#inputOf(this.#embedForm, 'aspect')
if (aspect !== '' && !isValidAspect(aspect)) { if (aspect !== '' && !isValidAspect(aspect)) {
this.#embedForm.error.textContent = this.#labels.embedIdInvalid this.#embedForm.error.textContent = this.#labels.embedAspectInvalid
return return
} }
const height = this.#inputOf(this.#embedForm, 'height') const height = this.#inputOf(this.#embedForm, 'height')
if (height !== '' && !isValidHeight(height)) { if (height !== '' && !isValidHeight(height)) {
this.#embedForm.error.textContent = this.#labels.embedIdInvalid this.#embedForm.error.textContent = this.#labels.embedHeightInvalid
return return
} }
const fallbackAlt = this.#inputOf(this.#embedForm, 'fallbackAlt') const fallbackAlt = this.#inputOf(this.#embedForm, 'fallbackAlt')

View File

@@ -43,6 +43,7 @@ const YOUTUBE_HOSTS = new Set([
]) ])
const EMBED_KEY_RE = /^[a-z][a-z0-9_-]{0,31}$/ const EMBED_KEY_RE = /^[a-z][a-z0-9_-]{0,31}$/
const RESERVED_EMBED_KEYS = new Set(['constructor', 'prototype'])
const EMBED_ASPECT_RE = /^[1-9][0-9]{0,3}(?:\s*\/\s*[1-9][0-9]{0,3}|\.[0-9]{1,4})?$/ const EMBED_ASPECT_RE = /^[1-9][0-9]{0,3}(?:\s*\/\s*[1-9][0-9]{0,3}|\.[0-9]{1,4})?$/
const EMBED_HEIGHT_RE = /^[1-9][0-9]{0,3}(?:px)?$/ const EMBED_HEIGHT_RE = /^[1-9][0-9]{0,3}(?:px)?$/
@@ -92,7 +93,7 @@ export function resolveEmbedProviders(raw: unknown): ResolvedEmbedProvider[] {
if (!item || typeof item !== 'object' || Array.isArray(item)) continue if (!item || typeof item !== 'object' || Array.isArray(item)) continue
const cfg = item as Record<string, unknown> const cfg = item as Record<string, unknown>
const key = typeof cfg.key === 'string' ? cfg.key.trim() : '' const key = typeof cfg.key === 'string' ? cfg.key.trim() : ''
if (!EMBED_KEY_RE.test(key) || seen.has(key)) continue if (!EMBED_KEY_RE.test(key) || RESERVED_EMBED_KEYS.has(key) || seen.has(key)) continue
const patternSrc = typeof cfg.idPattern === 'string' ? cfg.idPattern.trim() : '' const patternSrc = typeof cfg.idPattern === 'string' ? cfg.idPattern.trim() : ''
if (!patternSrc) continue if (!patternSrc) continue
let idPattern: RegExp let idPattern: RegExp
@@ -103,9 +104,11 @@ export function resolveEmbedProviders(raw: unknown): ResolvedEmbedProvider[] {
continue continue
} }
const name = typeof cfg.name === 'string' && cfg.name.trim() !== '' ? cfg.name.trim() : key const name = typeof cfg.name === 'string' && cfg.name.trim() !== '' ? cfg.name.trim() : key
const idFromUrl = key === 'youtube' ? EMBED_PROVIDERS.youtube.idFromUrl : undefined
const rawMode = typeof cfg.mode === 'string' ? cfg.mode.trim() : '' const rawMode = typeof cfg.mode === 'string' ? cfg.mode.trim() : ''
// Only providers with a URL parser can operate in URL mode (WR-03).
const mode: EmbedInputMode = const mode: EmbedInputMode =
rawMode === 'url' || rawMode === 'id' ? rawMode : key === 'youtube' ? 'url' : 'id' rawMode === 'url' && idFromUrl ? 'url' : rawMode === 'id' ? 'id' : idFromUrl ? 'url' : 'id'
const placeholder = typeof cfg.placeholder === 'string' && cfg.placeholder.trim() !== '' ? cfg.placeholder.trim() : undefined const placeholder = typeof cfg.placeholder === 'string' && cfg.placeholder.trim() !== '' ? cfg.placeholder.trim() : undefined
const resolved: ResolvedEmbedProvider = { const resolved: ResolvedEmbedProvider = {
key, key,
@@ -113,7 +116,7 @@ export function resolveEmbedProviders(raw: unknown): ResolvedEmbedProvider[] {
idPattern, idPattern,
mode, mode,
...(placeholder ? { placeholder } : {}), ...(placeholder ? { placeholder } : {}),
...(key === 'youtube' ? { idFromUrl: EMBED_PROVIDERS.youtube.idFromUrl } : {}), ...(idFromUrl ? { idFromUrl } : {}),
} }
seen.add(key) seen.add(key)
out.push(resolved) out.push(resolved)

View File

@@ -48,7 +48,9 @@ export interface Labels {
embedFallbackAlt: string embedFallbackAlt: string
embedCaption: string embedCaption: string
embedAspect: string embedAspect: string
embedAspectInvalid: string
embedHeight: string embedHeight: string
embedHeightInvalid: string
embedGeneric: string embedGeneric: string
cancel: string cancel: string
uploading: string uploading: string
@@ -133,7 +135,9 @@ const en: Labels = {
embedFallbackAlt: 'Fallback alt text (optional)', embedFallbackAlt: 'Fallback alt text (optional)',
embedCaption: 'Caption (optional)', embedCaption: 'Caption (optional)',
embedAspect: 'Aspect ratio (optional)', embedAspect: 'Aspect ratio (optional)',
embedAspectInvalid: 'Enter a valid aspect ratio (e.g. 16/9 or 1.5).',
embedHeight: 'Height (optional)', embedHeight: 'Height (optional)',
embedHeightInvalid: 'Enter a valid height in pixels (e.g. 420 or 420px).',
embedGeneric: 'Embed', embedGeneric: 'Embed',
cancel: 'Cancel', cancel: 'Cancel',
uploading: 'Uploading {name}…', uploading: 'Uploading {name}…',
@@ -215,7 +219,9 @@ const pl: Labels = {
embedFallbackAlt: 'Tekst alternatywny obrazu (opcjonalny)', embedFallbackAlt: 'Tekst alternatywny obrazu (opcjonalny)',
embedCaption: 'Podpis (opcjonalny)', embedCaption: 'Podpis (opcjonalny)',
embedAspect: 'Proporcje (opcjonalne)', embedAspect: 'Proporcje (opcjonalne)',
embedAspectInvalid: 'Wpisz poprawne proporcje (np. 16/9 lub 1.5).',
embedHeight: 'Wysokość (opcjonalna)', embedHeight: 'Wysokość (opcjonalna)',
embedHeightInvalid: 'Wpisz poprawną wysokość w pikselach (np. 420 lub 420px).',
embedGeneric: 'Osadź', embedGeneric: 'Osadź',
cancel: 'Anuluj', cancel: 'Anuluj',
uploading: 'Wysyłanie {name}…', uploading: 'Wysyłanie {name}…',

View File

@@ -161,7 +161,7 @@ export function previewBody(
if (provider === 'youtube' && figure.childNodes.length === 0) { if (provider === 'youtube' && figure.childNodes.length === 0) {
const card = doc.createElement('figure') const card = doc.createElement('figure')
card.className = 'embed-card' card.className = 'embed-card embed-card--youtube'
const img = doc.createElement('img') const img = doc.createElement('img')
img.setAttribute('src', youtubeThumbnail(id)) img.setAttribute('src', youtubeThumbnail(id))
img.setAttribute('alt', '') img.setAttribute('alt', '')
@@ -220,7 +220,8 @@ function previewStyles(c: PreviewColors, font: string): string {
`th{background:${c.subtle};font-weight:600;text-align:left}`, `th{background:${c.subtle};font-weight:600;text-align:left}`,
`figcaption{font-size:13px;color:${c.muted};margin-top:4px}`, `figcaption{font-size:13px;color:${c.muted};margin-top:4px}`,
`.embed-card{max-width:480px;border:1px solid ${c.border};border-radius:8px;overflow:hidden;background:${c.subtle}}`, `.embed-card{max-width:480px;border:1px solid ${c.border};border-radius:8px;overflow:hidden;background:${c.subtle}}`,
'.embed-card img{display:block;width:100%;height:auto;aspect-ratio:16/9;object-fit:cover}', '.embed-card img{display:block;width:100%;height:auto}',
'.embed-card--youtube img{aspect-ratio:16/9;object-fit:cover}',
`.embed-card__placeholder{padding:24px 16px;text-align:center;font-size:14px;color:${c.muted}}`, `.embed-card__placeholder{padding:24px 16px;text-align:center;font-size:14px;color:${c.muted}}`,
'.embed-card figcaption{padding:8px 12px;margin:0}', '.embed-card figcaption{padding:8px 12px;margin:0}',
].join('\n') ].join('\n')

View File

@@ -27,6 +27,13 @@ var (
embedAspectPattern = regexp.MustCompile(`^[1-9][0-9]{0,3}(?:\s*/\s*[1-9][0-9]{0,3}|\.[0-9]{1,4})?$`) embedAspectPattern = regexp.MustCompile(`^[1-9][0-9]{0,3}(?:\s*/\s*[1-9][0-9]{0,3}|\.[0-9]{1,4})?$`)
embedHeightPattern = regexp.MustCompile(`^[1-9][0-9]{0,3}(?:px)?$`) embedHeightPattern = regexp.MustCompile(`^[1-9][0-9]{0,3}(?:px)?$`)
// reservedEmbedProviderKeys mirrors vue-journal-layer's prototype-property
// guard so Go, Blog Editor, and Nuxt enforce the exact same key allow-list.
reservedEmbedProviderKeys = map[string]bool{
"constructor": true,
"prototype": true,
}
// defaultEmbedRegistry is the immutable youtube-only registry used when // defaultEmbedRegistry is the immutable youtube-only registry used when
// callers invoke package-level HTML helpers without a backpack.App. // callers invoke package-level HTML helpers without a backpack.App.
defaultEmbedRegistry = NewEmbedRegistry() defaultEmbedRegistry = NewEmbedRegistry()
@@ -97,8 +104,8 @@ func (r *EmbedRegistry) Register(p EmbedProvider) error {
return fmt.Errorf("embed provider: registry is nil") return fmt.Errorf("embed provider: registry is nil")
} }
p.Key = strings.TrimSpace(p.Key) p.Key = strings.TrimSpace(p.Key)
if !embedProviderKeyPattern.MatchString(p.Key) { if !embedProviderKeyPattern.MatchString(p.Key) || reservedEmbedProviderKeys[p.Key] {
return fmt.Errorf("embed provider %q: key must match %s", p.Key, embedProviderKeyPattern.String()) return fmt.Errorf("embed provider %q: key must match %s and must not be a reserved name", p.Key, embedProviderKeyPattern.String())
} }
p.IDPattern = strings.TrimSpace(p.IDPattern) p.IDPattern = strings.TrimSpace(p.IDPattern)
if p.IDPattern == "" { if p.IDPattern == "" {

View File

@@ -127,6 +127,8 @@ journal:
}{ }{
{"path traversal key", EmbedProvider{Key: "../x", IDPattern: `^[a-z]+$`}, "../x"}, {"path traversal key", EmbedProvider{Key: "../x", IDPattern: `^[a-z]+$`}, "../x"},
{"uppercase key", EmbedProvider{Key: "YouTube", IDPattern: `^[a-z]+$`}, "YouTube"}, {"uppercase key", EmbedProvider{Key: "YouTube", IDPattern: `^[a-z]+$`}, "YouTube"},
{"reserved constructor key", EmbedProvider{Key: "constructor", IDPattern: `^[a-z]+$`}, "constructor"},
{"reserved prototype key", EmbedProvider{Key: "prototype", IDPattern: `^[a-z]+$`}, "prototype"},
{"empty key", EmbedProvider{Key: "", IDPattern: `^[a-z]+$`}, `""`}, {"empty key", EmbedProvider{Key: "", IDPattern: `^[a-z]+$`}, `""`},
{"missing pattern", EmbedProvider{Key: "viz", IDPattern: ""}, "viz"}, {"missing pattern", EmbedProvider{Key: "viz", IDPattern: ""}, "viz"},
{"invalid regex", EmbedProvider{Key: "viz", IDPattern: `[unclosed`}, "viz"}, {"invalid regex", EmbedProvider{Key: "viz", IDPattern: `[unclosed`}, "viz"},

View File

@@ -315,10 +315,15 @@ describe('dynamic embed providers (Phase 38)', () => {
{ key: 'viz', name: 'Duplicate', idPattern: '^[0-9]+$' }, { key: 'viz', name: 'Duplicate', idPattern: '^[0-9]+$' },
{ key: '../bad', name: 'Bad Key', idPattern: '^[a-z]+$' }, { key: '../bad', name: 'Bad Key', idPattern: '^[a-z]+$' },
{ key: 'BadCase', name: 'Upper', idPattern: '^[a-z]+$' }, { key: 'BadCase', name: 'Upper', idPattern: '^[a-z]+$' },
{ key: 'constructor', name: 'Reserved', idPattern: '^[a-z]+$' },
{ key: 'prototype', name: 'Reserved2', idPattern: '^[a-z]+$' },
{ key: 'broken', name: 'Bad Regex', idPattern: '[unclosed' }, { key: 'broken', name: 'Bad Regex', idPattern: '[unclosed' },
{ key: 'empty', name: 'No Pattern', idPattern: '' }, { key: 'empty', name: 'No Pattern', idPattern: '' },
{ key: 'custom_url', name: 'Custom URL', idPattern: '^[a-z0-9-]+$', mode: 'url' },
]) ])
expect(resolved.map((p) => p.key)).toEqual(['youtube', 'viz']) expect(resolved.map((p) => p.key)).toEqual(['youtube', 'viz', 'custom_url'])
// Custom providers without a URL parser degrade to 'id' mode (WR-03).
expect(resolved.find((p) => p.key === 'custom_url')?.mode).toBe('id')
expect(validateEmbedId(resolved, 'viz', 'demo-1')).toBe(true) expect(validateEmbedId(resolved, 'viz', 'demo-1')).toBe(true)
expect(validateEmbedId(resolved, 'viz', 'demo-1!')).toBe(false) expect(validateEmbedId(resolved, 'viz', 'demo-1!')).toBe(false)
expect(validateEmbedId(resolved, 'youtube', 'demo-1')).toBe(false) expect(validateEmbedId(resolved, 'youtube', 'demo-1')).toBe(false)
@@ -378,7 +383,15 @@ describe('dynamic embed providers (Phase 38)', () => {
) )
fill(embedForm.querySelector('input[name="embedId"]'), 'demo-1') fill(embedForm.querySelector('input[name="embedId"]'), 'demo-1')
// Invalid aspect / height report dedicated error messages (WR-03).
fill(embedForm.querySelector('input[name="aspect"]'), '16:9')
click(embedForm.querySelector('[data-action="insert"]'))
expect(embedForm.querySelector('[data-error]')!.textContent).toBe(labelsFor('en').embedAspectInvalid)
fill(embedForm.querySelector('input[name="aspect"]'), '4/3') fill(embedForm.querySelector('input[name="aspect"]'), '4/3')
fill(embedForm.querySelector('input[name="height"]'), '420em')
click(embedForm.querySelector('[data-action="insert"]'))
expect(embedForm.querySelector('[data-error]')!.textContent).toBe(labelsFor('en').embedHeightInvalid)
fill(embedForm.querySelector('input[name="height"]'), '')
click(embedForm.querySelector('[data-action="insert"]')) click(embedForm.querySelector('[data-action="insert"]'))
expect(form(el, 'embed')).toBeNull() expect(form(el, 'embed')).toBeNull()