// ---------- the endpoint as the company admin
const ADMIN = 805, STAFF = 806;
$ids = [];
foreach (['Lead Assigned', 'Carrier Registered', 'Quotation Approved', 'Bid Approved', 'Order Approved', 'Invoice Payment Received', 'Rate Config Signed'] as $title) {
$ids[$title] = Notification::create(['user_id' => null, 'admin_id' => ADMIN, 'title' => $title, 'body' => "NMOD test $title", 'read' => 0, 'usertype' => 'admin'])->id;
}
register_shutdown_function(function () { DB::table('notifications')->where('body', 'like', 'NMOD test%')->delete(); });
$j = json_decode(call('/get-notifications', ADMIN)->getContent(), true);
$m = $j['modules'] ?? [];
t('response has a modules block', is_array($m) && $m !== []);
$has = fn ($key, $needle) => isset($m[$key]) && str_contains($m[$key]['html'], $needle);
t('CRM tab has the lead notification only', $has('crm', 'NMOD test Lead Assigned') && ! $has('crm', 'Quotation Approved'));
t('CRM tab also has the carrier registration', $has('crm', 'NMOD test Carrier Registered'));
t('Quotation tab has the quotation notification', $has('quotation', 'NMOD test Quotation Approved'));
t('Load Board tab has the bid notification', $has('loadboard', 'NMOD test Bid Approved'));
t('Order tab has the order notification', $has('order', 'NMOD test Order Approved'));