2022-11-09 06:25:00 -08:00
|
|
|
import { Reset } from '@/commands/user-management/reset';
|
2023-02-21 10:21:56 -08:00
|
|
|
import { InternalHooks } from '@/InternalHooks';
|
|
|
|
import { LoadNodesAndCredentials } from '@/LoadNodesAndCredentials';
|
|
|
|
import { NodeTypes } from '@/NodeTypes';
|
2023-11-10 06:04:26 -08:00
|
|
|
import Container from 'typedi';
|
|
|
|
import { UserRepository } from '@db/repositories/user.repository';
|
|
|
|
|
|
|
|
import { mockInstance } from '../../shared/mocking';
|
|
|
|
import * as testDb from '../shared/testDb';
|
2023-11-08 07:29:39 -08:00
|
|
|
import { createUser } from '../shared/db/users';
|
2022-06-03 08:44:34 -07:00
|
|
|
|
|
|
|
beforeAll(async () => {
|
2023-02-21 10:21:56 -08:00
|
|
|
mockInstance(InternalHooks);
|
|
|
|
mockInstance(LoadNodesAndCredentials);
|
|
|
|
mockInstance(NodeTypes);
|
2023-01-13 09:12:22 -08:00
|
|
|
await testDb.init();
|
2022-06-03 08:44:34 -07:00
|
|
|
});
|
|
|
|
|
2022-06-25 21:03:46 -07:00
|
|
|
beforeEach(async () => {
|
2023-01-13 09:12:22 -08:00
|
|
|
await testDb.truncate(['User']);
|
2022-06-25 21:03:46 -07:00
|
|
|
});
|
|
|
|
|
2022-06-03 08:44:34 -07:00
|
|
|
afterAll(async () => {
|
2023-01-13 09:12:22 -08:00
|
|
|
await testDb.terminate();
|
2022-06-03 08:44:34 -07:00
|
|
|
});
|
|
|
|
|
2023-05-24 00:45:37 -07:00
|
|
|
// eslint-disable-next-line n8n-local-rules/no-skipped-tests
|
2023-03-10 07:53:05 -08:00
|
|
|
test.skip('user-management:reset should reset DB to default user state', async () => {
|
2024-01-24 04:38:57 -08:00
|
|
|
await createUser({ role: 'global:owner' });
|
2022-06-03 08:44:34 -07:00
|
|
|
|
2022-06-25 21:03:46 -07:00
|
|
|
await Reset.run();
|
2022-06-03 08:44:34 -07:00
|
|
|
|
2024-01-24 04:38:57 -08:00
|
|
|
const user = await Container.get(UserRepository).findOneBy({ role: 'global:owner' });
|
2022-06-03 08:44:34 -07:00
|
|
|
|
2022-06-25 21:03:46 -07:00
|
|
|
if (!user) {
|
|
|
|
fail('No owner found after DB reset to default user state');
|
|
|
|
}
|
2022-06-03 08:44:34 -07:00
|
|
|
|
2022-06-25 21:03:46 -07:00
|
|
|
expect(user.email).toBeNull();
|
|
|
|
expect(user.firstName).toBeNull();
|
|
|
|
expect(user.lastName).toBeNull();
|
|
|
|
expect(user.password).toBeNull();
|
|
|
|
expect(user.personalizationAnswers).toBeNull();
|
2022-06-03 08:44:34 -07:00
|
|
|
});
|