Skip to content

Commit 12bfe59

Browse files
committed
fix: stabilize graphing ESM runtime and targeted strategy tests
Prevent autosize sync rewrites from generating invalid graphing labels in ESM mode, and make unified strategy tests target graphing parabola demos and strategy subsets for focused regression coverage. Made-with: Cursor
1 parent 54feaa4 commit 12bfe59

5 files changed

Lines changed: 23 additions & 21 deletions

File tree

apps/element-demo/test/e2e/unified-player-strategy.spec.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
import { expect, test, type Page } from '@playwright/test';
22

33
const ELEMENT = process.env.UNIFIED_PLAYER_E2E_ELEMENT?.trim() || 'multiple-choice';
4-
const DEMO_QUERY = ELEMENT === 'multiple-choice' ? '&demo=math-algebra-quadratic' : '';
4+
const DEMO_ID =
5+
process.env.UNIFIED_PLAYER_E2E_DEMO?.trim() ||
6+
(ELEMENT === 'multiple-choice' ? 'math-algebra-quadratic' : ELEMENT === 'graphing' ? 'parabola-vertex' : '');
7+
const DEMO_QUERY = DEMO_ID ? `&demo=${DEMO_ID}` : '';
8+
const STRATEGIES = (process.env.UNIFIED_PLAYER_E2E_STRATEGIES?.trim() || 'esm,iife')
9+
.split(',')
10+
.map((s) => s.trim())
11+
.filter((s): s is 'esm' | 'iife' => s === 'esm' || s === 'iife');
512

613
async function waitForHostSettled(page: Page) {
714
await page.waitForFunction(
@@ -26,7 +33,7 @@ test.describe('Unified element player strategy host', () => {
2633
test('delivery uses one host for esm and iife', async ({ page }) => {
2734
test.setTimeout(120_000);
2835

29-
for (const strategy of ['esm', 'iife'] as const) {
36+
for (const strategy of STRATEGIES) {
3037
await page.goto(
3138
`/${ELEMENT}/deliver?mode=gather&role=student&player=${strategy}${DEMO_QUERY}`
3239
);
@@ -52,7 +59,7 @@ test.describe('Unified element player strategy host', () => {
5259
test('author and print mount through one host', async ({ page }) => {
5360
test.setTimeout(120_000);
5461

55-
for (const strategy of ['esm', 'iife'] as const) {
62+
for (const strategy of STRATEGIES) {
5663
await page.goto(`/${ELEMENT}/author?player=${strategy}`);
5764
await page.waitForSelector('pie-element-player[view="author"]', { timeout: 45_000 });
5865
await waitForHostSettled(page);

bun.lock

Lines changed: 0 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/element-player/src/players/PieElementPlayer.svelte

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,10 @@ function attachInstanceHandlers(viewMode: ElementPlayerView) {
192192
modelHandler = (event: Event) => {
193193
const customEvent = event as CustomEvent;
194194
const detail = customEvent.detail as any;
195-
dispatch('model-changed', detail?.update ?? detail);
195+
// Many elements emit partial updates in model.updated detail;
196+
// emit a full model snapshot to keep host state consistent.
197+
const nextModel = (elementInstance as any)?.model ?? detail?.model ?? detail?.update ?? detail;
198+
dispatch('model-changed', nextModel);
196199
};
197200
elementInstance.addEventListener('model.updated', modelHandler);
198201
}

packages/lib-react/graphing/src/mark-label.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export const coordinates = (graphProps, mark, rect = { width: 0, height: 0 }, po
115115
};
116116

117117
const LabelInput = ({ _ref, externalInputRef, label, disabled, inputStyle, onChange }) => (
118-
<AutosizeInputComponentComponent
118+
<AutosizeInputComponent
119119
inputRef={(r) => {
120120
_ref(r);
121121
externalInputRef(r);

tools/cli/src/lib/upstream/sync-presets.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ export function getPostSyncTextPatches(projectRoot: string): PostSyncTextPatch[]
8181
from: '<AutosizeInput',
8282
to: '<AutosizeInputComponent',
8383
},
84+
{
85+
from: '<AutosizeInputComponentComponent',
86+
to: '<AutosizeInputComponent',
87+
},
8488
{
8589
from: 'const AutosizeInputComponent = AutosizeInput?.default ?? AutosizeInput;\nconst AutosizeInputComponent = AutosizeInput?.default ?? AutosizeInput;',
8690
to: 'const AutosizeInputComponent = AutosizeInput?.default ?? AutosizeInput;',
@@ -100,6 +104,10 @@ export function getPostSyncTextPatches(projectRoot: string): PostSyncTextPatch[]
100104
from: '<AutosizeInput',
101105
to: '<AutosizeInputComponent',
102106
},
107+
{
108+
from: '<AutosizeInputComponentComponent',
109+
to: '<AutosizeInputComponent',
110+
},
103111
{
104112
from: 'const AutosizeInputComponent = AutosizeInput?.default ?? AutosizeInput;\nconst AutosizeInputComponent = AutosizeInput?.default ?? AutosizeInput;',
105113
to: 'const AutosizeInputComponent = AutosizeInput?.default ?? AutosizeInput;',

0 commit comments

Comments
 (0)