fix: Bug - Fresh users have the server list in dashboard completely empty until anything searched

This commit is contained in:
2026-06-11 02:11:31 +02:00
parent 494a05e606
commit b1b3d93851
7 changed files with 224 additions and 50 deletions

View File

@@ -0,0 +1,98 @@
import { test, expect } from '../../fixtures/multi-client';
import { type Client } from '../../fixtures/multi-client';
import { RegisterPage } from '../../pages/register.page';
import { ServerSearchPage } from '../../pages/server-search.page';
import { dashboardSearchInput, expectDashboardReady } from '../../helpers/dashboard';
import { MULTI_DEVICE_PASSWORD, uniqueMultiDeviceName } from '../../helpers/multi-device-session';
/**
* Regression coverage for: "Fresh users have the server list in dashboard
* completely empty until anything searched."
*
* The directory exposes a curated discovery view (featured/trending) that must
* populate the dashboard "Popular Servers" panel and the /servers page without
* the user typing a search query. A stale client-side host blocklist used to
* short-circuit discovery to [] for the default production endpoints, so servers
* only appeared once a search ran. These tests prove the default view is
* populated, and that discovery self-heals when an endpoint lacks the
* featured/trending routes (older signal servers answer them with 404).
*/
async function createPublicServer(client: Client, username: string, serverName: string): Promise<void> {
const register = new RegisterPage(client.page);
await register.goto();
await register.register(username, 'Discovery Host', MULTI_DEVICE_PASSWORD);
await expect(client.page).toHaveURL(/\/dashboard/, { timeout: 15_000 });
const search = new ServerSearchPage(client.page);
await search.createServer(serverName, { description: 'Public discovery server' });
await expect(client.page).toHaveURL(/\/room\//, { timeout: 15_000 });
}
function popularServersPanel(client: Client) {
return client.page.locator('div.rounded-xl', { hasText: 'Popular Servers' });
}
test.describe('Server discovery default view', () => {
test.describe.configure({ timeout: 120_000, retries: 1 });
test('a fresh account sees public servers in Popular Servers without searching', async ({ createClient }) => {
const suffix = uniqueMultiDeviceName('discovery-default');
const serverName = `Discovery Default ${suffix}`;
const host = await createClient();
const visitor = await createClient();
await test.step('host registers and publishes a public server', async () => {
await createPublicServer(host, `host_${suffix}`, serverName);
});
await test.step('a brand-new account registers', async () => {
const register = new RegisterPage(visitor.page);
await register.goto();
await register.register(`visitor_${suffix}`, 'Discovery Visitor', MULTI_DEVICE_PASSWORD);
await expectDashboardReady(visitor.page);
});
await test.step('Popular Servers lists the public server with no search query entered', async () => {
await expect(dashboardSearchInput(visitor.page)).toHaveValue('');
await expect(popularServersPanel(visitor).getByText(serverName)).toBeVisible({ timeout: 30_000 });
});
});
test('discovery falls back to the public listing when featured/trending routes 404', async ({ createClient }) => {
const suffix = uniqueMultiDeviceName('discovery-fallback');
const serverName = `Discovery Fallback ${suffix}`;
const host = await createClient();
const visitor = await createClient();
await test.step('host registers and publishes a public server', async () => {
await createPublicServer(host, `host_${suffix}`, serverName);
});
await test.step('simulate a legacy signal server without featured/trending routes', async () => {
const notFound = {
status: 404,
contentType: 'application/json',
body: JSON.stringify({ error: 'Server not found', errorCode: 'SERVER_NOT_FOUND' })
};
await visitor.page.route('**/api/servers/featured**', (route) => route.fulfill(notFound));
await visitor.page.route('**/api/servers/trending**', (route) => route.fulfill(notFound));
});
await test.step('a brand-new account registers against the legacy-style endpoint', async () => {
const register = new RegisterPage(visitor.page);
await register.goto();
await register.register(`visitor_${suffix}`, 'Discovery Visitor', MULTI_DEVICE_PASSWORD);
await expectDashboardReady(visitor.page);
});
await test.step('Popular Servers still lists the server via the public-listing fallback', async () => {
await expect(dashboardSearchInput(visitor.page)).toHaveValue('');
await expect(popularServersPanel(visitor).getByText(serverName)).toBeVisible({ timeout: 30_000 });
});
});
});