refactor: update import paths to use absolute paths for better clarity and maintainability
This commit is contained in:
parent
decb28dc19
commit
74aea1677b
11 changed files with 30 additions and 21 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||||
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
|
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
|
||||||
import { AutodraftSettings } from '../AutodraftSettings';
|
import { AutodraftSettings } from '~/components/AutodraftSettings';
|
||||||
|
|
||||||
// Mock fetch
|
// Mock fetch
|
||||||
global.fetch = vi.fn();
|
global.fetch = vi.fn();
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { describe, it, expect } from "vitest";
|
import { describe, it, expect } from "vitest";
|
||||||
import { calculateDraftEligibility, getEligibilitySummary } from "../draft-eligibility";
|
import { calculateDraftEligibility, getEligibilitySummary } from "~/lib/draft-eligibility";
|
||||||
|
|
||||||
// Helper to create test data
|
// Helper to create test data
|
||||||
const createSport = (id: string, name: string) => ({ id, name });
|
const createSport = (id: string, name: string) => ({ id, name });
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { describe, it, expect } from 'vitest';
|
import { describe, it, expect } from 'vitest';
|
||||||
import { cn } from '../utils';
|
import { cn } from '~/lib/utils';
|
||||||
|
|
||||||
describe('Utils', () => {
|
describe('Utils', () => {
|
||||||
describe('cn (className merger)', () => {
|
describe('cn (className merger)', () => {
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
import { getAuth } from "@clerk/react-router/server";
|
import { getAuth } from "@clerk/react-router/server";
|
||||||
import { database } from "../../../database/context";
|
import { database } from "~/database/context";
|
||||||
import * as schema from "../../../database/schema";
|
import * as schema from "~/database/schema";
|
||||||
import { eq, and } from "drizzle-orm";
|
import { eq, and } from "drizzle-orm";
|
||||||
import { getSocketIO } from "../../../server/socket";
|
import { getSocketIO } from "~/server/socket";
|
||||||
|
|
||||||
export async function action(args: any) {
|
export async function action(args: any) {
|
||||||
const { request } = args;
|
const { request } = args;
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
import { describe, it, expect, vi, beforeEach } from "vitest";
|
import { describe, it, expect, vi, beforeEach } from "vitest";
|
||||||
import { action } from "../../api/autodraft.update";
|
import { action } from "~/routes/api/autodraft.update";
|
||||||
|
|
||||||
// Mock dependencies
|
// Mock dependencies
|
||||||
vi.mock("../../../../database/context");
|
vi.mock("~/database/context");
|
||||||
vi.mock("../../../../server/socket", () => ({
|
vi.mock("~/server/socket", () => ({
|
||||||
getSocketIO: vi.fn(),
|
getSocketIO: vi.fn(),
|
||||||
}));
|
}));
|
||||||
vi.mock("@clerk/react-router/server", () => ({
|
vi.mock("@clerk/react-router/server", () => ({
|
||||||
|
|
@ -27,7 +27,7 @@ describe("Autodraft Settings API", () => {
|
||||||
emit: vi.fn(),
|
emit: vi.fn(),
|
||||||
};
|
};
|
||||||
|
|
||||||
const socketModule = await import("../../../../server/socket");
|
const socketModule = await import("~/server/socket");
|
||||||
vi.mocked(socketModule.getSocketIO).mockReturnValue(mockSocketIO);
|
vi.mocked(socketModule.getSocketIO).mockReturnValue(mockSocketIO);
|
||||||
|
|
||||||
// Mock database
|
// Mock database
|
||||||
|
|
@ -48,7 +48,7 @@ describe("Autodraft Settings API", () => {
|
||||||
values: vi.fn().mockReturnThis(),
|
values: vi.fn().mockReturnThis(),
|
||||||
};
|
};
|
||||||
|
|
||||||
const { database } = await import("../../../../database/context");
|
const { database } = await import("~/database/context");
|
||||||
vi.mocked(database).mockReturnValue(mockDb);
|
vi.mocked(database).mockReturnValue(mockDb);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,9 @@ import express from "express";
|
||||||
import postgres from "postgres";
|
import postgres from "postgres";
|
||||||
import { RouterContextProvider } from "react-router";
|
import { RouterContextProvider } from "react-router";
|
||||||
|
|
||||||
import { DatabaseContext } from "../database/context";
|
import { DatabaseContext } from "~/database/context";
|
||||||
import * as schema from "../database/schema";
|
import * as schema from "~/database/schema";
|
||||||
import { expressValueContext } from "../app/contexts/express";
|
import { expressValueContext } from "~/contexts/express";
|
||||||
|
|
||||||
export const app = express();
|
export const app = express();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { drizzle } from "drizzle-orm/postgres-js";
|
import { drizzle } from "drizzle-orm/postgres-js";
|
||||||
import postgres from "postgres";
|
import postgres from "postgres";
|
||||||
import * as schema from "../database/schema";
|
import * as schema from "~/database/schema";
|
||||||
import { eq, and, desc, asc, inArray, notInArray } from "drizzle-orm";
|
import { eq, and, desc, asc, inArray, notInArray } from "drizzle-orm";
|
||||||
import { getSocketIO } from "./socket";
|
import { getSocketIO } from "./socket";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,10 @@
|
||||||
"noEmit": true,
|
"noEmit": true,
|
||||||
"baseUrl": ".",
|
"baseUrl": ".",
|
||||||
"paths": {
|
"paths": {
|
||||||
"@/*": ["./app/*"]
|
"~/*": ["./app/*"],
|
||||||
|
"@/*": ["./app/*"],
|
||||||
|
"~/database/*": ["./database/*"],
|
||||||
|
"~/server/*": ["./server/*"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,9 @@
|
||||||
"baseUrl": ".",
|
"baseUrl": ".",
|
||||||
"paths": {
|
"paths": {
|
||||||
"~/*": ["./app/*"],
|
"~/*": ["./app/*"],
|
||||||
"~/database/*": ["./database/*"]
|
"@/*": ["./app/*"],
|
||||||
|
"~/database/*": ["./database/*"],
|
||||||
|
"~/server/*": ["./server/*"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"include": [
|
"include": [
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@
|
||||||
"paths": {
|
"paths": {
|
||||||
"@/*": ["./app/*"],
|
"@/*": ["./app/*"],
|
||||||
"~/database/*": ["./database/*"],
|
"~/database/*": ["./database/*"],
|
||||||
|
"~/server/*": ["./server/*"],
|
||||||
"~/*": ["./app/*"]
|
"~/*": ["./app/*"]
|
||||||
},
|
},
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
|
|
|
||||||
|
|
@ -24,9 +24,12 @@ export default defineConfig({
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
resolve: {
|
resolve: {
|
||||||
alias: {
|
alias: [
|
||||||
'~': path.resolve(__dirname, './app'),
|
{ find: /^~\/database\/(.*)$/, replacement: path.resolve(__dirname, './database/$1') },
|
||||||
'app': path.resolve(__dirname, './app'),
|
{ find: /^~\/server\/(.*)$/, replacement: path.resolve(__dirname, './server/$1') },
|
||||||
},
|
{ find: /^~\/(.*)$/, replacement: path.resolve(__dirname, './app/$1') },
|
||||||
|
{ find: /^@\/(.*)$/, replacement: path.resolve(__dirname, './app/$1') },
|
||||||
|
{ find: 'app', replacement: path.resolve(__dirname, './app') },
|
||||||
|
],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue