diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 037820f5b..aed581e9e 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -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 diff --git a/packages/integration-tests/src/api/admin-user.ts b/packages/integration-tests/src/api/admin-user.ts index 68194b21d..3a9806b24 100644 --- a/packages/integration-tests/src/api/admin-user.ts +++ b/packages/integration-tests/src/api/admin-user.ts @@ -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, diff --git a/packages/integration-tests/src/helpers/index.ts b/packages/integration-tests/src/helpers/index.ts index cd06018f2..8b978ccb1 100644 --- a/packages/integration-tests/src/helpers/index.ts +++ b/packages/integration-tests/src/helpers/index.ts @@ -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, }); }; diff --git a/packages/integration-tests/src/tests/api/admin-user.search.test.ts b/packages/integration-tests/src/tests/api/admin-user.search.test.ts index e4491057a..3f51986df 100644 --- a/packages/integration-tests/src/tests/api/admin-user.search.test.ts +++ b/packages/integration-tests/src/tests/api/admin-user.search.test.ts @@ -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); }) ); }); diff --git a/packages/integration-tests/src/tests/ui/bootstrap.test.ts b/packages/integration-tests/src/tests/ui/bootstrap.test.ts index 340aa9b87..e0d8c497d 100644 --- a/packages/integration-tests/src/tests/ui/bootstrap.test.ts +++ b/packages/integration-tests/src/tests/ui/bootstrap.test.ts @@ -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(); + + 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(); + + 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));