-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1713 from quadratichq/qa
QA: Aug 13th
- Loading branch information
Showing
288 changed files
with
15,210 additions
and
2,383 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
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
2 changes: 2 additions & 0 deletions
2
quadratic-api/prisma/migrations/20240809223557_team_client_data_kv/migration.sql
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,2 @@ | ||
-- AlterTable | ||
ALTER TABLE "Team" ADD COLUMN "client_data_kv" JSONB NOT NULL DEFAULT '{}'; |
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 |
---|---|---|
|
@@ -2,44 +2,35 @@ import { User } from 'auth0'; | |
import request from 'supertest'; | ||
import { app } from '../../app'; | ||
import dbClient from '../../dbClient'; | ||
import { clearDb } from '../../tests/testDataGenerator'; | ||
import { clearDb, createFile, createTeam, createUser } from '../../tests/testDataGenerator'; | ||
|
||
beforeEach(async () => { | ||
// Create some users & team | ||
const user_1 = await dbClient.user.create({ | ||
data: { | ||
auth0Id: 'team_1_owner', | ||
}, | ||
}); | ||
const user_2 = await dbClient.user.create({ | ||
data: { | ||
auth0Id: 'team_1_editor', | ||
}, | ||
}); | ||
const user_3 = await dbClient.user.create({ | ||
data: { | ||
auth0Id: 'team_1_viewer', | ||
}, | ||
}); | ||
await dbClient.user.create({ | ||
data: { | ||
auth0Id: 'user_without_team', | ||
}, | ||
}); | ||
await dbClient.team.create({ | ||
data: { | ||
const user_1 = await createUser({ auth0Id: 'team_1_owner' }); | ||
const user_2 = await createUser({ auth0Id: 'team_1_editor' }); | ||
const user_3 = await createUser({ auth0Id: 'team_1_viewer' }); | ||
await createUser({ auth0Id: 'user_without_team' }); | ||
|
||
const team = await createTeam({ | ||
team: { | ||
name: 'Test Team 1', | ||
uuid: '00000000-0000-4000-8000-000000000001', | ||
UserTeamRole: { | ||
create: [ | ||
{ | ||
userId: user_1.id, | ||
role: 'OWNER', | ||
}, | ||
{ userId: user_2.id, role: 'EDITOR' }, | ||
{ userId: user_3.id, role: 'VIEWER' }, | ||
], | ||
}, | ||
users: [ | ||
{ | ||
userId: user_1.id, | ||
role: 'OWNER', | ||
}, | ||
{ userId: user_2.id, role: 'EDITOR' }, | ||
{ userId: user_3.id, role: 'VIEWER' }, | ||
], | ||
connections: [{ type: 'POSTGRES' }], | ||
}); | ||
|
||
await createFile({ | ||
data: { | ||
name: 'Test File 1', | ||
ownerTeamId: team.id, | ||
creatorUserId: user_1.id, | ||
}, | ||
}); | ||
}); | ||
|
@@ -95,14 +86,6 @@ jest.mock('auth0', () => { | |
}); | ||
|
||
describe('GET /v0/teams/:uuid', () => { | ||
// TODO the auth/team middleware should handle all this...? | ||
describe('sending a bad request', () => { | ||
it.todo('responds with a 401 without authentication'); | ||
it.todo('responds with a 404 for requesting a team that doesn’t exist'); | ||
it.todo('responds with a 400 for failing schema validation on the team UUID'); | ||
it.todo('responds with a 400 for failing schema validation on the payload'); | ||
}); | ||
|
||
describe('get a team you belong to', () => { | ||
// TODO different responses for OWNER, EDITOR, VIEWER? | ||
it('responds with a team', async () => { | ||
|
@@ -113,7 +96,11 @@ describe('GET /v0/teams/:uuid', () => { | |
.expect((res) => { | ||
expect(res.body).toHaveProperty('team'); | ||
expect(res.body.team.uuid).toBe('00000000-0000-4000-8000-000000000001'); | ||
expect(res.body.team.name).toBe('Test Team 1'); | ||
|
||
expect(res.body.clientDataKv).toStrictEqual({}); | ||
expect(res.body.connections).toHaveLength(1); | ||
expect(res.body.files).toHaveLength(1); | ||
expect(typeof res.body.files[0].file.creatorId).toBe('number'); | ||
|
||
expect(res.body.users[0].email).toBe('[email protected]'); | ||
expect(res.body.users[0].role).toBe('OWNER'); | ||
|
@@ -128,5 +115,27 @@ describe('GET /v0/teams/:uuid', () => { | |
expect(res.body.users[2].name).toBe('Test User 3'); | ||
}); | ||
}); | ||
|
||
it('does not return archived connections', async () => { | ||
// delete all connections in a team | ||
const team = await dbClient.team.findUniqueOrThrow({ | ||
where: { | ||
uuid: '00000000-0000-4000-8000-000000000001', | ||
}, | ||
}); | ||
await dbClient.connection.deleteMany({ | ||
where: { | ||
teamId: team.id, | ||
}, | ||
}); | ||
|
||
await request(app) | ||
.get(`/v0/teams/00000000-0000-4000-8000-000000000001`) | ||
.set('Authorization', `Bearer ValidToken team_1_owner`) | ||
.expect(200) | ||
.expect((res) => { | ||
expect(res.body.connections).toHaveLength(0); | ||
}); | ||
}); | ||
}); | ||
}); |
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,5 @@ | ||
{ | ||
"cSpell.words": [ | ||
"shadcn" | ||
] | ||
} |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Oops, something went wrong.