Repository navigation
Complete search quality plan #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
de6d375
feat: complete search quality plan
Programcode 2df7afb
docs: mark Factoids source list complete
Programcode a9a3f75
Merge remote-tracking branch 'origin/main' into t3code/search-quality…
Programcode e34bc26
fix: validate discovered source URLs
Programcode ecb2d3f
fix: normalize discovered source URLs
Programcode c0362ed
Merge remote-tracking branch 'origin/main' into t3code/search-quality…
Programcode 79009c1
Merge remote-tracking branch 'origin/main' into t3code/search-quality…
Programcode File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| import { expect, test } from '@playwright/test'; | ||
| import { setLocale, stubSupabaseSession } from './helpers/auth'; | ||
|
|
||
| const strongSourceUrl = 'https://energy.gov/reports/solar-costs-2024'; | ||
| const weakSourceUrl = 'https://example.com/broad-commentary'; | ||
|
|
||
| test('authenticated Factoids shows the consulted-source quality panel', async ({ page }) => { | ||
| await setLocale(page, 'en'); | ||
| await stubSupabaseSession(page); | ||
|
|
||
| await page.route('**/functions/v1/ai', async (route) => { | ||
| await route.fulfill({ | ||
| status: 200, | ||
| contentType: 'application/json', | ||
| body: JSON.stringify({ | ||
| output: { | ||
| factoids: [{ | ||
| id: 'fact-1', | ||
| shortClaim: 'Solar costs fell by 42 percent', | ||
| keyFigure: '42%', | ||
| context: 'The official report compares the relevant period.', | ||
| limitations: 'The result depends on the measured market segment.', | ||
| citation: { | ||
| title: 'Official energy statistics', | ||
| publisher: 'Department of Energy', | ||
| date: '2024', | ||
| url: strongSourceUrl, | ||
| verified: 'verified', | ||
| }, | ||
| howToUse: 'Use this as a bounded cost trend.', | ||
| relevanceScore: 92, | ||
| }], | ||
| searchSuggestions: [], | ||
| warnings: [], | ||
| verificationStatus: 'complete', | ||
| }, | ||
| discoveredSources: [{ | ||
| title: 'Official energy statistics', | ||
| url: strongSourceUrl, | ||
| content: 'Official government statistics.', | ||
| sourceType: 'government', | ||
| qualityScore: 91, | ||
| qualityLabel: 'strong', | ||
| query: 'solar energy costs government evidence', | ||
| }, { | ||
| title: 'Broad commentary', | ||
| url: weakSourceUrl, | ||
| content: 'General commentary.', | ||
| sourceType: 'generic', | ||
| qualityScore: 30, | ||
| qualityLabel: 'weak', | ||
| query: 'solar energy costs commentary', | ||
| }], | ||
| }), | ||
| }); | ||
| }); | ||
|
|
||
| await page.route('**/rest/v1/source_folders*', async (route) => { | ||
| await route.fulfill({ status: 201, contentType: 'application/json', body: '{}' }); | ||
| }); | ||
| await page.route('**/rest/v1/sources*', async (route) => { | ||
| await route.fulfill({ | ||
| status: 201, | ||
| contentType: 'application/json', | ||
| body: JSON.stringify({ | ||
| id: 'source-1', | ||
| title: 'Consulted source', | ||
| content: 'Evidence', | ||
| type: 'url', | ||
| origin: strongSourceUrl, | ||
| folder: 'Auto-saved', | ||
| metadata: {}, | ||
| is_active: true, | ||
| created_at: new Date().toISOString(), | ||
| }), | ||
| }); | ||
| }); | ||
|
|
||
| await page.goto('/app/factoids'); | ||
| await page.getByRole('textbox', { name: /statement/i }).fill('Solar energy costs are falling'); | ||
| await page.getByRole('button', { name: /find factoids/i }).click(); | ||
|
|
||
| await expect(page.getByRole('heading', { name: /researched sources/i })).toBeVisible(); | ||
| await expect(page.getByRole('link', { name: /official energy statistics/i }).first()).toHaveAttribute('href', strongSourceUrl); | ||
| await expect(page.getByRole('link', { name: /broad commentary/i })).toHaveAttribute('href', weakSourceUrl); | ||
| await expect(page.getByText('strong', { exact: true })).toBeVisible(); | ||
| await expect(page.getByText('weak', { exact: true })).toBeVisible(); | ||
| await expect(page.getByText('fallback context only', { exact: true })).toBeVisible(); | ||
| await expect(page.getByText('Solar costs fell by 42 percent')).toBeVisible(); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.