fix(alerts): final sweep — drop ACKNOWLEDGED from AlertStateChip + CMD-K; harden V17 IT
UI: AlertStateChip.LABELS and .COLORS no longer include ACKNOWLEDGED (dropped in V17). AlertStateChip.test.tsx test-cases trimmed to the three remaining states. LayoutShell CMD-K now searches FIRING alerts with acked=false (was state=[FIRING,ACKNOWLEDGED]). Test: V17MigrationIT.open_rule_index_predicate_is_reworked replaced with a structural-only assertion (index exists, indisunique). The pg_get_indexdef pretty-printer varies across Postgres versions, so predicate semantics are verified behaviorally in PostgresAlertInstanceRepositoryIT (findOpenForRule_* + save_rejectsSecondOpenInstanceForSameRuleAndExchange). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -35,14 +35,24 @@ class V17MigrationIT extends AbstractPostgresIT {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void open_rule_index_predicate_is_reworked() {
|
void open_rule_index_exists_and_is_unique() {
|
||||||
String def = jdbcTemplate.queryForObject("""
|
// Structural check only — the pg_get_indexdef pretty-printer varies across
|
||||||
SELECT pg_get_indexdef(indexrelid)
|
// Postgres versions. Predicate semantics (ack doesn't close; soft-delete
|
||||||
FROM pg_index
|
// frees the slot; RESOLVED excluded) are covered behaviorally by
|
||||||
|
// PostgresAlertInstanceRepositoryIT#findOpenForRule_* and
|
||||||
|
// #save_rejectsSecondOpenInstanceForSameRuleAndExchange.
|
||||||
|
Integer count = jdbcTemplate.queryForObject("""
|
||||||
|
SELECT COUNT(*)::int FROM pg_indexes
|
||||||
|
WHERE indexname = 'alert_instances_open_rule_uq'
|
||||||
|
AND tablename = 'alert_instances'
|
||||||
|
""", Integer.class);
|
||||||
|
assertThat(count).isEqualTo(1);
|
||||||
|
|
||||||
|
Boolean isUnique = jdbcTemplate.queryForObject("""
|
||||||
|
SELECT indisunique FROM pg_index
|
||||||
JOIN pg_class ON pg_class.oid = pg_index.indexrelid
|
JOIN pg_class ON pg_class.oid = pg_index.indexrelid
|
||||||
WHERE pg_class.relname = 'alert_instances_open_rule_uq'
|
WHERE pg_class.relname = 'alert_instances_open_rule_uq'
|
||||||
""", String.class);
|
""", Boolean.class);
|
||||||
assertThat(def).contains("state = ANY (ARRAY['PENDING'::alert_state_enum, 'FIRING'::alert_state_enum])");
|
assertThat(isUnique).isTrue();
|
||||||
assertThat(def).contains("deleted_at IS NULL");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ describe('AlertStateChip', () => {
|
|||||||
it.each([
|
it.each([
|
||||||
['PENDING', /pending/i],
|
['PENDING', /pending/i],
|
||||||
['FIRING', /firing/i],
|
['FIRING', /firing/i],
|
||||||
['ACKNOWLEDGED', /acknowledged/i],
|
|
||||||
['RESOLVED', /resolved/i],
|
['RESOLVED', /resolved/i],
|
||||||
] as const)('renders %s label', (state, pattern) => {
|
] as const)('renders %s label', (state, pattern) => {
|
||||||
renderWithTheme(<AlertStateChip state={state} />);
|
renderWithTheme(<AlertStateChip state={state} />);
|
||||||
|
|||||||
@@ -6,14 +6,12 @@ type State = NonNullable<AlertDto['state']>;
|
|||||||
const LABELS: Record<State, string> = {
|
const LABELS: Record<State, string> = {
|
||||||
PENDING: 'Pending',
|
PENDING: 'Pending',
|
||||||
FIRING: 'Firing',
|
FIRING: 'Firing',
|
||||||
ACKNOWLEDGED: 'Acknowledged',
|
|
||||||
RESOLVED: 'Resolved',
|
RESOLVED: 'Resolved',
|
||||||
};
|
};
|
||||||
|
|
||||||
const COLORS: Record<State, 'auto' | 'success' | 'warning' | 'error'> = {
|
const COLORS: Record<State, 'auto' | 'success' | 'warning' | 'error'> = {
|
||||||
PENDING: 'warning',
|
PENDING: 'warning',
|
||||||
FIRING: 'error',
|
FIRING: 'error',
|
||||||
ACKNOWLEDGED: 'warning',
|
|
||||||
RESOLVED: 'success',
|
RESOLVED: 'success',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -368,7 +368,7 @@ function LayoutContent() {
|
|||||||
const { data: envRecords = [] } = useEnvironments();
|
const { data: envRecords = [] } = useEnvironments();
|
||||||
|
|
||||||
// Open alerts + rules for CMD-K (env-scoped).
|
// Open alerts + rules for CMD-K (env-scoped).
|
||||||
const { data: cmdkAlerts } = useAlerts({ state: ['FIRING', 'ACKNOWLEDGED'], limit: 100 });
|
const { data: cmdkAlerts } = useAlerts({ state: ['FIRING'], acked: false, limit: 100 });
|
||||||
const { data: cmdkRules } = useAlertRules();
|
const { data: cmdkRules } = useAlertRules();
|
||||||
|
|
||||||
// Merge environments from both the environments table and agent heartbeats
|
// Merge environments from both the environments table and agent heartbeats
|
||||||
|
|||||||
Reference in New Issue
Block a user