mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-07-04 19:21:51 +00:00
fix(ui): align Lighthouse business context limit
This commit is contained in:
@@ -89,16 +89,16 @@ describe("LighthouseV2BusinessContextForm", () => {
|
||||
/>,
|
||||
);
|
||||
|
||||
// When: paste in one event instead of 1001 keystrokes
|
||||
// When: paste in one event instead of 5001 keystrokes
|
||||
await user.click(
|
||||
screen.getByRole("textbox", { name: /Business context/i }),
|
||||
);
|
||||
await user.paste("a".repeat(1001));
|
||||
await user.paste("a".repeat(5001));
|
||||
|
||||
// Then
|
||||
expect(screen.getByText("1001/1000")).toBeInTheDocument();
|
||||
expect(screen.getByText("5001/5000")).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByText("Business context cannot exceed 1000 characters."),
|
||||
screen.getByText("Business context cannot exceed 5000 characters."),
|
||||
).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByRole("button", { name: "Save business context" }),
|
||||
|
||||
@@ -35,18 +35,24 @@ export function LighthouseV2BusinessContextForm({
|
||||
|
||||
setSaving(true);
|
||||
setError(null);
|
||||
const result = await updateLighthouseV2Configuration(configurationId, {
|
||||
businessContext,
|
||||
});
|
||||
setSaving(false);
|
||||
|
||||
if ("error" in result) {
|
||||
setError(result.error);
|
||||
return;
|
||||
try {
|
||||
const result = await updateLighthouseV2Configuration(configurationId, {
|
||||
businessContext,
|
||||
});
|
||||
|
||||
if ("error" in result) {
|
||||
setError(result.error);
|
||||
return;
|
||||
}
|
||||
|
||||
setSavedContext(result.data.businessContext);
|
||||
setBusinessContext(result.data.businessContext);
|
||||
} catch {
|
||||
setError("Something went wrong while saving. Please try again.");
|
||||
} finally {
|
||||
setSaving(false);
|
||||
}
|
||||
|
||||
setSavedContext(result.data.businessContext);
|
||||
setBusinessContext(result.data.businessContext);
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -69,11 +69,21 @@ export function LighthouseV2ConfigPage({
|
||||
providers.find((provider) => provider.id === selectedProvider) ??
|
||||
providers[0];
|
||||
|
||||
// Replace in place (don't filter+append): the shared business-context editor
|
||||
// is anchored to localConfigurations[0], so reordering on every save/test
|
||||
// would silently retarget it to a different provider's configuration.
|
||||
const upsertConfiguration = (configuration: LighthouseV2Configuration) => {
|
||||
setLocalConfigurations((current) => [
|
||||
...current.filter((config) => config.id !== configuration.id),
|
||||
configuration,
|
||||
]);
|
||||
setLocalConfigurations((current) => {
|
||||
const index = current.findIndex(
|
||||
(config) => config.id === configuration.id,
|
||||
);
|
||||
if (index === -1) {
|
||||
return [...current, configuration];
|
||||
}
|
||||
const next = [...current];
|
||||
next[index] = configuration;
|
||||
return next;
|
||||
});
|
||||
};
|
||||
|
||||
const handleConfigurationSaved = (
|
||||
@@ -134,6 +144,7 @@ export function LighthouseV2ConfigPage({
|
||||
>
|
||||
{businessContextConfig ? (
|
||||
<LighthouseV2BusinessContextForm
|
||||
key={businessContextConfig.id}
|
||||
configurationId={businessContextConfig.id}
|
||||
initialBusinessContext={businessContextConfig.businessContext}
|
||||
/>
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
type LighthouseV2ProviderType,
|
||||
} from "@/app/(prowler)/lighthouse/_types";
|
||||
|
||||
export const BUSINESS_CONTEXT_LIMIT = 1000;
|
||||
export const BUSINESS_CONTEXT_LIMIT = 5000;
|
||||
|
||||
export const CONNECTION_STATUS = {
|
||||
CONNECTED: "connected",
|
||||
|
||||
Reference in New Issue
Block a user