From fbcbe23b32f338e7c71a1492dfdac9be408df205 Mon Sep 17 00:00:00 2001 From: "agile.zhou" Date: Sun, 30 Aug 2026 17:33:17 +0800 Subject: [PATCH] fix: stabilize browser e2e setup --- .github/workflows/master-ci.yml | 2 +- .github/workflows/master-pr-ci.yml | 2 +- .../react-ui-antd/e2e/scripts/start-server.js | 2 +- .../e2e/specs/configuration-lifecycle.spec.ts | 28 +++++++++++++------ .../react-ui-antd/src/pages/Apps/index.tsx | 4 +++ .../react-ui-antd/src/pages/Configs/index.tsx | 5 +++- 6 files changed, 30 insertions(+), 13 deletions(-) diff --git a/.github/workflows/master-ci.yml b/.github/workflows/master-ci.yml index 5aac5f2..f1a44b7 100644 --- a/.github/workflows/master-ci.yml +++ b/.github/workflows/master-ci.yml @@ -29,7 +29,7 @@ jobs: - run: npm install - run: npm run build - run: npx playwright install --with-deps chromium - - run: npm run test:e2e + - run: E2E_SKIP_UI_BUILD=true npm run test:e2e build-dotnet: runs-on: ubuntu-latest diff --git a/.github/workflows/master-pr-ci.yml b/.github/workflows/master-pr-ci.yml index 8111772..38fe76d 100644 --- a/.github/workflows/master-pr-ci.yml +++ b/.github/workflows/master-pr-ci.yml @@ -29,7 +29,7 @@ jobs: - run: npm install - run: npm run build - run: npx playwright install --with-deps chromium - - run: npm run test:e2e + - run: E2E_SKIP_UI_BUILD=true npm run test:e2e build-dotnet: runs-on: ubuntu-latest diff --git a/src/AgileConfig.Server.UI/react-ui-antd/e2e/scripts/start-server.js b/src/AgileConfig.Server.UI/react-ui-antd/e2e/scripts/start-server.js index d65215e..9b13cf6 100644 --- a/src/AgileConfig.Server.UI/react-ui-antd/e2e/scripts/start-server.js +++ b/src/AgileConfig.Server.UI/react-ui-antd/e2e/scripts/start-server.js @@ -16,7 +16,7 @@ function run(command, args, cwd) { execFileSync(command, args, { cwd, stdio: 'inherit', shell: process.platform === 'win32' }); } -if (!existsSync(uiSource)) { +if (!process.env.E2E_SKIP_UI_BUILD || !existsSync(uiSource)) { run('npm', ['run', 'build'], frontendRoot); } run('dotnet', ['build', apiProject, '-c', 'Release', '--nologo'], repositoryRoot); diff --git a/src/AgileConfig.Server.UI/react-ui-antd/e2e/specs/configuration-lifecycle.spec.ts b/src/AgileConfig.Server.UI/react-ui-antd/e2e/specs/configuration-lifecycle.spec.ts index 47ba1a1..a72b665 100644 --- a/src/AgileConfig.Server.UI/react-ui-antd/e2e/specs/configuration-lifecycle.spec.ts +++ b/src/AgileConfig.Server.UI/react-ui-antd/e2e/specs/configuration-lifecycle.spec.ts @@ -7,31 +7,41 @@ test('an administrator can publish a configuration from the hosted management UI const key = `e2e.key.${suffix}`; const value = `value-${suffix}`; + const login = await request.post('/admin/jwt/login', { + data: { userName: 'admin', password: 'e2e-admin-password' }, + }); + await expect(login).toBeOK(); + const { token } = await login.json(); + const addNode = await request.post('/ServerNode/Add', { + headers: { Authorization: `Bearer ${token}` }, + data: { address: 'http://127.0.0.1:5187', remark: 'E2E local node' }, + }); + await expect(addNode).toBeOK(); + await page.goto('/ui#/user/login'); await page.getByRole('textbox', { name: 'Username', exact: true }).fill('admin'); await page.getByRole('textbox', { name: 'Password', exact: true }).fill('e2e-admin-password'); await page.getByRole('button', { name: 'Login', exact: true }).click(); await expect(page).toHaveURL(/#\/home$/); - await page.getByRole('button', { name: 'Add Now', exact: true }).click(); await page.goto('/ui#/app'); - await page.getByRole('button', { name: /Create$/ }).click(); + await page.getByTestId('app-create').click(); const applicationDialog = page.getByRole('dialog'); - await applicationDialog.getByLabel('Name').fill(appName); - await applicationDialog.getByLabel('AppID').fill(appId); - await applicationDialog.getByLabel('Secret').fill('e2e-app-secret'); + await applicationDialog.locator('#app-create-name').fill(appName); + await applicationDialog.locator('#app-create-id').fill(appId); + await applicationDialog.locator('#app-create-secret').fill('e2e-app-secret'); await applicationDialog.getByRole('button', { name: 'Submit', exact: true }).click(); await expect(page.getByText(appId, { exact: true })).toBeVisible(); await page.goto(`/ui#/app/config/${appId}/${encodeURIComponent(appName)}`); - await page.getByRole('button', { name: /Add$/ }).click(); + await page.getByTestId('config-create').click(); const configurationDialog = page.getByRole('dialog'); - await configurationDialog.getByLabel('Key').fill(key); - await configurationDialog.getByLabel('Value').fill(value); + await configurationDialog.locator('#config-create-key').fill(key); + await configurationDialog.locator('#config-create-value').fill(value); await configurationDialog.getByRole('button', { name: 'Submit', exact: true }).click(); await expect(page.getByText(key, { exact: true })).toBeVisible(); - await page.getByRole('button', { name: /Publish All$/ }).click(); + await page.getByTestId('config-publish-all').click(); const publishDialog = page.getByRole('dialog'); await publishDialog.getByRole('button', { name: 'OK', exact: true }).click(); await expect(page.getByText('Publish Success!', { exact: true })).toBeVisible(); diff --git a/src/AgileConfig.Server.UI/react-ui-antd/src/pages/Apps/index.tsx b/src/AgileConfig.Server.UI/react-ui-antd/src/pages/Apps/index.tsx index f2f4a48..44c318b 100644 --- a/src/AgileConfig.Server.UI/react-ui-antd/src/pages/Apps/index.tsx +++ b/src/AgileConfig.Server.UI/react-ui-antd/src/pages/Apps/index.tsx @@ -521,6 +521,7 @@ const appList: React.FC = (props) => { ,