chore: more tests

This commit is contained in:
Nathnael
2026-07-21 12:49:36 +00:00
parent b8b8c4adf7
commit 20a6ef7906
11 changed files with 609 additions and 22 deletions

View File

@@ -109,8 +109,11 @@ join iam.units un on un.key = 'edr_freight_app' and un.organization_id = o.id
where u.email like '%@edr.local'
and not exists (select 1 from iam.employees e where e.user_id = u.id);
insert into iam.employee_positions (id, is_delegate, is_current, status, unit_id, employee_id, position_id)
select gen_random_uuid(), false, true, 'APPROVED', un.id, e.id, p.id
-- start_date must be set: the login query filters positions on
-- start_date <= NOW(), and a NULL start_date silently drops the position
-- (and with it every permission) from the JWT.
insert into iam.employee_positions (id, is_delegate, is_current, status, start_date, unit_id, employee_id, position_id)
select gen_random_uuid(), false, true, 'APPROVED', now() - interval '1 day', un.id, e.id, p.id
from (values
('linestaff@edr.local', 'operation'),
('chief@edr.local', 'chief'),
@@ -128,3 +131,7 @@ join iam.positions p on p.key = v.position_key and p.unit_id = un.id
where not exists (
select 1 from iam.employee_positions ep where ep.employee_id = e.id and ep.position_id = p.id
);
-- Backfill for rows created before start_date was included above.
update iam.employee_positions set start_date = now() - interval '1 day'
where start_date is null;