-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into N21-841-use-user-login-migration
- Loading branch information
Showing
116 changed files
with
4,078 additions
and
1,880 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
69 changes: 48 additions & 21 deletions
69
apps/server/src/console/api-test/database-management.console.api.spec.ts
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 |
---|---|---|
@@ -1,52 +1,79 @@ | ||
import { INestApplicationContext } from '@nestjs/common'; | ||
import { BootstrapConsole, ConsoleService } from 'nestjs-console'; | ||
import { ConsoleWriterService } from '@shared/infra/console'; | ||
import { ServerConsoleModule } from '@src/console/console.module'; | ||
import { CommanderError } from 'commander'; | ||
import { execute, TestBootstrapConsole } from './test-bootstrap.console'; | ||
import { BootstrapConsole, ConsoleService } from 'nestjs-console'; | ||
import { TestBootstrapConsole, execute } from './test-bootstrap.console'; | ||
|
||
describe('DatabaseManagementConsole (API)', () => { | ||
let app: INestApplicationContext; | ||
let console: BootstrapConsole; | ||
let bootstrap: BootstrapConsole; | ||
let consoleService: ConsoleService; | ||
beforeAll(async () => { | ||
console = new TestBootstrapConsole({ | ||
let consoleWriter: ConsoleWriterService; | ||
|
||
beforeEach(async () => { | ||
bootstrap = new TestBootstrapConsole({ | ||
module: ServerConsoleModule, | ||
useDecorators: true, | ||
}); | ||
app = await console.init(); | ||
app = await bootstrap.init(); | ||
await app.init(); | ||
consoleService = app.get(ConsoleService); | ||
consoleWriter = app.get(ConsoleWriterService); | ||
}); | ||
|
||
afterAll(async () => { | ||
afterEach(async () => { | ||
consoleService.resetCli(); | ||
await app.close(); | ||
}); | ||
|
||
describe('Command "database"', () => { | ||
beforeEach(() => { | ||
const setup = () => { | ||
const cli = consoleService.getCli('database'); | ||
const exitFn = (err: CommanderError) => { | ||
if (err.exitCode !== 0) throw err; | ||
}; | ||
cli?.exitOverride(exitFn); | ||
const rootCli = consoleService.getRootCli(); | ||
rootCli.exitOverride(exitFn); | ||
}); | ||
const spyConsoleWriterInfo = jest.spyOn(consoleWriter, 'info'); | ||
return { spyConsoleWriterInfo }; | ||
}; | ||
describe('when command not exists', () => { | ||
it('should fail for unknown command', async () => { | ||
setup(); | ||
await expect(execute(bootstrap, ['database', 'not_existing_command'])).rejects.toThrow( | ||
`error: unknown command 'not_existing_command'` | ||
); | ||
|
||
afterEach(() => { | ||
consoleService.resetCli(); | ||
consoleService.resetCli(); | ||
}); | ||
}); | ||
|
||
it('should fail for unknown command', async () => { | ||
await expect(execute(console, ['database', 'not_existing_command'])).rejects.toThrow( | ||
`error: unknown command 'not_existing_command'` | ||
); | ||
}); | ||
it('should provide command "seed"', async () => { | ||
await execute(console, ['database', 'seed']); | ||
}); | ||
it('should provide command "export"', async () => { | ||
await execute(console, ['database', 'export']); | ||
describe('when command exists', () => { | ||
it('should provide command "seed"', async () => { | ||
const { spyConsoleWriterInfo } = setup(); | ||
|
||
await execute(bootstrap, ['database', 'seed']); | ||
|
||
expect(spyConsoleWriterInfo).toBeCalled(); | ||
}); | ||
|
||
it('should provide command "export"', async () => { | ||
const { spyConsoleWriterInfo } = setup(); | ||
|
||
await execute(bootstrap, ['database', 'export']); | ||
|
||
expect(spyConsoleWriterInfo).toBeCalled(); | ||
}); | ||
|
||
it('should provide command "sync-indexes"', async () => { | ||
const { spyConsoleWriterInfo } = setup(); | ||
|
||
await execute(bootstrap, ['database', 'sync-indexes']); | ||
|
||
expect(spyConsoleWriterInfo).toBeCalled(); | ||
}); | ||
}); | ||
}); | ||
}); |
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: 1 addition & 1 deletion
2
apps/server/src/modules/authentication/strategy/jwt-validation.adapter.spec.ts
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
3 changes: 2 additions & 1 deletion
3
apps/server/src/modules/authentication/strategy/jwt-validation.adapter.ts
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,9 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { ClassService } from './service'; | ||
import { ClassesRepo } from './repo'; | ||
|
||
@Module({ | ||
providers: [ClassService, ClassesRepo], | ||
exports: [ClassService], | ||
}) | ||
export class ClassModule {} |
15 changes: 15 additions & 0 deletions
15
apps/server/src/modules/class/domain/class-source-options.do.ts
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,15 @@ | ||
export interface ClassSourceOptionsProps { | ||
tspUid?: string; | ||
} | ||
|
||
export class ClassSourceOptions { | ||
protected props: ClassSourceOptionsProps; | ||
|
||
constructor(props: ClassSourceOptionsProps) { | ||
this.props = props; | ||
} | ||
|
||
get tspUid(): string | undefined { | ||
return this.props.tspUid; | ||
} | ||
} |
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,77 @@ | ||
import { EntityId } from '@shared/domain/types'; | ||
import { AuthorizableObject, DomainObject } from '../../../shared/domain/domain-object'; | ||
import { ClassSourceOptions } from './class-source-options.do'; | ||
|
||
export interface ClassProps extends AuthorizableObject { | ||
name: string; | ||
schoolId: EntityId; | ||
userIds?: EntityId[]; | ||
teacherIds: EntityId[]; | ||
invitationLink?: string; | ||
year?: EntityId; | ||
gradeLevel?: number; | ||
ldapDN?: string; | ||
successor?: EntityId; | ||
source?: string; | ||
sourceOptions?: ClassSourceOptions; | ||
createdAt: Date; | ||
updatedAt: Date; | ||
} | ||
|
||
export class Class extends DomainObject<ClassProps> { | ||
get name(): string { | ||
return this.props.name; | ||
} | ||
|
||
get schoolId(): EntityId { | ||
return this.props.schoolId; | ||
} | ||
|
||
get userIds(): EntityId[] | undefined { | ||
return this.props.userIds; | ||
} | ||
|
||
get teacherIds(): EntityId[] { | ||
return this.props.teacherIds; | ||
} | ||
|
||
get invitationLink(): string | undefined { | ||
return this.props.invitationLink; | ||
} | ||
|
||
get year(): EntityId | undefined { | ||
return this.props.year; | ||
} | ||
|
||
get gradeLevel(): number | undefined { | ||
return this.props.gradeLevel; | ||
} | ||
|
||
get ldapDN(): string | undefined { | ||
return this.props.ldapDN; | ||
} | ||
|
||
get successor(): EntityId | undefined { | ||
return this.props.successor; | ||
} | ||
|
||
get source(): string | undefined { | ||
return this.props.source; | ||
} | ||
|
||
get sourceOptions(): ClassSourceOptions | undefined { | ||
return this.props.sourceOptions; | ||
} | ||
|
||
get createdAt(): Date { | ||
return this.props.createdAt; | ||
} | ||
|
||
get updatedAt(): Date { | ||
return this.props.updatedAt; | ||
} | ||
|
||
public removeUser(userId: string) { | ||
this.props.userIds = this.props.userIds?.filter((userId1) => userId1 !== userId); | ||
} | ||
} |
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 @@ | ||
export * from './class.do'; |
Oops, something went wrong.