Skip to content

Commit 37f2f00

Browse files
committed
test for prompt creation
1 parent 32f5eab commit 37f2f00

24 files changed

+68
-25
lines changed

e2e/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Notes about e2e tests
2+
3+
When writing new spec file, make sure to import the test function from the fixtures file, like this:
4+
```
5+
import { test } from './fixtures'
6+
```
7+
.
8+
9+
So that the global foreach function runs for your tests.

e2e/prompts.spec.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { test } from './fixtures'
2+
import { expect } from '@playwright/test'
3+
import { acceptDisclaimer } from './utils/test-helpers'
4+
5+
test.describe('Prompt creation', () => {
6+
test.beforeEach(async ({ page }) => {
7+
await page.goto('/v2')
8+
await acceptDisclaimer(page)
9+
})
10+
11+
test('test', async ({ page }) => {
12+
await page.goto('/courses/test-course/prompts')
13+
14+
const newPromptName = `testausprompti-${test.info().workerIndex}`
15+
16+
await page.getByRole('textbox', { name: 'Prompt name' }).fill(newPromptName)
17+
await page.getByRole('textbox', { name: 'e.g. You are a helpful' }).fill('sanot aina "testi onnistui"')
18+
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+
22+
await page.getByRole('button', { name: 'Chat settings' }).click()
23+
24+
await page.locator('#prompt-selector-button').click()
25+
26+
expect(page.getByText(newPromptName)).toBeVisible()
27+
})
28+
})

src/client/components/Admin/Testing.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Box } from '@mui/material'
2-
import { OutlineButtonBlack, OutlineButtonBlue } from '../ChatV2/generics/Buttons'
2+
import { OutlineButtonBlack, OutlineButtonBlue } from '../ChatV2/general/Buttons'
33
import * as Sentry from '@sentry/react'
44
import useCurrentUser from '../../hooks/useCurrentUser'
55

src/client/components/ChatV2/Annotations.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { useTranslation } from 'react-i18next'
66
import { useFileSearchResults } from './api'
77
import ReactMarkdown from 'react-markdown'
88
import remarkGfm from 'remark-gfm'
9-
import { OutlineButtonBlack } from './generics/Buttons'
9+
import { OutlineButtonBlack } from './general/Buttons'
1010
import SubjectIcon from '@mui/icons-material/Subject'
1111

1212
const AnnotationTruncated = ({

src/client/components/ChatV2/ChatBox.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import useUserStatus from '../../hooks/useUserStatus'
1111
import { useParams } from 'react-router-dom'
1212
import { useTranslation } from 'react-i18next'
1313
import ModelSelector from './ModelSelector'
14-
import { BlueButton, GrayButton, OutlineButtonBlack } from './generics/Buttons'
14+
import { BlueButton, GrayButton, OutlineButtonBlack } from './general/Buttons'
1515
import { useIsEmbedded } from '../../contexts/EmbeddedContext'
1616

1717
export const ChatBox = ({

src/client/components/ChatV2/ChatV2.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ import { ChatBox } from './ChatBox'
1919
import { Conversation } from './Conversation'
2020
import { DisclaimerModal } from './Disclaimer'
2121
import { handleCompletionStreamError } from './error'
22-
import { ChatInfo } from './generics/ChatInfo'
22+
import { ChatInfo } from './general/ChatInfo'
2323
import RagSelector from './RagSelector'
2424
import { SettingsModal } from './SettingsModal'
2525
import { getCompletionStream } from './util'
26-
import { OutlineButtonBlack } from './generics/Buttons'
26+
import { OutlineButtonBlack } from './general/Buttons'
2727
import useCurrentUser from '../../hooks/useCurrentUser'
2828
import { useChatStream } from './useChatStream'
2929
import Annotations from './Annotations'

src/client/components/ChatV2/Conversation.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ import remarkGfm from 'remark-gfm'
88
import remarkMath from 'remark-math'
99
import type { FileSearchCompletedData } from '../../../shared/types'
1010
import type { ActivityPeriod, Message } from '../../types'
11-
import { ConversationSplash } from './generics/ConversationSplash'
12-
import { LoadingMessage } from './generics/LoadingMessage'
11+
import { ConversationSplash } from './general/ConversationSplash'
12+
import { LoadingMessage } from './general/LoadingMessage'
1313
import { preprocessMath } from './util'
1414
import 'katex/dist/katex.min.css'
1515
import 'katex/dist/contrib/mhchem'
1616
import CopyToClipboardButton from '../Chat/CopyToClipboardButton'
1717
import { t } from 'i18next'
1818
import FormatQuoteIcon from '@mui/icons-material/FormatQuote'
1919
import useLocalStorageState from '../../hooks/useLocalStorageState'
20-
import { BlueButton } from './generics/Buttons'
20+
import { BlueButton } from './general/Buttons'
2121
import { MutableRefObject } from 'react'
2222

2323
const UserMessage = ({ content, attachements }: { content: string; attachements?: string }) => (

src/client/components/ChatV2/Disclaimer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Modal, Box, IconButton, Checkbox, FormControlLabel, FormGroup } from '@mui/material'
22
import { Close } from '@mui/icons-material'
33
import { useTranslation } from 'react-i18next'
4-
import { BlueButton } from './generics/Buttons'
4+
import { BlueButton } from './general/Buttons'
55
import ReactMarkdown from 'react-markdown'
66
import remarkGfm from 'remark-gfm'
77
import { useState, useEffect } from 'react'

src/client/components/ChatV2/EmailButton.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { useTranslation } from 'react-i18next'
88
import useCurrentUser from '../../hooks/useCurrentUser'
99
import type { Message } from '../../types'
1010
import { sendEmail } from '../../util/email'
11-
import { OutlineButtonBlack } from './generics/Buttons'
11+
import { OutlineButtonBlack } from './general/Buttons'
1212

1313
const escapeHtml = (str: string): string =>
1414
str.replaceAll('&', '&amp;').replaceAll('<', '&lt;').replaceAll('>', '&gt;').replaceAll('"', '&quot;').replaceAll("'", '&#39;')
@@ -158,7 +158,7 @@ const formatEmail = (messages: Message[], t: any): string => {
158158
<head>
159159
<meta charset="UTF-8">
160160
<style>
161-
body {
161+
body {
162162
color: rgba(0, 0, 0, 0.8);
163163
line-height: 1.6;
164164
margin: 0 auto;

src/client/components/ChatV2/PromptSelector.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Box, Button, Divider, IconButton, ListSubheader, Menu, MenuItem } from
33
import { useState } from 'react'
44
import { useTranslation } from 'react-i18next'
55
import type { Prompt } from '../../types'
6+
import { OutlineButtonBlack } from './general/Buttons'
67

78
const PromptSelector = ({
89
coursePrompts,
@@ -36,17 +37,17 @@ const PromptSelector = ({
3637

3738
return (
3839
<Box mb={'0.5rem'}>
39-
<Button
40+
<OutlineButtonBlack
41+
id="prompt-selector-button"
4042
disabled={!!mandatoryPrompt}
41-
variant="outlined"
4243
onClick={(event) => {
4344
setAnchorEl(event.currentTarget)
4445
}}
4546
endIcon={mandatoryPrompt ? <Lock /> : <KeyboardArrowDown />}
4647
>
4748
{activePrompt?.name ?? t('settings:choosePrompt')}
4849
{!!mandatoryPrompt && ` - ${t('settings:promptLocked')}`}
49-
</Button>
50+
</OutlineButtonBlack>
5051

5152
<Menu anchorEl={anchorEl} open={Boolean(anchorEl)} onClose={() => setAnchorEl(null)}>
5253
<MenuItem onClick={() => handleSelect(undefined)}>{t('settings:default')}</MenuItem>

0 commit comments

Comments
 (0)