tengri/Content/Toasts/Tests/FT_ToastLimit.ts

66 lines
3.4 KiB
TypeScript

// Toasts/Tests/FT_ToastLimit.ts
import { AC_ToastSystem } from '#root/Toasts/Components/AC_ToastSystem.ts';
import { EFunctionalTestResult } from '#root/UE/EFunctionalTestResult.ts';
import { FunctionalTest } from '#root/UE/FunctionalTest.ts';
import { E_MessageType } from '#root/UI/Enums/E_MessageType.ts';
/**
* Functional Test: Toast System Capacity Management
* Validates that the toast system enforces MaxVisibleToasts limit correctly
* Tests that oldest toasts are removed when limit is exceeded
*/
export class FT_ToastLimit extends FunctionalTest {
// ════════════════════════════════════════════════════════════════════════════════════════
// GRAPHS
// ════════════════════════════════════════════════════════════════════════════════════════
// ────────────────────────────────────────────────────────────────────────────────────────
// EventGraph
// ────────────────────────────────────────────────────────────────────────────────────────
/**
* Test execution - validates toast limit enforcement
* Creates more toasts than allowed and verifies limit is enforced
*/
EventStartTest(): void {
this.ToastComponent.InitializeToastSystem();
// Create MaxVisibleToasts + 3 toasts to test overflow handling
for (
let i = 1;
i <= this.ToastComponent.ToastSettings.MaxVisibleToasts + 3;
i++
) {
this.ToastComponent.ShowToast(
`Limit test toast ${i}`,
E_MessageType.Info,
10
);
}
// Verify that only MaxVisibleToasts are actually visible
if (
this.ToastComponent.GetTestData().length ===
this.ToastComponent.ToastSettings.MaxVisibleToasts
) {
this.FinishTest(EFunctionalTestResult.Succeeded);
} else {
this.FinishTest(
EFunctionalTestResult.Failed,
`Expected ${this.ToastComponent.ToastSettings.MaxVisibleToasts} to display, got ${this.ToastComponent.GetTestData().length}`
);
}
}
// ════════════════════════════════════════════════════════════════════════════════════════
// VARIABLES
// ════════════════════════════════════════════════════════════════════════════════════════
/**
* Toast notification system - component under test
* @category Components
*/
private ToastComponent = new AC_ToastSystem();
}