0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00

test(core): add hasActiveUser test case (#4307)

* test(core): add hasActiveUser test case

add hasActiveUser test case

* ci: remove integration-test code owner

remove integration-test code owner
This commit is contained in:
simeng-li 2023-08-10 10:28:35 +08:00 committed by GitHub
parent d2ced458df
commit 74849dde22
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 41 additions and 14 deletions

1
.github/CODEOWNERS vendored
View file

@ -2,5 +2,4 @@
/packages/core @simeng-li @wangsijie @gao-sun
/packages/console @wangsijie @charIeszhao
/packages/ui @simeng-li @charIeszhao
/packages/integration-tests @simeng-li
/.changeset @gao-sun

View file

@ -8,10 +8,9 @@ type CreateUserPayload = Partial<{
username: string;
password: string;
name: string;
isAdmin: boolean;
}>;
export const createUser = async (payload: CreateUserPayload) =>
export const createUser = async (payload: CreateUserPayload = {}) =>
authedAdminApi
.post('users', {
json: payload,

View file

@ -15,8 +15,7 @@ export const createUserByAdmin = async (
password?: string,
primaryEmail?: string,
primaryPhone?: string,
name?: string,
isAdmin = false
name?: string
) => {
return createUser({
username: username ?? generateUsername(),
@ -24,7 +23,6 @@ export const createUserByAdmin = async (
name: name ?? username ?? 'John',
primaryEmail,
primaryPhone,
isAdmin,
});
};

View file

@ -49,14 +49,7 @@ describe('admin console user search params', () => {
const primaryPhone =
phonePrefix[index % phonePrefix.length]! + index.toString().padStart(5, '0');
return createUserByAdmin(
prefix + username,
undefined,
primaryEmail,
primaryPhone,
name,
index < 3
);
return createUserByAdmin(prefix + username, undefined, primaryEmail, primaryPhone, name);
})
);
});

View file

@ -1,5 +1,7 @@
import { type User } from '@logto/schemas';
import { appendPath } from '@silverhand/essentials';
import { authedAdminTenantApi } from '#src/api/api.js';
import {
consolePassword,
consoleUsername,
@ -16,6 +18,42 @@ import { appendPathname, expectNavigation } from '#src/utils.js';
describe('smoke testing for console admin account creation and sign-in', () => {
const logtoConsoleUrl = new URL(logtoConsoleUrlString);
it('should not navigate to welcome page if admin tenant user table is not empty', async () => {
// Create a admin user
const { id } = await authedAdminTenantApi
.post('users', {
json: { username: 'test_admin_user' },
})
.json<User>();
await expectNavigation(page.goto(logtoConsoleUrl.href));
await expect(page).toMatchElement('#app');
expect(page.url()).not.toBe(new URL('console/welcome', logtoConsoleUrl).href);
// Clean up
await authedAdminTenantApi.delete(`users/${id}`);
});
it('should navigate to welcome page if all admin user are suspended', async () => {
// Create a admin user
const { id } = await authedAdminTenantApi
.post('users', {
json: { username: 'test_admin_user' },
})
.json<User>();
await authedAdminTenantApi.patch(`users/${id}/is-suspended`, { json: { isSuspended: true } });
await expectNavigation(page.goto(logtoConsoleUrl.href));
await expect(page).toMatchElement('#app');
expect(page.url()).toBe(new URL('console/welcome', logtoConsoleUrl).href);
// Clean up
await authedAdminTenantApi.delete(`users/${id}`);
});
it('can open with app element and navigate to welcome page', async () => {
await expectNavigation(page.goto(logtoConsoleUrl.href));