2022-07-26 01:29:38 -05:00
|
|
|
import { assert } from '@silverhand/essentials';
|
|
|
|
|
2022-07-27 21:30:37 -05:00
|
|
|
import { getLogs, getLog } from '@/api';
|
|
|
|
import { registerNewUser } from '@/helpers';
|
|
|
|
import { generateUsername, generatePassword } from '@/utils';
|
2022-07-26 01:29:38 -05:00
|
|
|
|
|
|
|
describe('admin console logs', () => {
|
2022-07-27 21:30:37 -05:00
|
|
|
const username = generateUsername();
|
|
|
|
const password = generatePassword();
|
|
|
|
|
2022-07-26 01:29:38 -05:00
|
|
|
it('should get logs and visit log details successfully', async () => {
|
2022-07-27 21:30:37 -05:00
|
|
|
await registerNewUser(username, password);
|
|
|
|
|
|
|
|
const logs = await getLogs();
|
2022-07-26 01:29:38 -05:00
|
|
|
|
2022-07-27 21:30:37 -05:00
|
|
|
const registerLog = logs.filter(
|
|
|
|
({ type, payload }) =>
|
|
|
|
type === 'RegisterUsernamePassword' &&
|
|
|
|
(payload as Record<string, unknown>).username === username
|
|
|
|
);
|
2022-07-26 01:29:38 -05:00
|
|
|
|
2022-07-27 21:30:37 -05:00
|
|
|
expect(registerLog.length).toBeGreaterThan(0);
|
2022-07-26 01:29:38 -05:00
|
|
|
|
2022-07-27 21:30:37 -05:00
|
|
|
assert(registerLog[0], new Error('Log is not valid'));
|
2022-07-26 01:29:38 -05:00
|
|
|
|
2022-07-27 21:30:37 -05:00
|
|
|
const logDetails = await getLog(registerLog[0].id);
|
2022-07-26 01:29:38 -05:00
|
|
|
|
2022-07-27 21:30:37 -05:00
|
|
|
expect(logDetails).toMatchObject(registerLog[0]);
|
2022-07-26 01:29:38 -05:00
|
|
|
});
|
|
|
|
});
|