Skip to content

Commit b9ebc98

Browse files
test(super-editor): resolve handleBase64 source path from package or repo root
The url-validation source-check test hardcoded a package-relative path, so it failed when the suite ran from the repo root. Probe the package-relative path first and fall back to the root-relative one, picking whichever exists before reading the file.
1 parent 2013eb2 commit b9ebc98

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

packages/super-editor/src/editors/v1/extensions/image/imageHelpers/handleBase64.test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, it, expect, afterEach, vi } from 'vitest';
2-
import { readFileSync } from 'node:fs';
2+
import { existsSync, readFileSync } from 'node:fs';
33
import { resolve } from 'node:path';
44
import { base64ToFile, getBase64FileMeta } from './handleBase64.js';
55

@@ -26,10 +26,10 @@ describe('handleBase64', () => {
2626
});
2727

2828
it('uses shared url-validation helpers directly instead of converter helpers', () => {
29-
const source = readFileSync(
30-
resolve(process.cwd(), 'src/editors/v1/extensions/image/imageHelpers/handleBase64.js'),
31-
'utf8',
32-
);
29+
const packageRelativePath = 'src/editors/v1/extensions/image/imageHelpers/handleBase64.js';
30+
const rootRelativePath = `packages/super-editor/${packageRelativePath}`;
31+
const sourcePath = existsSync(resolve(process.cwd(), packageRelativePath)) ? packageRelativePath : rootRelativePath;
32+
const source = readFileSync(resolve(process.cwd(), sourcePath), 'utf8');
3333

3434
expect(source).toContain("from '@superdoc/url-validation'");
3535
expect(source).not.toContain("from '@converter/helpers/mediaHelpers.js'");

0 commit comments

Comments
 (0)