mirror of
https://github.com/logto-io/logto.git
synced 2024-12-23 20:33:16 -05:00
6a2e604926
* test(ui): init smoke testing * fix(test): logto url env key
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);
|
|
}
|
|
});
|
|
});
|