Skip to content

Commit 71a3557

Browse files
committed
fix comments
1 parent a1886a4 commit 71a3557

4 files changed

Lines changed: 29 additions & 23 deletions

File tree

e2e/integration/lib/test-fixtures.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@ export function makeCredentials(prefix = 'pw'): Credentials {
2424

2525
async function applyCookiesToContext(context: BrowserContext, cookies: AuthCookies): Promise<void> {
2626
const url = new URL(FRONTEND_URL);
27-
const apiHost = (process.env.TEST_BACKEND_URL ?? 'https://api.openshock.dev').replace(
28-
/^https?:\/\//,
29-
''
30-
);
27+
const apiHost = new URL(process.env.TEST_BACKEND_URL ?? 'https://api.openshock.dev').hostname;
3128
const parsed = cookies.flatMap((raw) => {
3229
const [pair, ...attrs] = raw.split(';').map((s) => s.trim());
3330
const [name, ...rest] = pair.split('=');

e2e/integration/sessions-connections.spec.ts

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,18 @@ test.describe('sessions page', () => {
2121
test('session list shows an IP address or device info', async ({ authedPage }) => {
2222
await authedPage.goto('/settings/sessions');
2323
await authedPage.waitForLoadState('networkidle');
24-
// IP addresses or user-agent info should be visible in the session list
25-
await expect(authedPage.locator('td, [data-ip], [data-agent]').first())
26-
.toBeVisible({ timeout: 5000 })
27-
.catch(() => {
28-
// May use a different layout
24+
// The current session must be identifiable — assert either layout-cell info
25+
// or a recognizable IPv4 pattern is present somewhere on the page.
26+
const cellVisible = await authedPage
27+
.locator('td, [data-ip], [data-agent]')
28+
.first()
29+
.isVisible({ timeout: 5000 })
30+
.catch(() => false);
31+
if (!cellVisible) {
32+
await expect(authedPage.getByText(/\b\d{1,3}(\.\d{1,3}){3}\b/).first()).toBeVisible({
33+
timeout: 5000,
2934
});
35+
}
3036
});
3137
});
3238

@@ -37,14 +43,20 @@ test.describe('connections / OAuth page', () => {
3743
await expect(authedPage.locator('main').first()).toBeVisible();
3844
});
3945

40-
test('shows available OAuth providers', async ({ authedPage }) => {
46+
test('shows available OAuth providers or an empty state', async ({ authedPage }) => {
4147
await authedPage.goto('/settings/connections');
4248
await authedPage.waitForLoadState('networkidle');
43-
// Should list at least one OAuth provider (e.g. Discord, GitHub, Google)
44-
await expect(authedPage.getByText(/discord|github|google|oauth|provider/i).first())
45-
.toBeVisible({ timeout: 5000 })
46-
.catch(() => {
47-
// Page might not have any OAuth providers configured on dev backend
48-
});
49+
// Either provider UI is present, or an empty/none-configured state is shown.
50+
// Both are acceptable — what's not acceptable is rendering nothing at all.
51+
const providerVisible = await authedPage
52+
.getByText(/discord|github|google|oauth|provider/i)
53+
.first()
54+
.isVisible({ timeout: 5000 })
55+
.catch(() => false);
56+
if (!providerVisible) {
57+
await expect(
58+
authedPage.getByText(/no.*(provider|connection|configured)|none\s*(available|configured)/i).first()
59+
).toBeVisible({ timeout: 5000 });
60+
}
4961
});
5062
});

e2e/integration/signalr.spec.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,9 @@ test.describe('SignalR connection lifecycle', () => {
4949
await authedPage.waitForLoadState('networkidle');
5050
await authedPage.waitForTimeout(3000);
5151

52-
// On an authenticated session the frontend should attempt to establish a
53-
// SignalR connection (negotiate HTTP + WebSocket upgrade).
54-
// If the backend is not running this will fail gracefully — we just check
55-
// that the attempt was made.
56-
expect(wsRequests.length).toBeGreaterThanOrEqual(0); // always passes
57-
// The real assertion: no crash occurred (covered by pageerror listener above)
52+
// On an authenticated session the frontend must attempt to establish a
53+
// SignalR connection — assert at least one negotiate/WebSocket request fired.
54+
expect(wsRequests.length).toBeGreaterThan(0);
5855
});
5956
});
6057

vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ export default defineConfig(async ({ command, mode, isPreview }) => {
290290
extends: true,
291291
// Resolve Svelte to its browser (client) build so that `mount` and
292292
// other client-only APIs are available in the jsdom test environment.
293-
resolve: { conditions: ['browser', 'module', 'svelte', 'development|production'] },
293+
resolve: { conditions: ['browser', 'module', 'svelte', 'development', 'production'] },
294294
test: {
295295
name: 'components',
296296
environment: 'jsdom',

0 commit comments

Comments
 (0)