@@ -1923,6 +1923,71 @@ describe("fetchers", () => {
19231923 expect ( t . router . getFetcher ( keyB ) ?. state ) . toBe ( "idle" ) ;
19241924 } ) ;
19251925 } ) ;
1926+
1927+ it ( "properly ignores aborted action revalidation fetchers when a navigation triggers revalidations" , async ( ) => {
1928+ let keyA = "a" ;
1929+ let keyB = "b" ;
1930+ let t = initializeTest ( ) ;
1931+
1932+ // Complete a fetch load
1933+ let A = await t . fetch ( "/foo" , keyA , "root" ) ;
1934+ await A . loaders . foo . resolve ( "FOO" ) ;
1935+ expect ( t . fetchers [ keyA ] ) . toMatchObject ( {
1936+ state : "idle" ,
1937+ data : "FOO" ,
1938+ } ) ;
1939+ expect ( t . router . state . fetchers . get ( keyA ) ) . toBe ( undefined ) ;
1940+
1941+ // Submit to trigger fetch revalidation
1942+ let B = await t . fetch ( "/bar" , keyB , "root" , {
1943+ formMethod : "post" ,
1944+ formData : createFormData ( { } ) ,
1945+ } ) ;
1946+ t . shimHelper ( B . loaders , "fetch" , "loader" , "foo" ) ;
1947+ await B . actions . bar . resolve ( "BAR" ) ;
1948+ expect ( t . fetchers [ keyB ] ) . toMatchObject ( {
1949+ state : "loading" ,
1950+ data : "BAR" ,
1951+ } ) ;
1952+ expect ( t . fetchers [ keyA ] ) . toMatchObject ( {
1953+ state : "loading" ,
1954+ data : "FOO" ,
1955+ } ) ;
1956+
1957+ // Interrupt revalidation with GEt navigation
1958+ // TODO: This shouldn't actually abort the revalidation but it does currently
1959+ // which then causes the invalid invariant error. This test is to ensure
1960+ // the invariant doesn't throw, but we'll fix the unnecessary revalidation
1961+ // in https://github.com/remix-run/react-router/issues/14115
1962+ let C = await t . navigate ( "/baz" , undefined , [ "foo" ] ) ;
1963+ expect ( B . loaders . foo . signal . aborted ) . toBe ( true ) ;
1964+ expect ( t . fetchers [ keyA ] ) . toMatchObject ( {
1965+ state : "loading" ,
1966+ data : "FOO" ,
1967+ } ) ;
1968+
1969+ // Complete the aborted fetcher revalidation calls
1970+ await B . loaders . root . resolve ( "NOPE" ) ;
1971+ await B . loaders . index . resolve ( "NOPE" ) ;
1972+ await B . loaders . foo . resolve ( "NOPE" ) ;
1973+
1974+ // Complete the navigation
1975+ await C . loaders . root . resolve ( "ROOT*" ) ;
1976+ await C . loaders . baz . resolve ( "BAZ" ) ;
1977+ await C . loaders . foo . resolve ( "FOO*" ) ;
1978+ expect ( t . router . state ) . toMatchObject ( {
1979+ navigation : IDLE_NAVIGATION ,
1980+ location : { pathname : "/baz" } ,
1981+ loaderData : {
1982+ root : "ROOT*" ,
1983+ baz : "BAZ" ,
1984+ } ,
1985+ } ) ;
1986+ expect ( t . fetchers [ keyA ] ) . toMatchObject ( {
1987+ state : "idle" ,
1988+ data : "FOO*" ,
1989+ } ) ;
1990+ } ) ;
19261991 } ) ;
19271992
19281993 describe ( "fetcher revalidation" , ( ) => {
0 commit comments