Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
+50
@@ -0,0 +1,50 @@
|
||||
import "@testing-library/jest-dom";
|
||||
import { render } from "@testing-library/react";
|
||||
import { MemoryRouter } from "react-router";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import NewTenantSelector from "./NewTenantSelector";
|
||||
|
||||
let capturedOptions: Array<Record<string, unknown>> = [];
|
||||
|
||||
vi.mock("react-i18next", () => ({
|
||||
useTranslation: () => ({ t: (key: string) => key }),
|
||||
}));
|
||||
|
||||
vi.mock("~/components/ui/input/InputSelector", () => ({
|
||||
default: ({ options }: { options: Array<Record<string, unknown>> }) => {
|
||||
capturedOptions = options;
|
||||
return <div data-testid="tenant-selector" />;
|
||||
},
|
||||
}));
|
||||
|
||||
vi.mock("~/utils/data/useAppData", () => ({
|
||||
useAppData: () => ({
|
||||
currentTenant: { id: "tenant_1", slug: "acme", name: "Acme" },
|
||||
myTenants: [
|
||||
{ id: "tenant_1", slug: "acme", name: "Acme", icon: null },
|
||||
{ id: "tenant_2", slug: "beta", name: "Beta", icon: null },
|
||||
],
|
||||
}),
|
||||
}));
|
||||
|
||||
vi.mock("~/utils/data/useRootData", () => ({
|
||||
useRootData: () => ({ routing: {} }),
|
||||
}));
|
||||
|
||||
describe("NewTenantSelector", () => {
|
||||
beforeEach(() => {
|
||||
capturedOptions = [];
|
||||
});
|
||||
|
||||
it("does not expose placeholder copy as option metadata", () => {
|
||||
render(
|
||||
<MemoryRouter initialEntries={["/acme/dashboard"]}>
|
||||
<NewTenantSelector />
|
||||
</MemoryRouter>
|
||||
);
|
||||
|
||||
const createOption = capturedOptions.find((option) => option.value === "{new}");
|
||||
expect(createOption).toBeDefined();
|
||||
expect(createOption).not.toHaveProperty("title");
|
||||
});
|
||||
});
|
||||
+3
-9
@@ -6,15 +6,14 @@ import InputSelector from "~/components/ui/input/InputSelector";
|
||||
import { useAppData } from "~/utils/data/useAppData";
|
||||
import { useRootData } from "~/utils/data/useRootData";
|
||||
import { absolutePublicAppPath, isAbsoluteHttpUrl } from "~/utils/app/CrossHostUrls";
|
||||
import { translateLabel } from "~/utils/i18n/translateLabel";
|
||||
import { getTenantSwitchPath } from "./tenant-switch-url";
|
||||
|
||||
interface Props {
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export default function TenantSelector({ className }: Props) {
|
||||
const { t, i18n } = useTranslation();
|
||||
export default function TenantSelector({ className: _className }: Props) {
|
||||
const { t } = useTranslation();
|
||||
const appData = useAppData();
|
||||
const rootData = useRootData();
|
||||
const location = useLocation();
|
||||
@@ -39,12 +38,8 @@ export default function TenantSelector({ className }: Props) {
|
||||
function getAllTenants() {
|
||||
const items = appData?.myTenants
|
||||
.map((f) => {
|
||||
let group = t("models.tenant.plural");
|
||||
if (f.types.length > 0) {
|
||||
group = translateLabel(t, i18n, f.types[0].titlePlural) || t("models.tenant.plural");
|
||||
}
|
||||
return {
|
||||
group,
|
||||
group: t("models.tenant.plural"),
|
||||
value: f.slug,
|
||||
name: (
|
||||
<div className="flex items-center space-x-2">
|
||||
@@ -66,7 +61,6 @@ export default function TenantSelector({ className }: Props) {
|
||||
return [
|
||||
...unique,
|
||||
{
|
||||
title: "hey",
|
||||
value: "{new}",
|
||||
className: "border-t border-border rounded-none",
|
||||
name: (
|
||||
|
||||
+3
-8
@@ -3,15 +3,14 @@ import { Fragment, useEffect, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import InputSelectorDarkMode from "~/components/ui/input/dark/InputSelectorDarkMode";
|
||||
import { useAppData } from "~/utils/data/useAppData";
|
||||
import { translateLabel } from "~/utils/i18n/translateLabel";
|
||||
import { getTenantSwitchPath } from "./tenant-switch-url";
|
||||
|
||||
interface Props {
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export default function TenantSelector({ className }: Props) {
|
||||
const { t, i18n } = useTranslation();
|
||||
export default function TenantSelector({ className: _className }: Props) {
|
||||
const { t } = useTranslation();
|
||||
const appData = useAppData();
|
||||
const location = useLocation();
|
||||
const navigate = useNavigate();
|
||||
@@ -35,12 +34,8 @@ export default function TenantSelector({ className }: Props) {
|
||||
function getAllTenants() {
|
||||
const items = appData.myTenants
|
||||
.map((f) => {
|
||||
let group = t("models.tenant.plural");
|
||||
if (f.types.length > 0) {
|
||||
group = translateLabel(t, i18n, f.types[0].titlePlural) || t("models.tenant.plural");
|
||||
}
|
||||
return {
|
||||
group,
|
||||
group: t("models.tenant.plural"),
|
||||
value: f.slug,
|
||||
name: f.name,
|
||||
img: f.icon ? (
|
||||
|
||||
Reference in new issue
Block a user