@@ -14,6 +14,8 @@ import { act } from "react";
1414import { create , type ReactTestRenderer } from "react-test-renderer" ;
1515import { afterEach , beforeEach , expect , it , vi } from "vite-plus/test" ;
1616
17+ const settingsFromServerWithoutMigration = DEFAULT_SERVER_SETTINGS ;
18+
1719const state = vi . hoisted ( ( ) => ( {
1820 settings : undefined as unknown as Atom . Writable < ServerSettings | null > ,
1921 connection : undefined as unknown as Atom . Writable <
@@ -57,12 +59,13 @@ let renderer: ReactTestRenderer | undefined;
5759beforeEach ( ( ) => {
5860 vi . stubGlobal ( "IS_REACT_ACT_ENVIRONMENT" , true ) ;
5961 registry = AtomRegistry . make ( ) ;
60- // A server that predates the migration never reports favorites.
61- state . settings = Atom . make < ServerSettings | null > ( DEFAULT_SERVER_SETTINGS ) ;
62+ state . settings = Atom . make < ServerSettings | null > ( settingsFromServerWithoutMigration ) ;
6263 state . connection = Atom . make < AsyncResult . AsyncResult < SupervisorConnectionState > > (
6364 AsyncResult . success ( connected ( 1 ) ) ,
6465 ) ;
65- state . persist . mockReset ( ) . mockResolvedValue ( AsyncResult . success ( DEFAULT_SERVER_SETTINGS ) ) ;
66+ state . persist
67+ . mockReset ( )
68+ . mockResolvedValue ( AsyncResult . success ( settingsFromServerWithoutMigration ) ) ;
6669} ) ;
6770
6871function connected ( generation : number ) : SupervisorConnectionState {
@@ -81,7 +84,7 @@ async function renderModelPicker(environmentId: EnvironmentId) {
8184
8285async function pushSettings ( count : number ) {
8386 for ( let push = 0 ; push < count ; push += 1 ) {
84- await act ( async ( ) => registry . set ( state . settings , { ...DEFAULT_SERVER_SETTINGS } ) ) ;
87+ await act ( async ( ) => registry . set ( state . settings , { ...settingsFromServerWithoutMigration } ) ) ;
8588 }
8689}
8790
@@ -92,7 +95,6 @@ afterEach(async () => {
9295} ) ;
9396
9497it ( "migrates once when the server drops the migration and keeps pushing settings" , async ( ) => {
95- // Attempts are module state, so each test uses its own environment.
9698 const environmentId = EnvironmentId . make ( "remote" ) ;
9799 await renderModelPicker ( environmentId ) ;
98100 await pushSettings ( 3 ) ;
0 commit comments