mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-29 21:14:29 -05:00
test: allow creating testSetup with users
Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
8cfe4896bc
commit
2096e23e35
1 changed files with 23 additions and 0 deletions
|
@ -36,6 +36,7 @@ import { NotesModule } from '../src/notes/notes.module';
|
||||||
import { NotesService } from '../src/notes/notes.service';
|
import { NotesService } from '../src/notes/notes.service';
|
||||||
import { PermissionsModule } from '../src/permissions/permissions.module';
|
import { PermissionsModule } from '../src/permissions/permissions.module';
|
||||||
import { RevisionsModule } from '../src/revisions/revisions.module';
|
import { RevisionsModule } from '../src/revisions/revisions.module';
|
||||||
|
import { User } from '../src/users/user.entity';
|
||||||
import { UsersModule } from '../src/users/users.module';
|
import { UsersModule } from '../src/users/users.module';
|
||||||
import { UsersService } from '../src/users/users.service';
|
import { UsersService } from '../src/users/users.service';
|
||||||
import { setupSessionMiddleware } from '../src/utils/session';
|
import { setupSessionMiddleware } from '../src/utils/session';
|
||||||
|
@ -52,6 +53,8 @@ export class TestSetup {
|
||||||
historyService: HistoryService;
|
historyService: HistoryService;
|
||||||
aliasService: AliasService;
|
aliasService: AliasService;
|
||||||
|
|
||||||
|
users: User[] = [];
|
||||||
|
|
||||||
public static async create(): Promise<TestSetup> {
|
public static async create(): Promise<TestSetup> {
|
||||||
const testSetup = new TestSetup();
|
const testSetup = new TestSetup();
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
|
@ -129,4 +132,24 @@ export class TestSetup {
|
||||||
|
|
||||||
return testSetup;
|
return testSetup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async withUsers(): Promise<TestSetup> {
|
||||||
|
// Create users
|
||||||
|
this.users.push(
|
||||||
|
await this.userService.createUser('testuser1', 'Test User 1'),
|
||||||
|
);
|
||||||
|
this.users.push(
|
||||||
|
await this.userService.createUser('testuser2', 'Test User 2'),
|
||||||
|
);
|
||||||
|
this.users.push(
|
||||||
|
await this.userService.createUser('testuser3', 'Test User 3'),
|
||||||
|
);
|
||||||
|
|
||||||
|
// Create identities for login
|
||||||
|
await this.identityService.createLocalIdentity(this.users[0], 'testuser1');
|
||||||
|
await this.identityService.createLocalIdentity(this.users[1], 'testuser2');
|
||||||
|
await this.identityService.createLocalIdentity(this.users[2], 'testuser3');
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue