mirror of
https://github.com/logto-io/logto.git
synced 2024-12-23 20:33:16 -05:00
0957899d57
* refactor(test): refactor me,logs, dashboard refactor me,logs, dashboard * fix(test): cr update cr update
54 lines
2 KiB
TypeScript
54 lines
2 KiB
TypeScript
import { getTotalUsersCount, getNewUsersData, getActiveUsersData, StatisticsData } from '@/api';
|
|
import { createUserByAdmin, registerNewUser, signIn } from '@/helpers';
|
|
import { generateUsername, generatePassword } from '@/utils';
|
|
|
|
describe('admin console dashboard', () => {
|
|
it('should get total user count successfully', async () => {
|
|
const { totalUserCount: originTotalUserCount } = await getTotalUsersCount();
|
|
|
|
const password = generatePassword();
|
|
const username = generateUsername();
|
|
await createUserByAdmin(username, password);
|
|
|
|
const { totalUserCount } = await getTotalUsersCount();
|
|
|
|
expect(totalUserCount).toBe(originTotalUserCount + 1);
|
|
});
|
|
|
|
it('should get new user statistics successfully', async () => {
|
|
const originUserStatistics = await getNewUsersData();
|
|
|
|
await registerNewUser(generateUsername(), generatePassword());
|
|
|
|
const newUserStatistics = await getNewUsersData();
|
|
|
|
const keyToCompare: Array<keyof StatisticsData> = ['count', 'delta'];
|
|
|
|
for (const key of keyToCompare) {
|
|
expect(newUserStatistics.today[key]).toBe(originUserStatistics.today[key] + 1);
|
|
expect(newUserStatistics.last7Days[key]).toBe(originUserStatistics.last7Days[key] + 1);
|
|
}
|
|
});
|
|
|
|
it('should get active user statistics successfully', async () => {
|
|
const originActiveUserStatistics = await getActiveUsersData();
|
|
|
|
const password = generatePassword();
|
|
const username = generateUsername();
|
|
await createUserByAdmin(username, password);
|
|
|
|
await signIn(username, password);
|
|
|
|
const newActiveUserStatistics = await getActiveUsersData();
|
|
|
|
expect(newActiveUserStatistics.dauCurve.length).toBeGreaterThan(0);
|
|
|
|
const keyToCompare: Array<keyof StatisticsData> = ['count', 'delta'];
|
|
|
|
for (const key of keyToCompare) {
|
|
expect(newActiveUserStatistics.dau[key]).toBe(originActiveUserStatistics.dau[key] + 1);
|
|
expect(newActiveUserStatistics.wau[key]).toBe(originActiveUserStatistics.wau[key] + 1);
|
|
expect(newActiveUserStatistics.mau[key]).toBe(originActiveUserStatistics.mau[key] + 1);
|
|
}
|
|
});
|
|
});
|