The Unified and Autonomous Development Platform
refactor: Update confidence threshold for suggestions in E2E tests and related components
Robin Shen738a10c45476
diff --git a/e2e-test/README.md b/e2e-test/README.mdindex f29a9276e5..efba13ce9e 100644--- a/e2e-test/README.md+++ b/e2e-test/README.md@@ -138,7 +138,7 @@ 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, with no project path or other-metadata in the request state; saving suggestions at the 85% confidence threshold;+metadata in the request state; saving suggestions at the 75% confidence threshold;ignoring lower-confidence/unknown choices; preserving a manual choice;discarding a response after the title changes; and recovering from an API failureon a later edit.@@ -188,7 +188,7 @@ pre-existing messages on its first connection. Outgoing notifications also stayinside GreenMail. Its protocol log is attached to each test result.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%+without the project path. They check single and multiple choices at the 75%confidence threshold, assignee scripts using the resolved values, and configuredfallbacks for lower-confidence or unknown answers and API failures.diff --git a/e2e-test/tests/jev-issue-suggestions.spec.js b/e2e-test/tests/jev-issue-suggestions.spec.jsindex 0303b1927b..6f8858cfe1 100644--- a/e2e-test/tests/jev-issue-suggestions.spec.js+++ b/e2e-test/tests/jev-issue-suggestions.spec.js@@ -25,7 +25,7 @@ test('Jev suggestions populate required fields and are saved with the new issue'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, { Type: ['Bug', 0.85], Priority: ['Major', 0.85] });+ jev.reply(request, { Type: ['Bug', 0.75], Priority: ['Major', 0.75] });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.8499], Priority: ['unknown', 0.99] });+ jev.reply(await jev.nextRequest(), { Type: ['Bug', 0.7499], 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('');diff --git a/e2e-test/tests/jev-service-desk.spec.js b/e2e-test/tests/jev-service-desk.spec.jsindex 6a3fdbecaf..2992125d1f 100644--- a/e2e-test/tests/jev-service-desk.spec.js+++ b/e2e-test/tests/jev-service-desk.spec.js@@ -86,7 +86,7 @@ const test = base.extend({const scenarios = [{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] },+ answers: { Type: ['Bug', 0.75], Priority: ['Major', 0.75], 'E2E Labels': ['Bug', 0.75] },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.8499], Priority: ['unknown', 0.99], 'E2E Labels': ['Bug', 0.8499] },+ answers: { Type: ['Bug', 0.7499], Priority: ['unknown', 0.99], 'E2E Labels': ['Bug', 0.7499] },expected: { Type: 'Support Request', Priority: 'Normal', 'E2E Labels': ['Improvement', 'Task'] },assignee: 'supportAssignee',},diff --git a/server-core/src/main/java/io/onedev/server/model/support/issue/field/FieldUtils.java b/server-core/src/main/java/io/onedev/server/model/support/issue/field/FieldUtils.javaindex de5ad17bc1..fb2e52ce91 100644--- a/server-core/src/main/java/io/onedev/server/model/support/issue/field/FieldUtils.java+++ b/server-core/src/main/java/io/onedev/server/model/support/issue/field/FieldUtils.java@@ -52,7 +52,7 @@ import io.onedev.server.web.util.ProjectAware;public class FieldUtils {- private static final double SUGGESTION_MINIMUM_CONFIDENCE = 0.85;+ private static final double SUGGESTION_MINIMUM_CONFIDENCE = 0.75;private static final Logger logger = LoggerFactory.getLogger(FieldUtils.class);diff --git a/server-core/src/main/java/io/onedev/server/web/editable/issue/fieldinstance/FieldListEditPanel.java b/server-core/src/main/java/io/onedev/server/web/editable/issue/fieldinstance/FieldListEditPanel.javaindex 322a0d2542..1bf6481a8a 100644--- a/server-core/src/main/java/io/onedev/server/web/editable/issue/fieldinstance/FieldListEditPanel.java+++ b/server-core/src/main/java/io/onedev/server/web/editable/issue/fieldinstance/FieldListEditPanel.java@@ -197,7 +197,7 @@ class FieldListEditPanel extends PropertyEditor<List<Serializable>> {});container.add(valueProviderChoice);- container.add(new Label("defaultValue", "Default value (used when confidence is below 85% or Jev is unavailable)") {+ container.add(new Label("defaultValue", "Default value (used when confidence is below 75% or Jev is unavailable)") {@Overrideprotected void onConfigure() {super.onConfigure();diff --git a/server-core/src/test/java/io/onedev/server/model/support/ServiceDeskFieldSuggestionTest.java b/server-core/src/test/java/io/onedev/server/model/support/ServiceDeskFieldSuggestionTest.javaindex 3bca771173..8a12fadc7d 100644--- a/server-core/src/test/java/io/onedev/server/model/support/ServiceDeskFieldSuggestionTest.java+++ b/server-core/src/test/java/io/onedev/server/model/support/ServiceDeskFieldSuggestionTest.java@@ -101,8 +101,8 @@ class ServiceDeskFieldSuggestionTest {when(response.statusCode()).thenReturn(200);when(response.body()).thenReturn("""{"answers": {- "field0": {"choice": "choice0", "confidence": 0.85},- "field1": {"choice": "choice0", "confidence": 0.8499},+ "field0": {"choice": "choice0", "confidence": 0.75},+ "field1": {"choice": "choice0", "confidence": 0.7499},"field2": {"choice": "choice0", "confidence": 0.99}}}""");@@ -117,7 +117,7 @@ class ServiceDeskFieldSuggestionTest {utils.when(() -> FieldUtils.getFieldBeanClass(false)).thenReturn(Fields.class);var names = List.of("Type", "Priority", "Labels");assertEquals(Map.of("Type", "Bug", "Labels", List.of("Bug")), FieldUtils.suggestFieldValues(issue, names));- verify(jev).choose(contains("Cannot log in"), anyMap(), eq(0.85));+ verify(jev).choose(contains("Cannot log in"), anyMap(), eq(0.75));verify(client).send(any(HttpRequest.class), ArgumentMatchers.<HttpResponse.BodyHandler<String>>any());when(response.body()).thenReturn("{\"answers\":{\"field0\":{\"choice\":\"unknown\",\"confidence\":1}}}");@@ -178,7 +178,7 @@ class ServiceDeskFieldSuggestionTest {for (var outcome: List.of("bug", "support", "uncertain", "unconfigured")) {clearInvocations(provider);ai.setJevSetting(outcome.equals("unconfigured") ? null : jev);- when(jev.choose(anyString(), anyMap(), eq(0.85))).thenReturn(switch (outcome) {+ when(jev.choose(anyString(), anyMap(), eq(0.75))).thenReturn(switch (outcome) {case "bug" -> Map.of("field0", "choice0");case "support" -> Map.of("field0", "choice1");default -> Map.of();