From b6f8725ff47d86430d02541036cbca2d75ef2c30 Mon Sep 17 00:00:00 2001 From: Logan McAnsh Date: Tue, 14 Mar 2023 16:26:29 -0400 Subject: [PATCH] test: move to e2e test as flatRoutesUniversal wants only route files Signed-off-by: Logan McAnsh --- integration/flat-routes-test.ts | 42 +++++++++++++++++++ .../remix-dev/__tests__/flat-routes-test.ts | 17 -------- 2 files changed, 42 insertions(+), 17 deletions(-) diff --git a/integration/flat-routes-test.ts b/integration/flat-routes-test.ts index 7a03b9b58a5..f685f4b4fff 100644 --- a/integration/flat-routes-test.ts +++ b/integration/flat-routes-test.ts @@ -270,3 +270,45 @@ test.describe("emits warnings for route conflicts", async () => { expect(buildOutput).toContain(`⚠️ Route Path Collision: "/"`); }); }); + +test.describe("", () => { + let buildStdio = new PassThrough(); + let buildOutput: string; + + let originalConsoleLog = console.log; + let originalConsoleWarn = console.warn; + let originalConsoleError = console.error; + + test.beforeAll(async () => { + console.log = () => {}; + console.warn = () => {}; + console.error = () => {}; + await createFixtureProject({ + buildStdio, + future: { v2_routeConvention: true }, + files: { + "app/routes/_index/route.jsx": js``, + "app/routes/_index/utils.js": js``, + }, + }); + + let chunks: Buffer[] = []; + buildOutput = await new Promise((resolve, reject) => { + buildStdio.on("data", (chunk) => chunks.push(Buffer.from(chunk))); + buildStdio.on("error", (err) => reject(err)); + buildStdio.on("end", () => + resolve(Buffer.concat(chunks).toString("utf8")) + ); + }); + }); + + test.afterAll(() => { + console.log = originalConsoleLog; + console.warn = originalConsoleWarn; + console.error = originalConsoleError; + }); + + test("doesn't emit a warning for nested index files with co-located files", () => { + expect(buildOutput).not.toContain(`Route Path Collision`); + }); +}); diff --git a/packages/remix-dev/__tests__/flat-routes-test.ts b/packages/remix-dev/__tests__/flat-routes-test.ts index d55667cac6d..8929c5084ff 100644 --- a/packages/remix-dev/__tests__/flat-routes-test.ts +++ b/packages/remix-dev/__tests__/flat-routes-test.ts @@ -671,23 +671,6 @@ describe("flatRoutes", () => { ); }); - test("nested index files", () => { - let testFiles = [ - path.join("routes", "_index", "index.tsx"), - path.join("routes", "_index", "utils.ts"), - ]; - - // route manifest uses the full path - let fullPaths = testFiles.map((file) => path.join(APP_DIR, file)); - - let routeManifest = flatRoutesUniversal(APP_DIR, fullPaths); - - let routes = Object.values(routeManifest); - - expect(routes).toHaveLength(1); - expect(consoleError).not.toHaveBeenCalled(); - }); - test("folder/route.tsx matching folder.tsx", () => { let testFiles = [ path.join("routes", "dashboard", "route.tsx"),