Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
import { readFileSync } from 'node:fs';
import { fileURLToPath } from 'node:url';
import { describe, expect, it } from 'vitest';
const readConsumer = (relativePath: string) =>
readFileSync(fileURLToPath(new URL(relativePath, import.meta.url)), 'utf8');
describe('protected media consumers', () => {
it.each([
[
'video field thumbnails',
'../../nodes/components/flow/nodes/Invocation/fields/inputs/VideoFieldInputComponent.tsx',
'src={videoDTO.thumbnail_url}',
],
[
'video frame scrubbers',
'../../nodes/components/flow/nodes/Invocation/fields/IntegerField/VideoFrameIndexFieldInput.tsx',
'videoUrl={videoDTO.video_url}',
],
[
'reference image previews',
'../../controlLayers/components/RefImage/RefImagePreview.tsx',
'src={imageDTO.image_url}',
],
])('%s refreshes its URL after the media cookie changes', (_name, relativePath, rawUsage) => {
const source = readConsumer(relativePath);
expect(source).toContain("from 'features/auth/store/mediaCookieRefresh'");
expect(source).toContain('useMediaUrl(');
expect(source).not.toContain(rawUsage);
});
it('opens the video metadata link through the shared direct opener', () => {
const source = readConsumer('../../gallery/components/ImageMetadataViewer/VideoMetadataViewer.tsx');
expect(source).toContain('openMediaInNewTab');
expect(source).toContain("from 'common/util/openMediaInNewTab'");
expect(source).not.toContain('href={video.video_url}');
expect(source).not.toContain('href={videoUrl}');
});
it('opens the video metadata link only for primary or middle clicks', () => {
const source = readConsumer('../../gallery/components/ImageMetadataViewer/VideoMetadataViewer.tsx');
expect(source).toContain('event.button === 1');
});
it('does not give the protected video link a misleading hash target', () => {
const source = readConsumer('../../gallery/components/ImageMetadataViewer/VideoMetadataViewer.tsx');
expect(source).not.toContain('href="#"');
});
});