feat: add manager guide and contextual help
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class AddHelpTextsEnabled1785520800000 implements MigrationInterface {
|
||||
name = 'AddHelpTextsEnabled1785520800000';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
'ALTER TABLE "user" ADD "helpTextsEnabled" boolean NOT NULL DEFAULT true',
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
'ALTER TABLE "user" DROP COLUMN "helpTextsEnabled"',
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import { getMetadataArgsStorage } from 'typeorm';
|
||||
import { User } from '../../users/entities/user.entity';
|
||||
|
||||
describe('AddHelpTextsEnabled1785520800000', () => {
|
||||
it('adds a reversible enabled-by-default user preference', async () => {
|
||||
const migrationModule = require('./1785520800000-AddHelpTextsEnabled');
|
||||
const migration = new migrationModule.AddHelpTextsEnabled1785520800000();
|
||||
const queryRunner = { query: jest.fn() } as any;
|
||||
|
||||
await migration.up(queryRunner);
|
||||
expect(queryRunner.query).toHaveBeenCalledWith(
|
||||
'ALTER TABLE "user" ADD "helpTextsEnabled" boolean NOT NULL DEFAULT true',
|
||||
);
|
||||
|
||||
queryRunner.query.mockClear();
|
||||
await migration.down(queryRunner);
|
||||
expect(queryRunner.query).toHaveBeenCalledWith(
|
||||
'ALTER TABLE "user" DROP COLUMN "helpTextsEnabled"',
|
||||
);
|
||||
});
|
||||
|
||||
it('keeps the user entity default aligned with the migration', () => {
|
||||
const column = getMetadataArgsStorage().columns.find(
|
||||
(candidate) =>
|
||||
candidate.target === User &&
|
||||
candidate.propertyName === 'helpTextsEnabled',
|
||||
);
|
||||
|
||||
expect(column?.options).toMatchObject({ type: Boolean, default: true });
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user