Copilot commented on code in PR #3277:
URL: https://github.com/apache/apisix-dashboard/pull/3277#discussion_r2872348023


##########
e2e/tests/upstreams.empty-discovery-args.spec.ts:
##########
@@ -0,0 +1,117 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { upstreamsPom } from '@e2e/pom/upstreams';
+import { e2eReq } from '@e2e/utils/req';
+import { test } from '@e2e/utils/test';
+import { uiHasToastMsg } from '@e2e/utils/ui';
+import { expect } from '@playwright/test';
+
+import { deleteAllUpstreams, putUpstreamReq } from '@/apis/upstreams';
+import { API_UPSTREAMS } from '@/config/constant';
+import type { APISIXType } from '@/types/schema/apisix';
+
+/**
+ * Test that editing an upstream with service discovery and empty 
discovery_args
+ * does not cause the discovery_args field to be dropped.
+ * Regression test for: https://github.com/apache/apisix-dashboard/issues/3270
+ */
+const upstream: APISIXType['Upstream'] = {
+    id: 'upstream_discovery_test',
+    name: 'upstream_discovery_test',
+    desc: 'Upstream with service discovery',
+    discovery_type: 'nacos',
+    service_name: 'test-service',
+    discovery_args: {},
+};
+
+test.beforeAll(async () => {
+    await deleteAllUpstreams(e2eReq);
+    await putUpstreamReq(e2eReq, upstream);
+});
+
+test.afterAll(async () => {
+    await deleteAllUpstreams(e2eReq);
+});
+
+test('should preserve empty discovery_args after editing upstream', async ({
+    page,
+}) => {
+    await test.step('verify upstream exists and has discovery fields', async 
() => {
+        // Verify upstream was created with discovery_args via API
+        const resp = await e2eReq.get(`${API_UPSTREAMS}/${upstream.id}`);
+        const data = resp.data;
+        expect(data.value.discovery_type).toBe('nacos');
+        expect(data.value.service_name).toBe('test-service');
+        expect(data.value.discovery_args).toEqual({});
+    });

Review Comment:
   This new spec file uses 4-space indentation in object literals and blocks, 
while the existing e2e specs in this repo consistently use 2-space indentation 
(e.g., `e2e/tests/upstreams.list.spec.ts`). Reformatting this file to match the 
established style will keep diffs/lint noise down.
   ```suggestion
     id: 'upstream_discovery_test',
     name: 'upstream_discovery_test',
     desc: 'Upstream with service discovery',
     discovery_type: 'nacos',
     service_name: 'test-service',
     discovery_args: {},
   };
   
   test.beforeAll(async () => {
     await deleteAllUpstreams(e2eReq);
     await putUpstreamReq(e2eReq, upstream);
   });
   
   test.afterAll(async () => {
     await deleteAllUpstreams(e2eReq);
   });
   
   test('should preserve empty discovery_args after editing upstream', async ({
     page,
   }) => {
     await test.step('verify upstream exists and has discovery fields', async 
() => {
       // Verify upstream was created with discovery_args via API
       const resp = await e2eReq.get(`${API_UPSTREAMS}/${upstream.id}`);
       const data = resp.data;
       expect(data.value.discovery_type).toBe('nacos');
       expect(data.value.service_name).toBe('test-service');
       expect(data.value.discovery_args).toEqual({});
     });
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to