-
Notifications
You must be signed in to change notification settings - Fork 3
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
131 add feature tests #149
Merged
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
9d9ba72
add key perk to landing page (#107)
leilabb 37f8a60
98-clarify-copy-when-creating-a-team
leilabb b8032f3
104-change-the-word-fork-it-to-clone-including-icon
leilabb ce0b05d
add missing env vars to example
tonioriol 1d5d352
Create dependabot.yml
eriklindgren de85015
Bump vite from 4.3.9 to 4.5.2 (#112)
dependabot[bot] 3366c6b
Update dependabot.yml
eriklindgren 1495c89
Bump actions/checkout from 2 to 4 (#123)
dependabot[bot] 15eaa95
Bump actions/setup-node from 2 to 4 (#122)
dependabot[bot] 6898977
Upgrade to node 20
eriklindgren 0a78d74
Run tests on push to dev
eriklindgren f38e2bf
Bump axios, openai and postmark (#113)
dependabot[bot] 1411633
99 group chat history by monthyear (#111)
leilabb ae02100
add test db in compose and gh actions
tonioriol 440785f
add test db setup script
tonioriol 15cae89
move cleanDatabase to a helper file
tonioriol 5e5c418
rm unused test
tonioriol aa7443d
adjustments to make it work
tonioriol 6b05863
remove header param from playwright and add NODE_ENV=test in gh test …
tonioriol c4785a6
try again
tonioriol 24c5da2
by god
tonioriol 3d5f480
try again
tonioriol 773e4ba
by god
tonioriol 3116194
by god
tonioriol 87583e8
by god
tonioriol ee77daa
add register flow test
leilabb a2220f9
add login flow test
leilabb a1d25b9
create team test
leilabb 58fe146
add chat/team flow tests
leilabb d46b1aa
Merge branch 'dev' into 131-add-feature-tests
leilabb 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 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 |
---|---|---|
|
@@ -56,4 +56,4 @@ jobs: | |
run: npx prisma migrate deploy | ||
|
||
- name: Run tests | ||
run: npm test | ||
run: npm test |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,157 @@ | ||
import { expect, test } from '@playwright/test' | ||
import { faker } from '@faker-js/faker' | ||
import { cleanDatabase } from '../prisma/helpers' | ||
import { PrismaClient, Role } from '@prisma/client' | ||
import { encrypt } from '../src/lib/server/utils/crypto' | ||
import pkg from 'bcryptjs' | ||
|
||
const { hashSync } = pkg | ||
const prisma = new PrismaClient() | ||
|
||
type Team = { | ||
id: number | ||
name: string | ||
openAiApiKey: string | null | ||
createdAt: Date | ||
updatedAt: Date | ||
} | ||
|
||
async function createTeam(name: string) { | ||
return await prisma.team.create({ | ||
data: { | ||
name: name, | ||
openAiApiKey: | ||
process.env.OPENAI_API_KEY && process.env.SECRET_KEY | ||
? encrypt(process.env.OPENAI_API_KEY, process.env.SECRET_KEY) | ||
: null, | ||
}, | ||
}) | ||
} | ||
|
||
async function createUser(team: Team) { | ||
const email = '[email protected]' | ||
return await prisma.user.create({ | ||
data: { | ||
email, | ||
name: 'Test1', | ||
password: { | ||
create: { | ||
hash: hashSync('password', 10), | ||
}, | ||
}, | ||
userTeams: { | ||
create: { | ||
teamId: team.id, | ||
role: Role.OWNER, | ||
}, | ||
}, | ||
}, | ||
include: { | ||
userTeams: true, | ||
}, | ||
}) | ||
} | ||
|
||
test.describe('app flow tests', () => { | ||
test.beforeEach(async () => { | ||
await cleanDatabase() | ||
}) | ||
|
||
test('register flow', async ({ page }) => { | ||
const name = faker.person.firstName() | ||
const email = faker.internet.email() | ||
const password = faker.internet.password() | ||
|
||
await page.goto('/') | ||
await page.getByText('Register').click() | ||
await expect(page).toHaveURL('/signup') | ||
|
||
await page.getByLabel('Name').fill(name) | ||
await page.getByLabel('Email').fill(email) | ||
await page.getByLabel('Password', { exact: true }).fill(password) | ||
await page.getByLabel('Confirm Password').fill(password) | ||
|
||
await page.getByText('Sign up').click() | ||
|
||
await page.waitForURL('/app/settings/teams') | ||
|
||
await expect(page).toHaveURL('/app/settings/teams') | ||
}), | ||
test('login flow', async ({ page }) => { | ||
let team = await createTeam('Test Team') | ||
let user = await createUser(team) | ||
|
||
await page.goto('/') | ||
await page.getByText('Sign in').click() | ||
await expect(page).toHaveURL('/signin') | ||
|
||
await page.getByLabel('Email').fill(user.email) | ||
await page.getByLabel('Password', { exact: true }).fill('password') | ||
await page.getByRole('button').click() | ||
|
||
await page.waitForURL('/app/settings/teams') | ||
|
||
await expect(page).toHaveURL('/app/settings/teams') | ||
}), | ||
test('create a team', async ({ page }) => { | ||
let team = await createTeam('Test Team') | ||
let user = await createUser(team) | ||
|
||
//log in | ||
await page.goto('/') | ||
await page.getByText('Sign in').click() | ||
await expect(page).toHaveURL('/signin') | ||
|
||
await page.getByLabel('Email').fill(user.email) | ||
await page.getByLabel('Password', { exact: true }).fill('password') | ||
await page.getByRole('button').click() | ||
|
||
await page.waitForURL('/app/settings/teams') | ||
|
||
await expect(page).toHaveURL('/app/settings/teams') | ||
|
||
//close popup | ||
await page.getByRole('button', { name: /Close/i }).click() | ||
|
||
//create new team | ||
await page.getByText('New Team').click() | ||
await expect(page).toHaveURL('/app/settings/teams/new') | ||
|
||
await page.getByLabel('Name*').fill('Test Team 2') | ||
await page.getByLabel('OpenAI API Key*').fill(process.env.OPENAI_API_KEY || '') | ||
await page.getByRole('button', { name: /Create/i }).click() | ||
|
||
await page.waitForURL(new RegExp('app/settings/teams/\\d+')) | ||
await expect(page).toHaveURL(new RegExp('app/settings/teams/\\d+')) | ||
}), | ||
test('create a chat', async ({ page }) => { | ||
let team = await createTeam('Test Team') | ||
let user = await createUser(team) | ||
|
||
//log in | ||
await page.goto('/') | ||
await page.getByText('Sign in').click() | ||
await expect(page).toHaveURL('/signin') | ||
|
||
await page.getByLabel('Email').fill(user.email) | ||
await page.getByLabel('Password', { exact: true }).fill('password') | ||
await page.getByRole('button').click() | ||
|
||
await page.waitForURL('/app/settings/teams') | ||
|
||
await expect(page).toHaveURL('/app/settings/teams') | ||
//select a team | ||
await page.getByRole('button', { name: /Select/i }).click() | ||
await page.waitForURL('/app') | ||
await expect(page).toHaveURL('/app') | ||
|
||
//type | ||
await page.getByRole('textbox').fill('Dis a test chat') | ||
//send | ||
await page.locator('button[name="send"]').click() | ||
|
||
await page.waitForTimeout(1000) | ||
await page.waitForURL(new RegExp('/app/chats/\\d+')) | ||
await expect(page).toHaveURL(new RegExp('/app/chats/\\d+')) | ||
}) | ||
}) |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is that necessary for the tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes exactly. There was no other way I could find that targets the send button otherwise.