Skip to content

Commit

Permalink
[UI v2] feat: Adds @tests alias for easier access when writing tests (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
devinvillarosa authored Dec 10, 2024
1 parent 2fffdca commit ea85716
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 23 deletions.
4 changes: 2 additions & 2 deletions ui-v2/src/hooks/deployments/deployments.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import { describe, expect, it } from "vitest";

import {
type Deployment,
usePaginateDeployments,
useCountDeployments,
usePaginateDeployments,
} from "./index";

import { server } from "../../../tests/mocks/node";
import { server } from "@tests/mocks";

describe("deployments hooks", () => {
const seedDeployments = (): Deployment[] => [
Expand Down
3 changes: 1 addition & 2 deletions ui-v2/src/hooks/global-concurrency-limits.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { act, renderHook, waitFor } from "@testing-library/react";
import { server } from "@tests/mocks";
import { http, HttpResponse } from "msw";
import { describe, expect, it } from "vitest";

Expand All @@ -12,8 +13,6 @@ import {
useUpdateGlobalConcurrencyLimit,
} from "./global-concurrency-limits";

import { server } from "../../tests/mocks/node";

describe("global concurrency limits hooks", () => {
const seedGlobalConcurrencyLimits = () => [
{
Expand Down
3 changes: 1 addition & 2 deletions ui-v2/src/hooks/variables.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { http, HttpResponse } from "msw";
import { describe, expect, it } from "vitest";

import { components } from "@/api/prefect";
import { server } from "@tests/mocks";

import {
buildCountQuery,
Expand All @@ -14,8 +15,6 @@ import {
useVariables,
} from "./variables";

import { server } from "../../tests/mocks/node";

describe("variable hooks", () => {
const seedVariables = () => [
{
Expand Down
1 change: 1 addition & 0 deletions ui-v2/tests/mocks/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { server } from "./node";
6 changes: 3 additions & 3 deletions ui-v2/tests/setup.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/// <reference lib="dom" />
import { expect, afterEach, vi, beforeAll, afterAll } from "vitest";
import { cleanup } from "@testing-library/react";
import * as matchers from "@testing-library/jest-dom/matchers";
import { cleanup } from "@testing-library/react";
import { afterAll, afterEach, beforeAll, expect, vi } from "vitest";
import "@testing-library/jest-dom";
import { server } from "./mocks/node";
import { server } from "./mocks";

beforeAll(() => {
server.listen({
Expand Down
23 changes: 11 additions & 12 deletions ui-v2/tests/variables/variables.test.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
import "./mocks";
import { Toaster } from "@/components/ui/toaster";
import { VariablesDataTable } from "@/components/variables/data-table";
import { router } from "@/router";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { RouterProvider } from "@tanstack/react-router";
import {
getByLabelText,
getByTestId,
getByText,
render,
screen,
} from "@testing-library/react";
import { VariablesDataTable } from "@/components/variables/data-table";
import userEvent from "@testing-library/user-event";
import { server } from "@tests/mocks";
import { http, HttpResponse } from "msw";
import {
afterEach,
beforeAll,
beforeEach,
describe,
it,
expect,
it,
vi,
afterEach,
beforeEach,
beforeAll,
} from "vitest";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { Toaster } from "@/components/ui/toaster";
import { server } from "../mocks/node";
import { HttpResponse } from "msw";
import { http } from "msw";
import { router } from "@/router";
import { RouterProvider } from "@tanstack/react-router";

const renderVariablesPage = async () => {
const user = userEvent.setup();
Expand Down
3 changes: 2 additions & 1 deletion ui-v2/tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"skipLibCheck": true,
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
"@/*": ["./src/*"],
"@tests/*": ["./tests/*"]
},
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
Expand Down
3 changes: 2 additions & 1 deletion ui-v2/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
"@/*": ["./src/*"],
"@tests/*": ["./tests/*"]
}
}
}
1 change: 1 addition & 0 deletions ui-v2/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default defineConfig({
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
"@tests": path.resolve(__dirname, "./tests"),
},
},
});

0 comments on commit ea85716

Please sign in to comment.