测试:军团练兵场测试
This commit is contained in:
@@ -1,10 +1,10 @@
|
|||||||
import { Application, BackendSession, HandlerService, } from 'pinus';
|
import { Application, BackendSession, HandlerService, } from 'pinus';
|
||||||
import { resResult, genCode, getRandSingleEelm } from '../../../pubUtils/util';
|
import { resResult, genCode, getRandSingleEelm } from '../../../pubUtils/util';
|
||||||
import { STATUS, TASK_TYPE } from '../../../consts';
|
import { DEBUG_MAGIC_WORD, STATUS, TASK_TYPE } from '../../../consts';
|
||||||
import { GuildTrainModel } from '../../../db/GuildTrain';
|
import { GuildTrainModel } from '../../../db/GuildTrain';
|
||||||
import { BattleRecordModel } from '../../../db/BattleRecord';
|
import { BattleRecordModel } from '../../../db/BattleRecord';
|
||||||
import { nowSeconds, getTimeFun, getZeroPoint } from '../../../pubUtils/timeUtil';
|
import { nowSeconds, getTimeFun, getZeroPoint } from '../../../pubUtils/timeUtil';
|
||||||
import { refreshTrain, getGuildTrainInfo, unlockTrain, getGuildTrainRewards, getGuildTrainInstance, getTrainBoxRewardsResult } from '../../../services/guildTrainService';
|
import { refreshTrain, getGuildTrainInfo, unlockTrain, getGuildTrainRewards, getGuildTrainInstance, getTrainBoxRewardsResult, resetTrain } from '../../../services/guildTrainService';
|
||||||
import { findIndex, findWhere } from 'underscore'
|
import { findIndex, findWhere } from 'underscore'
|
||||||
import { lockData } from '../../../services/redLockService';
|
import { lockData } from '../../../services/redLockService';
|
||||||
import { GUILD_REPORT_NUM, GUILD_POINT_WAYS } from '../../../consts/constModules/guildConst';
|
import { GUILD_REPORT_NUM, GUILD_POINT_WAYS } from '../../../consts/constModules/guildConst';
|
||||||
@@ -367,4 +367,29 @@ export class GuildTrainHandler {
|
|||||||
let { trainCount, buyTrainCount } = await UserGuildModel.addTrainCount(roleId, count);
|
let { trainCount, buyTrainCount } = await UserGuildModel.addTrainCount(roleId, count);
|
||||||
return resResult(STATUS.SUCCESS, { trainCount, buyTrainCount });
|
return resResult(STATUS.SUCCESS, { trainCount, buyTrainCount });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// debug接口: 添加挑战次数
|
||||||
|
async debugAddTrainCount(msg: { magicWord: string }, session: BackendSession) {
|
||||||
|
const { magicWord } = msg;
|
||||||
|
if (magicWord !== DEBUG_MAGIC_WORD) {
|
||||||
|
return resResult(STATUS.TOKEN_ERR);
|
||||||
|
}
|
||||||
|
const roleId: string = session.get('roleId');
|
||||||
|
await UserGuildModel.addTrainCount(roleId, 1);
|
||||||
|
return resResult(STATUS.SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
// debug接口: 重置试炼场
|
||||||
|
async debugResetTrainInstance(msg: { magicWord: string }, session: BackendSession) {
|
||||||
|
const { magicWord } = msg;
|
||||||
|
if (magicWord !== DEBUG_MAGIC_WORD) {
|
||||||
|
return resResult(STATUS.TOKEN_ERR);
|
||||||
|
}
|
||||||
|
|
||||||
|
const guildCode: string = session.get('guildCode');
|
||||||
|
const serverId: number = session.get('serverId');
|
||||||
|
await GuildModel.updateInfo(guildCode, { resetTrainTimeDaily: new Date(Date.now() - 86400000)})
|
||||||
|
await resetTrain(guildCode, serverId);
|
||||||
|
return resResult(STATUS.SUCCESS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+120
-11
@@ -2,7 +2,9 @@ import 'mocha';
|
|||||||
import { PinusWSClient } from 'pinus-robot-plugin';
|
import { PinusWSClient } from 'pinus-robot-plugin';
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import { Client } from './Client';
|
import { Client } from './Client';
|
||||||
import { checkDisplayItems, checkSuccessResponse } from './CheckPatten';
|
import { checkDisplayItems, checkSuccessResponse, checkTimeStamp } from './CheckPatten';
|
||||||
|
import { getRandSingleEelm } from '../app/pubUtils/util';
|
||||||
|
import { DEBUG_MAGIC_WORD } from '../app/consts';
|
||||||
describe('军团测试', function() {
|
describe('军团测试', function() {
|
||||||
let pinusClient: PinusWSClient;
|
let pinusClient: PinusWSClient;
|
||||||
let guildList;
|
let guildList;
|
||||||
@@ -259,23 +261,130 @@ describe('军团测试', function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
it('获得捐献所数据', function (done) {
|
it('获得捐献所数据', function (done) {
|
||||||
|
pinusClient.request('guild.donateHandler.getDonation', {}, (res) => {
|
||||||
|
checkSuccessResponse(res);
|
||||||
|
expect(res.data.receiveBoxs).to.be.an('array');
|
||||||
|
res.data.receiveBoxs.forEach(box => {
|
||||||
|
expect(box).to.be.a('number');
|
||||||
|
});
|
||||||
|
expect(res.data.donateFund).to.be.a('number');
|
||||||
|
expect(res.data.reports).to.be.an('array');
|
||||||
|
res.data.reports.forEach(report => {
|
||||||
|
expect(report.id).to.be.a('number');
|
||||||
|
expect(report.roleName).to.be.a('string');
|
||||||
|
checkTimeStamp(report.time, 10, true);
|
||||||
|
});
|
||||||
|
expect(res.data.donateCnt).to.be.a('number');
|
||||||
|
expect(res.data.donationLv).to.be.a('number');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it.skip('捐献', function (done) {
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('捐献', function (done) {
|
let trainInstances;
|
||||||
done();
|
let trainId;
|
||||||
});
|
|
||||||
|
|
||||||
it('获取练兵场信息', function (done) {
|
it('获取练兵场信息', function (done) {
|
||||||
done();
|
pinusClient.request('guild.guildTrainHandler.getTrainInstance', {}, (res) => {
|
||||||
|
checkSuccessResponse(res);
|
||||||
|
checkGuildTrain(res.data.guildTrain);
|
||||||
|
checkTrainCount(res.data)
|
||||||
|
expect(res.data.buyTrainCount).to.be.a('number');
|
||||||
|
expect(res.data.trainLv).to.be.a('number');
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function checkTrainCount(data) {
|
||||||
|
expect(data.trainCount).to.be.a('number');
|
||||||
|
expect(data.trainRewards).to.be.an('array');
|
||||||
|
data.trainRewards.forEach(reward => {
|
||||||
|
expect(reward).to.be.a('number');
|
||||||
|
})
|
||||||
|
}
|
||||||
|
function checkGuildTrain(guildTrain) {
|
||||||
|
expect(guildTrain.trainId).to.be.a('number');
|
||||||
|
trainId = guildTrain.trainId;
|
||||||
|
expect(guildTrain.isComplete).to.be.a('boolean');
|
||||||
|
checkTrainInstances(guildTrain.trainInstances);
|
||||||
|
if(guildTrain.reports) checkTrainReports(guildTrain.reports)
|
||||||
|
if(guildTrain.trainBoxs) checkTrainBoxs(guildTrain.trainBoxs);
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkTrainInstances(data) {
|
||||||
|
expect(data).to.be.an('array');
|
||||||
|
data.forEach(trainInstance => {
|
||||||
|
expect(trainInstance.hid).to.be.a('number');
|
||||||
|
expect(trainInstance.progress).to.be.a('number');
|
||||||
|
expect(trainInstance.endTime).to.be.a('number');
|
||||||
|
expect(trainInstance.isComplete).to.be.a('boolean');
|
||||||
|
});
|
||||||
|
trainInstances = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkTrainReports(reports) {
|
||||||
|
expect(reports).to.be.an('array');
|
||||||
|
reports.forEach(report => {
|
||||||
|
expect(report.roleId).to.be.a('string');
|
||||||
|
expect(report.trainId).to.be.a('number');
|
||||||
|
expect(report.hid).to.be.a('number');
|
||||||
|
expect(report.score).to.be.a('number');
|
||||||
|
expect(report.time).to.be.a('number');
|
||||||
|
expect(report.isSuccessed).to.be.a('boolean');
|
||||||
|
expect(report.type).to.be.a('number');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkTrainBoxs(boxs) {
|
||||||
|
expect(boxs).to.be.an('array');
|
||||||
|
boxs.forEach(box => {
|
||||||
|
expect(box.hid).to.be.a('number');
|
||||||
|
expect(box.recordBoxs).to.be.an('array');
|
||||||
|
box.recordBoxs.forEach(obj => {
|
||||||
|
expect(obj.roleId).to.be.a('string');
|
||||||
|
expect(obj.good).to.be.an('object');
|
||||||
|
expect(obj.good.id).to.be.a('number');
|
||||||
|
expect(obj.good.count).to.be.a('number');
|
||||||
|
expect(obj.good.index).to.be.a('number');
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(box.endTime).to.be.a('number');
|
||||||
|
expect(box.trainId).to.be.a('number');
|
||||||
|
expect(box.isComplete).to.be.a('boolean');
|
||||||
|
});
|
||||||
|
}
|
||||||
it('进入练兵战场', function (done) {
|
it('进入练兵战场', function (done) {
|
||||||
done();
|
let trainInstance: any = getRandSingleEelm(trainInstances.filter(cur => !cur.isComplete));
|
||||||
|
if(!trainInstances) {
|
||||||
|
pinusClient.request('guild.guildTrainHandler.debugResetTrainInstance', { magicWord: DEBUG_MAGIC_WORD }, (res) => {
|
||||||
|
checkSuccessResponse(res, false);
|
||||||
|
trainBattleStart()
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
trainBattleStart()
|
||||||
|
}
|
||||||
|
function trainBattleStart() {
|
||||||
|
pinusClient.request('guild.guildTrainHandler.debugAddTrainCount', { magicWord: DEBUG_MAGIC_WORD }, (res) => {
|
||||||
|
checkSuccessResponse(res, false);
|
||||||
|
pinusClient.request('guild.guildTrainHandler.trainBattleStart', { hid: trainInstance.hid, difficulty: 1, trainId, battleId: 8501 }, (res) => {
|
||||||
|
checkSuccessResponse(res);
|
||||||
|
expect(res.data.battleCode).to.be.a('string');
|
||||||
|
battleCode = res.data.battleCode;
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('战斗结算', function (done) {
|
it('战斗结算', function (done) {
|
||||||
done();
|
pinusClient.request('guild.guildTrainHandler.trainBattleEnd', { battleCode, isSuccess: true }, (res) => {
|
||||||
|
checkSuccessResponse(res);
|
||||||
|
checkDisplayItems(res.data.battleGoods);
|
||||||
|
checkGuildTrain(res.data.guildTrain);
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('获得练兵场战报', function (done) {
|
it('获得练兵场战报', function (done) {
|
||||||
@@ -286,11 +395,11 @@ describe('军团测试', function() {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('点亮研发', function (done) {
|
it.skip('点亮研发', function (done) {
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('炼器', function (done) {
|
it.skip('炼器', function (done) {
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -298,7 +407,7 @@ describe('军团测试', function() {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('许愿', function (done) {
|
it.skip('许愿', function (done) {
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user