diff --git a/src/shared/InlineReference.module.css b/src/shared/InlineReference.module.css index e9617e57..86cda422 100644 --- a/src/shared/InlineReference.module.css +++ b/src/shared/InlineReference.module.css @@ -23,6 +23,11 @@ outline-offset: 2px; } +/* Channel hosts reset ordinary buttons to inherited text color. */ +[data-mention-kind].link { + color: var(--link-text); +} + .icon { display: inline-block; width: 1em; diff --git a/tests/browser/composer-links.spec.mjs b/tests/browser/composer-links.spec.mjs index f0a6703f..c3e62cfb 100644 --- a/tests/browser/composer-links.spec.mjs +++ b/tests/browser/composer-links.spec.mjs @@ -35,6 +35,31 @@ test("editable composer renders links and mentions while preserving source and n await expect(preview.locator('[data-mention-kind="agent"]')).toHaveText( "Build Bot", ); + const delivered = page.locator('[data-message-id="link-row"]'); + const deliveredLink = delivered + .locator('a:has([data-link-kind="github"])') + .first(); + const deliveredMentions = delivered.locator("[data-mention-kind]"); + const inlineStyles = await Promise.all( + [deliveredLink, deliveredMentions.nth(0), deliveredMentions.nth(1)].map( + (locator) => + locator.evaluate((element) => { + const style = getComputedStyle(element); + return { + color: style.color, + paddingBlock: [style.paddingTop, style.paddingBottom], + height: element.getBoundingClientRect().height, + }; + }), + ), + ); + for (const mentionStyle of inlineStyles.slice(1)) { + expect(mentionStyle.color).toBe(inlineStyles[0].color); + expect(mentionStyle.paddingBlock).toEqual(inlineStyles[0].paddingBlock); + expect( + Math.abs(mentionStyle.height - inlineStyles[0].height), + ).toBeLessThan(1); + } await expect(preview.getByRole("link")).toHaveCount(0); await expect(preview.getByRole("button")).toHaveCount(0); diff --git a/tests/fixtures/link-messages.tsx b/tests/fixtures/link-messages.tsx index dc909c5b..99046252 100644 --- a/tests/fixtures/link-messages.tsx +++ b/tests/fixtures/link-messages.tsx @@ -7,6 +7,7 @@ import type { PluginModule } from "../../src/plugins/api"; import type { ChannelMessage } from "../../src/features/relay/contracts"; import type { RelaySession } from "../../src/features/relay/session"; import * as links from "../../src/bundled/links"; +import channelStyles from "../../src/bundled/channels/Channels.module.css"; import { readView, writeView } from "../../src/shared/view-state"; import "../../src/shared/styles/globals.css"; @@ -120,6 +121,7 @@ const library = { identities: [{ pubkey: "b".repeat(64), name: "Build Bot" }], }; const emoji = { status: "ready", entries: [] }; +const typing: readonly never[] = []; const sent: Array<{ text: string; mentions: readonly string[] }> = []; Object.assign(window, { linkComposerFixture: { sent } }); const previewSession = { @@ -135,6 +137,10 @@ const previewSession = { return `preview-${sent.length}`; }, }, + typing: { + snapshot: () => typing, + subscribe: () => () => {}, + }, channels: { list: () => directory, subscribeList: () => () => {} }, profiles: { snapshot: () => profiles, @@ -186,6 +192,7 @@ function Preview() { const [enabled, setEnabled] = useState("on"); return (