Add projects
This commit is contained in:
parent
2d3a9ad623
commit
8b607dd700
1802 changed files with 503346 additions and 2 deletions
37
frontend/tests/visualConfigDisableImageGeneration.test.ts
Normal file
37
frontend/tests/visualConfigDisableImageGeneration.test.ts
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
import { describe, expect, test } from 'vitest';
|
||||
import { createElement, useState } from 'react';
|
||||
import { renderToStaticMarkup } from 'react-dom/server';
|
||||
import { parse as parseYaml } from 'yaml';
|
||||
import {
|
||||
parseDisableImageGenerationMode,
|
||||
useVisualConfig,
|
||||
} from '../src/hooks/useVisualConfig';
|
||||
|
||||
describe('visual config disable-image-generation', () => {
|
||||
test('loads and writes the passthrough mode', () => {
|
||||
expect(parseDisableImageGenerationMode('passthrough')).toBe('passthrough');
|
||||
|
||||
function Harness() {
|
||||
const visualConfig = useVisualConfig();
|
||||
const [phase, setPhase] = useState(0);
|
||||
|
||||
if (phase === 0) {
|
||||
visualConfig.setVisualValues({ disableImageGeneration: 'passthrough' });
|
||||
setPhase(1);
|
||||
} else {
|
||||
return createElement(
|
||||
'pre',
|
||||
null,
|
||||
visualConfig.applyVisualChangesToYaml('disable-image-generation: false\n')
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
const markup = renderToStaticMarkup(createElement(Harness));
|
||||
const result = markup.slice('<pre>'.length, -'</pre>'.length);
|
||||
|
||||
expect(parseYaml(result)).toEqual({ 'disable-image-generation': 'passthrough' });
|
||||
});
|
||||
});
|
||||
Loading…
Reference in a new issue