mirror of
https://github.com/vector-im/element-web.git
synced 2026-07-10 09:19:38 +00:00
a0639bfc4b
* Forward the scroller element and scroll handle through VirtualizedList The room list needs two things the generic list did not expose: the underlying scroll container (to observe which items are genuinely visible) and the imperative scroll handle (to scroll an item into view). Forward an optional scrollerRef from useVirtualizedList and pass scrollHandleRef through FlatVirtualizedList, mirroring what GroupedVirtualizedList already exposes. Both are additive and optional, so other consumers are unaffected. Signed-off-by: David Langley <langley.dave@gmail.com> * Add an unread-activity toast to the room list Show a clickable "You have unread activity" pill when there are unread rooms scrolled below the visible fold, including unreads hidden inside collapsed sections whose header is below the fold. Clicking it scrolls the next such unread into view. The visible fold is tracked with an IntersectionObserver over the rendered item elements, so the toast appears as soon as a room crosses the fold rather than only once it leaves Virtuoso's overscan buffer. The toast click is wired through an imperative scroll handle the view registers with the view model. Signed-off-by: David Langley <langley.dave@gmail.com> * Change toast to target notifications only, not unread activity. * Fix formatting and refresh Toast snapshots for compound-web 9.7.0 - Apply oxfmt to the room list view model and virtualized view. - Refresh the RoomListToast/RoomListView story snapshots: compound-web 9.7.0 moves the typography classes onto the toast .content element and rebuilds the Toast CSS module hashes. - Add the missing UnreadActivityToast render snapshot baseline. * Add e2e tests for the room list unread activity toast Cover the unread-activity toast end to end: - it appears for a notifying room scrolled below the fold and clicking it scrolls that room into view (then the toast clears); - a room with only an unread-activity dot (no notification count) does not raise it; - a collapsed section hiding a notifying room raises it, and clicking scrolls the section header into view. * Add visual snapshot baselines for the unread-activity toast stories * Converge room-list toast codepaths into a single state-driven toast Reviewer feedback: the unread-activity toast and the transient event toasts (section_created / chat_moved) should share one mechanism, with toast lifecycle and precedence owned by the view model rather than split across a separate snapshot flag and a view-level ternary. - RoomListViewModel now reconciles the transient event toast and the derived unread-activity state into a single snapshot.toast via recomputeToast(); the event toast still takes precedence and auto-dismisses, and the unread toast reappears once it clears. Drops hasUnreadActivityBelow from the snapshot. - RoomListView renders a single RoomListToast driven by snapshot.toast; the ToastType union gains 'unread_activity'. The standalone UnreadActivityToast component is folded into RoomListToast (clickable arrow-down variant). - Adds VM tests for the unread-activity toast and the event/unread precedence. * Pre-bundle the room-list dnd-kit + virtuoso graph in vitest browser mode The room-list suites (RoomListView, VirtualizedRoomListView, RoomListItemMoreOptionsMenu) import a heavy @dnd-kit + react-virtuoso graph. Only @dnd-kit/abstract was pinned in optimizeDeps.include; @dnd-kit/dom, @dnd-kit/react, @dnd-kit/abstract/modifiers and react-virtuoso were left to runtime discovery. Under CI load the browser-mode dep optimizer can discover them late, re-bundle and reload the page, which fails the in-flight setupTests.ts import for those suites. Pinning the whole graph forces it into the initial optimize pass so no re-run happens while tests load. --------- Signed-off-by: David Langley <langley.dave@gmail.com>
138 lines
5.8 KiB
TypeScript
138 lines
5.8 KiB
TypeScript
/*
|
|
Copyright 2026 Element Creations Ltd.
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
|
Please see LICENSE files in the repository root for full details.
|
|
*/
|
|
|
|
import { defineConfig } from "vitest/config";
|
|
import path from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
import { storybookTest } from "@storybook/addon-vitest/vitest-plugin";
|
|
import { storybookVis } from "storybook-addon-vis/vitest-plugin";
|
|
import { playwright, PlaywrightProviderOptions } from "@vitest/browser-playwright";
|
|
import { nodePolyfills } from "vite-plugin-node-polyfills";
|
|
|
|
import rootConfig from "../../vitest.config";
|
|
import react from "@vitejs/plugin-react";
|
|
|
|
const dirname = typeof __dirname !== "undefined" ? __dirname : path.dirname(fileURLToPath(import.meta.url));
|
|
|
|
const commonContextOptions: PlaywrightProviderOptions["contextOptions"] = {
|
|
reducedMotion: "reduce",
|
|
// Force consistent font rendering
|
|
colorScheme: "light",
|
|
// Disable font smoothing for consistent rendering
|
|
deviceScaleFactor: 1,
|
|
};
|
|
|
|
const commonLaunchOptions = {
|
|
// Options to try to make font rendering more consistent
|
|
args: ["--font-render-hinting=none", "--disable-font-subpixel-positioning", "--disable-lcd-text"],
|
|
};
|
|
|
|
export default defineConfig({
|
|
test: {
|
|
coverage: {
|
|
exclude: ["src/**/*.stories.tsx"],
|
|
provider: "v8",
|
|
include: ["src/**/*.{ts,tsx}"],
|
|
reporter: [["lcov", { projectRoot: "../../" }]],
|
|
},
|
|
reporters: rootConfig.test?.reporters,
|
|
environment: "node",
|
|
pool: "threads",
|
|
globals: false,
|
|
projects: [
|
|
{
|
|
extends: true,
|
|
plugins: [
|
|
// The plugin will run tests for the stories defined in your Storybook config
|
|
// See options at: https://storybook.js.org/docs/next/writing-tests/integrations/vitest-addon#storybooktest
|
|
storybookTest({
|
|
configDir: path.join(dirname, ".storybook"),
|
|
storybookScript: "storybook --ci",
|
|
tags: {
|
|
exclude: ["skip-test"],
|
|
},
|
|
}),
|
|
storybookVis({
|
|
// 3px of difference allowed before marking as failed
|
|
failureThreshold: 3,
|
|
// When running in CI=1 mode, set the platform to `linux` as that is the platform where the browser-in-docker is running
|
|
snapshotRootDir: ({ ci, platform }) => `__vis__/${ci ? "linux" : platform}`,
|
|
}),
|
|
],
|
|
test: {
|
|
name: "storybook",
|
|
browser: {
|
|
enabled: true,
|
|
headless: true,
|
|
provider: playwright({
|
|
contextOptions: commonContextOptions,
|
|
launchOptions: commonLaunchOptions,
|
|
connectOptions: process.env.PW_TEST_CONNECT_WS_ENDPOINT
|
|
? {
|
|
wsEndpoint: process.env.PW_TEST_CONNECT_WS_ENDPOINT,
|
|
exposeNetwork: "<loopback>",
|
|
}
|
|
: undefined,
|
|
}),
|
|
instances: [{ browser: "chromium" }],
|
|
},
|
|
setupFiles: [".storybook/vitest.setup.ts"],
|
|
},
|
|
},
|
|
{
|
|
extends: true,
|
|
// as any is workaround for https://github.com/davidmyersdev/vite-plugin-node-polyfills/issues/150
|
|
plugins: [nodePolyfills({ include: ["util"], globals: { global: false } }) as any],
|
|
test: {
|
|
name: "unit",
|
|
browser: {
|
|
enabled: true,
|
|
headless: true,
|
|
provider: playwright({
|
|
// These tests don't actually take screenshots (at least at time of writing)
|
|
// but let's pass these options everywhere for consistency
|
|
contextOptions: commonContextOptions,
|
|
launchOptions: commonLaunchOptions,
|
|
}),
|
|
instances: [{ browser: "chromium" }],
|
|
},
|
|
setupFiles: ["src/test/setupTests.ts"],
|
|
},
|
|
css: {
|
|
modules: {
|
|
// Stabilise snapshots while keeping names distinct across CSS modules.
|
|
generateScopedName: "[name]_[local]",
|
|
},
|
|
},
|
|
},
|
|
],
|
|
},
|
|
optimizeDeps: {
|
|
include: [
|
|
"vite-plugin-node-polyfills/shims/buffer",
|
|
"vite-plugin-node-polyfills/shims/process",
|
|
"@vector-im/compound-design-tokens/assets/web/icons",
|
|
"storybook/preview-api",
|
|
// The room-list view pulls in a heavy dnd-kit + react-virtuoso graph. If these are left to
|
|
// runtime discovery, the browser-mode dep optimizer can re-bundle mid-run and reload the page,
|
|
// which fails the in-flight setupTests.ts import for the room-list unit suites. Pre-bundle the
|
|
// whole graph up front so the optimizer never needs to re-run while tests are loading.
|
|
"@dnd-kit/abstract",
|
|
"@dnd-kit/abstract/modifiers",
|
|
"@dnd-kit/dom",
|
|
"@dnd-kit/react",
|
|
"react-virtuoso",
|
|
],
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
"@test-utils": path.resolve(__dirname, "./src/test/utils/index.tsx"),
|
|
},
|
|
},
|
|
plugins: [react()],
|
|
});
|