mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-04-01 05:37:14 +00:00
test: added test and fixed reload issue
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -149,4 +149,13 @@ export class ProfileOrganizationsHarness {
|
||||
async cancel() {
|
||||
await this.cancelButton().click();
|
||||
}
|
||||
|
||||
async submitDelete() {
|
||||
await this.submitButton(/delete/i).click();
|
||||
}
|
||||
|
||||
async selectTargetTenant(name: string) {
|
||||
await this.targetTenantSelect().click();
|
||||
await this.orgName(name).last().click();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
switchTenant,
|
||||
SwitchTenantState,
|
||||
} from "@/actions/users/tenants";
|
||||
import { reloadPage } from "@/lib/navigation";
|
||||
import { useToast } from "@/components/ui";
|
||||
import { CustomServerInput } from "@/components/ui/custom";
|
||||
import { FormButtons } from "@/components/ui/form";
|
||||
@@ -39,7 +40,7 @@ export const CreateTenantForm = ({
|
||||
title: "Organization created",
|
||||
description: "Switching to the new organization.",
|
||||
});
|
||||
window.location.reload();
|
||||
reloadPage();
|
||||
} else {
|
||||
// Create succeeded but switch failed — org exists, user can switch manually
|
||||
toast({
|
||||
|
||||
@@ -16,6 +16,7 @@ vi.mock("@/auth.config", () => ({
|
||||
vi.mock("@/actions/users/tenants", () => ({
|
||||
deleteTenant: vi.fn(),
|
||||
switchTenant: vi.fn(),
|
||||
switchThenDeleteTenant: vi.fn(),
|
||||
}));
|
||||
|
||||
const mockToast = vi.fn();
|
||||
|
||||
@@ -4,6 +4,7 @@ import { useSession } from "next-auth/react";
|
||||
import { Dispatch, SetStateAction, useActionState, useEffect } from "react";
|
||||
|
||||
import { switchTenant } from "@/actions/users/tenants";
|
||||
import { reloadPage } from "@/lib/navigation";
|
||||
import { useToast } from "@/components/ui";
|
||||
import { FormButtons } from "@/components/ui/form";
|
||||
|
||||
@@ -30,7 +31,7 @@ export const SwitchTenantForm = ({
|
||||
title: "Organization switched",
|
||||
description: "The page will reload to apply the change.",
|
||||
});
|
||||
window.location.reload();
|
||||
reloadPage();
|
||||
} else {
|
||||
toast({
|
||||
variant: "destructive",
|
||||
|
||||
@@ -2,7 +2,7 @@ import { http, HttpResponse } from "msw";
|
||||
|
||||
const API_BASE =
|
||||
process.env.NEXT_PUBLIC_API_BASE_URL ?? "https://api.test.prowler.com/api/v1";
|
||||
|
||||
1;
|
||||
/**
|
||||
* Default MSW handlers for the prowler backend API.
|
||||
* These provide sensible defaults for server action tests.
|
||||
|
||||
Reference in New Issue
Block a user