MC/website/tests/pol-decision-deeplink.test.mjs
2026-11-27 23:43:05 +00:00

10 lines
890 B
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import {linkedPoliticalDecision} from '../control-panel/public/cp-v2/cp-v2-progression.mjs';
test('native decision links open the exact existing political catalogue entry, not an action or arbitrary route',()=>{
for(const [id,office] of [['IMP-02','IMP'],['FRE-07','FRE'],['NF-CONVERT','NF'],['ORD-03','ORD']]){
assert.equal(linkedPoliticalDecision(new URLSearchParams({xp:'pol',view:'decisions',decision:id}),'personal')?.office,office);
}
for(const params of [{xp:'personal',view:'decisions',decision:'IMP-02'},{xp:'pol',view:'missions',decision:'IMP-02'},{xp:'pol',view:'decisions',decision:'unknown'}])assert.equal(linkedPoliticalDecision(new URLSearchParams(params),'personal'),null);
assert.equal(linkedPoliticalDecision(new URLSearchParams({xp:'pol',view:'decisions',decision:'IMP-02'}),'clan'),null);
});