46 lines
1.3 KiB
JavaScript
46 lines
1.3 KiB
JavaScript
'use strict';
|
|
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
const {
|
|
getAuthToken,
|
|
invokeSystemMethod,
|
|
} = require('../../support/system_method_client');
|
|
|
|
const RUNTIME_FILE = path.join(process.cwd(), 'test', '.runtime', 'system_user_info_web_all.json');
|
|
|
|
function saveRuntime(payload) {
|
|
fs.mkdirSync(path.dirname(RUNTIME_FILE), { recursive: true });
|
|
fs.writeFileSync(RUNTIME_FILE, JSON.stringify(payload, null, 2), 'utf8');
|
|
}
|
|
|
|
describe('test/app/controller/system.user.info.web.test.js', () => {
|
|
it('should call user.info with platform=web project=all and persist response', async () => {
|
|
const { token } = await getAuthToken();
|
|
const infoRes = await invokeSystemMethod('user.info', {}, token, {
|
|
platform: 'web',
|
|
project: 'all',
|
|
});
|
|
|
|
assert.equal(infoRes.status, 200);
|
|
assert.equal(infoRes.body.flag, 'success');
|
|
assert.equal(infoRes.body.code, 200);
|
|
assert.ok(infoRes.body.data);
|
|
assert.equal(infoRes.body.data.platform_code, 'web');
|
|
assert.ok(Array.isArray(infoRes.body.data.employees));
|
|
|
|
saveRuntime({
|
|
savedAt: new Date().toISOString(),
|
|
method: 'user.info',
|
|
headers: {
|
|
platform: 'web',
|
|
project: 'all',
|
|
},
|
|
response: infoRes.body,
|
|
});
|
|
|
|
assert.equal(fs.existsSync(RUNTIME_FILE), true);
|
|
});
|
|
});
|