@@ -478,6 +478,79 @@ public void frontendCustomReactFilesAreCleanedAndBackUppedWhenReactIsDisabled()
478478 new File (frontend , "routes.tsx.flowBackup" ).exists ());
479479 }
480480
481+ @ Test
482+ public void routesContainExport_noConst_noExceptionThrown ()
483+ throws IOException , ExecutionFailedException {
484+ String content = """
485+ import { RouterConfigurationBuilder } from '@vaadin/hilla-file-router/runtime.js';
486+ import Flow from 'Frontend/generated/flow/Flow';
487+
488+ const { router, originalRoutes } = new RouterConfigurationBuilder();
489+ .withFallback(Flow)
490+ .build();
491+
492+ const routes = originalRoutes;
493+ export { router, routes }
494+ """ ;
495+
496+ FileUtils .write (routesTsx , content , StandardCharsets .UTF_8 );
497+
498+ TaskGenerateReactFiles task = new TaskGenerateReactFiles (options );
499+
500+ task .execute ();
501+ }
502+
503+ @ Test
504+ public void routesContainExport_twoSingleExports_noExceptionThrown ()
505+ throws IOException , ExecutionFailedException {
506+ String content = """
507+ import { RouterConfigurationBuilder } from '@vaadin/hilla-file-router/runtime.js';
508+ import Flow from 'Frontend/generated/flow/Flow';
509+
510+ const { router, originalRoutes } = new RouterConfigurationBuilder();
511+ .withFallback(Flow)
512+ .build();
513+
514+ const routes = originalRoutes;
515+ export { routes }
516+ router = anotherRouter;
517+ export {router}
518+ """ ;
519+
520+ FileUtils .write (routesTsx , content , StandardCharsets .UTF_8 );
521+
522+ TaskGenerateReactFiles task = new TaskGenerateReactFiles (options );
523+
524+ task .execute ();
525+ }
526+
527+ @ Test
528+ public void routesContainExport_oneSingleExport_exceptionThrown ()
529+ throws IOException , ExecutionFailedException {
530+ String content = """
531+ import { RouterConfigurationBuilder } from '@vaadin/hilla-file-router/runtime.js';
532+ import Flow from 'Frontend/generated/flow/Flow';
533+
534+ const { router, originalRoutes } = new RouterConfigurationBuilder();
535+ .withFallback(Flow)
536+ .build();
537+
538+ const routes = originalRoutes;
539+ export { routes }
540+ """ ;
541+
542+ FileUtils .write (routesTsx , content , StandardCharsets .UTF_8 );
543+
544+ TaskGenerateReactFiles task = new TaskGenerateReactFiles (options );
545+
546+ Exception exception = Assert .assertThrows (
547+ ExecutionFailedException .class , () -> task .execute ());
548+ Assert .assertEquals (
549+ String .format (TaskGenerateReactFiles .MISSING_ROUTES_EXPORT ,
550+ routesTsx .getPath ()),
551+ exception .getMessage ());
552+ }
553+
481554 @ Tag ("div" )
482555 @ Route ("test" )
483556 private class TestRoute extends Component {
0 commit comments