mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 11:50:43 +00:00
refactor: route plugin test helpers through sdk
This commit is contained in:
@@ -43,6 +43,19 @@ const MOCK_RELATIVE_MODULE_PATTERN =
|
||||
const RELATIVE_CORE_HINT =
|
||||
"Use openclaw/plugin-sdk/testing or a focused plugin-sdk test/runtime subpath instead of core internals.";
|
||||
|
||||
const EXTENSION_TEST_HELPER_BRIDGE_FILES = [
|
||||
"test/helpers/plugins/env.ts",
|
||||
"test/helpers/plugins/fetch-mock.ts",
|
||||
"test/helpers/plugins/media-understanding.ts",
|
||||
"test/helpers/plugins/mock-http-response.ts",
|
||||
"test/helpers/plugins/plugin-registration.ts",
|
||||
"test/helpers/plugins/plugin-registry.ts",
|
||||
"test/helpers/plugins/runtime-taskflow.ts",
|
||||
"test/helpers/plugins/temp-dir.ts",
|
||||
"test/helpers/plugins/temp-home.ts",
|
||||
"test/helpers/plugins/typed-cases.ts",
|
||||
];
|
||||
|
||||
function isExtensionTestFile(filePath: string): boolean {
|
||||
return /\.test\.[cm]?[jt]sx?$/u.test(filePath) || /\.e2e\.test\.[cm]?[jt]sx?$/u.test(filePath);
|
||||
}
|
||||
@@ -109,7 +122,12 @@ function collectRelativeCoreImportOffenders(
|
||||
|
||||
function main() {
|
||||
const extensionsDir = path.join(process.cwd(), "extensions");
|
||||
const files = collectExtensionTestFiles(extensionsDir);
|
||||
const files = [
|
||||
...collectExtensionTestFiles(extensionsDir),
|
||||
...EXTENSION_TEST_HELPER_BRIDGE_FILES.map((file) => path.join(process.cwd(), file)).filter(
|
||||
(file) => fs.existsSync(file),
|
||||
),
|
||||
];
|
||||
const offenders: Offender[] = [];
|
||||
|
||||
for (const file of files) {
|
||||
@@ -130,7 +148,7 @@ function main() {
|
||||
|
||||
if (offenders.length > 0) {
|
||||
console.error(
|
||||
"Extension test files must stay on extension test bridges or public plugin-sdk surfaces.",
|
||||
"Extension test files and helper bridges must stay on public plugin-sdk surfaces.",
|
||||
);
|
||||
for (const offender of offenders.toSorted((a, b) => a.file.localeCompare(b.file))) {
|
||||
const location = offender.line
|
||||
@@ -143,7 +161,7 @@ function main() {
|
||||
}
|
||||
|
||||
console.log(
|
||||
`OK: extension test files and support helpers avoid direct core test/internal imports (${files.length} checked).`,
|
||||
`OK: extension test files, support helpers, and helper bridges avoid direct core test/internal imports (${files.length} checked).`,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user