fix(workspaces): projects resolver only returns projects for the user
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
||||
import {
|
||||
BasicTestUser,
|
||||
createAuthTokenForUser,
|
||||
createTestUser,
|
||||
createTestUsers
|
||||
} from '@/test/authHelper'
|
||||
import { Roles } from '@speckle/shared'
|
||||
@@ -22,9 +23,10 @@ import {
|
||||
UpdateWorkspaceRoleDocument,
|
||||
ActiveUserLeaveWorkspaceDocument,
|
||||
GetWorkspaceWithBillingDocument,
|
||||
CreateProjectDocument,
|
||||
CreateObjectDocument,
|
||||
CreateProjectVersionDocument
|
||||
CreateProjectVersionDocument,
|
||||
GetWorkspaceWithProjectsDocument,
|
||||
CreateProjectDocument
|
||||
} from '@/test/graphql/generated/graphql'
|
||||
import { beforeEachContext } from '@/test/hooks'
|
||||
import { AllScopes } from '@/modules/core/helpers/mainConstants'
|
||||
@@ -37,7 +39,10 @@ import {
|
||||
import { BasicTestCommit, createTestCommit } from '@/test/speckle-helpers/commitHelper'
|
||||
import { BasicTestStream, createTestStream } from '@/test/speckle-helpers/streamHelper'
|
||||
import knex from '@/db/knex'
|
||||
import { createRandomPassword } from '@/modules/core/helpers/testHelpers'
|
||||
import {
|
||||
createRandomPassword,
|
||||
createRandomEmail
|
||||
} from '@/modules/core/helpers/testHelpers'
|
||||
import { getBranchesByStreamId } from '@/modules/core/services/branches'
|
||||
|
||||
const createProjectWithVersions =
|
||||
@@ -234,6 +239,43 @@ describe('Workspaces GQL CRUD', () => {
|
||||
expect(res.data?.activeUser?.workspaces?.items?.length).to.equal(1)
|
||||
})
|
||||
})
|
||||
|
||||
describe('query workspace.projects', () => {
|
||||
it('should return all projects for a user in the workspace', async () => {
|
||||
const user = {
|
||||
id: createRandomPassword(),
|
||||
email: createRandomEmail(),
|
||||
name: createRandomPassword()
|
||||
}
|
||||
|
||||
const resProject1 = await apollo.execute(CreateProjectDocument, {
|
||||
input: {
|
||||
name: createRandomPassword(),
|
||||
workspaceId: workspace.id
|
||||
}
|
||||
})
|
||||
expect(resProject1).to.not.haveGraphQLErrors()
|
||||
|
||||
const res = await apollo.execute(GetWorkspaceWithProjectsDocument, {
|
||||
workspaceId: workspace.id
|
||||
})
|
||||
expect(res).to.not.haveGraphQLErrors()
|
||||
expect(res.data?.workspace?.projects.items?.length).to.equal(1)
|
||||
expect(res.data?.workspace?.projects.totalCount).to.equal(1)
|
||||
|
||||
await createTestUser(user)
|
||||
const session2 = await testApolloServer({
|
||||
authUserId: user.id
|
||||
})
|
||||
await assignToWorkspace(workspace, user, Roles.Workspace.Guest)
|
||||
const res2 = await session2.execute(GetWorkspaceWithProjectsDocument, {
|
||||
workspaceId: workspace.id
|
||||
})
|
||||
expect(res2).to.not.haveGraphQLErrors()
|
||||
expect(res.data?.workspace?.projects.items?.length).to.equal(0)
|
||||
// expect(res.data?.workspace?.projects.totalCount).to.equal(0)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('management operations', () => {
|
||||
|
||||
Reference in New Issue
Block a user