refactor: streamline code formatting and enhance test organization mocks
This commit is contained in:
@@ -201,9 +201,7 @@ async def ensure_member_for_user(
|
||||
|
||||
# Serialize first-time provisioning per user to avoid concurrent duplicate org/member creation.
|
||||
await session.exec(
|
||||
select(User.id)
|
||||
.where(col(User.id) == user.id)
|
||||
.with_for_update(),
|
||||
select(User.id).where(col(User.id) == user.id).with_for_update(),
|
||||
)
|
||||
|
||||
existing_member = await get_first_membership(session, user.id)
|
||||
|
||||
@@ -216,8 +216,7 @@ async def test_ensure_member_for_user_creates_personal_org_and_owner(
|
||||
assert out.all_boards_write is True
|
||||
assert out.organization_id == user.active_organization_id
|
||||
assert any(
|
||||
isinstance(item, Organization) and item.id == out.organization_id
|
||||
for item in session.added
|
||||
isinstance(item, Organization) and item.id == out.organization_id for item in session.added
|
||||
)
|
||||
assert session.committed == 1
|
||||
|
||||
|
||||
@@ -6,6 +6,18 @@ import ActivityPage from "./page";
|
||||
import { AuthProvider } from "@/components/providers/AuthProvider";
|
||||
import { QueryProvider } from "@/components/providers/QueryProvider";
|
||||
|
||||
vi.mock("next/navigation", () => ({
|
||||
usePathname: () => "/activity",
|
||||
useRouter: () => ({
|
||||
push: vi.fn(),
|
||||
replace: vi.fn(),
|
||||
prefetch: vi.fn(),
|
||||
back: vi.fn(),
|
||||
forward: vi.fn(),
|
||||
refresh: vi.fn(),
|
||||
}),
|
||||
}));
|
||||
|
||||
vi.mock("next/link", () => {
|
||||
type LinkProps = React.PropsWithChildren<{
|
||||
href: string | { pathname?: string };
|
||||
|
||||
@@ -6,6 +6,18 @@ import GlobalApprovalsPage from "./page";
|
||||
import { AuthProvider } from "@/components/providers/AuthProvider";
|
||||
import { QueryProvider } from "@/components/providers/QueryProvider";
|
||||
|
||||
vi.mock("next/navigation", () => ({
|
||||
usePathname: () => "/approvals",
|
||||
useRouter: () => ({
|
||||
push: vi.fn(),
|
||||
replace: vi.fn(),
|
||||
prefetch: vi.fn(),
|
||||
back: vi.fn(),
|
||||
forward: vi.fn(),
|
||||
refresh: vi.fn(),
|
||||
}),
|
||||
}));
|
||||
|
||||
vi.mock("next/link", () => {
|
||||
type LinkProps = React.PropsWithChildren<{
|
||||
href: string | { pathname?: string };
|
||||
|
||||
Reference in New Issue
Block a user