Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions apps/meteor/tests/e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,26 @@ Do **not** apply when:
- Suite covers auth, 2FA, or session lifecycle — the browser state is the subject.
- Suite has more than ~15 tests: the debug cost of shared state outgrows the speed win (see "Big test files should not be `.serial`" above).

### Pattern 3 — navigate to a known room by URL, not by search

When a test already knows the room it needs (a channel created via API, `general`, etc.), open it directly with `poHomeChannel.gotoChannel(name)` instead of `page.goto('/home')` + `navbar.openChat(name)`.

```ts
// ❌ fragile — three independent things must align before the combobox `fill` resolves
await page.goto('/home');
await poHomeChannel.navbar.openChat(targetChannel);

// ✅ deterministic — navigate straight to the room, then wait for it to be ready
await poHomeChannel.gotoChannel(targetChannel);
```

Why: searching the navbar couples the navigation to (1) the app shell hydrating, (2) the **search index** having picked up the room — a real lag for a channel created moments earlier via API — and (3) the listbox rendering and the option becoming clickable. Any one stalling makes `searchInput.fill` hang until the test timeout, surfacing as the misleading `Target page, context or browser has been closed`. `gotoChannel` loads `/channel/<name>` and then `waitForChannel()` (main region, heading, message list, `aria-busy` cleared), so it has a proper readiness wait without the search dependency.

Do **not** apply when:
- The navbar search is the actual subject of the test.
- Navigating to a **DM** (`/direct/<username>`) or a **discussion** — `gotoChannel` builds a `/channel/` URL only.
- Reaching a channel the user is **not a member of** — the direct URL hits a different preview/join flow; verify the behavior before switching.

## API helpers for state seeding

Prefer these helpers in `beforeAll` / `beforeEach` and in setup `test.step`s. All live under `apps/meteor/tests/e2e/utils/`.
Expand Down Expand Up @@ -296,8 +316,7 @@ test.describe.serial('Feature X', () => {
page = await context.newPage();
poHomeChannel = new HomeChannel(page);

await page.goto('/home');
await poHomeChannel.navbar.openChat(targetChannel);
await poHomeChannel.gotoChannel(targetChannel);
});

test.afterAll(async ({ api }) => {
Expand Down Expand Up @@ -332,6 +351,7 @@ Recipe for a single spec. Keep PRs to at most 5 files so reviews stay tractable.
- `poHomeChannel.content.sendMessage(...)` used inside `beforeEach` or `beforeAll` — that is setup, should be `sendMessage(api, ...)`.
- Opening meatball menus or modals purely to create a discussion, thread, or DM as a setup step.
- `test.describe.serial` combined with `beforeEach(async ({ page }) => { await page.goto(...) })` — the context should be shared in `beforeAll`.
- `page.goto('/home')` + `navbar.openChat(name)` to reach a room the test already knows — use `poHomeChannel.gotoChannel(name)` (see Pattern 3). Searching a just-created channel races the search index and hangs until timeout.
- New non-serial suites whose tests still each carry >3s of UI setup.
- Inline `api.post('/im.create', …)` / `api.post('/chat.sendMessage', …)` in a spec instead of extending the helpers in `utils/`.

15 changes: 5 additions & 10 deletions apps/meteor/tests/e2e/embedded-layout.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ test.describe('embedded-layout', () => {

test.describe('Layout elements visibility', () => {
test('should hide primary navigation elements in embedded layout', async ({ page }) => {
await page.goto('/home');
await poHomeChannel.navbar.openChat(targetChannelId);
await poHomeChannel.gotoChannel(targetChannelId);
await expect(poHomeChannel.roomHeaderToolbar).toBeVisible();

await page.goto(embeddedLayoutURL(page.url()));
Expand All @@ -50,8 +49,7 @@ test.describe('embedded-layout', () => {
});

test('should show room header toolbar as top navbar when setting enabled', async ({ page }) => {
await page.goto('/home');
await poHomeChannel.navbar.openChat(targetChannelId);
await poHomeChannel.gotoChannel(targetChannelId);
await page.goto(embeddedLayoutURL(page.url()));

await expect(poHomeChannel.roomHeaderToolbar).toBeVisible();
Expand All @@ -61,8 +59,7 @@ test.describe('embedded-layout', () => {

test.describe('Channel member functionality', () => {
test('should hide join button and enable messaging for members', async ({ page }) => {
await page.goto('/home');
await poHomeChannel.navbar.openChat(targetChannelId);
await poHomeChannel.gotoChannel(targetChannelId);
await page.goto(embeddedLayoutURL(page.url()));

await expect(poHomeChannel.composer.inputMessage).toBeVisible();
Expand All @@ -71,8 +68,7 @@ test.describe('embedded-layout', () => {
});

test('should allow sending and receiving messages', async ({ page }) => {
await page.goto('/home');
await poHomeChannel.navbar.openChat(targetChannelId);
await poHomeChannel.gotoChannel(targetChannelId);
await page.goto(embeddedLayoutURL(page.url()));

const testMessage = `Embedded test message ${Date.now()}`;
Expand All @@ -81,8 +77,7 @@ test.describe('embedded-layout', () => {
});

test('should preserve message composer functionality', async ({ page }) => {
await page.goto('/home');
await poHomeChannel.navbar.openChat(targetChannelId);
await poHomeChannel.gotoChannel(targetChannelId);
await page.goto(embeddedLayoutURL(page.url()));

await expect(poHomeChannel.composer.inputMessage).toBeVisible();
Expand Down
8 changes: 3 additions & 5 deletions apps/meteor/tests/e2e/file-upload.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ test.describe.serial('file-upload', () => {
test.beforeEach(async ({ page }) => {
poHomeChannel = new HomeChannel(page);

await page.goto('/home');
await poHomeChannel.navbar.openChat(targetChannel);
await poHomeChannel.gotoChannel(targetChannel);
});

test.afterAll(async ({ api }) => {
Expand Down Expand Up @@ -132,7 +131,7 @@ test.describe.serial('file-upload', () => {

test('should upload file in composer after recording video message', async ({ context }) => {
await context.grantPermissions(['camera', 'microphone']);
await poHomeChannel.navbar.openChat(targetChannel);
await poHomeChannel.gotoChannel(targetChannel);

await test.step('should be able to record a video with text content in composer ', async () => {
await poHomeChannel.composer.inputMessage.fill('this is a message with video message');
Expand Down Expand Up @@ -235,8 +234,7 @@ test.describe('file-upload-not-member', () => {
test.beforeEach(async ({ page }) => {
poHomeChannel = new HomeChannel(page);

await page.goto('/home');
await poHomeChannel.navbar.openChat(targetChannel);
await poHomeChannel.gotoChannel(targetChannel);
});

test.afterAll(async ({ api }) => {
Expand Down
3 changes: 1 addition & 2 deletions apps/meteor/tests/e2e/image-upload.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ test.describe('image-upload', () => {

test.beforeEach(async ({ page }) => {
poHomeChannel = new HomeChannel(page);
await page.goto('/home');
await poHomeChannel.navbar.openChat(targetChannel);
await poHomeChannel.gotoChannel(targetChannel);
});

test.afterAll(async ({ api }) => {
Expand Down
3 changes: 1 addition & 2 deletions apps/meteor/tests/e2e/quote-attachment.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ test.describe.parallel('Quote Attachment', () => {

test.beforeEach(async ({ page }) => {
poHomeChannel = new HomeChannel(page);
await page.goto('/home');
await poHomeChannel.navbar.openChat(targetChannel);
await poHomeChannel.gotoChannel(targetChannel);
});

test.afterAll(async ({ api }) => {
Expand Down
3 changes: 1 addition & 2 deletions apps/meteor/tests/e2e/quote-messages.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ test.describe.serial('Quote Messages', () => {
page = await context.newPage();
poHomeChannel = new HomeChannel(page);

await page.goto('/home');
await poHomeChannel.navbar.openChat(targetChannel);
await poHomeChannel.gotoChannel(targetChannel);
});

test.afterAll(async ({ api }) => {
Expand Down
Loading