Skip to content

Commit 8dd9456

Browse files
refactor: remove remaining fixed editor assumptions.
1 parent 1b7d618 commit 8dd9456

25 files changed

Lines changed: 313 additions & 307 deletions

playwright/github-pr-drawer/active-context-sync.spec.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,10 +1045,13 @@ test('Active PR context push commit uses Git Database API atomic path by default
10451045
const tabs = Array.isArray(workspaceRecord?.tabs)
10461046
? (workspaceRecord.tabs as Array<Record<string, unknown>>)
10471047
: []
1048-
const tabIds = new Set(
1049-
tabs.map(tab => (typeof tab?.id === 'string' ? tab.id : '')).filter(Boolean),
1050-
)
1051-
const hasPrimaryTabs = tabIds.has('component') && tabIds.has('styles')
1048+
const hasEntryTab = tabs.some(tab => tab?.role === 'entry')
1049+
const hasStyleTab = tabs.some(tab => {
1050+
const language =
1051+
typeof tab?.language === 'string' ? tab.language.trim().toLowerCase() : ''
1052+
return language === 'css' || language === 'less' || language === 'sass'
1053+
})
1054+
const hasPrimaryTabs = hasEntryTab && hasStyleTab
10521055
return hasPrimaryTabs && tabs.every(tab => tab?.isDirty === false)
10531056
},
10541057
{ timeout: 10_000 },
@@ -2186,8 +2189,11 @@ test('Reloaded active PR context does not apply partial sync when one primary fi
21862189
? (workspaceRecord.tabs as Array<Record<string, unknown>>)
21872190
: []
21882191

2189-
const entryTab = tabs.find(tab => tab?.id === 'component')
2190-
const stylesTab = tabs.find(tab => tab?.id === 'styles')
2192+
const entryTab = tabs.find(tab => tab?.role === 'entry')
2193+
const stylesTab = tabs.find(
2194+
tab =>
2195+
typeof tab?.path === 'string' && tab.path.trim() === 'src/styles/app.css',
2196+
)
21912197

21922198
return {
21932199
entryContent: typeof entryTab?.content === 'string' ? entryTab.content : '',
@@ -2377,7 +2383,7 @@ test('Reloaded active PR context sync does not overwrite non-primary module tabs
23772383
? (workspaceRecord.tabs as Array<Record<string, unknown>>)
23782384
: []
23792385

2380-
const entryTab = tabs.find(tab => tab?.id === 'component')
2386+
const entryTab = tabs.find(tab => tab?.role === 'entry')
23812387
const boopTab = tabs.find(tab => tab?.id === 'module-boop')
23822388
const beepTab = tabs.find(tab => tab?.id === 'module-beep')
23832389

@@ -2590,7 +2596,7 @@ test('Reloaded active PR context sync does not overwrite non-primary tabs with s
25902596
? (workspaceRecord.tabs as Array<Record<string, unknown>>)
25912597
: []
25922598

2593-
const entryTab = tabs.find(tab => tab?.id === 'component')
2599+
const entryTab = tabs.find(tab => tab?.role === 'entry')
25942600
const boopTab = tabs.find(tab => tab?.id === 'module-boop')
25952601
const beepTab = tabs.find(tab => tab?.id === 'module-beep')
25962602

playwright/github-pr-drawer/github-pr-drawer.helpers.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ export const seedActivePrWorkspaceContext = async (
566566
renderMode,
567567
tabs: [
568568
{
569-
id: 'component',
569+
id: 'entry',
570570
name: 'App.tsx',
571571
path: 'src/components/App.tsx',
572572
language: 'javascript-jsx',
@@ -575,7 +575,7 @@ export const seedActivePrWorkspaceContext = async (
575575
content: 'export const App = () => <main>Hello from Knighted</main>',
576576
},
577577
{
578-
id: 'styles',
578+
id: 'style',
579579
name: 'app.css',
580580
path: 'src/styles/app.css',
581581
language: safeStyleLanguage,
@@ -584,7 +584,7 @@ export const seedActivePrWorkspaceContext = async (
584584
content: 'main { color: #111; }',
585585
},
586586
],
587-
activeTabId: 'component',
587+
activeTabId: 'entry',
588588
createdAt: Date.now() + 60_000,
589589
lastModified: Date.now() + 60_000,
590590
},
@@ -706,7 +706,7 @@ export const getWorkspaceComponentContent = (record: Record<string, unknown> | n
706706
return false
707707
}
708708

709-
return (tab as { id?: unknown }).id === 'component'
709+
return (tab as { role?: unknown }).role === 'entry'
710710
}) as { content?: unknown } | undefined
711711

712712
return typeof componentTab?.content === 'string' ? componentTab.content : ''
@@ -829,7 +829,7 @@ export const runActiveWorkspaceSwitchIntegrityScenario = async ({
829829
renderMode: 'react',
830830
tabs: [
831831
{
832-
id: 'component',
832+
id: 'entry',
833833
name: 'App.tsx',
834834
path: 'src/components/App.tsx',
835835
language: 'javascript-jsx',
@@ -838,7 +838,7 @@ export const runActiveWorkspaceSwitchIntegrityScenario = async ({
838838
content: 'export const App = () => <main>Active A content</main>',
839839
},
840840
],
841-
activeTabId: 'component',
841+
activeTabId: 'entry',
842842
createdAt: Date.now() - 60_000,
843843
lastModified: Date.now() - 60_000,
844844
},
@@ -853,7 +853,7 @@ export const runActiveWorkspaceSwitchIntegrityScenario = async ({
853853
renderMode: 'dom',
854854
tabs: [
855855
{
856-
id: 'component',
856+
id: 'entry',
857857
name: 'App.tsx',
858858
path: 'src/components/App.tsx',
859859
language: 'javascript-jsx',
@@ -862,7 +862,7 @@ export const runActiveWorkspaceSwitchIntegrityScenario = async ({
862862
content: `export const App = () => <main>Target ${targetState} content</main>`,
863863
},
864864
],
865-
activeTabId: 'component',
865+
activeTabId: 'entry',
866866
createdAt: Date.now() - 120_000,
867867
lastModified: Date.now() - 120_000,
868868
},
@@ -1077,7 +1077,7 @@ export const runActiveWorkspaceCrossRepoSwitchIntegrityScenario = async ({
10771077
renderMode: 'react',
10781078
tabs: [
10791079
{
1080-
id: 'component',
1080+
id: 'entry',
10811081
name: 'App.tsx',
10821082
path: 'src/components/App.tsx',
10831083
language: 'javascript-jsx',
@@ -1086,7 +1086,7 @@ export const runActiveWorkspaceCrossRepoSwitchIntegrityScenario = async ({
10861086
content: 'export const App = () => <main>Cross source active content</main>',
10871087
},
10881088
],
1089-
activeTabId: 'component',
1089+
activeTabId: 'entry',
10901090
createdAt: Date.now() - 60_000,
10911091
lastModified: Date.now() - 60_000,
10921092
},
@@ -1101,7 +1101,7 @@ export const runActiveWorkspaceCrossRepoSwitchIntegrityScenario = async ({
11011101
renderMode: 'dom',
11021102
tabs: [
11031103
{
1104-
id: 'component',
1104+
id: 'entry',
11051105
name: 'App.tsx',
11061106
path: 'src/components/App.tsx',
11071107
language: 'javascript-jsx',
@@ -1110,7 +1110,7 @@ export const runActiveWorkspaceCrossRepoSwitchIntegrityScenario = async ({
11101110
content: `export const App = () => <main>Cross target ${targetState} content</main>`,
11111111
},
11121112
],
1113-
activeTabId: 'component',
1113+
activeTabId: 'entry',
11141114
createdAt: Date.now() - 120_000,
11151115
lastModified: Date.now() - 120_000,
11161116
},

playwright/github-pr-drawer/open-pr-create.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@ test('Open PR success normalizes trailing newline without showing Edited indicat
784784

785785
await setComponentEditorSource(page, 'const App = () => <button>tap me</button>')
786786
await setStylesEditorSource(page, '.button { color: red; }')
787-
await addWorkspaceTab(page, { kind: 'styles' })
787+
await addWorkspaceTab(page, { type: 'style' })
788788

789789
const moduleStylesEditor = page
790790
.locator('.editor-panel[data-editor-kind="styles"] .cm-content')
@@ -816,7 +816,7 @@ test('Open PR success normalizes trailing newline without showing Edited indicat
816816
? (workspaceRecord.tabs as Array<Record<string, unknown>>)
817817
: []
818818

819-
const componentTab = tabs.find(tab => tab?.id === 'component')
819+
const componentTab = tabs.find(tab => tab?.role === 'entry')
820820
const appStylesTab = tabs.find(
821821
tab =>
822822
typeof tab?.path === 'string' && tab.path.trim() === 'src/styles/app.css',

playwright/helpers/app-test-helpers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,10 @@ export const getPreviewFrame = (page: Page) => page.frameLocator('#preview-host
155155

156156
export const addWorkspaceTab = async (
157157
page: Page,
158-
{ kind = 'component' }: { kind?: 'component' | 'styles' } = {},
158+
{ type = 'script' }: { type?: 'script' | 'style' } = {},
159159
) => {
160160
await page.getByRole('button', { name: 'Add workspace tab' }).click()
161-
if (kind === 'styles') {
161+
if (type === 'style') {
162162
await page.getByRole('button', { name: 'Add styles tab' }).click()
163163
return
164164
}

playwright/rendering-modes/core.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ test('preview styles require explicit import from entry graph', async ({ page })
7373
test('nested module imports can bring styles into preview graph', async ({ page }) => {
7474
await waitForInitialRender(page)
7575

76-
await addWorkspaceTab(page, { kind: 'component' })
77-
await addWorkspaceTab(page, { kind: 'styles' })
76+
await addWorkspaceTab(page, { type: 'script' })
77+
await addWorkspaceTab(page, { type: 'style' })
7878

7979
await setWorkspaceTabSource(page, {
8080
fileName: 'module.tsx',

playwright/workspace-tabs.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ const seedSyncedComponentTab = async (page: import('@playwright/test').Page) =>
6868
return tab
6969
}
7070

71-
if ((tab as { id?: unknown }).id !== 'component') {
71+
if ((tab as { role?: unknown }).role !== 'entry') {
7272
return tab
7373
}
7474

@@ -572,7 +572,7 @@ test('add menu can create styles tab while component tab is active', async ({ pa
572572
await waitForInitialRender(page)
573573

574574
await page.getByRole('button', { name: 'Open tab App.tsx' }).click()
575-
await addWorkspaceTab(page, { kind: 'styles' })
575+
await addWorkspaceTab(page, { type: 'style' })
576576

577577
await expect(page.getByRole('button', { name: 'Open tab module.css' })).toHaveAttribute(
578578
'aria-current',

0 commit comments

Comments
 (0)