Files
mxpic_EDA/tests/account-pdk-access-static.test.js
2026-05-30 12:23:51 +08:00

53 lines
1.7 KiB
JavaScript

/*
* Description: Static and helper regression tests for MXPIC EDA frontend/backend integration contracts.
* Inside functions: N/A - assertion-based test/module script.
* Developer : Qin Yue @ 2026
* Organization : OptiHK Limited
*/
const assert = require('assert');
const fs = require('fs');
const path = require('path');
const root = path.resolve(__dirname, '..');
const backend = path.join(root, 'backend');
const databasePy = fs.readFileSync(path.join(backend, 'database.py'), 'utf8');
const serverPy = fs.readFileSync(path.join(backend, 'server.py'), 'utf8');
const dashboardHtml = fs.readFileSync(path.join(root, 'frontend', 'dashboard.html'), 'utf8');
assert(
databasePy.includes('user_group'),
'database migration should add users.user_group'
);
assert(
databasePy.includes("'admin'") && databasePy.includes("'manager'"),
'admin should be migrated/seeded as manager'
);
assert(
databasePy.includes("'engineer'") && databasePy.includes("'developers'"),
'engineer should be migrated/seeded as developers'
);
assert(
serverPy.includes("session['user_group']") || serverPy.includes('session["user_group"]'),
'login should store user_group in the session'
);
assert(
serverPy.includes('"user_group"'),
'/api/profile should return user_group'
);
assert(
fs.existsSync(path.join(backend, 'pdk_access.py')),
'backend/pdk_access.py should resolve role-based PDK roots'
);
assert(
serverPy.includes('pdk_root_for_session'),
'server should resolve PDK root per logged-in user group'
);
assert(
dashboardHtml.includes('profile-group'),
'dashboard should show read-only profile group information'
);
assert(
!dashboardHtml.includes('profile-group"></select'),
'profile group must not be editable'
);