Skip to content

Commit b46a9eb

Browse files
committed
test prompt with rag
1 parent f359991 commit b46a9eb

File tree

4 files changed

+38
-7
lines changed

4 files changed

+38
-7
lines changed

e2e/chat.spec.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,6 @@ testMatrix.forEach((testConfig) => {
160160
await expect(page.getByTestId('assistant-message').last()).toContainText('Temperature: 1')
161161
})
162162

163-
if (course) {
164-
// @todo test course chat RAG feature
165-
}
166-
167163
if (!course) {
168164
test('Every validModel is available in general chat', async ({ page }) => {
169165
await acceptDisclaimer(page)

e2e/fixtures.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const adminTest = base.extend<{ forEachTest: void }>({
1212
* Parallel worker isolation: each worker has its own test user identified by the worker index.
1313
*/
1414

15-
const testUserIdx = studentTest.info().workerIndex
15+
const testUserIdx = adminTest.info().workerIndex
1616
const testUserRole = 'admin'
1717

1818
page.context().setExtraHTTPHeaders({

e2e/prompts.spec.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,40 @@ test.describe('Prompts', () => {
105105
expect(page.getByText(newPromptName, { exact: true })).not.toBeVisible()
106106
})
107107

108+
test('Prompt with RAG works', async ({ page }) => {
109+
await page.goto('/courses/test-course/prompts')
110+
111+
const newPromptName = `testausprompti-${test.info().workerIndex}-rag`
112+
113+
await page.getByTestId('create-prompt-button').click()
114+
115+
await page.getByTestId('prompt-name-input').fill(newPromptName)
116+
await page.getByTestId('system-message-input').fill('what ever')
117+
await page.getByTestId('rag-select').click()
118+
await page.getByTestId(`source-material-rag-${test.info().workerIndex}-teacher`).click()
119+
await page.getByRole('button', { name: 'Save' }).click()
120+
121+
await page.getByTestId('close-prompt-editor').click()
122+
123+
// Prompt is created and link is visible
124+
await page.getByText(`Link to chat with the prompt '${newPromptName}' active`).click()
125+
126+
// Now in chat view
127+
await acceptDisclaimer(page)
128+
129+
// The prompt is active.
130+
await expect(page.getByTestId('prompt-selector-button').first()).toContainText(newPromptName)
131+
132+
// Send something
133+
await sendChatMessage(page, 'rag')
134+
await closeSendPreference(page)
135+
136+
// The result should be echo of the course prompt
137+
await expect(page.getByTestId('assistant-message')).toContainText('Ok! Got some great results from that mock tool call!')
138+
139+
await expect(page.getByTestId('sources-header')).toBeVisible()
140+
})
141+
108142
test('Own prompts work in course chat and normal chat', async ({ page }) => {
109143
// First create own prompt in course chat view
110144
await page.goto('/test-course')

src/client/components/Prompt/PromptEditor.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,16 @@ export const PromptEditor = ({ prompt, ragIndices, type, chatInstanceId }: Promp
117117
<InputLabel>{t('rag:sourceMaterials')}</InputLabel>
118118
{ragIndices && (
119119
<Select
120+
data-testid="rag-select"
120121
value={ragIndexId || ''}
121122
onChange={(e) => setRagIndexId(e.target.value ? Number(e.target.value) : undefined)}
122123
disabled={ragIndices === undefined || ragIndices.length === 0}
123124
>
124-
<MenuItem value="">
125+
<MenuItem value="" data-testid="no-source-materials">
125126
<em>{t('prompt:noSourceMaterials')}</em>
126127
</MenuItem>
127128
{ragIndices?.map((index) => (
128-
<MenuItem key={index.id} value={index.id}>
129+
<MenuItem key={index.id} value={index.id} data-testid={`source-material-${index.metadata.name}`}>
129130
{index.metadata.name}
130131
</MenuItem>
131132
))}

0 commit comments

Comments
 (0)