123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204 |
- "use strict";
- var testConfig = require('../config');
- var APIv1 = require('../../../src/doctor/include/endpoints').APIv1;
- var should = require("should");
- var restTemplate = require('supertest').agent(testConfig.host);
- var userId = '0de7295862dd11e69faffa163e8aee56'; //
- var targetUserId = '37959ddf86f211e6b394fa163e424525'; //
- var adminTeamId = 5; // 行政团队ID: 黄庄家庭医生团队
- var consultGroupId = 'bcfd47c57ea74ba19fa049222c76befd'; // 讨论组ID
- var at = '';
- describe('Chat api', function () {
- // 发送系统消息
- describe('when send SYSTEM message correctly', function () {
- it('should return 200', function (done) {
- var path = APIv1.Chats.Base + APIv1.Chats.SM;
- restTemplate.post(path)
- .send({
- to: userId,
- title: "系统消息",
- summary: "您有一条新的工作记录",
- contentType: "1",
- content: "患者已经签约,可以制定随访计划。"
- })
- .end(function (err, response) {
- if(response.status !== 200){
- console.log(response.body);
- }
- response.status.should.equal(200);
- done();
- });
- });
- });
- describe('when send SYSTEM message that user not exist', function () {
- it('should return 404', function (done) {
- var path = APIv1.Chats.Base + APIv1.Chats.SM;
- restTemplate.post(path)
- .send({
- to: "Rose Unknown",
- title: "System Message",
- summary: "You have new job",
- contentType: "1",
- content: "The patient has been followed in the scheduler, please make new follow plan as soon as possible."
- })
- .end(function (err, response) {
- response.status.should.equal(404);
- done();
- });
- });
- });
- // 发送私信
- describe('when send PRIVATE message correctly', function () {
- it('should return 200', function (done) {
- var path = APIv1.Chats.Base + APIv1.Chats.PM;
- restTemplate.post(path)
- .send({
- from: userId,
- to: targetUserId,
- contentType: 1,
- content: "此患者白细胞如此高,中性粒值也高,同时感染细菌与病毒吗?"
- })
- .end(function (err, response) {
- response.status.should.equal(200);
- done();
- });
- });
- });
- // 向行政团队发送群消息
- describe('when send GROUP of admin team message correctly', function () {
- it('should return 200', function (done) {
- var path = APIv1.Chats.Base + APIv1.Chats.GM;
- restTemplate.post(path)
- .send({
- from: userId,
- at: '',
- group: adminTeamId,
- groupType: 1,
- contentType: 1,
- content: "请问:居民签约人数是否达标"
- })
- .end(function (err, response) {
- if(response.status !== 200){
- console.log(response.body);
- }
- response.status.should.equal(200);
- done();
- });
- });
- });
- // 向讨论组发送群消息
- describe('when send GROUP of consult team message correctly', function () {
- it('should return 200', function (done) {
- var path = APIv1.Chats.Base + APIv1.Chats.GM;
- restTemplate.post(path)
- .send({
- from: '0de705f962dd11e69faffa163e8aee56',
- at: '794f637bd3c64b948b112f16911a7883',
- group: consultGroupId,
- groupType: 2,
- contentType: 1,
- content: "庄医生,患者体征数据是否正常?"
- })
- .end(function (err, response) {
- if(response.status !== 200){
- console.log(response.body);
- }
- response.status.should.equal(200);
- done();
- });
- });
- });
- // 所有聊天列表
- describe('when get ALL CHAT list', function () {
- it('should return 200 and all chat list', function (done) {
- var path = APIv1.Chats.Base + APIv1.Chats.List + "?user_id=" + userId;
- restTemplate.get(path)
- .end(function (err, response) {
- console.log("User " + userId + "'s all chat list: \n", response.body);
- response.status.should.equal(200);
- done();
- });
- });
- });
- // 未读组数量
- describe('when get ALL GROUP unread chat count', function () {
- it('should return 200 and group chat count', function (done) {
- var path = APIv1.Chats.Base + APIv1.Chats.GMUnreadCount + "?user_id=" + userId;
- restTemplate.get(path)
- .end(function (err, response) {
- console.log("User " + userId + "'s group chat count: \n", response.body);
- response.status.should.equal(200);
- done();
- });
- })
- });
- // 未读私信数量
- describe('when get ALL PRIVATE unread chat list', function () {
- it('should return 200 and private chat count', function (done) {
- var path = APIv1.Chats.Base + APIv1.Chats.PMUnreadCount + "?user_id=" + userId;
- restTemplate.get(path)
- .end(function (err, response) {
- console.log("User " + userId + "'s private chat count: \n", response.body);
- response.status.should.equal(200);
- done();
- });
- })
- });
- // 所有未读消息数量
- describe('when get ALL unread message count', function () {
- it('should return 200 and all unread message count', function (done) {
- var path = APIv1.Chats.Base + APIv1.Chats.UnreadMsgCount + "?user_id=" + userId;
- restTemplate.get(path)
- .end(function (err, response) {
- console.log("User " + userId + "'s all unread message count: \n", response.body);
- response.status.should.equal(200);
- done();
- });
- });
- });
- // 获取角标数
- describe('when get badge number', function () {
- it('shout return 200 and badge number', function (done) {
- var path = APIv1.Application.Base + APIv1.Application.BadgeNo + "?user_id=" + userId;
- restTemplate.get(path)
- .end(function (err, response) {
- console.log("User " + userId + "'s badge number: \n", response.body);
- response.status.should.equal(200);
- done();
- });
- });
- });
- });
|