mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-11 06:30:03 +00:00
fix(lint): address render preflight review feedback (#2739)
This commit is contained in:
@@ -848,6 +848,108 @@ body {
|
||||
});
|
||||
});
|
||||
|
||||
describe("repeated_id_descendant_selector", () => {
|
||||
it("reports a selector that nests the same id inside itself", async () => {
|
||||
const html = `<div id="scene_01" data-composition-id="root" data-width="1920" data-height="1080">
|
||||
<style>#scene_01 #scene_01 .headline { color: red; }</style>
|
||||
</div>`;
|
||||
const result = await lintHyperframeHtml(html);
|
||||
const finding = result.findings.find((f) => f.code === "repeated_id_descendant_selector");
|
||||
expect(finding?.severity).toBe("error");
|
||||
expect(finding?.selector).toBe("#scene_01 #scene_01 .headline");
|
||||
});
|
||||
|
||||
it("does not report distinct descendant ids", async () => {
|
||||
const html = `<div id="scene_01" data-composition-id="root" data-width="1920" data-height="1080">
|
||||
<style>#scene_01 #headline { color: red; }</style>
|
||||
</div>`;
|
||||
const result = await lintHyperframeHtml(html);
|
||||
expect(
|
||||
result.findings.find((f) => f.code === "repeated_id_descendant_selector"),
|
||||
).toBeUndefined();
|
||||
});
|
||||
|
||||
it.each(["#scene_01 > #scene_01", "#scene_01 .wrapper #scene_01"])(
|
||||
"reports repeated ids across descendant combinators: %s",
|
||||
async (selector) => {
|
||||
const html = `<div data-composition-id="root" data-width="1920" data-height="1080">
|
||||
<style>${selector} { color: red; }</style>
|
||||
</div>`;
|
||||
const result = await lintHyperframeHtml(html);
|
||||
expect(
|
||||
result.findings.find((f) => f.code === "repeated_id_descendant_selector"),
|
||||
).toBeDefined();
|
||||
},
|
||||
);
|
||||
|
||||
it.each([
|
||||
":is(#scene_01) #scene_01",
|
||||
":where(#scene_01) #scene_01",
|
||||
"#scene_01 :is(#scene_01)",
|
||||
])("reports repeated ids required by selector pseudos: %s", async (selector) => {
|
||||
const html = `<div data-composition-id="root" data-width="1920" data-height="1080">
|
||||
<style>${selector} { color: red; }</style>
|
||||
</div>`;
|
||||
const result = await lintHyperframeHtml(html);
|
||||
expect(
|
||||
result.findings.find((f) => f.code === "repeated_id_descendant_selector"),
|
||||
).toBeDefined();
|
||||
});
|
||||
|
||||
it.each([
|
||||
":is(#scene_01, .scene) #scene_01",
|
||||
":not(#scene_01) #scene_01",
|
||||
":has(#scene_01) #scene_01",
|
||||
])("does not report ids that are not required by a selector pseudo: %s", async (selector) => {
|
||||
const html = `<div data-composition-id="root" data-width="1920" data-height="1080">
|
||||
<style>${selector} { color: red; }</style>
|
||||
</div>`;
|
||||
const result = await lintHyperframeHtml(html);
|
||||
expect(
|
||||
result.findings.find((f) => f.code === "repeated_id_descendant_selector"),
|
||||
).toBeUndefined();
|
||||
});
|
||||
|
||||
it.each(["& #scene_01 .headline", "#scene_01 .headline"])(
|
||||
"reports repeated ids created by nested CSS: %s",
|
||||
async (nestedSelector) => {
|
||||
const html = `<div data-composition-id="root" data-width="1920" data-height="1080">
|
||||
<style>#scene_01 { ${nestedSelector} { color: red; } }</style>
|
||||
</div>`;
|
||||
const result = await lintHyperframeHtml(html);
|
||||
const finding = result.findings.find(
|
||||
(candidate) => candidate.code === "repeated_id_descendant_selector",
|
||||
);
|
||||
expect(finding).toBeDefined();
|
||||
expect(finding?.selector).toContain("#scene_01 #scene_01");
|
||||
},
|
||||
);
|
||||
|
||||
it("preserves dollar sequences while resolving nested selectors", async () => {
|
||||
const html = `<div data-composition-id="root" data-width="1920" data-height="1080">
|
||||
<style>#scene_01[data-query="$1"] { & #scene_01 { color: red; } }</style>
|
||||
</div>`;
|
||||
const result = await lintHyperframeHtml(html);
|
||||
const finding = result.findings.find(
|
||||
(candidate) => candidate.code === "repeated_id_descendant_selector",
|
||||
);
|
||||
expect(finding?.selector).toBe('#scene_01[data-query="$1"] #scene_01');
|
||||
});
|
||||
|
||||
it.each(['[data-query="#scene_01 #scene_01"]', String.raw`#scene_01 #scene_01\:child`])(
|
||||
"does not report non-repeated parsed ids: %s",
|
||||
async (selector) => {
|
||||
const html = `<div data-composition-id="root" data-width="1920" data-height="1080">
|
||||
<style>${selector} { color: red; }</style>
|
||||
</div>`;
|
||||
const result = await lintHyperframeHtml(html);
|
||||
expect(
|
||||
result.findings.find((f) => f.code === "repeated_id_descendant_selector"),
|
||||
).toBeUndefined();
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
it("warns when a timeline-visible element has no stable id for Studio editing", async () => {
|
||||
const html = `
|
||||
<html><body>
|
||||
|
||||
Reference in New Issue
Block a user