Path follow-up to the 4-package split — the action registrations moved from `packages/core/src/onebot/actions/` to `packages/onebot/src/actions/` in Phase 3. The test was failing with ENOENT on the old path before reaching the actual assertion. Note that this test has a separate pre-existing failure (it imports a non-exported `SNOWLUMA_ACTIONS` symbol from the SDK); the path fix just clears the first of the two errors.
24 lines
913 B
TypeScript
24 lines
913 B
TypeScript
import fs from 'node:fs';
|
|
import { fileURLToPath } from 'node:url';
|
|
import { describe, expect, it } from 'vitest';
|
|
import { SNOWLUMA_ACTIONS } from '../src';
|
|
|
|
describe('SnowLuma action list', () => {
|
|
it('stays in sync with core registerAction calls', () => {
|
|
// Actions moved out of @snowluma/core into the dedicated
|
|
// @snowluma/onebot package in the RoadMap #3 4-way split.
|
|
const actionsDir = fileURLToPath(new URL('../../onebot/src/actions/', import.meta.url));
|
|
const registered = new Set<string>();
|
|
|
|
for (const file of fs.readdirSync(actionsDir)) {
|
|
if (!file.endsWith('.ts')) continue;
|
|
const source = fs.readFileSync(new URL(file, `file://${actionsDir}/`), 'utf8');
|
|
for (const match of source.matchAll(/registerAction\('([^']+)'/g)) {
|
|
registered.add(match[1]!);
|
|
}
|
|
}
|
|
|
|
expect([...SNOWLUMA_ACTIONS].sort()).toEqual([...registered].sort());
|
|
});
|
|
});
|