Copilot commented on code in PR #3317:
URL: https://github.com/apache/apisix-dashboard/pull/3317#discussion_r2930861419
##########
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:
If the regex doesn’t match (config format changes, whitespace/indentation
differs, key renamed, etc.), `updatedContent` will equal `fileContent` and the
test will proceed without actually changing the proxy mode—making failures
harder to diagnose. Consider asserting the replacement happened (e.g., check
`updatedContent !== fileContent` and throw with a clear message if not).
--
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]