Skip to content

Commit 59e858a

Browse files
committed
fixing rebase off main
1 parent 32b4bbd commit 59e858a

File tree

4 files changed

+66
-18
lines changed

4 files changed

+66
-18
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"$schema": "https://opencode.ai/config.json",
3+
"default_agent": "telescopetest-io",
4+
"agent": {
5+
"telescopetest-io": {
6+
"permission": {
7+
"edit": "ask",
8+
"webfetch": "allow",
9+
"bash": {
10+
"*": "ask",
11+
"git status *": "allow",
12+
"git branch --show-current": "allow",
13+
"git diff *": "allow",
14+
"git log *": "allow",
15+
"git show *": "allow",
16+
"gh pr list *": "allow",
17+
"gh pr view *": "allow",
18+
"ls *": "allow",
19+
"cat *": "allow",
20+
"grep *": "allow",
21+
"find *": "allow",
22+
"wc *": "allow",
23+
"jq *": "allow",
24+
"npm *": "ask",
25+
"npx *": "ask",
26+
"wrangler *": "ask",
27+
"node *": "ask",
28+
},
29+
},
30+
},
31+
},
32+
}

telescopetest-io/src/lib/repositories/testRepository.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,29 @@ export async function findTestIdByZipKey(
4545
return { testId: test.test_id, contentRating: test.content_rating };
4646
}
4747

48+
/**
49+
* Find a single test by its testId
50+
* Returns the test or null if not found
51+
*/
52+
export async function getTestById(
53+
prisma: PrismaClient,
54+
testId: string,
55+
): Promise<Tests | null> {
56+
const row = await prisma.tests.findUnique({
57+
where: { test_id: testId },
58+
select: {
59+
test_id: true,
60+
url: true,
61+
test_date: true,
62+
browser: true,
63+
name: true,
64+
description: true,
65+
content_rating: true,
66+
},
67+
});
68+
return row ?? null;
69+
}
70+
4871
/**
4972
* Find all tests.
5073
* When AI rating is enabled, only safe tests are returned.

telescopetest-io/src/pages/api/tests/[testId]/rating.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { APIContext, APIRoute } from 'astro';
2-
import { createPrismaClient } from '@/lib/prisma/client';
2+
import { getPrismaClient } from '@/lib/prisma/client';
33
import {
44
getTestRating,
55
updateContentRating,
@@ -22,7 +22,7 @@ export const GET: APIRoute = async (context: APIContext) => {
2222
});
2323
}
2424
const env = context.locals.runtime.env;
25-
const prisma = createPrismaClient(env.TELESCOPE_DB);
25+
const prisma = getPrismaClient(context);
2626
const test = await getTestRating(prisma, testId);
2727
if (test === null) {
2828
return new Response(JSON.stringify({ error: 'Test not found' }), {

telescopetest-io/src/pages/results/[testId].astro

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
---
22
import Page from '@/layouts/Page.astro';
3-
import Summary from '@/components/Summary.astro';
3+
import MetricsSection from '@/components/MetricsSection.astro';
44
import ScreenshotDisplay from '@/components/ScreenshotDisplay.astro';
55
import TestInfoPanel from '@/components/TestInfoPanel.astro';
66
import Tabs from '@/components/Tabs.astro';
77
import AllMetrics from '@/components/AllMetrics.astro';
88
99
import { getPrismaClient } from '@/lib/prisma/client';
10-
import { getTestById, getTestRating } from '@/lib/repositories/testRepository';
11-
import { ContentRating } from '@/generated/prisma/client';
10+
import { getTestById } from '@/lib/repositories/test-repository';
11+
import { ContentRating } from '@/lib/classes/TestConfig';
1212
13-
import type { MetricsJson } from '@/lib/types/results';
13+
import type { MetricsJson } from '@/lib/metrics/types';
1414
import {
1515
extractFcp,
1616
extractLcp,
@@ -24,7 +24,7 @@ import {
2424
getLcpRating,
2525
getClsRating,
2626
getTtfbRating,
27-
} from '@/lib/metrics/ratings';
27+
} from '@/lib/metrics/web-vitals';
2828
import { formatMs, formatDecimal, formatKb } from '@/lib/metrics/formatters';
2929
3030
export const prerender = false;
@@ -43,14 +43,9 @@ if (!test) {
4343
return Astro.redirect('/results');
4444
}
4545
46-
const rating = await getTestRating(prisma, testId);
47-
if (rating === null) {
48-
return Astro.redirect('/results');
49-
}
50-
5146
// When AI rating is disabled, treat everything as safe
52-
const isUnknown = aiEnabled && (test.rating === ContentRating.UNKNOWN || test.rating === ContentRating.IN_PROGRESS);
53-
const isUnsafe = aiEnabled && test.rating === ContentRating.UNSAFE;
47+
const isUnknown = aiEnabled && (test.content_rating === ContentRating.UNKNOWN || test.content_rating === ContentRating.IN_PROGRESS);
48+
const isUnsafe = aiEnabled && test.content_rating === ContentRating.UNSAFE;
5449
5550
5651
// --- Screenshot ---
@@ -135,8 +130,7 @@ const formattedDate = date.toLocaleString('en-US', {
135130
</div>
136131
)}
137132

138-
139-
{!isUnsafe && (
133+
{!isUnsafe && !isUnknown && (
140134
<>
141135
<div class="title-section">
142136
{test.name ? <h1>{test.name}</h1> : <h1>{test.test_id}</h1>}
@@ -240,8 +234,7 @@ const formattedDate = date.toLocaleString('en-US', {
240234
const res = await fetch(`/api/tests/${testId}/rating`);
241235
const data: { rating: string } = await res.json();
242236
if (data.rating === 'safe') {
243-
if (pendingBanner) pendingBanner.style.display = 'none';
244-
if (testContent) testContent.style.display = '';
237+
window.location.reload();
245238
return;
246239
}
247240
if (data.rating === 'unsafe') {

0 commit comments

Comments
 (0)