Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
488fd018e5 |
@@ -1,6 +1,6 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { changesFor } from '../scope-view.js';
|
||||
import { buildScopedView, changesFor } from '../scope-view.js';
|
||||
|
||||
// 部長看得到的人員異動:只有姓名、離開或加入、生效月份。
|
||||
// 不分離職或轉調,也不說轉調去哪裡。
|
||||
@@ -52,3 +52,37 @@ test('沒有預排、或部門沒人異動時回空陣列', () => {
|
||||
assert.deepEqual(changesFor('動畫部', model, plans), []);
|
||||
assert.deepEqual(changesFor('廣告部', { people: [] }, null), []);
|
||||
});
|
||||
|
||||
// ---- 誰看得到人員異動 ----
|
||||
// 只有看得到整個部門的人才拿得到:該部門的部長、全公司檢視、最高管理者。
|
||||
// 別的部門的部長拿不到;只看單一組別的組長完全沒有這個欄位。
|
||||
const scopeModel = {
|
||||
people: model.people,
|
||||
codaGroups: {
|
||||
廣告部: { coda: 0, avgDailyCoda: 0, groups: { 企劃組: { coda: 0, avgDailyCoda: 0, people: [] } } },
|
||||
業務部: { coda: 0, avgDailyCoda: 0, groups: { 業務組: { coda: 0, avgDailyCoda: 0, people: [] } } },
|
||||
},
|
||||
};
|
||||
const basePermission = { employeeNumber: '9', admin: false, company: false, personDetail: false, simulate: false, depts: [], groups: [] };
|
||||
const scoped = (permission) => buildScopedView(scopeModel, null, { ...basePermission, ...permission }, { year: 2027, plans }).depts;
|
||||
const shape = (rows) => rows.map(r => `${r.dept}|${r.full ? 'full' : 'group'}|${'changes' in r ? r.changes.length : 'none'}`);
|
||||
|
||||
test('部長只看得到自己部門的人員異動,看不到別的部門', () => {
|
||||
assert.deepEqual(shape(scoped({ depts: ['廣告部'] })), ['廣告部|full|4']);
|
||||
assert.deepEqual(shape(scoped({ depts: ['業務部'] })), ['業務部|full|1']);
|
||||
});
|
||||
|
||||
test('只看單一組別的組長完全沒有人員異動這個欄位', () => {
|
||||
const rows = scoped({ groups: ['廣告部|企劃組'] });
|
||||
assert.deepEqual(shape(rows), ['廣告部|group|none']);
|
||||
assert.equal(rows[0].changes, undefined);
|
||||
});
|
||||
|
||||
test('部長同時兼組長時,別的部門的組別還是看不到人員異動', () => {
|
||||
assert.deepEqual(shape(scoped({ depts: ['廣告部'], groups: ['業務部|業務組'] })), ['廣告部|full|4', '業務部|group|none']);
|
||||
});
|
||||
|
||||
test('全公司檢視和最高管理者看得到每個部門的人員異動', () => {
|
||||
assert.deepEqual(shape(scoped({ company: true })), ['廣告部|full|4', '業務部|full|1']);
|
||||
assert.deepEqual(shape(scoped({ admin: true })), ['廣告部|full|4', '業務部|full|1']);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user