-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
210 additions
and
85 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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,72 @@ | ||
import { expect, test } from './fixtures'; | ||
import { loadChatPage } from './helpers/navigationHelpers'; | ||
import { createPDF, deleteFixtureFile, uploadFiles } from './helpers/fileHelpers'; | ||
import { deleteActiveThread } from './helpers/threadHelpers'; | ||
import { faker } from '@faker-js/faker'; | ||
|
||
test('it can translate an audio file', async ({ page, openAIClient }) => { | ||
await loadChatPage(page); | ||
|
||
await uploadFiles({ | ||
page, | ||
filenames: ['spanish.m4a'], | ||
testId: 'upload-file-btn' | ||
}); | ||
|
||
const chatTools = page.getByTestId('chat-tools'); | ||
await chatTools.getByRole('button', { name: 'Translate spanish.m4a' }).click(); | ||
|
||
await expect(page.getByTestId('loading-msg')).toHaveCount(1); // loading skeleton | ||
await expect(page.getByTestId('loading-msg')).not.toBeVisible(); | ||
await expect(page.getByTestId('message')).toHaveCount(2); | ||
// Edit and regen disabled for translated messages | ||
await expect(page.getByTestId('edit-message')).not.toBeVisible(); | ||
await expect(page.getByTestId('regenerate btn')).not.toBeVisible(); | ||
const messages = await page.getByTestId('message').all(); | ||
const responseText = await messages[1].innerText(); | ||
expect(responseText).toContain('unicorn'); | ||
|
||
await deleteActiveThread(page, openAIClient); | ||
}); | ||
|
||
test('it can removes the audio file but keeps other files after translating', async ({ | ||
page, | ||
openAIClient | ||
}) => { | ||
await loadChatPage(page); | ||
const fakeContent = faker.word.words(3); | ||
const pdfFilename = await createPDF({ content: fakeContent, filename: 'shortname.pdf' }); | ||
|
||
await uploadFiles({ | ||
page, | ||
filenames: ['spanish.m4a', pdfFilename], | ||
testId: 'upload-file-btn' | ||
}); | ||
|
||
await page.getByTestId('spanish.m4a-uploaded'); | ||
await page.getByTestId(`${pdfFilename}-uploaded`); | ||
|
||
const messagesContainer = page.getByTestId('messages-container'); | ||
const chatToolsContainer = page.getByTestId('chat-tools'); | ||
|
||
const chatToolsPDFFileCard = chatToolsContainer.getByTestId(`${pdfFilename}-file-uploaded-card`); | ||
const chatToolsAudioCard = chatToolsContainer.getByTestId('spanish.m4a-file-uploaded-card'); | ||
|
||
await expect(chatToolsPDFFileCard).toBeVisible(); | ||
await expect(chatToolsAudioCard).toBeVisible(); | ||
|
||
const translateBtn = chatToolsContainer.getByRole('button', { name: 'Translate spanish.m4a' }); | ||
await translateBtn.click(); | ||
|
||
await expect(page.getByTestId('message')).toHaveCount(2); | ||
|
||
await expect(chatToolsAudioCard).not.toBeVisible(); | ||
await expect(translateBtn).not.toBeVisible(); | ||
|
||
await expect(messagesContainer.getByTestId('spanish.m4a-file-uploaded-card')).toBeVisible(); | ||
await expect(chatToolsPDFFileCard).toBeVisible(); | ||
|
||
// cleanup | ||
deleteFixtureFile(pdfFilename); | ||
await deleteActiveThread(page, openAIClient); | ||
}); |
This file contains 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.