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


##########
e2e/tests/stream_routes.show-disabled-error.spec.ts:
##########
@@ -33,36 +33,29 @@
 import { exec } from 'node:child_process';
 import { readFile, writeFile } from 'node:fs/promises';
 import path from 'node:path';
+import { fileURLToPath } from 'node:url';
 import { promisify } from 'node:util';
 
 import { streamRoutesPom } from '@e2e/pom/stream_routes';
 import { env } from '@e2e/utils/env';
 import { test } from '@e2e/utils/test';
 import { expect } from '@playwright/test';
-import { produce, type WritableDraft } from 'immer';
-import { parse, stringify } from 'yaml';
 
 const execAsync = promisify(exec);
 
-type APISIXConf = {
-  apisix: {
-    proxy_mode: string;
-  };
-};
-
 const getE2EServerDir = () => {
-  const currentDir = new URL('.', import.meta.url).pathname;
+  const currentDir = path.dirname(fileURLToPath(import.meta.url));
   return path.join(currentDir, '../server');
 };
 
-const updateAPISIXConf = async (
-  func: (v: WritableDraft<APISIXConf>) => void
-) => {
+const updateAPISIXProxyMode = async (mode: string) => {
   const confPath = path.join(getE2EServerDir(), 'apisix_conf.yml');
   const fileContent = await readFile(confPath, 'utf-8');
-  const config = parse(fileContent) as APISIXConf;
 
-  const updatedContent = stringify(produce(config, func));
+  const updatedContent = fileContent.replace(
+    /proxy_mode:\s+[^\r\n]*/,
+    `proxy_mode: ${mode}`
+  );

Review Comment:
   This assumes the YAML always contains a `proxy_mode:` line matching the 
regex, and silently does nothing if it doesn’t match (or if formatting 
changes), which could make the test pass/fail inconsistently after refactors to 
`apisix_conf.yml`. Consider validating that the replacement actually changed 
the content (and throw with a clear error if not), or revert to parsing/editing 
YAML structurally to make the edit robust.
   



-- 
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