mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-08-04 06:52:47 +00:00
🖼️ fix: Hide Duplicate Image Placeholder During Image Generation (#12654)
* fix: Hide duplicate image placeholder during image generation * test: Update OpenAIImageGen tests for conditional Image rendering
This commit is contained in:
parent
5d108df665
commit
b40e8be7c8
2 changed files with 15 additions and 13 deletions
|
|
@ -238,13 +238,15 @@ export default function OpenAIImageGen({
|
|||
height={dimensions.height}
|
||||
/>
|
||||
)}
|
||||
<Image
|
||||
altText={filename}
|
||||
imagePath={filepath ?? ''}
|
||||
width={Number(dimensions.width?.split('px')[0])}
|
||||
height={Number(dimensions.height?.split('px')[0])}
|
||||
args={parsedArgs}
|
||||
/>
|
||||
{filepath && (
|
||||
<Image
|
||||
altText={filename}
|
||||
imagePath={filepath}
|
||||
width={Number(dimensions.width?.split('px')[0])}
|
||||
height={Number(dimensions.height?.split('px')[0])}
|
||||
args={parsedArgs}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -62,13 +62,13 @@ describe('OpenAIImageGen', () => {
|
|||
jest.useRealTimers();
|
||||
});
|
||||
|
||||
describe('image preloading', () => {
|
||||
it('keeps Image mounted during generation (progress < 1)', () => {
|
||||
describe('image visibility', () => {
|
||||
it('hides Image during generation when no filepath exists', () => {
|
||||
render(<OpenAIImageGen {...defaultProps} initialProgress={0.5} />);
|
||||
expect(screen.getByTestId('image-component')).toBeInTheDocument();
|
||||
expect(screen.queryByTestId('image-component')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('shows Image when progress >= 1', () => {
|
||||
it('shows Image when filepath is available', () => {
|
||||
render(
|
||||
<OpenAIImageGen
|
||||
{...defaultProps}
|
||||
|
|
@ -127,7 +127,7 @@ describe('OpenAIImageGen', () => {
|
|||
|
||||
it('handles invalid JSON args gracefully', () => {
|
||||
render(<OpenAIImageGen {...defaultProps} args="invalid json" />);
|
||||
expect(screen.getByTestId('image-component')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('progress-text')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('handles object args', () => {
|
||||
|
|
@ -137,7 +137,7 @@ describe('OpenAIImageGen', () => {
|
|||
args={{ prompt: 'a dog', quality: 'low', size: '512x512' }}
|
||||
/>,
|
||||
);
|
||||
expect(screen.getByTestId('image-component')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('progress-text')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue