e2e-chat
# E2E Group Chat Tests
What this skill does
# E2E Group Chat Tests
Playwright test suite for Constellation v3 group chat features. Tests message sending and display, threaded replies, emoji reactions, and @mention autocomplete. Uses `page.route()` to mock chat API responses and provides seed helpers for creating test channels and messages.
## When to Use This Skill
Use this skill when the user says:
- "test chat"
- "add chat e2e tests"
- "e2e chat"
- "test group chat"
- "playwright chat tests"
- "test chat messages"
- "test chat threads"
## Prerequisites
- Next.js app with App Router
- `e2e` skill installed (Playwright configured with `playwright.config.ts`)
- `group-chat` skill installed (chat channels, messages, threads, reactions, mentions)
- `auth-dev` skill installed (seed users for authentication)
- Dev server running on `localhost:3000`
## Installation
No additional packages required. The `e2e` skill provides `@playwright/test` and the Playwright configuration.
## What Gets Created
```
e2e/
├── fixtures/
│ └── mock-chat.ts # Chat API mock and seed helpers
├── helpers/
│ └── chat-auth.ts # Reusable sign-in helper for chat tests
├── chat-messages.spec.ts # Message list, send, display, pagination tests
├── chat-threads.spec.ts # Thread panel, replies, thread count tests
├── chat-reactions.spec.ts # Emoji picker, reaction toggle, count tests
└── chat-mentions.spec.ts # @mention autocomplete, insertion, display tests
```
## Setup Steps
### Step 1: Create `e2e/fixtures/mock-chat.ts`
Helpers for creating test data and intercepting chat API routes. Provides both seed functions (for real API calls) and mock functions (for intercepted responses).
```typescript
import type { Page } from "@playwright/test";
/**
* Shape of a chat channel returned by the API.
*/
type MockChannel = {
id: string;
name: string;
description: string;
createdAt: string;
memberCount: number;
};
/**
* Shape of a chat message returned by the API.
*/
type MockMessage = {
id: string;
channelId: string;
content: string;
authorId: string;
authorName: string;
authorAvatar: string;
createdAt: string;
threadCount: number;
reactions: Array<{
emoji: string;
count: number;
userIds: string[];
}>;
};
/**
* Shape of a chat user for mention autocomplete.
*/
type MockUser = {
id: string;
name: string;
email: string;
avatar: string;
};
const MOCK_CHANNEL: MockChannel = {
id: "ch-test-001",
name: "general",
description: "General discussion channel for testing",
createdAt: "2026-02-18T00:00:00.000Z",
memberCount: 2,
};
const MOCK_USERS: MockUser[] = [
{
id: "user-admin-1",
name: "Admin User",
email: "[email protected]",
avatar: "/avatars/admin.png",
},
{
id: "user-member-1",
name: "Member User",
email: "[email protected]",
avatar: "/avatars/member.png",
},
];
/**
* Generates an array of mock messages for a given channel.
*/
function generateMockMessages(
channelId: string,
count: number
): MockMessage[] {
const messages: MockMessage[] = [];
for (let i = 0; i < count; i++) {
const author = MOCK_USERS[i % MOCK_USERS.length];
messages.push({
id: `msg-${channelId}-${String(i).padStart(4, "0")}`,
channelId,
content: `Test message number ${i + 1} in the channel`,
authorId: author.id,
authorName: author.name,
authorAvatar: author.avatar,
createdAt: new Date(Date.now() - (count - i) * 60_000).toISOString(),
threadCount: 0,
reactions: [],
});
}
return messages;
}
/**
* Seeds a test chat channel by calling the actual API.
* Returns the created channel data.
*
* Requires the user to be authenticated (call signInAsTestUser first).
*/
export async function seedChatChannel(page: Page): Promise<MockChannel> {
const response = await page.request.post("/api/chat/channels", {
data: {
name: `test-${Date.now()}`,
description: "E2E test channel",
},
});
if (response.ok()) {
const body = (await response.json()) as { channel: MockChannel };
return body.channel;
}
// If the API is not available, return mock data
return { ...MOCK_CHANNEL, id: `ch-test-${Date.now()}` };
}
/**
* Seeds messages into a channel by calling the actual API.
*
* Requires the user to be authenticated.
*/
export async function seedMessages(
page: Page,
channelId: string,
count: number
): Promise<MockMessage[]> {
const messages: MockMessage[] = [];
for (let i = 0; i < count; i++) {
const response = await page.request.post(
`/api/chat/channels/${channelId}/messages`,
{
data: {
content: `Seeded test message ${i + 1}`,
},
}
);
if (response.ok()) {
const body = (await response.json()) as { message: MockMessage };
messages.push(body.message);
}
}
return messages;
}
/**
* Intercepts chat API routes with mock responses.
* Use this when you want fully mocked data without hitting the real API.
*
* Intercepts:
* - GET /api/chat/channels -> channel list
* - GET /api/chat/channels/:id -> single channel
* - GET /api/chat/channels/:id/messages -> message list (with pagination)
* - POST /api/chat/channels/:id/messages -> send message
* - POST /api/chat/channels/:id/messages/:mid/react -> add reaction
* - GET /api/chat/channels/:id/messages/:mid/thread -> thread messages
* - POST /api/chat/channels/:id/messages/:mid/thread -> reply in thread
* - GET /api/chat/users/search -> mention autocomplete
*/
export async function interceptChatApi(page: Page): Promise<void> {
// Track messages so newly sent ones appear in subsequent fetches
const messageStore: MockMessage[] = generateMockMessages(
MOCK_CHANNEL.id,
5
);
// Channel list
await page.route("**/api/chat/channels", async (route) => {
if (route.request().method() === "GET") {
await route.fulfill({
status: 200,
contentType: "application/json",
body: JSON.stringify({ channels: [MOCK_CHANNEL] }),
});
return;
}
if (route.request().method() === "POST") {
const data = route.request().postDataJSON() as {
name: string;
description?: string;
};
const newChannel: MockChannel = {
...MOCK_CHANNEL,
id: `ch-${Date.now()}`,
name: data.name,
description: data.description ?? "",
};
await route.fulfill({
status: 201,
contentType: "application/json",
body: JSON.stringify({ channel: newChannel }),
});
return;
}
await route.continue();
});
// Messages in a channel (supports pagination via ?cursor param)
await page.route(
/\/api\/chat\/channels\/[^/]+\/messages$/,
async (route) => {
if (route.request().method() === "GET") {
const url = new URL(route.request().url());
const cursor = url.searchParams.get("cursor");
const limit = Number(url.searchParams.get("limit") ?? "20");
// Simple pagination: if cursor is provided, return older messages
let messagesToReturn: MockMessage[];
if (cursor) {
// Generate older messages for pagination
messagesToReturn = generateMockMessages(
MOCK_CHANNEL.id,
limit
).map((msg, idx) => ({
...msg,
id: `msg-old-${idx}`,
content: `Older message ${idx + 1}`,
createdAt: new Date(
Date.now() - (limit + idx) * 120_000
).toISOString(),
}));
} else {
messagesToReturn = messageStore.slice(-limit);
}
await route.fulfill({
status: 200,
contentType: "application/json",
body: JSON.stringify({
messages: messagesToReturn,
nextCursor:
messagesToReturn.length >= limit
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.