fleet/frontend/components/forms/RegistrationForm/OrgDetails/OrgDetails.tests.tsx
Nico b4a207fb5a
Add ability to upload custom org logos (#44390)
<!-- Add the related story/sub-task/bug number, like Resolves #123, or
remove if NA -->
**Related issue:** Resolves #44330, Resolves #44331

# Checklist for submitter

- [x] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.
See [Changes
files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/guides/committing-changes.md#changes-files)
for more information.

## Testing

- [x] Added/updated automated tests. (I'd defer integration tests to a
separate PR since this one is pretty large already.)

- [x] QA'd all new/changed functionality manually. I've tested this on
both the setup flow and the organization settings page. I haven't had
the time to test this on other places where we render the logo (macOS
setup experience / MDM migration dialog).


https://github.com/user-attachments/assets/95d4eae5-3da6-40f4-98a1-8575b97d96b3

## New Fleet configuration settings

- [x] Setting(s) is/are explicitly excluded from GitOps.

Will handle GitOps in a separate PR.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
  * Organizations can upload custom logos for light and dark modes.
* Registration and Org Settings support logo file upload, preview,
per-mode replace/delete, and validation (size & image formats).
* Activity feed records logo changes/deletions; site nav displays
uploaded logos per theme.
* File uploader/preview adds a Fleet logo graphic option and improved
logo validation.
  * Config/GitOps outputs now include separate dark/light logo fields.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-05-05 14:42:52 +02:00

52 lines
1.5 KiB
TypeScript

import React from "react";
import { render, screen } from "@testing-library/react";
import { renderWithSetup } from "test/test-utils";
import OrgDetails from "components/forms/RegistrationForm/OrgDetails";
describe("OrgDetails - form", () => {
const handleSubmitSpy = jest.fn();
beforeEach(() => {
handleSubmitSpy.mockReset();
});
it("renders", () => {
render(<OrgDetails handleSubmit={handleSubmitSpy} currentPage />);
expect(
screen.getByRole("textbox", { name: "Organization name" })
).toBeInTheDocument();
expect(screen.getByRole("button", { name: "Next" })).toBeInTheDocument();
});
it("validates presence of org_name field", async () => {
const { user } = renderWithSetup(
<OrgDetails handleSubmit={handleSubmitSpy} currentPage />
);
await user.click(screen.getByRole("button", { name: "Next" }));
expect(handleSubmitSpy).not.toHaveBeenCalled();
expect(
screen.getByText("Organization name must be present")
).toBeInTheDocument();
});
it("submits with the org name and a null logo when no file is selected", async () => {
const { user } = renderWithSetup(
<OrgDetails handleSubmit={handleSubmitSpy} currentPage />
);
await user.type(
screen.getByRole("textbox", { name: "Organization name" }),
"The Gnar Co"
);
await user.click(screen.getByRole("button", { name: "Next" }));
expect(handleSubmitSpy).toHaveBeenCalledWith({
org_name: "The Gnar Co",
org_logo_file: null,
});
});
});