+ test("renders matching routes (flat file)", async ({ page }) => {
+ let app = new PlaywrightFixture(appFixture, page);
+ await app.goto("/flat/file");
+ expect(await app.getHtml("#content")).toBe(`
`);
- });
+ });
- test("renders matching routes (nested)", async ({ page }) => {
- let app = new PlaywrightFixture(appFixture, page);
- await app.goto("/dashboard");
- expect(await app.getHtml("#content")).toBe(`
+ test("renders matching routes (nested)", async ({ page }) => {
+ let app = new PlaywrightFixture(appFixture, page);
+ await app.goto("/dashboard");
+ expect(await app.getHtml("#content")).toBe(`
Root
Dashboard Layout
Dashboard Index
`);
+ });
+ }
+});
+
+test.describe("emits warnings for route conflicts", async () => {
+ 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: {
+ "routes/_dashboard._index.tsx": js`
+ export default function () {
+ return
routes/_dashboard._index
;
+ }
+ `,
+ "app/routes/_index.jsx": js`
+ export default function () {
+ return
routes._index
;
+ }
+ `,
+ "app/routes/_landing._index.jsx": js`
+ export default function () {
+ return
routes/_landing._index
;
+ }
+ `,
+ },
+ });
+
+ 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("warns about conflicting routes", () => {
+ console.log(buildOutput);
+ expect(buildOutput).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 4cedf056a46..8bb588e7b84 100644
--- a/packages/remix-dev/__tests__/flat-routes-test.ts
+++ b/packages/remix-dev/__tests__/flat-routes-test.ts
@@ -629,7 +629,7 @@ describe("flatRoutes", () => {
let testFiles = [
"routes/_landing._index.tsx",
"routes/_dashboard._index.tsx",
- "routes/._index.tsx",
+ "routes/_index.tsx",
];
let routeManifest = flatRoutesUniversal(
@@ -650,7 +650,7 @@ describe("flatRoutes", () => {
🟢 routes${path.sep}_landing._index.tsx
⭕️️ routes${path.sep}_dashboard._index.tsx
- ⭕️️ routes${path.sep}._index.tsx
+ ⭕️️ routes${path.sep}_index.tsx
`)
);
});