Files
ontime/apps/client/src/views/cuesheet/__tests__/EditableImage.test.ts
T
Claude 9efac0a60a refactor(cuesheet): images are referenced by link only
A path to a local file resolves on the machine running ontime, but not
for the clients we serve the cuesheet to, so we no longer accept it.

Validation now parses the value as a URL and checks the protocol, which
also rejects malformed values that the previous prefix check let through.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CKXcDrZoQXbJpaXiLi1aff
2026-08-30 10:37:25 +00:00

25 lines
1.1 KiB
TypeScript

import { describe, expect, test } from 'vitest';
import { isValidImageSource } from '../cuesheet-table/cuesheet-table-elements/EditableImage';
describe('isValidImageSource()', () => {
test('accepts links to a hosted image', () => {
expect(isValidImageSource('https://example.com/image.png')).toBe(true);
expect(isValidImageSource('http://example.com/image.png')).toBe(true);
});
test('rejects references to a local file, they would not resolve for our clients', () => {
expect(isValidImageSource('/user/image.png')).toBe(false);
expect(isValidImageSource('user/image.png')).toBe(false);
expect(isValidImageSource('file:///Users/me/image.png')).toBe(false);
expect(isValidImageSource('C:\\images\\image.png')).toBe(false);
});
test('rejects values which would not resolve to an image', () => {
expect(isValidImageSource('www.example.com/image.png')).toBe(false);
expect(isValidImageSource('example.com/image.png')).toBe(false);
expect(isValidImageSource('https://')).toBe(false);
expect(isValidImageSource('some text')).toBe(false);
});
});