mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-21 17:27:54 +00:00
fix: resolve three flaky tests (#7058)
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
|
||||
import type { Mock } from 'vitest';
|
||||
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
||||
import { waitFor } from '@testing-library/react';
|
||||
import { renderWithProviders } from '../test-utils/render.js';
|
||||
import { AppWrapper as App } from './App.js';
|
||||
import type {
|
||||
@@ -399,9 +400,10 @@ describe('App UI', () => {
|
||||
);
|
||||
currentUnmount = unmount;
|
||||
|
||||
await new Promise((resolve) => setTimeout(resolve, 10));
|
||||
|
||||
expect(spawn).not.toHaveBeenCalled();
|
||||
// Wait for any potential async operations to complete
|
||||
await waitFor(() => {
|
||||
expect(spawn).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
it('should show a success message when update succeeds', async () => {
|
||||
@@ -427,11 +429,12 @@ describe('App UI', () => {
|
||||
|
||||
updateEventEmitter.emit('update-success', info);
|
||||
|
||||
await new Promise((resolve) => setTimeout(resolve, 10));
|
||||
|
||||
expect(lastFrame()).toContain(
|
||||
'Update successful! The new version will be used on your next run.',
|
||||
);
|
||||
// Wait for the success message to appear
|
||||
await waitFor(() => {
|
||||
expect(lastFrame()).toContain(
|
||||
'Update successful! The new version will be used on your next run.',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('should show an error message when update fails', async () => {
|
||||
@@ -457,11 +460,12 @@ describe('App UI', () => {
|
||||
|
||||
updateEventEmitter.emit('update-failed', info);
|
||||
|
||||
await new Promise((resolve) => setTimeout(resolve, 10));
|
||||
|
||||
expect(lastFrame()).toContain(
|
||||
'Automatic update failed. Please try updating manually',
|
||||
);
|
||||
// Wait for the error message to appear
|
||||
await waitFor(() => {
|
||||
expect(lastFrame()).toContain(
|
||||
'Automatic update failed. Please try updating manually',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('should show an error message when spawn fails', async () => {
|
||||
@@ -489,11 +493,12 @@ describe('App UI', () => {
|
||||
// which is what should be emitted when a spawn error occurs elsewhere.
|
||||
updateEventEmitter.emit('update-failed', info);
|
||||
|
||||
await new Promise((resolve) => setTimeout(resolve, 10));
|
||||
|
||||
expect(lastFrame()).toContain(
|
||||
'Automatic update failed. Please try updating manually',
|
||||
);
|
||||
// Wait for the error message to appear
|
||||
await waitFor(() => {
|
||||
expect(lastFrame()).toContain(
|
||||
'Automatic update failed. Please try updating manually',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('should not auto-update if GEMINI_CLI_DISABLE_AUTOUPDATER is true', async () => {
|
||||
@@ -519,9 +524,10 @@ describe('App UI', () => {
|
||||
);
|
||||
currentUnmount = unmount;
|
||||
|
||||
await new Promise((resolve) => setTimeout(resolve, 10));
|
||||
|
||||
expect(spawn).not.toHaveBeenCalled();
|
||||
// Wait for any potential async operations to complete
|
||||
await waitFor(() => {
|
||||
expect(spawn).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user