From 700107f59bc2f0d6519d897c17a52b7c0d9d32c8 Mon Sep 17 00:00:00 2001 From: Gao Sun Date: Mon, 6 Feb 2023 12:14:05 +0800 Subject: [PATCH] refactor(test): update integration ui test --- .github/workflows/integration-test.yml | 2 -- packages/integration-tests/src/constants.ts | 10 +++++++--- .../integration-tests/src/tests/ui/smoke.test.ts | 16 ++++++++-------- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 0acfa2fa4..16a0ae409 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -101,5 +101,3 @@ jobs: cd tests/packages/integration-tests pnpm build pnpm test:${{ matrix.test_target }} - env: - INTEGRATION_TESTS_LOGTO_URL: http://localhost:3001 diff --git a/packages/integration-tests/src/constants.ts b/packages/integration-tests/src/constants.ts index e02fe489c..319961cbc 100644 --- a/packages/integration-tests/src/constants.ts +++ b/packages/integration-tests/src/constants.ts @@ -1,12 +1,16 @@ import { SignInIdentifier, demoAppApplicationId } from '@logto/schemas'; -import { assertEnv } from '@silverhand/essentials'; +import { getEnv } from '@silverhand/essentials'; -export const logtoUrl = assertEnv('INTEGRATION_TESTS_LOGTO_URL'); +export const logtoUrl = getEnv('INTEGRATION_TESTS_LOGTO_URL', 'http://localhost:3001'); +export const logtoConsoleUrl = getEnv( + 'INTEGRATION_TESTS_LOGTO_CONSOLE_URL', + 'http://localhost:3002' +); export const discoveryUrl = `${logtoUrl}/oidc/.well-known/openid-configuration`; export const demoAppRedirectUri = `${logtoUrl}/${demoAppApplicationId}`; -export const adminConsoleRedirectUri = `${logtoUrl}/console/callback`; +export const adminConsoleRedirectUri = `${logtoConsoleUrl}/console/callback`; export const signUpIdentifiers = { username: [SignInIdentifier.Username], diff --git a/packages/integration-tests/src/tests/ui/smoke.test.ts b/packages/integration-tests/src/tests/ui/smoke.test.ts index a42eb906d..bf9c302f2 100644 --- a/packages/integration-tests/src/tests/ui/smoke.test.ts +++ b/packages/integration-tests/src/tests/ui/smoke.test.ts @@ -1,4 +1,4 @@ -import { logtoUrl } from '#src/constants.js'; +import { logtoConsoleUrl } from '#src/constants.js'; import { generatePassword } from '#src/utils.js'; describe('smoke testing', () => { @@ -7,11 +7,11 @@ describe('smoke testing', () => { it('opens with app element and navigates to welcome page', async () => { const navigation = page.waitForNavigation({ waitUntil: 'networkidle0' }); - await page.goto(logtoUrl); + await page.goto(logtoConsoleUrl); await navigation; await expect(page.waitForSelector('#app')).resolves.not.toBeNull(); - expect(page.url()).toBe(new URL('console/welcome', logtoUrl).href); + expect(page.url()).toBe(new URL('console/welcome', logtoConsoleUrl).href); }); it('registers a new admin account and automatically signs in', async () => { @@ -22,7 +22,7 @@ describe('smoke testing', () => { await createAccountButton.click(); await navigateToRegister; - expect(page.url()).toBe(new URL('register', logtoUrl).href); + expect(page.url()).toBe(new URL('register', logtoConsoleUrl).href); const usernameField = await page.waitForSelector('input[name=new-username]'); const submitButton = await page.waitForSelector('button'); @@ -33,7 +33,7 @@ describe('smoke testing', () => { await submitButton.click(); await navigateToSignIn; - expect(page.url()).toBe(new URL('register/username/password', logtoUrl).href); + expect(page.url()).toBe(new URL('register/username/password', logtoConsoleUrl).href); const passwordField = await page.waitForSelector('input[name=newPassword]'); const confirmPasswordField = await page.waitForSelector('input[name=confirmPassword]'); @@ -45,7 +45,7 @@ describe('smoke testing', () => { await saveButton.click(); await navigateToGetStarted; - expect(page.url()).toBe(new URL('console/get-started', logtoUrl).href); + expect(page.url()).toBe(new URL('console/get-started', logtoConsoleUrl).href); }); it('signs out of admin console', async () => { @@ -62,7 +62,7 @@ describe('smoke testing', () => { await signOutButton.click(); await navigation; - expect(page.url()).toBe(new URL('sign-in', logtoUrl).href); + expect(page.url()).toBe(new URL('sign-in', logtoConsoleUrl).href); }); it('signs in to admin console', async () => { @@ -77,7 +77,7 @@ describe('smoke testing', () => { await submitButton.click(); await navigation; - expect(page.url()).toBe(new URL('console/get-started', logtoUrl).href); + expect(page.url()).toBe(new URL('console/get-started', logtoConsoleUrl).href); const userElement = await page.waitForSelector('div[class$=topbar] > div:last-child'); const usernameString = await userElement.$eval('div > div', (element) => element.textContent);