Skip to content

Commit e87e745

Browse files
committed
fix prompt test
1 parent f36dfe6 commit e87e745

File tree

8 files changed

+14
-21
lines changed

8 files changed

+14
-21
lines changed

e2e/prompts.spec.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@ import { expect } from '@playwright/test'
33
import { acceptDisclaimer } from './utils/test-helpers'
44

55
test.describe('Prompt creation', () => {
6-
test.beforeEach(async ({ page }) => {
7-
await page.goto('/v2')
8-
await acceptDisclaimer(page)
9-
})
10-
116
test('test', async ({ page }) => {
127
await page.goto('/courses/test-course/prompts')
138

@@ -16,13 +11,10 @@ test.describe('Prompt creation', () => {
1611
await page.getByRole('textbox', { name: 'Prompt name' }).fill(newPromptName)
1712
await page.getByRole('textbox', { name: 'e.g. You are a helpful' }).fill('sanot aina "testi onnistui"')
1813
await page.getByRole('button', { name: 'Save' }).click()
19-
expect(page.getByText(newPromptName)).toBeVisible()
20-
await page.getByText('Link to chat with this prompt active').last().click()
21-
14+
await page.getByText(`Link to chat with the prompt '${newPromptName}' active`).click()
15+
await acceptDisclaimer(page)
2216
await page.getByRole('button', { name: 'Chat settings' }).click()
2317

24-
await page.locator('#prompt-selector-button').click()
25-
2618
expect(page.getByText(newPromptName)).toBeVisible()
2719
})
2820
})

src/client/components/ChatV2/SettingsModal.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import { useSearchParams } from 'react-router-dom'
1313
import { BlueButton, OutlineButtonBlack } from './general/Buttons'
1414
import { useAnalyticsDispatch } from '../../stores/analytics'
1515
import useLocalStorageState from '../../hooks/useLocalStorageState'
16-
import { IframeCopy } from '../common/IframeCopy'
1716

1817
const useUrlPromptId = () => {
1918
const [searchParams] = useSearchParams()

src/client/components/Courses/Course/Prompt.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ const Prompt = ({ prompt, handleDelete, mandatoryPromptId }: { prompt: PromptTyp
7979
</Typography>
8080
<Box sx={{ display: 'flex', alignItems: 'center' }}>
8181
<Link component={RouterLink} to={chatPath} variant="caption">
82-
{t('course:directPromptLink')}
82+
{t('course:directPromptLink', { name: prompt.name })}
8383
</Link>
84-
<Tooltip title={t('course:copyDirectPromptLinkInfo')}>
84+
<Tooltip title={t('course:copyDirectPromptLinkInfo', { name: prompt.name })}>
8585
<IconButton size="small" onClick={() => navigator.clipboard.writeText(directLink)}>
8686
<ContentCopyOutlined fontSize="small" />
8787
</IconButton>

src/client/hooks/usePrompts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const usePrompts = (chatInstanceId: string) => {
1414
return data
1515
}
1616

17-
const { data: prompts, ...rest } = useQuery({ queryKey, queryFn })
17+
const { data: prompts, ...rest } = useQuery({ queryKey, queryFn, select: (data) => data.sort((a, b) => Date.parse(a.createdAt) - Date.parse(b.createdAt)) })
1818

1919
return { prompts: prompts || [], ...rest }
2020
}

src/client/locales/en.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,8 @@
278278
"isSavedOptOut": "The course discussions will be saved anonymously, if you grant permission to save. Saved discussions can be used for research purposes.",
279279
"isSavedNotOptOut": "The course discussions will be saved anonymously.\n\nSaved discussions can be used for research purposes",
280280
"isSavedForTeacherOptOut": "The course discussions will be saved anonymously, if user grants the permission to save. Saved discussions can be used for research purposes",
281-
"directPromptLink": "Link to chat with this prompt active",
282-
"copyDirectPromptLinkInfo": "Copy a link to chat with this prompt active",
281+
"directPromptLink": "Link to chat with the prompt '{{name}}' active",
282+
"copyDirectPromptLinkInfo": "Copy a link to chat with the prompt '{{name}}' active",
283283
"stats": "Statistics",
284284
"discussions": "Discussions",
285285
"prompts": "Prompts",
@@ -308,4 +308,4 @@
308308
"titleV1": "This is the old chat view. You've selected the new view as default but can restore the old default here:",
309309
"buttonV1": "Select as default"
310310
}
311-
}
311+
}

src/client/locales/fi.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,8 @@
278278
"isSavedOptOut": "Kurssilla käymäsi keskustelut tallennetaan anonyymisti, jos annat tallennusluvan.\nTallennettuja keskusteluja voidaan käyttää tutkimuksessa.",
279279
"isSavedNotOptOut": "Kurssilla käymäsi keskustelut tallennetaan anonyymisti.\n\nTallennettuja keskusteluja voidaan käyttää tutkimuksessa",
280280
"isSavedForTeacherOptOut": "Kurssin keskustelut tallennetaan anonyymisti, jos käyttäjä antaa luvan.",
281-
"directPromptLink": "Linkki kurssichattiin käyttäen tätä alustusta",
282-
"copyDirectPromptLinkInfo": "Kopioi linkki tämän alustuksen kurssichattiin",
281+
"directPromptLink": "Linkki kurssichattiin alustuksella '{{name}}'",
282+
"copyDirectPromptLinkInfo": "Kopioi linkki kurssichattiin alustuksella '{{name}}'",
283283
"stats": "Statistiikka",
284284
"discussions": "Keskustelut",
285285
"prompts": "Alustukset",
@@ -308,4 +308,4 @@
308308
"titleV1": "Tämä on vanha chattinäkymä. Olet valinnut oletukseksi uuden näkymän mutta voit palauttaa vanhan tästä:",
309309
"buttonV1": "Valitse oletusarvoksi"
310310
}
311-
}
311+
}

src/client/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ export type Prompt = {
6767
hidden: boolean
6868
mandatory: boolean
6969
type: 'CHAT_INSTANCE' | 'PERSONAL' | 'RAG_INDEX'
70+
createdAt: string
7071
}
7172

7273
export interface ChatInstance {

src/server/routes/prompt.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ promptRouter.get('/:courseId', async (req, res) => {
3434
include: {
3535
model: Prompt,
3636
as: 'prompts',
37-
order: [['name', 'ASC']],
37+
separate: true,
38+
order: [['createdAt', 'ASC']],
3839
},
3940
})
4041

0 commit comments

Comments
 (0)