|
1 | 1 | import { test, expect } from "./fixture.mjs"; |
2 | 2 | import { open } from "./timeline.mjs"; |
| 3 | +import { openChannelDetails } from "./channel-details.mjs"; |
3 | 4 |
|
4 | 5 | test.use({ productionBroker: true, savedSidebar: true, sortingSidebar: true }); |
5 | 6 |
|
@@ -315,6 +316,129 @@ test.describe("nearby motion after layout changes", () => { |
315 | 316 | } |
316 | 317 | }); |
317 | 318 |
|
| 319 | +// Membership updates bypass prepared ordering; real layout and presence fades |
| 320 | +// must remain correct after hidden layout or rem-based geometry changes. |
| 321 | +test.describe("membership changes after layout changes", () => { |
| 322 | + test.use({ initialSidebarSort: { channels: "recent" } }); |
| 323 | + for (const change of ["Solo to Team", "interface text size"]) { |
| 324 | + test(`keeps retained rows still and fades additions/removals after ${change}`, async ({ |
| 325 | + page, |
| 326 | + app, |
| 327 | + }) => { |
| 328 | + await open(page, app); |
| 329 | + const section = page.locator('[data-sidebar-section="channels"]'); |
| 330 | + const rows = section.locator("button[data-channel-id]:not([inert] *)"); |
| 331 | + await expect(rows.first()).toHaveAttribute("data-channel-id", "willow"); |
| 332 | + await openChannelDetails(page); |
| 333 | + await page.getByText("Diagnostics", { exact: true }).click(); |
| 334 | + const refresh = page.getByRole("button", { |
| 335 | + name: "Refresh groups and stars", |
| 336 | + exact: true, |
| 337 | + }); |
| 338 | + let starred = ["alpha"]; |
| 339 | + // Model only the host's decoded preferences; its real store drives the rows. |
| 340 | + await page.route("**/sidebar-preferences", (route) => |
| 341 | + route.fulfill({ |
| 342 | + json: { |
| 343 | + sections: [{ id: "work", name: "Work", order: 0 }], |
| 344 | + assignments: { beta: "work" }, |
| 345 | + starred, |
| 346 | + muted: [], |
| 347 | + sort: { channels: "recent" }, |
| 348 | + }, |
| 349 | + }), |
| 350 | + ); |
| 351 | + for (const insertion of [false, true]) { |
| 352 | + if (change === "Solo to Team") { |
| 353 | + const channel = insertion |
| 354 | + ? await rows.last().getAttribute("data-channel-id") |
| 355 | + : "cedar"; |
| 356 | + await page.getByRole("tab", { name: "Solo", exact: true }).click(); |
| 357 | + await expect(section).toBeHidden(); |
| 358 | + app.activity({ channel, kind: 45003, age: insertion ? 29 : 30 }); |
| 359 | + await expect(rows.first()).toHaveAttribute( |
| 360 | + "data-channel-id", |
| 361 | + channel, |
| 362 | + ); |
| 363 | + await page.getByRole("tab", { name: "Team", exact: true }).click(); |
| 364 | + await expect(section).toBeVisible(); |
| 365 | + } else { |
| 366 | + const modifier = await page.evaluate(() => |
| 367 | + /Mac|iPhone|iPad/.test(navigator.platform) ? "Meta" : "Control", |
| 368 | + ); |
| 369 | + for (let step = 0; step < 3; step++) |
| 370 | + await page.keyboard.press(`${modifier}+=`); |
| 371 | + await expect(page.locator("html")).toHaveCSS( |
| 372 | + "--buzz-text-scale", |
| 373 | + insertion ? "1.6" : "1.3", |
| 374 | + ); |
| 375 | + } |
| 376 | + if (!insertion) |
| 377 | + starred.push(await rows.first().getAttribute("data-channel-id")); |
| 378 | + const id = starred[1]; |
| 379 | + const leaving = !insertion |
| 380 | + ? await rows.first().elementHandle() |
| 381 | + : undefined; |
| 382 | + const motion = await holdSidebarMotion(page); |
| 383 | + try { |
| 384 | + if (insertion) starred = ["alpha"]; |
| 385 | + await refresh.click(); |
| 386 | + await expect(rows).toHaveCount(insertion ? 3 : 2); |
| 387 | + await motion.seek("opacity"); |
| 388 | + expect( |
| 389 | + await rows.evaluateAll( |
| 390 | + (elements, id) => |
| 391 | + elements |
| 392 | + .filter((element) => element.dataset.channelId !== id) |
| 393 | + .every((element) => { |
| 394 | + const row = element.closest( |
| 395 | + "[data-channel-sidebar-row]", |
| 396 | + ).parentElement; |
| 397 | + return ( |
| 398 | + !row.hasAttribute("data-moving") && |
| 399 | + row |
| 400 | + .getAnimations() |
| 401 | + .every( |
| 402 | + (animation) => |
| 403 | + !animation.effect |
| 404 | + .getKeyframes() |
| 405 | + .some((frame) => "transform" in frame), |
| 406 | + ) |
| 407 | + ); |
| 408 | + }), |
| 409 | + id, |
| 410 | + ), |
| 411 | + ).toBe(true); |
| 412 | + const fading = insertion |
| 413 | + ? await section |
| 414 | + .locator(`button[data-channel-id="${id}"]:not([inert] *)`) |
| 415 | + .elementHandle() |
| 416 | + : leaving; |
| 417 | + const opacity = await fading.evaluate((element) => |
| 418 | + Number( |
| 419 | + getComputedStyle( |
| 420 | + element.closest("[data-channel-sidebar-row]").parentElement, |
| 421 | + ).opacity, |
| 422 | + ), |
| 423 | + ); |
| 424 | + expect(opacity).toBeGreaterThan(0); |
| 425 | + expect(opacity).toBeLessThan(1); |
| 426 | + if (!insertion) |
| 427 | + expect( |
| 428 | + await leaving.evaluate((element) => !!element.closest("[inert]")), |
| 429 | + ).toBe(true); |
| 430 | + } finally { |
| 431 | + await motion.release(); |
| 432 | + } |
| 433 | + await expect(section.locator("[inert] [data-channel-id]")).toHaveCount( |
| 434 | + 0, |
| 435 | + ); |
| 436 | + await expect(refresh).toBeEnabled(); |
| 437 | + } |
| 438 | + }); |
| 439 | + } |
| 440 | +}); |
| 441 | + |
318 | 442 | // Cedar and Willow exchange indices between A–Z and Recent; Maple keeps its |
319 | 443 | // index. Real browser frames prove the anchor never dims or shifts. |
320 | 444 | test("keeps a stationary selected row visible while its neighbors exchange places", async ({ |
|
0 commit comments