This commit is contained in:
1 parent
e4843e7d1d
commit
1808f14cc6
17 files changed
+711
-23
No files matched your search
@@ -0,0 +1,30 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import vm from 'node:vm';
|
||||
|
||||
const source = readFileSync(new URL('../egbim/app.js', import.meta.url), 'utf8');
|
||||
const context = vm.createContext({
|
||||
window: { QA_CONFIG: {}, location: { origin: 'https://qa.example.test' } },
|
||||
document: { cookie: '', addEventListener() {} },
|
||||
sessionStorage: { getItem() { return null; } },
|
||||
localStorage: { getItem() { return null; } }, URL
|
||||
});
|
||||
vm.runInContext(source.replace(/\}\)\(\);\s*$/, 'globalThis.testPage = { normalizeRemotePost, getPostCompanyLabel, normalizeAuthUser }; })();'), context);
|
||||
const page = context.testPage;
|
||||
|
||||
test('saved organization has priority over email-domain inference in list and detail', () => {
|
||||
const post = page.normalizeRemotePost({ id: 'fixture', requester_email: 'fixture@brsw.kr', requester_affiliation: '저장된 회사', requester_department: '저장된 부서' });
|
||||
assert.equal(post.company, '저장된 회사');
|
||||
assert.equal(post.department, '저장된 부서');
|
||||
assert.equal(page.getPostCompanyLabel(post, { company: '현재 조회자 회사' }), '저장된 회사');
|
||||
});
|
||||
test('a matching tenant does not copy the current viewer company to an unrelated author', () => {
|
||||
const label = page.getPostCompanyLabel({ requesterTenantId: 'shared', raw: {} }, { tenantId: 'shared', company: '다른 작성자 회사' });
|
||||
assert.notEqual(label, '다른 작성자 회사');
|
||||
});
|
||||
test('server organization has priority over stale browser custom attributes', () => {
|
||||
const user = page.normalizeAuthUser({ company: '서버 회사', department: '서버 부서', email: 'fixture@brsw.kr', customAttributes: { company: 'old', department: 'old' } }, {});
|
||||
assert.equal(user.company, '서버 회사');
|
||||
assert.equal(user.department, '서버 부서');
|
||||
});
|
||||
Reference in new issue
Block a user