Skip to content
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

BC-8187 - Creating and using boards in rooms #5313

Merged
merged 33 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
03458a4
implement board creation in room
uidp Oct 25, 2024
c9fa8b8
add api endpoint for getting room content
uidp Oct 28, 2024
269354f
Merge branch 'main' of github.com:hpi-schul-cloud/schulcloud-server i…
uidp Oct 28, 2024
e3fac0a
refactor api from content to boards
uidp Oct 29, 2024
9bd8bb3
refactor static method
uidp Oct 29, 2024
516f5da
remove outdated TODO.md
uidp Oct 29, 2024
f8b8b95
update roles seeds
uidp Oct 29, 2024
1f962c4
Merge branch 'main' of github.com:hpi-schul-cloud/schulcloud-server i…
uidp Oct 29, 2024
b068231
add room context to board context service
uidp Oct 30, 2024
e51167f
Merge branch 'main' of github.com:hpi-schul-cloud/schulcloud-server i…
uidp Oct 30, 2024
c8cd5df
add missing module import
uidp Oct 30, 2024
0a81cc0
add board layout reponse property
uidp Oct 30, 2024
56b44a7
update board layout api property
uidp Nov 1, 2024
88be7ed
Merge branch 'main' of github.com:hpi-schul-cloud/schulcloud-server i…
uidp Nov 1, 2024
5bfc888
adding board context service tests for room context
MartinSchuhmacher Nov 1, 2024
8eabc7c
Merge branch 'BC-8187-board-in-room' of github.com:hpi-schul-cloud/sc…
uidp Nov 1, 2024
5df2644
add board room visibility response property
uidp Nov 1, 2024
5462261
Spliting board api tests between course and room context
MartinSchuhmacher Nov 3, 2024
2fb9f2b
add roommember module to board ws api
uidp Nov 4, 2024
9a7601c
Merge branch 'main' of github.com:hpi-schul-cloud/schulcloud-server i…
uidp Nov 4, 2024
51d6d4e
add missing import
uidp Nov 4, 2024
ddab8d0
Merge branch 'main' of github.com:hpi-schul-cloud/schulcloud-server i…
uidp Nov 6, 2024
1a507c2
fix tests
uidp Nov 6, 2024
5592ec9
fix linter error
uidp Nov 6, 2024
0b81bf8
Merge branch 'main' of github.com:hpi-schul-cloud/schulcloud-server i…
uidp Nov 7, 2024
9c22e56
Merge branch 'main' into BC-8187-board-in-room
uidp Nov 7, 2024
c8fc1db
fix board context authorization
uidp Nov 7, 2024
b7211e8
Merge branch 'BC-8187-board-in-room' of github.com:hpi-schul-cloud/sc…
uidp Nov 7, 2024
f0b6aec
Merge branch 'main' into BC-8187-board-in-room
uidp Nov 7, 2024
4a7515f
update uc parent permission check
uidp Nov 8, 2024
cd2ecb2
Merge branch 'BC-8187-board-in-room' of github.com:hpi-schul-cloud/sc…
uidp Nov 8, 2024
b854af1
Merge branch 'main' of github.com:hpi-schul-cloud/schulcloud-server i…
uidp Nov 8, 2024
b3033bf
fix linter error
uidp Nov 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 0 additions & 91 deletions TODO.md

This file was deleted.

3 changes: 2 additions & 1 deletion apps/server/src/modules/board/board-api.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ import {
import { BoardModule } from './board.module';
import { BoardNodePermissionService } from './service';
import { BoardUc, CardUc, ColumnUc, ElementUc, SubmissionItemUc } from './uc';
import { RoomMemberModule } from '../room-member';

@Module({
imports: [BoardModule, LoggerModule, forwardRef(() => AuthorizationModule)],
imports: [BoardModule, LoggerModule, RoomMemberModule, forwardRef(() => AuthorizationModule)],
controllers: [BoardController, ColumnController, CardController, ElementController, BoardSubmissionController],
providers: [BoardUc, BoardNodePermissionService, ColumnUc, CardUc, ElementUc, SubmissionItemUc, CourseRepo],
})
Expand Down
9 changes: 5 additions & 4 deletions apps/server/src/modules/board/board-ws-api.module.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import { AuthorizationModule } from '@modules/authorization';
import { UserModule } from '@modules/user';
import { forwardRef, Module } from '@nestjs/common';
import { CourseRepo } from '@shared/repo';
import { LoggerModule } from '@src/core/logger';
import { AuthorizationModule } from '@modules/authorization';
import { UserModule } from '@modules/user';
import { RoomMemberModule } from '../room-member';
import { BoardModule } from './board.module';
import { BoardCollaborationGateway } from './gateway/board-collaboration.gateway';
import { MetricsService } from './metrics/metrics.service';
import { BoardUc, CardUc, ColumnUc, ElementUc } from './uc';
import { BoardNodePermissionService } from './service';
import { BoardUc, CardUc, ColumnUc, ElementUc } from './uc';

@Module({
imports: [BoardModule, forwardRef(() => AuthorizationModule), LoggerModule, UserModule],
imports: [BoardModule, forwardRef(() => AuthorizationModule), LoggerModule, UserModule, RoomMemberModule],
providers: [
BoardCollaborationGateway,
BoardNodePermissionService,
Expand Down
6 changes: 4 additions & 2 deletions apps/server/src/modules/board/board.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import { Module } from '@nestjs/common';
import { CqrsModule } from '@nestjs/cqrs';
import { CourseRepo } from '@shared/repo';
import { LoggerModule } from '@src/core/logger';
import { AuthorizationModule } from '../authorization';
import { RoomMemberModule } from '../room-member';
import { BoardNodeRule } from './authorisation/board-node.rule';
import { BoardNodeFactory } from './domain';
import { BoardNodeRepo } from './repo';
import {
Expand All @@ -30,8 +33,6 @@ import {
ColumnBoardTitleService,
ContentElementUpdateService,
} from './service/internal';
import { BoardNodeRule } from './authorisation/board-node.rule';
import { AuthorizationModule } from '../authorization';

@Module({
imports: [
Expand All @@ -45,6 +46,7 @@ import { AuthorizationModule } from '../authorization';
CqrsModule,
CollaborativeTextEditorModule,
AuthorizationModule,
RoomMemberModule,
],
providers: [
// TODO: move BoardDoAuthorizableService, BoardDoRepo, BoardDoService, BoardNodeRepo in separate module and move mediaboard related services in mediaboard module
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { BoardExternalReferenceType } from '../../domain';

const baseRouteName = '/boards';

describe('board get context (api)', () => {
describe('board get context in course (api)', () => {
let app: INestApplication;
let em: EntityManager;
let testApiClient: TestApiClient;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
import { EntityManager } from '@mikro-orm/mongodb';
import { ServerTestModule } from '@modules/server';
import { INestApplication } from '@nestjs/common';
import { Test, TestingModule } from '@nestjs/testing';
import { TestApiClient, cleanupCollections, groupEntityFactory, roleFactory, userFactory } from '@shared/testing';
import { Permission, RoleName } from '@shared/domain/interface';
import { accountFactory } from '@src/modules/account/testing';
import { GroupEntityTypes } from '@src/modules/group/entity';
import { roomMemberEntityFactory } from '@src/modules/room-member/testing';
import { roomEntityFactory } from '@src/modules/room/testing';
import { columnBoardEntityFactory } from '../../testing';
import { BoardExternalReferenceType } from '../../domain';

const baseRouteName = '/boards';

describe('board get context in room (api)', () => {
let app: INestApplication;
let em: EntityManager;
let testApiClient: TestApiClient;

beforeAll(async () => {
const module: TestingModule = await Test.createTestingModule({
imports: [ServerTestModule],
}).compile();

app = module.createNestApplication();
await app.init();
em = module.get(EntityManager);
testApiClient = new TestApiClient(app, baseRouteName);
});

afterAll(async () => {
await app.close();
});

beforeEach(async () => {
await cleanupCollections(em);
});

const setup = async () => {
const userWithEditRole = userFactory.buildWithId();
const accountWithEditRole = accountFactory.withUser(userWithEditRole).build();

const userWithViewRole = userFactory.buildWithId();
const accountWithViewRole = accountFactory.withUser(userWithViewRole).build();

const noAccessUser = userFactory.buildWithId();
const noAccessAccount = accountFactory.withUser(noAccessUser).build();

const roleRoomEdit = roleFactory.buildWithId({
name: RoleName.ROOM_EDITOR,
permissions: [Permission.ROOM_EDIT],
});
const roleRoomView = roleFactory.buildWithId({
name: RoleName.ROOM_VIEWER,
permissions: [Permission.ROOM_VIEW],
});

const userGroup = groupEntityFactory.buildWithId({
type: GroupEntityTypes.ROOM,
users: [
{ user: userWithEditRole, role: roleRoomEdit },
{ user: userWithViewRole, role: roleRoomView },
],
});

const room = roomEntityFactory.buildWithId();

const roomMember = roomMemberEntityFactory.build({ roomId: room.id, userGroupId: userGroup.id });

await em.persistAndFlush([
accountWithEditRole,
accountWithViewRole,
noAccessAccount,
userWithEditRole,
userWithViewRole,
noAccessUser,
roleRoomEdit,
roleRoomView,
userGroup,
room,
roomMember,
]);

const columnBoardNode = columnBoardEntityFactory.build({
isVisible: false,
context: { id: room.id, type: BoardExternalReferenceType.Room },
});

await em.persistAndFlush([columnBoardNode]);
em.clear();

return { accountWithEditRole, accountWithViewRole, noAccessAccount, columnBoardNode };
};

describe('with user who has edit role in room', () => {
it('should return status 200', async () => {
const { accountWithEditRole, columnBoardNode } = await setup();

const loggedInClient = await testApiClient.login(accountWithEditRole);

const response = await loggedInClient.get(`${columnBoardNode.id}/context`);

expect(response.status).toEqual(200);
});

it('should return the context', async () => {
const { accountWithEditRole, columnBoardNode } = await setup();

const loggedInClient = await testApiClient.login(accountWithEditRole);

const response = await loggedInClient.get(`${columnBoardNode.id}/context`);

expect(response.body).toEqual({ id: columnBoardNode.context?.id, type: columnBoardNode.context?.type });
});
});

describe('with user who has only view role in room', () => {
it('should return status 403', async () => {
const { accountWithViewRole, columnBoardNode } = await setup();

const loggedInClient = await testApiClient.login(accountWithViewRole);

const response = await loggedInClient.get(`${columnBoardNode.id}/context`);

expect(response.status).toEqual(403);
});
});

describe('with user who is not part of the room', () => {
it('should return status 403', async () => {
const { noAccessAccount, columnBoardNode } = await setup();

const loggedInClient = await testApiClient.login(noAccessAccount);

const response = await loggedInClient.get(`${columnBoardNode.id}/context`);

expect(response.status).toEqual(403);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { BoardExternalReferenceType } from '../../domain';

const baseRouteName = '/boards';

describe(`board copy (api)`, () => {
describe(`board copy with course relation (api)`, () => {
let app: INestApplication;
let em: EntityManager;
let testApiClient: TestApiClient;
Expand Down Expand Up @@ -39,13 +39,13 @@ describe(`board copy (api)`, () => {
const { teacherAccount, teacherUser } = UserAndAccountTestFactory.buildTeacher();

const course = courseFactory.build({ teachers: [teacherUser] });
await em.persistAndFlush([teacherUser, course]);
await em.persistAndFlush([teacherAccount, teacherUser, course]);

const columnBoardNode = columnBoardEntityFactory.build({
context: { id: course.id, type: BoardExternalReferenceType.Course },
});

await em.persistAndFlush([teacherAccount, teacherUser, columnBoardNode]);
await em.persistAndFlush([columnBoardNode]);
em.clear();

const loggedInClient = await testApiClient.login(teacherAccount);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { CreateBoardBodyParams } from '../dto';

const baseRouteName = '/boards';

describe(`create board (api)`, () => {
describe(`create board in course (api)`, () => {
let app: INestApplication;
let em: EntityManager;
let testApiClient: TestApiClient;
Expand Down
Loading
Loading