The Unified and Autonomous Development Platform
fix: Failed E2E test
Robin Shen0c747367578b
diff --git a/e2e-test/README.md b/e2e-test/README.mdindex 8e533878a0..4a9324cfde 100644--- a/e2e-test/README.md+++ b/e2e-test/README.md@@ -128,9 +128,11 @@ npm test -- tests/websocket-*.spec.js`tests/jev-issue-suggestions.spec.js` configures a fake API key and tests the realnew-issue form against a local HTTP mock. It verifies the outgoing authorization,-model, title, description and choice questions; saving suggested values;-ignoring low-confidence/unknown choices; preserving a manual choice; and-discarding a response after the title changes.+model, title, description and choice questions, with no project path or other+metadata in the request state; saving suggestions at the 85% confidence threshold;+ignoring lower-confidence/unknown choices; preserving a manual choice;+discarding a response after the title changes; and recovering from an API failure+on a later edit.Jev requests originate in the Java server, so browser request interception cannotmock them. The fixture starts a local HTTP server on an automatically assigned@@ -176,8 +178,10 @@ waits for OneDev to poll the empty inbox before sending, because OneDev skipspre-existing messages on its first connection. Outgoing notifications also stayinside GreenMail. Its protocol log is attached to each test result.-The tests verify created issue fields and configured fallbacks for low-confidence-or unknown answers and API failures.+The tests verify that request state contains only the email title and description,+without the project path. They check single and multiple choices at the 85%+confidence threshold, assignee scripts using the resolved values, and configured+fallbacks for lower-confidence or unknown answers and API failures.Use a dedicated server and one worker, as with the new-issue form tests. Testsettings are restored, and test projects and users are removed. No externaldiff --git a/e2e-test/tests/jev-fixtures.js b/e2e-test/tests/jev-fixtures.jsindex 410e756bfd..47c86791a4 100644--- a/e2e-test/tests/jev-fixtures.js+++ b/e2e-test/tests/jev-fixtures.js@@ -77,6 +77,10 @@ export const test = base.extend({expect(request.headers.authorization).toBe(`Bearer ${fakeApiKey}`);expect(request.headers['content-type']).toBe('application/json');expect(request.body.model).toBe('jev-latest');+ // Check retries and form edits too: no project path or server metadata.+ expect(JSON.parse(request.body.state)).toEqual({+ title: expect.any(String), description: expect.any(String),+ });return request;},reply(request, selections = { Type: ['Bug', 0.99], Priority: ['Major', 0.99] }, status = 200) {diff --git a/e2e-test/tests/jev-issue-suggestions.spec.js b/e2e-test/tests/jev-issue-suggestions.spec.jsindex aba652b695..0303b1927b 100644--- a/e2e-test/tests/jev-issue-suggestions.spec.js+++ b/e2e-test/tests/jev-issue-suggestions.spec.js@@ -22,10 +22,10 @@ test('Jev suggestions populate required fields and are saved with the new issue'await page.locator('.new-issue .description textarea').fill(description);await page.getByPlaceholder('Input title here').fill(title);const request = await jev.nextRequest();- expect(JSON.parse(request.body.state)).toEqual({ project: project.name, title, description });+ expect(JSON.parse(request.body.state)).toEqual({ title, description });expect(Object.keys(request.body.questions)).toHaveLength(2);await expect(field(page, 'Type')).toContainText('Suggesting...');- jev.reply(request);+ jev.reply(request, { Type: ['Bug', 0.85], Priority: ['Major', 0.85] });await expect(field(page, 'Type').locator('.select2-selection__rendered')).toHaveText('Bug');await expect(field(page, 'Priority').locator('.select2-selection__rendered')).toHaveText('Major');await page.getByRole('button', { name: 'Save', exact: true }).click();@@ -38,7 +38,7 @@ test('Jev suggestions populate required fields and are saved with the new issue'test('uncertain and unknown suggestions leave fields empty and manual choices still work', async ({ page, api, jev }) => {await openIssue(page, api);await page.getByPlaceholder('Input title here').fill('Something needs attention');- jev.reply(await jev.nextRequest(), { Type: ['Bug', 0.84], Priority: ['unknown', 0.99] });+ jev.reply(await jev.nextRequest(), { Type: ['Bug', 0.8499], Priority: ['unknown', 0.99] });await expect(field(page, 'Type').locator('.select2-selection__placeholder')).not.toContainText('Suggesting...');await expect(field(page, 'Type').locator('select')).toHaveValue('');await expect(field(page, 'Priority').locator('select')).toHaveValue('');@@ -59,9 +59,39 @@ test('a response for an older title is ignored and the updated title is suggesteawait page.getByPlaceholder('Input title here').fill('Add a new dashboard');jev.reply(oldRequest);const newRequest = await jev.nextRequest(1);- expect(JSON.parse(newRequest.body.state).title).toBe('Add a new dashboard');+ expect(JSON.parse(oldRequest.body.state)).toEqual({ title: 'An old bug report', description: '' });+ expect(JSON.parse(newRequest.body.state)).toEqual({ title: 'Add a new dashboard', description: '' });await expect(field(page, 'Type').locator('select')).toHaveValue('');jev.reply(newRequest, { Type: ['New Feature', 0.99], Priority: ['Normal', 0.99] });await expect(field(page, 'Type').locator('select')).toHaveValue('New Feature');await expect(field(page, 'Priority').locator('select')).toHaveValue('Normal');});++test('a Jev API failure leaves fields empty and a later edit can retry successfully', async ({ page, api, jev }) => {+ const project = await openIssue(page, api);+ const description = 'Signing in produces a server error.';+ await page.locator('.new-issue .description textarea').fill(description);+ await page.getByPlaceholder('Input title here').fill('Cannot sign in');+ const failedRequest = await jev.nextRequest();+ expect(JSON.parse(failedRequest.body.state)).toEqual({ title: 'Cannot sign in', description });+ jev.reply(failedRequest, undefined, 503);+ for (const name of ['Type', 'Priority']) {+ await expect(field(page, name)).not.toContainText('Suggesting...');+ await expect(field(page, name).locator('select')).toHaveValue('');+ }++ const title = 'Cannot sign in after resetting my password';+ await page.getByPlaceholder('Input title here').fill(title);+ const retry = await jev.nextRequest(1);+ expect(JSON.parse(retry.body.state)).toEqual({ title, description });+ expect(Object.keys(retry.body.questions)).toHaveLength(2);+ jev.reply(retry);+ await expect(field(page, 'Type').locator('select')).toHaveValue('Bug');+ await expect(field(page, 'Priority').locator('select')).toHaveValue('Major');+ await page.getByRole('button', { name: 'Save', exact: true }).click();+ await page.waitForURL(new RegExp(`/${project.name}/~issues/\\d+`));+ await page.reload();+ await expect(page.locator('.issue-editable-title')).toContainText(title);+ await expect(page.locator('.field-values')).toContainText(['Bug', 'Major']);+ expect(jev.requests).toHaveLength(2);+});diff --git a/e2e-test/tests/jev-service-desk.spec.js b/e2e-test/tests/jev-service-desk.spec.jsindex 11dc39a059..6a3fdbecaf 100644--- a/e2e-test/tests/jev-service-desk.spec.js+++ b/e2e-test/tests/jev-service-desk.spec.js@@ -85,8 +85,8 @@ const test = base.extend({const scenarios = [{- name: 'confident decisions populate single and multiple choices before the assignee script',- answers: { Type: ['Bug', 0.99], Priority: ['Major', 0.95], 'E2E Labels': ['Bug', 0.9] },+ name: 'decisions at the confidence threshold populate single and multiple choices before the assignee script',+ answers: { Type: ['Bug', 0.85], Priority: ['Major', 0.85], 'E2E Labels': ['Bug', 0.85] },expected: { Type: 'Bug', Priority: 'Major', 'E2E Labels': ['Bug'] },assignee: 'bugAssignee',},@@ -98,7 +98,7 @@ const scenarios = [},{name: 'uncertain and unknown decisions retain configured fallbacks',- answers: { Type: ['Bug', 0.84], Priority: ['unknown', 0.99], 'E2E Labels': ['Bug', 0.84] },+ answers: { Type: ['Bug', 0.8499], Priority: ['unknown', 0.99], 'E2E Labels': ['Bug', 0.8499] },expected: { Type: 'Support Request', Priority: 'Normal', 'E2E Labels': ['Improvement', 'Task'] },assignee: 'supportAssignee',},@@ -120,9 +120,7 @@ for (const scenario of scenarios) {const request = await jev.nextRequest();const state = JSON.parse(request.body.state);- expect(state.project).toBe(project.name);- expect(state.title).toBe(title);- expect(state.description).toContain(body);+ expect(state).toEqual({ title, description: expect.stringContaining(body) });expect(Object.values(request.body.questions).map(question =>question.instructions.match(/issue field '([^']+)'/)[1]).sort()).toEqual(['E2E Labels', 'Priority', 'Type']);