Skip to content

Commit 7afed49

Browse files
authored
feat(app): contextual + dropdown and clean 4-card empty side panel (#68593)
1 parent 045e9e3 commit 7afed49

12 files changed

Lines changed: 267 additions & 447 deletions

File tree

‎packages/app/component-tests/browser-pane-restore.spec.ts‎

Lines changed: 16 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ test(
390390
},
391391
)
392392

393-
test("⌘T inside the browser pane opens the side panel's New tab, and a session everywhere else", async ({ page }) => {
393+
test("opens a browser tab with ⌘T inside the pane and a session everywhere else", async ({ page }) => {
394394
const root = page.getByTestId("browser-region-fixture")
395395
const mac = await page.evaluate(() => /Mac|iPhone|iPad|iPod/.test(navigator.platform))
396396
const mod = mac ? "Meta" : "Control"
@@ -399,7 +399,6 @@ test("⌘T inside the browser pane opens the side panel's New tab, and a session
399399
const editor = page.frameLocator('iframe[title="Browser page"]').getByRole("textbox", { name: "Editor page input" })
400400
const opens = root.getByTestId("browser-opens")
401401
const sessions = root.getByTestId("new-sessions")
402-
const newTabs = root.getByTestId("side-new-tabs")
403402
await expect(root.getByText("Registrations: 1", { exact: true })).toBeVisible()
404403
await outside.click()
405404
await expect(root.getByText("Registrations: 2", { exact: true })).toBeVisible()
@@ -410,12 +409,12 @@ test("⌘T inside the browser pane opens the side panel's New tab, and a session
410409
await outside.focus()
411410
await outside.press(`${mod}+t`)
412411
await expect(sessions).toHaveText("1")
413-
await expect(newTabs).toHaveText("0")
412+
await expect(opens).toHaveText("0")
414413

415-
// Inside the pane, as anywhere in the side panel, it opens a New tab rather than a blank browser tab.
414+
// Inside the pane it opens a browser tab directly.
416415
await address.focus()
417416
await address.press(`${mod}+t`)
418-
await expect(newTabs).toHaveText("1")
417+
await expect(opens).toHaveText("1")
419418

420419
// Dvorak's T sits on the physical K key: the shortcut follows the character, not the key position.
421420
await address.evaluate((element, meta) => {
@@ -430,47 +429,34 @@ test("⌘T inside the browser pane opens the side panel's New tab, and a session
430429
}),
431430
)
432431
}, mac)
433-
await expect(newTabs).toHaveText("2")
432+
await expect(opens).toHaveText("2")
434433

435434
// A focused page hands the reserved chord to the pane before it sees it.
436435
await editor.focus()
437436
await editor.press(`${mod}+t`)
438-
await expect(newTabs).toHaveText("3")
437+
await expect(opens).toHaveText("3")
439438
await expect(sessions).toHaveText("1")
440-
await expect(opens).toHaveText("0")
441439

442440
// The browser's own chord, which opens a blank browser tab, reaches the app from the page too.
443441
await editor.focus()
444442
await editor.press(mac ? "Control+Meta+b" : "Control+Alt+b")
445-
await expect(opens).toHaveText("1")
443+
await expect(opens).toHaveText("4")
446444
})
447445

448-
test("the side panel's New tab opens what its address field names in a browser tab", async ({ page }) => {
446+
test("the side panel's New tab view does not mount the browser address bar", async ({ page }) => {
449447
const root = page.getByTestId("browser-region-fixture")
450448
const mod = (await page.evaluate(() => /Mac|iPhone|iPad|iPod/.test(navigator.platform))) ? "Meta" : "Control"
451449
const panel = page.locator("#review-panel")
452450
const field = root.getByTestId("side-new-tab-view").getByRole("combobox", { name: "Browser address", exact: true })
453-
const opens = root.getByTestId("browser-opens")
454451
await expect(root.getByText("Registrations: 1", { exact: true })).toBeVisible()
455452
await root.getByRole("button", { name: "Beta", exact: true }).click()
456453
await root.getByRole("button", { name: "First inventory", exact: true }).click()
457454
await expect(root.getByTestId("selected")).toHaveText(/^browser:/)
458-
await expect(field).toHaveCount(0)
459455

460456
await panel.getByTestId("selected").click()
461457
await page.keyboard.press(`${mod}+t`)
462458
await expect(root.getByTestId("side-new-tab")).toHaveText("shown")
463-
464-
// An address opens as typed; main adds the scheme. Other text searches the web.
465-
await field.fill("example.com")
466-
await field.press("Enter")
467-
await expect(opens).toHaveText("1")
468-
await expect(root.getByRole("status").getByText("example.com", { exact: true })).toBeVisible()
469-
470-
await field.fill("solid signals")
471-
await field.press("Enter")
472-
await expect(opens).toHaveText("2")
473-
await expect(root.getByRole("status").getByText("https://www.google.com/search?q=solid%20signals", { exact: true })).toBeVisible()
459+
await expect(field).toHaveCount(0)
474460
})
475461

476462
test("⌘T and ⌘W follow focus: side tabs inside the side panel, session tabs elsewhere", async ({ page }) => {
@@ -497,16 +483,14 @@ test("⌘T and ⌘W follow focus: side tabs inside the side panel, session tabs
497483
await editor.click()
498484
await expect(panel).toHaveAttribute("data-focused")
499485
await editor.press(`${mod}+t`)
500-
await expect(newTab).toHaveText("shown")
501-
await expect(opens).toHaveText("0")
486+
await expect(opens).toHaveText("1")
487+
await expect(newTab).toHaveText("none")
502488
await expect(sessions).toHaveText("1")
503489

504-
// A click on the side panel's own surface, nothing focusable, leaves focus on the panel: ⌘W closes the new tab view
505-
// and ⌘T opens another, then ⌘W closes that view, then the selected tab.
490+
// A click on the side panel's own surface, nothing focusable, leaves focus on the panel: ⌘T opens the side panel's
491+
// new tab hook, then ⌘W closes that view, then the selected tab.
506492
await panel.getByTestId("selected").click()
507493
await expect(panel).toHaveAttribute("data-focused")
508-
await page.keyboard.press(`${mod}+w`)
509-
await expect(newTab).toHaveText("none")
510494
await page.keyboard.press(`${mod}+t`)
511495
await expect(newTab).toHaveText("shown")
512496
await page.keyboard.press(`${mod}+w`)
@@ -604,16 +588,15 @@ test("keeps blank browser tabs when adding tabs and selecting another panel", as
604588
const tabs = root.getByRole("tab", { name: "New tab", exact: true })
605589
await expect(tabs).toHaveAttribute("aria-selected", "true")
606590

607-
// The side panel's New tab opens over the blank browser tab and leaves it in the strip.
608591
await address.press(`${mac ? "Meta" : "Control"}+t`)
609-
await expect(root.getByTestId("side-new-tabs")).toHaveText("1")
610-
await expect(tabs).toHaveCount(1)
592+
await expect(tabs).toHaveCount(2)
593+
await expect(tabs.nth(1)).toHaveAttribute("aria-selected", "true")
611594
await expect(root.getByTestId("browser-closes")).toHaveText("[]")
612595

613596
// Selecting a different panel must not treat blank browser tabs as disposable placeholders.
614597
await address.press(`${mac ? "Meta" : "Control"}+1`)
615598
await expect(root.getByRole("tab", { name: "beta.ts", exact: true })).toHaveAttribute("aria-selected", "true")
616-
await expect(tabs).toHaveCount(1)
599+
await expect(tabs).toHaveCount(2)
617600
await expect(root.getByTestId("browser-closes")).toHaveText("[]")
618601
})
619602

‎packages/app/e2e/regression/review.spec.ts‎

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -494,32 +494,25 @@ test("context closes the side region only when its button opened it", async ({ p
494494
await toggle.click()
495495
await expect(toggle).toHaveAttribute("aria-expanded", "true")
496496
await expect(context).toHaveAttribute("aria-selected", "true")
497-
// "+" opens the New tab view over Context; picking a launcher replaces it with the tab it opens.
497+
// "+" opens the contextual launcher menu without adding a New tab; picking Review opens it directly.
498498
const newTab = panel.getByRole("tab", { name: "New tab", exact: true })
499499
await panel.getByRole("button", { name: "Add tab", exact: true }).click()
500-
await expect(newTab).toHaveAttribute("aria-selected", "true")
501-
await panel.getByRole("button", { name: /^Review/ }).click()
500+
await page.getByRole("menuitem", { name: /^Review/ }).click()
502501
await expect(newTab).toHaveCount(0)
503502
await expect(panel.locator("#session-side-panel-review-tab")).toHaveAttribute("aria-selected", "true")
504-
// Closing Review returns to Context, the tab the view opened over, without bringing the replaced view back.
503+
// Closing Review returns to Context without adding a New tab.
505504
await panel
506505
.locator('div[data-value="review:changes"]')
507506
.getByRole("button", { name: "Close tab", exact: true })
508507
.click()
509508
await expect(context).toHaveAttribute("aria-selected", "true")
510509
await expect(newTab).toHaveCount(0)
511-
// "Recently closed" lists only files, so the closed Review is offered again by its launcher alone.
510+
// The closed Review is offered again from the "+" menu.
512511
await panel.getByRole("button", { name: "Add tab", exact: true }).click()
513512
await expect(panel.getByRole("region", { name: "Recently closed", exact: true })).toHaveCount(0)
514-
await panel.getByRole("button", { name: /^Review/ }).click()
513+
await page.getByRole("menuitem", { name: /^Review/ }).click()
515514
await expect(panel.locator("#session-side-panel-review-tab")).toHaveAttribute("aria-selected", "true")
516515
await context.click()
517-
// Under a New tab view Context is not what the region shows, so its button shows it rather than closing it unseen.
518-
await panel.getByRole("button", { name: "Add tab", exact: true }).click()
519-
await expect(newTab).toHaveAttribute("aria-selected", "true")
520-
await contextButton.click()
521-
await expect(newTab).toHaveCount(0)
522-
await expect(context).toHaveAttribute("aria-selected", "true")
523516
await contextButton.click()
524517
await expect(context).toHaveCount(0)
525518
await expect(toggle).toHaveAttribute("aria-expanded", "true")
@@ -2225,14 +2218,14 @@ test("names a single change source and keeps the review header rows at 48px", as
22252218
await panel.getByRole("button", { name: "Close tab", exact: true }).click()
22262219
await expect(region).toHaveAttribute("aria-expanded", "false")
22272220
await region.click()
2228-
await expect(panel.getByRole("tab")).toHaveCount(1)
2229-
await expect(panel.getByRole("tab", { name: "New tab", exact: true })).toHaveAttribute("aria-selected", "true")
2230-
// "+" adds another New tab beside it instead of replacing it.
2231-
await panel.getByRole("button", { name: "Add tab", exact: true }).click()
2232-
await expect(panel.getByRole("tab", { name: "New tab", exact: true })).toHaveCount(2)
2233-
// Only its launchers: "Recently closed" lists files, not the closed Review.
2221+
// True 0-tab empty state shows the flat launcher stack with no "New tab" pill or "Recently closed" section.
2222+
await expect(panel.getByRole("tab")).toHaveCount(0)
22342223
await expect(panel.getByRole("button", { name: /^Review/ })).toBeVisible()
22352224
await expect(panel.getByRole("region", { name: "Recently closed", exact: true })).toHaveCount(0)
2225+
// "+" opens the contextual dropdown rather than adding a New tab.
2226+
await panel.getByRole("button", { name: "Add tab", exact: true }).click()
2227+
await expect(page.getByRole("menuitem", { name: /^Review/ })).toBeVisible()
2228+
await expect(panel.getByRole("tab")).toHaveCount(0)
22362229
})
22372230

22382231
test("Review from a new tab keeps the file browser and preview open", async ({ page }) => {
@@ -2251,10 +2244,8 @@ test("Review from a new tab keeps the file browser and preview open", async ({ p
22512244

22522245
await openFileLauncher(panel)
22532246
await expect(tab("Open file")).toHaveAttribute("aria-selected", "true")
2254-
// The empty panel's own New tab stays beside the one the file browser replaced, so the added one is the last.
22552247
await panel.getByRole("button", { name: "Add tab", exact: true }).click()
2256-
await expect(tab("New tab").last()).toHaveAttribute("aria-selected", "true")
2257-
await panel.getByRole("button", { name: /^Review/ }).click()
2248+
await page.getByRole("menuitem", { name: /^Review/ }).click()
22582249
await expect(tab("Review")).toHaveAttribute("aria-selected", "true")
22592250
await expect(tab("Open file")).toHaveAttribute("aria-selected", "false")
22602251
await tab("Review").hover()
@@ -2268,8 +2259,7 @@ test("Review from a new tab keeps the file browser and preview open", async ({ p
22682259

22692260
// Choosing Review also leaves a single-click file preview open beside it.
22702261
await panel.getByRole("button", { name: "Add tab", exact: true }).click()
2271-
await expect(tab("New tab").last()).toHaveAttribute("aria-selected", "true")
2272-
await panel.getByRole("button", { name: /^Review/ }).click()
2262+
await page.getByRole("menuitem", { name: /^Review/ }).click()
22732263
await expect(panel.locator("#session-side-panel-review-tab")).toHaveAttribute("aria-selected", "true")
22742264
await expect(tab("README.md")).toHaveCount(1)
22752265
})

0 commit comments

Comments
 (0)