Commit 6fce76ec authored by 张艳玲's avatar 张艳玲

Merge branch 'gifeature/2021071102' into 'master'

Gifeature/2021071102

See merge request test-group/kejiji!72
parents 0ef38ccb 7059fd79
package com.kjj.cases.assistant;
import static com.kjj.config.BasicConfig.*;
import com.kjj.cases.admin.Authorization;
import com.kjj.utils.BaseUtils;
import com.kjj.utils.ThreadSleepUtils;
import io.restassured.response.Response;
import org.testng.Assert;
import org.testng.annotations.*;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
public class homePage implements Authorization {
public int firstTagId; //获取种草素材标签ID
public String contentId; //获取素材文章id
public String tagId; //获取发圈素材标签ID
public String tagName; //获取发圈素材标签名称
public int hotTagId; //获取热榜标签ID
public int posterTagId; //获取海报标签ID
public String posterContentId; //获取海报的的contentId
@BeforeClass
public void setUp() {
// 创建用户 并传到network里
AGENT_TKU = BaseUtils.createTku();
network.agentCookies.put("tku", AGENT_TKU);
//System.out.println("代理人tku:"+AGENT_TKU);
// 获取访客tku
VISITOR_TKU = BaseUtils.getTku(VISITOR_USERID);
//System.out.println("访客tku:"+VISITOR_TKU);
}
//获取种草素材列表页
@Test(description = "首页_种草素材列表",priority = 1)
public void 首页_种草素材列表(){
Map<String,Object> params = new HashMap<>();
params.put("firstTagId","-1");
params.put("contentType","article");
params.put("pageIndex",1);
params.put("pageSize",20);
Response response = network.getResponse(params,HOME_getContentList);
Object obj = response.jsonPath().getJsonObject("data.list");
Assert.assertNotNull(obj, network.message(params,HOME_getContentList,"获取首页种草素材列表失败",response.body().asString()));
}
//获取发圈素材列表
@Test(description="获取发圈tab列表",priority = 2)
public void 获取发圈tab列表(){
Response response = network.getResponse(FRIENDS_GETMATERIALTAGS);
boolean hasList = response.jsonPath().getInt("data.size()") > 0;
int id = response.jsonPath().getInt("data.find {it.name == '保险'}.id"); //标签tab
firstTagId = response.jsonPath().getInt("data[0].id");//第一个标签的ID
System.out.println(firstTagId);
Assert.assertTrue(hasList,network.message(FRIENDS_GETMATERIALTAGS,"获取tab数量有误",response.body().asString()));
Assert.assertEquals(id,595,network.message(FRIENDS_GETMATERIALTAGS,"获取tab中不包含保险",response.body().asString()));
}
//获取未读发圈列表
@Test(description="获取发圈未读列表",priority = 3)
public void 获取发圈未读列表() {
Map<String, Object> params = new HashMap<String, Object>();
params.put("firstTagId",firstTagId);
Response response = network.getResponse(params,FRIENDS_GETUNREADTIMELINSLIST);
Object obj = response.jsonPath().getJsonObject("data");
System.out.println(obj);
Assert.assertNotNull(obj,network.message(params,FRIENDS_GETUNREADTIMELINSLIST,"获取推荐列表有误",response.body().asString()));
}
@Test(description = "获取所有发圈列表",priority = 4)
public void 获取所有发圈列表(){
Map<String,Object> params = new HashMap<>();
params.put("firstTagId",firstTagId);
params.put("pageIndex",1);
params.put("pageSize",20);
Response response = network.getResponse(params,FRIENDS_GETTIMELINELIST);
Object obj = response.jsonPath().getJsonObject("data");
contentId = response.jsonPath().getString("data.list.get(0).contentId"); //素材ID
System.out.println(contentId);
tagId = response.jsonPath().getString("data.list.get(0).materialTag"); //素材频道ID
tagName = response.jsonPath().getString("data.list.get(0).tagName"); //素材频道名称
Assert.assertNotNull(obj,network.message(params,FRIENDS_GETTIMELINELIST,"获取未读发圈列表失败",response.body().asString()));
}
@Test(description = "标记发圈素材是否已读",priority = 5)
public void 标记发圈素材是否已读(){
Map<String,Object> params = new HashMap<>();
params.put("firstTagId",firstTagId);
params.put("contentId",contentId);
Response response = network.postResponse(params,FRIENDS_ASYNCMARKTIMELINEREAD);
System.out.println(params);
boolean data = response.jsonPath().getBoolean("data");
boolean success = response.jsonPath().getBoolean("success");
Assert.assertTrue(data, network.message(params,FRIENDS_ASYNCMARKTIMELINEREAD,"标记发圈素材是否已读失败",response.body().asString()));
Assert.assertTrue(success, network.message(params,FRIENDS_ASYNCMARKTIMELINEREAD,"标记发圈素材是否已读失败",response.body().asString()));
}
@Test(description="收藏发圈素材",priority = 6)
public void 收藏发圈素材(){
// 收藏素材
Map<String, Object> params = new HashMap<String, Object>();
params.put("contentId",contentId);
params.put("operate",1);
Response response = network.getResponse(params,FRIENDS_ADDORCANCELCOLLECT);
boolean isAdd = response.jsonPath().getBoolean("data");
Assert.assertTrue(isAdd,network.message(params,FRIENDS_ADDORCANCELCOLLECT,"收藏素材失败",response.body().asString()));
// 查看收藏列表
params.put("pageSize",12);
response = network.getResponse(params,FRIENDS_QUERYLISTFORCOLLECT);
String collectContentId = response.jsonPath().getString("data[0].contentId");
Assert.assertEquals(collectContentId,contentId,network.message(params,FRIENDS_QUERYLISTFORCOLLECT,"收藏列表有误",response.body().asString()));
// 取消收藏
params.put("operate",2);
response = network.getResponse(params,FRIENDS_ADDORCANCELCOLLECT);
boolean isCancel = response.jsonPath().getBoolean("data");
Assert.assertTrue(isCancel,network.message(params,FRIENDS_ADDORCANCELCOLLECT,"取消收藏素材失败",response.body().asString()));
}
@Test(description="素材频道页",priority = 7)
public void 素材频道页(){
//频道页 头部
ThreadSleepUtils.sleep(500);
Map<String, Object> params = new HashMap<String, Object>();
params.put("tagId",tagId);
Response response = network.getResponse(params,FRIENDS_CHANNELDETAIL);
String name = response.jsonPath().getString("data.tagName");
Assert.assertEquals(name,tagName,network.message(params,FRIENDS_CHANNELDETAIL,"素材频道页-头部获取有误",response.body().asString()));
//频道页 列表
params.put("pageSize",10);
params.put("pageNo",1);
response = network.getResponse(params,FRIENDS_GETCHANNELLIST);
Object obj = response.jsonPath().getJsonObject("data");
Assert.assertNotNull(obj,network.message(params,FRIENDS_GETCHANNELLIST,"素材频道列表-获取有误",response.body().asString()));
}
@Test(description="从首页发圈列表页进入",priority = 8)
public void 从首页发圈列表页进入(){
// 获取首页发圈素材列表
Response response = network.getResponse(HOME_GETHOMETIMELINECONTENT);
String currentId = response.jsonPath().getString("data.materialVos[0].contentId");
Assert.assertNotNull(currentId,network.message(HOME_GETHOMETIMELINECONTENT,"获取首页发圈列表有误",response.body().asString()));
// 如果有推荐列表,进入发圈
if (currentId.length() > 0){
Map<String, Object> params = new HashMap<String, Object>();
params.put("currentId",currentId);
response = network.getResponse(params,FRIENDS_GETCURRENTINFO);
String topContentId = response.jsonPath().getString("data.contentId");
Assert.assertEquals(topContentId,currentId,network.message(params,FRIENDS_GETCURRENTINFO,"从首页进入发圈的头部素材有误",response.body().asString()));
}
}
//获取热榜标签列表
@Test(description = "获取热榜标签列表",priority = 9)
public void 获取热榜标签列表(){
Response response = network.getResponse(HOME_getTopHubTag);
Object obj = response.jsonPath().getJsonObject("data");
hotTagId = response.jsonPath().getInt("data[0].id");
Assert.assertNotNull(obj, network.message(HOME_getTopHubTag,"获取热榜标签列表失败",response.body().asString()));
}
@Test(description = "获取热榜文章列表",priority = 10)
public void 获取热榜文章列表(){
Map<String,Object> params = new HashMap<>();
params.put("tagId",hotTagId);
Response response = network.getResponse(params,HOME_getTopHubContentList);
Object obj = response.jsonPath().getJsonObject("data");
Assert.assertNotNull(obj, network.message(params,HOME_getTopHubContentList,"获取热榜文章列表失败",response.body().asString()));
}
@Test(description = "获取海报标签列表",priority = 11)
public void 获取海报标签列表(){
Response response = network.getResponse(HOME_getTags4Poster);
Object obj = response.jsonPath().getJsonObject("data");
posterTagId = response.jsonPath().getInt("data[1].id");
Assert.assertNotNull(obj, network.message(HOME_getTopHubTag,"获取海报标签列表",response.body().asString()));
}
@Test(description = "获取海报内容列表",priority = 12)
public void 获取海报内容列表(){
Map<String,Object> params = new HashMap<>();
params.put("firstTagId",posterTagId);
params.put("pageIndex",1);
params.put("pageSize",12);
Response response = network.getResponse(params,HOME_getPosterTemplateList);
Object obj = response.jsonPath().getJsonObject("data.list");
posterContentId = response.jsonPath().getString("data.list.get(0).contentId");
Assert.assertNotNull(obj, network.message(params,HOME_getPosterTemplateList,"获取海报内容失败",response.body().asString()));
}
@Test(description = "获取海报内容",priority = 13)
public void 获取海报内容(){
//根据contentId获得sCid
Map<String,Object> params = new HashMap<>();
params.put("contentId",posterContentId);
Response response = network.getResponse(params,GETSCID);
String sCid = response.jsonPath().getString("data");
System.out.println(sCid);
Assert.assertNotNull(sCid, network.message(params,GETSCID,"获取sCid失败",response.body().asString()));
//根据id查询海报
Map<String,Object> infoParams = new HashMap<>();
infoParams.put("scid",sCid);
Response findPosterRes = network.getResponse(infoParams,HOME_findPosterById);
Object data = findPosterRes.jsonPath().getJsonObject("data");
Assert.assertNotNull(data, network.message(infoParams,HOME_findPosterById,"查询海报失败",findPosterRes.body().asString()));
}
//获取首页视频列表
@Test(description = "首页_视频列表",priority = 14)
public void 首页_视频列表(){
Map<String,Object> params = new HashMap<>();
params.put("contentType","video");
Response response = network.getResponse(params,HOME_getContentList);
Object obj = response.jsonPath().getJsonObject("data.list");
Assert.assertNotNull(obj, network.message(params,HOME_getContentList,"获取首页视频列表失败",response.body().asString()));
}
}
...@@ -740,6 +740,13 @@ public class BasicConfig { ...@@ -740,6 +740,13 @@ public class BasicConfig {
public static final String HOME_GETHOMETIMELINECONTENT = HOST + "/kjy/mp/home/getHomeTimeLineContent"; public static final String HOME_GETHOMETIMELINECONTENT = HOST + "/kjy/mp/home/getHomeTimeLineContent";
public static final String HOME_getInfo = HOST + "/kjy/mp/dailyPoster/getInfo"; public static final String HOME_getInfo = HOST + "/kjy/mp/dailyPoster/getInfo";
public static final String HOME_selectPage = HOST + "/kjy/mp/dailyPoster/selectPage"; public static final String HOME_selectPage = HOST + "/kjy/mp/dailyPoster/selectPage";
public static final String HOME_getContentList = HOST +"/kjy/mp/grassContent/getContentList";
public static final String HOME_getTopHubTag = HOST + "/kjy/mp/home/getTopHubTag";
public static final String HOME_getTopHubContentList = HOST + "/kjy/mp/home/getTopHubContentList";
public static final String HOME_getTags4Poster = HOST + "/kjy/mp/posterTemplate/getTags4Poster";
public static final String HOME_getPosterTemplateList = HOST + "/kjy/mp/posterTemplate/getPosterTemplateList";
public static final String HOME_findPosterById = HOST + "/kjy/mp/posterTemplate/findPosterById";
// ************** 设置中心 *************** // ************** 设置中心 ***************
public static final String SELLERCONFIG_EDITCONFIG = HOST + "/kjy/mp/sellerConfig/editConfig"; public static final String SELLERCONFIG_EDITCONFIG = HOST + "/kjy/mp/sellerConfig/editConfig";
......
...@@ -52,6 +52,11 @@ ...@@ -52,6 +52,11 @@
<class name="com.kjj.cases.assistant.DailyPaper"/> <class name="com.kjj.cases.assistant.DailyPaper"/>
</classes> </classes>
</test> </test>
<test preserve-order="true" name = "首页">
<classes>
<class name="com.kjj.cases.assistant.homePage"/>
</classes>
</test>
</suite> </suite>
<!-- Suite --> <!-- Suite -->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment