Files
pbakaus_impeccable/tests/live-e2e-cli-options.test.mjs
T
Abdul WahabandGitHub 84135db0e6 Add DeepSeek live E2E adapter (#163)
* Add DeepSeek live E2E adapter

* Fix DeepSeek live E2E review issues

* Harden live-e2e helpers against silent failures

- htmlToJsx: match multi-line inline style attributes ([\s\S]*?)
- readCliOption: throw when --flag value is missing or another --flag
- llm-agent: echo parsed payload (first 500 chars) in schema-error throws

* Bind hoisted inline styles to their owning tag

normalizeVariantOutput previously hoisted every stripped style attribute
onto a selector derived from the variant's first tag, so a style on a
nested <span> landed on <h1>. Now walks each opening tag and emits one
rule per styled element with a descendant combinator so nested-element
styles target the correct node. Also fixes the duplicated multi-line
style regex bug (.*?) -> ([\s\S]*?) that survived the previous round.

Extracts parseVariantResponse from llm-agent for direct schema-throw
testing, and lifts readCliOption into its own module so its new
missing-value throws can be unit-tested.

Adds tests for:
- multi-line style hoisting
- nested-element tag binding and per-tag rule emission
- astro-global-prefixed selector shape
- no-op identity-return path
- opts.config short-circuit in createLlmAgent
- all four parseVariantResponse schema previews + JSON-parse failure
- readCliOption value/throw matrix

* Hoist inline styles via data attribute, not tag name

Two bugs in normalizeVariantOutput that Bugbot flagged:

1. Hoisted rules like `:scope span` matched every same-tag descendant of
   the variant wrap, so a style on one of several <span>s leaked onto its
   siblings.
2. The opening-tag scan used `[^>]*` for attributes, so a literal `>`
   inside a quoted attribute value (e.g. `aria-label="x > y"`) terminated
   the match early and the trailing `style="..."` was never seen.

stripInlineStylesPerElement now walks each opening tag character by
character respecting quoted attribute values, and tags every styled
element with `data-impeccable-hoist-id="N"`. Rules select on the
attribute so they bind to exactly the one element they came from.
The attribute is stripped during carbonize cleanup so it does not
survive into the final source.

* Harden live E2E variant CSS normalization

* Fix Radix tests

* Harden live E2E pick clicks
2026-05-22 09:28:36 -07:00

45 lines
1.5 KiB
JavaScript

import assert from 'node:assert/strict';
import { describe, it } from 'node:test';
import { readCliOption } from './live-e2e/cli-options.mjs';
describe('live-e2e readCliOption', () => {
const baseArgv = ['node', 'runner.mjs'];
it('reads --name=value form', () => {
assert.equal(readCliOption([...baseArgv, '--llm-model=foo'], 'llm-model'), 'foo');
});
it('reads --name value form', () => {
assert.equal(readCliOption([...baseArgv, '--llm-model', 'foo'], 'llm-model'), 'foo');
});
it('returns undefined when the flag is absent', () => {
assert.equal(readCliOption(baseArgv, 'llm-model'), undefined);
});
it('returns the first match when the flag appears more than once', () => {
assert.equal(
readCliOption([...baseArgv, '--llm-model=first', '--llm-model=second'], 'llm-model'),
'first',
);
});
it('throws when --name appears as the last argument with no value', () => {
assert.throws(
() => readCliOption([...baseArgv, '--llm-model'], 'llm-model'),
/--llm-model requires a value \(received no value\)/,
);
});
it('throws when the next argv would consume another flag as the value', () => {
assert.throws(
() => readCliOption([...baseArgv, '--llm-model', '--llm-provider=deepseek'], 'llm-model'),
/--llm-model requires a value \(received "--llm-provider=deepseek"\)/,
);
});
it('treats --name= (empty `=`) as an empty-string value, not a throw', () => {
assert.equal(readCliOption([...baseArgv, '--llm-model='], 'llm-model'), '');
});
});