How to use WithTimeout method in storybook-root

Best JavaScript code snippet using storybook-root

2_home_page.js

Source:2_home_page.js Github

copy

Full Screen

1describe('首页', () => {2 beforeEach(async () => {3 await device.reloadReactNative();4 });5 it('职通力', async () => {6 await expect(element(by.id('loginPhone_LoginMainScreen'))).toBeVisible();7 // 输入正确的手机号密码8 await element(by.id('loginPhone_LoginMainScreen')).replaceText('13812345678');9 await element(by.id('password_LoginMainScreen')).replaceText('123456');10 // await waitFor(element(by.id('loginButton_LoginMainScreen'))).toBeVisible().withTimeout(3000);11 await element(by.id('loginButton_LoginMainScreen')).tap();12 await waitFor(element(by.id('GrowTargetSwitch_HomeScreen'))).toBeVisible().withTimeout(10000);13 await element(by.id('GrowTargetSwitch_HomeScreen')).tap();14 // 时间选择器15 await waitFor(element(by.id('LightBoxScreen_ExpDetailScreen'))).toBeVisible().withTimeout(10000);16 await element(by.id('LightBoxScreen_ExpDetailScreen')).tap();17 await waitFor(element(by.text('确定'))).toBeVisible().withTimeout(10000);18 await element(by.id('确定')).tap();19 // await element(by.text('职通力成长趋势')).scrollTo('bottom');20 // await waitFor(element(by.text('职通力'))).toBeVisible().withTimeout(10000);21 // await element(by.text('职通力')).tap();22 });23 it('目标职位', async () => {24 // await expect(element(by.id('loginPhone_LoginMainScreen'))).toBeVisible();25 // // 输入正确的手机号密码26 // await element(by.id('loginPhone_LoginMainScreen')).replaceText('13812345678');27 // await element(by.id('password_LoginMainScreen')).replaceText('123456');28 // // await waitFor(element(by.id('loginButton_LoginMainScreen'))).toBeVisible().withTimeout(3000);29 // await element(by.id('loginButton_LoginMainScreen')).tap();30 await waitFor(element(by.id('targetJob_TextTwoLink'))).toBeVisible().withTimeout(10000);31 await element(by.id('targetJob_TextTwoLink')).tap();32 // 制定新的目标33 await waitFor(element(by.text('制定新的目标'))).toBeVisible().withTimeout(10000);34 await element(by.text('制定新的目标')).tap();35 await waitFor(element(by.text('专业对口'))).toBeVisible().withTimeout(10000);36 await element(by.text('专业对口')).tap();37 await element(by.id('majorBack_GrowingFutureChoose')).tap();38 await waitFor(element(by.id('DRefreshFutureList_GrowingFutureChoose'))).toBeVisible().withTimeout(10000);39 await element(by.id('draftGoal_GrowingFuture')).tap();40 await waitFor(element(by.text('IT'))).toBeVisible().withTimeout(10000);41 await element(by.text('IT')).tap();42 await waitFor(element(by.text('确定'))).toBeVisible().withTimeout(10000);43 await element(by.text('确定')).tap();44 await waitFor(element(by.text('下一步'))).toBeVisible().withTimeout(10000);45 await element(by.text('下一步')).tap();46 await waitFor(element(by.text('产品经理'))).toBeVisible().withTimeout(10000);47 await element(by.text('产品经理')).tap();48 await waitFor(element(by.text('加入我的规划'))).toBeVisible().withTimeout(10000);49 await element(by.text('加入我的规划')).tap();50 await expect(element(by.text('我的目标'))).toBeVisible();51 // 切换目标52 await waitFor(element(by.id('GrowTargetSwitch_HomeScreen'))).toBeVisible().withTimeout(10000);53 await element(by.id('GrowTargetSwitch_HomeScreen')).tap();54 await waitFor(element(by.id('homeScreen'))).toBeVisible().withTimeout(10000);55 await expect(element(by.id('homeScreen'))).toBeVisible();56 });57 it('开门指路', async () => {58 await waitFor(element(by.id('article_HomeScreen'))).toBeVisible().withTimeout(10000);59 await element(by.id('article_HomeScreen')).tap();60 await waitFor(element(by.id('articleDetail_StudentShare'))).toBeVisible().withTimeout(10000);61 await element(by.id('articleDetail_StudentShare')).tap();62 await element(by.text('有用')).tap();63 await element(by.text('收藏')).tap();64 // ?验证右上角排序65 });66 it('我的履历', async () => {67 await waitFor(element(by.id('myResume_HomeScreen'))).toBeVisible().withTimeout(10000);68 await element(by.id('myResume_HomeScreen')).tap();69 // //编辑基本信息70 await waitFor(element(by.id('nameInput_EditUserBaseInfoScreen'))).toBeVisible().withTimeout(10000);71 await element(by.id('nameInput_EditUserBaseInfoScreen')).replaceText(Math.random().toString().slice(-4));72 await element(by.text('保存')).tap();73 await expect(element(by.id('nameInput_EditUserBaseInfoScreen'))).toBeVisible();74 // //编辑教育经历75 await waitFor(element(by.id('editEducationnfo_TrackRecordScreen'))).toBeVisible().withTimeout(10000);76 await element(by.id('editEducationnfo_TrackRecordScreen')).tap();77 // 认证78 await waitFor(element(by.text('认证'))).toBeVisible().withTimeout(10000);79 await element(by.text('认证')).tap();80 await expect(element(by.id('nameInput_EditUserBaseInfoScreen'))).toBeVisible();81 await element(by.id('account_AddChisAccount')).replaceText('123');82 await element(by.id('password_AddChisAccount')).replaceText('123456');83 await element(by.text('绑定账号')).tap();84 await element(by.text('完成')).tap();85 // 编辑86 await waitFor(element(by.text('编辑'))).toBeVisible().withTimeout(10000);87 await element(by.text('编辑')).tap();88 await waitFor(element(by.text('删除该教育经历'))).toBeVisible().withTimeout(10000);89 await element(by.text('删除该教育经历')).tap();90 await expect(element(by.text('该教育经历已被设置为默认身份,不可删除!'))).toBeVisible();91 await element(by.text('确定')).tap();92 await waitFor(element(by.text('保存'))).toBeVisible().withTimeout(10000);93 await element(by.text('保存')).tap();94 await element(by.traits(['button']).and(by.label('Back'))).tap();95 // 添加96 // //添加在校成绩97 await waitFor(element(by.id('editLearnedCourse_TrackRecordScreen'))).toBeVisible().withTimeout(10000);98 await element(by.id('editLearnedCourse_TrackRecordScreen')).tap();99 await expect(element(by.text('正在验证中'))).toBeVisible();100 await element(by.traits(['button']).and(by.label('Back'))).tap();101 // //添加在校职务102 await waitFor(element(by.id('inSchoolJobs_TrackRecordScreen'))).toBeVisible().withTimeout(10000);103 await element(by.id('inSchoolJobs_TrackRecordScreen')).tap();104 // 职务105 await waitFor(element(by.id('jobInput_EditInSchoolJobsScreen'))).toBeVisible().withTimeout(10000);106 await element(by.id('jobInput_EditInSchoolJobsScreen')).replaceText('12345');107 // 开始时间108 await element(by.id('startInput_EditInSchoolJobsScreen')).tap();109 await waitFor(element(by.text('确定'))).toBeVisible().withTimeout(10000);110 await element(by.text('确定')).tap();111 // 结束时间112 await waitFor(element(by.id('endInput_EditInSchoolJobsScreen'))).toBeVisible().withTimeout(10000);113 await element(by.id('endInput_EditInSchoolJobsScreen')).tap();114 await element(by.label('SelectorDate')).scroll(100, 'down');115 await element(by.text('确定')).tap();116 // 职务描述117 await waitFor(element(by.id('inputDetail_EditInSchoolJobsScreen'))).toBeVisible().withTimeout(10000);118 await element(by.id('inputDetail_EditInSchoolJobsScreen')).replaceText('12345');119 await element(by.text('保存')).tap();120 await expect(element(by.text('在校职位'))).toBeVisible();121 // //添加获奖经历 无法定位相册图片问题122 // //添加实习经历123 await waitFor(element(by.id('addPractice_TrackRecordScreen'))).toBeVisible().withTimeout(10000);124 await element(by.id('addPractice_TrackRecordScreen')).tap();125 // 公司126 await waitFor(element(by.id('companyInput_AddPracticeScreen'))).toBeVisible().withTimeout(10000);127 await element(by.id('companyInput_AddPracticeScreen')).replaceText('12345');128 // 职务129 await waitFor(element(by.id('jobInput_AddPracticeScreen'))).toBeVisible().withTimeout(10000);130 await element(by.id('jobInput_AddPracticeScreen')).replaceText('12345');131 // 开始时间132 await element(by.text('开始时间')).tap();133 await waitFor(element(by.text('确定'))).toBeVisible().withTimeout(10000);134 await element(by.text('确定')).tap();135 // 结束时间136 await waitFor(element(by.id('结束时间'))).toBeVisible().withTimeout(10000);137 await element(by.id('结束时间')).tap();138 await element(by.label('SelectorDate')).scroll(100, 'down');139 await element(by.text('确定')).tap();140 // 工作内容描述141 await waitFor(element(by.id('workDetail_AddPracticeScreen'))).toBeVisible().withTimeout(10000);142 await element(by.id('workDetail_AddPracticeScreen')).replaceText('12345');143 await element(by.text('保存')).tap();144 await expect(element(by.text('实习经历'))).toBeVisible();145 // //添加证书 无法定位相册图片问题146 ////添加自我评价147 await waitFor(element(by.id('remarkInput_SelfEvaluationScreen'))).toBeVisible().withTimeout(10000);148 await element(by.id('remarkInput_SelfEvaluationScreen')).replaceText('12345');149 await element(by.text('保存')).tap();150 await expect(element(by.text('自我评价'))).toBeVisible();151 });152 it('我要成长', async () => {153 // 我的目标154 await waitFor(element(by.id('myGrow_HomeScreen'))).toBeVisible().withTimeout(10000);155 await element(by.id('myGrow_HomeScreen')).tap();156 await waitFor(element(by.id('targetJob_TextTwoLink'))).toBeVisible().withTimeout(10000);157 await element(by.id('targetJob_TextTwoLink')).tap();158 await expect(element(by.text('我的目标'))).toBeVisible();159 await element(by.text('收藏')).tap();160 await expect(element(by.text('实习经历'))).toBeVisible();161 await element(by.traits(['button']).and(by.label('Back'))).tap();162 // 开门指路163 await waitFor(element(by.id('imageStudentShare_GrowScreen'))).toBeVisible().withTimeout(10000);164 await element(by.id('imageStudentShare_GrowScreen')).tap();165 await expect(element(by.text('觉得有用'))).toBeVisible();166 await element(by.traits(['button']).and(by.label('Back'))).tap();167 // 职场技能168 await waitFor(element(by.id('jobSkill_GrowScreen'))).toBeVisible().withTimeout(10000);169 await element(by.id('jobSkill_GrowScreen')).tap();170 await waitFor(element(by.text('office-excel'))).toBeVisible().withTimeout(10000);171 await element(by.id('office-excel')).tap();172 await waitFor(element(by.text('完成'))).toBeVisible().withTimeout(10000);173 await element(by.id('完成')).tap();174 await waitFor(element(by.id('inputfeel_PunchSkill'))).toBeVisible().withTimeout(10000);175 await element(by.id('inputfeel_PunchSkill')).tap();176 await element(by.id('achiveCard_PunchSkill')).tap();177 // ?关闭弹出的完成任务提示178 // 证书考取,定位相册图片问题179 });180 it('每日打卡', async () => {181 await waitFor(element(by.id('growCheckin_HomeScreen'))).toBeVisible().withTimeout(10000);182 await element(by.id('growCheckin_HomeScreen')).tap();183 await waitFor(element(by.text('今日背单词了')).and(by.text('未打卡'))).toBeVisible().withTimeout(10000);184 await element(by.text('今日背单词了')).and(by.text('未打卡')).tap();185 await element(by.id('查看月汇总')).tap();186 await element(by.traits(['button']).and(by.label('Back'))).tap();187 // ?关闭弹出的完成任务提示188 });189 //// 算薪资190 it('算薪资', async () => {191 // 开始算薪资192 await waitFor(element(by.id('calSalary_HomeScreen'))).toBeVisible().withTimeout(10000);193 await element(by.id('calSalary_HomeScreen')).tap();194 await waitFor(element(by.text('开始算薪资'))).toBeVisible().withTimeout(10000);195 await element(by.text('开始算薪资')).tap();196 await waitFor(element(by.id('chengdu_Salary00'))).toBeVisible().withTimeout(10000);197 await element(by.id('chengdu_Salary00')).tap();198 await waitFor(element(by.id('gongChengShi_Salary01'))).toBeVisible().withTimeout(10000);199 await element(by.id('gongChengShi_Salary01')).tap();200 await waitFor(element(by.text('Android'))).toBeVisible().withTimeout(10000);201 await element(by.text('Android')).tap();202 await waitFor(element(by.id('benKe_Salary03'))).toBeVisible().withTimeout(10000);203 await element(by.id('benKe_Salary03')).tap();204 await waitFor(element(by.id('baiYang_Salary06'))).toBeVisible().withTimeout(10000);205 await element(by.id('baiYang_Salary06')).tap();206 await waitFor(element(by.id('nv_Salary07'))).toBeVisible().withTimeout(10000);207 await element(by.id('nv_Salary07')).tap();208 await waitFor(element(by.id('OT_Salary08'))).toBeVisible().withTimeout(10000);209 await element(by.id('OT_Salary08')).tap();210 await waitFor(element(by.id('praise_Salary09'))).toBeVisible().withTimeout(10000);211 await element(by.id('praise_Salary09')).tap();212 await waitFor(element(by.text('生成我的薪资'))).toBeVisible().withTimeout(10000);213 await element(by.text('生成我的薪资')).tap();214 // 再玩一次215 await waitFor(element(by.text('再玩一次'))).toBeVisible().withTimeout(10000);216 await element(by.text('再玩一次')).tap();217 await waitFor(element(by.id('calSalary_HomeScreen'))).toBeVisible().withTimeout(10000);218 await element(by.id('calSalary_HomeScreen')).tap();219 await waitFor(element(by.text('开始算薪资'))).toBeVisible().withTimeout(10000);220 await element(by.text('开始算薪资')).tap();221 await waitFor(element(by.id('chengdu_Salary00'))).toBeVisible().withTimeout(10000);222 await element(by.id('chengdu_Salary00')).tap();223 await waitFor(element(by.id('gongChengShi_Salary01'))).toBeVisible().withTimeout(10000);224 await element(by.id('gongChengShi_Salary01')).tap();225 await waitFor(element(by.text('Android'))).toBeVisible().withTimeout(10000);226 await element(by.text('Android')).tap();227 await waitFor(element(by.id('benKe_Salary03'))).toBeVisible().withTimeout(10000);228 await element(by.id('benKe_Salary03')).tap();229 await waitFor(element(by.id('baiYang_Salary06'))).toBeVisible().withTimeout(10000);230 await element(by.id('baiYang_Salary06')).tap();231 await waitFor(element(by.id('nv_Salary07'))).toBeVisible().withTimeout(10000);232 await element(by.id('nv_Salary07')).tap();233 await waitFor(element(by.id('OT_Salary08'))).toBeVisible().withTimeout(10000);234 await element(by.id('OT_Salary08')).tap();235 await waitFor(element(by.id('praise_Salary09'))).toBeVisible().withTimeout(10000);236 await element(by.id('praise_Salary09')).tap();237 await waitFor(element(by.text('生成我的薪资'))).toBeVisible().withTimeout(10000);238 await element(by.text('生成我的薪资')).tap();239 // 返回首页240 await waitFor(element(by.text('返回首页'))).toBeVisible().withTimeout(10000);241 await element(by.text('返回首页')).tap();242 await expect(element(by.id('calSalary_HomeScreen'))).toBeVisible();243 });244 // //薪资增长趋势245 it('薪资增长趋势', async () => {246 await waitFor(element(by.text('薪资增长趋势'))).toBeVisible().withTimeout(10000);247 await element(by.text('薪资增长趋势')).tap();248 await waitFor(element(by.text('本校就业情况'))).toBeVisible().withTimeout(10000);249 await element(by.text('本校就业情况')).tap();250 });251 // //薪资增长趋势252 it('就业领域分布', async () => {253 await waitFor(element(by.text('就业领域分布'))).toBeVisible().withTimeout(10000);254 await element(by.text('就业领域分布')).tap();255 await waitFor(element(by.text('就业行业分布'))).toBeVisible().withTimeout(10000);256 await element(by.text('就业行业分布')).scrollTo('bottom');257 });258 // //就业公司分布259 it('就业公司分布', async () => {260 await waitFor(element(by.text('就业领域分布'))).toBeVisible().withTimeout(10000);261 await element(by.text('就业领域分布')).scrollTo('bottom');262 await waitFor(element(by.text('就业公司分布'))).toBeVisible().withTimeout(10000);263 await element(by.text('就业公司分布')).tap();264 });265 // //查询更多266 it('查询更多', async () => {267 await waitFor(element(by.text('就业领域分布'))).toBeVisible().withTimeout(10000);268 await element(by.text('就业领域分布')).scrollTo('bottom');269 await waitFor(element(by.text('查询更多'))).toBeVisible().withTimeout(10000);270 await element(by.text('查询更多')).tap();271 // 学校272 await waitFor(element(by.text('成都理工大学'))).toBeVisible().withTimeout(10000);273 await element(by.text('成都理工大学')).scrollTo('bottom');274 await expect(element(by.text('四川财经职业学院'))).toBeVisible();275 // 专业276 await waitFor(element(by.text('专业'))).toBeVisible().withTimeout(10000);277 await element(by.text('专业')).tap();278 await waitFor(element(by.text('本科专业'))).toBeVisible().withTimeout(10000);279 await element(by.text('本科专业')).tap();280 await waitFor(element(by.text('哲学'))).toBeVisible().withTimeout(10000);281 await element(by.text('哲学')).tap();282 await waitFor(element(by.text('哲学类'))).toBeVisible().withTimeout(10000);283 await element(by.text('哲学类')).tap();284 await waitFor(element(by.text('哲学'))).toBeVisible().withTimeout(10000);285 await element(by.text('哲学')).tap();286 await element(by.text('专业概况')).scrollTo('bottom');287 // ?收藏按钮288 await element(by.traits(['button']).and(by.label('Back'))).tap();289 // 学校290 await waitFor(element(by.text('IT'))).toBeVisible().withTimeout(10000);291 await element(by.text('IT')).tap();292 await expect(element(by.text('数据解读'))).toBeVisible();293 // 职位294 await waitFor(element(by.text('IT'))).toBeVisible().withTimeout(10000);295 await element(by.text('IT')).tap();296 await waitFor(element(by.text('技术-人工智能'))).toBeVisible().withTimeout(10000);297 await element(by.text('技术-人工智能')).tap();298 await waitFor(element(by.text('机器学习工程师'))).toBeVisible().withTimeout(10000);299 await element(by.text('机器学习工程师')).tap();300 await waitFor(element(by.text('加入我的规划'))).toBeVisible().withTimeout(10000);301 await element(by.text('加入我的规划')).tap();302 await expect(element(by.text('我的目标'))).toBeVisible();303 });304 // //查询更多-搜索305 it('查询更多-搜索', async () => {306 /////307 });...

Full Screen

Full Screen

02-team.spec.js

Source:02-team.spec.js Github

copy

Full Screen

1const data = require('../../data');2const {3 navigateToLogin, login, tapBack, sleep, searchRoom4} = require('../../helpers/app');5async function navigateToRoom(roomName) {6 await searchRoom(`${ roomName }`);7 await element(by.id(`rooms-list-view-item-${ roomName }`)).tap();8 await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(5000);9}10async function openActionSheet(username) {11 await waitFor(element(by.id(`room-members-view-item-${ username }`))).toExist().withTimeout(5000);12 await element(by.id(`room-members-view-item-${ username }`)).tap();13 await sleep(300);14 await expect(element(by.id('action-sheet'))).toExist();15 await expect(element(by.id('action-sheet-handle'))).toBeVisible();16}17async function navigateToRoomActions() {18 await waitFor(element(by.id('room-view'))).toExist().withTimeout(2000);19 await element(by.id('room-header')).tap();20 await waitFor(element(by.id('room-actions-view'))).toExist().withTimeout(5000);21}22async function backToActions() {23 await tapBack();24 await waitFor(element(by.id('room-actions-view'))).toExist().withTimeout(2000);25}26async function closeActionSheet() {27 await element(by.id('action-sheet-handle')).swipe('down', 'fast', 0.6);28}29async function waitForToast() {30 await sleep(1000);31}32describe('Team', () => {33 const team = data.teams.private.name;34 const user = data.users.alternate;35 const room = `private${ data.random }-channel-team`;36 const existingRoom = data.groups.alternate.name;37 before(async() => {38 await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });39 await navigateToLogin();40 await login(data.users.regular.username, data.users.regular.password);41 await navigateToRoom(team);42 });43 describe('Team Room', () => {44 describe('Team Header', () => {45 it('should have actions button ', async() => {46 await expect(element(by.id('room-header'))).toExist();47 });48 it('should have team channels button ', async() => {49 await expect(element(by.id('room-view-header-team-channels'))).toExist();50 });51 it('should have threads button ', async() => {52 await expect(element(by.id('room-view-header-threads'))).toExist();53 });54 it('should have threads button ', async() => {55 await expect(element(by.id('room-view-search'))).toExist();56 });57 });58 describe('Team Header Usage', () => {59 it('should navigate to team channels view', async() => {60 await element(by.id('room-view-header-team-channels')).tap();61 await waitFor(element(by.id('team-channels-view'))).toExist().withTimeout(5000);62 });63 });64 describe('Team Channels Header', () => {65 it('should have actions button ', async() => {66 await expect(element(by.id('room-header'))).toExist();67 });68 it('should have team channels button ', async() => {69 await expect(element(by.id('team-channels-view-create'))).toExist();70 });71 it('should have threads button ', async() => {72 await expect(element(by.id('team-channels-view-search'))).toExist();73 });74 });75 describe('Team Channels Header Usage', () => {76 it('should navigate to add team channels view', async() => {77 await element(by.id('team-channels-view-create')).tap();78 await waitFor(element(by.id('add-channel-team-view'))).toExist().withTimeout(5000);79 });80 it('should have create new button', async() => {81 await waitFor(element(by.id('add-channel-team-view-create-channel'))).toExist().withTimeout(5000);82 });83 it('should add existing button', async() => {84 await waitFor(element(by.id('add-channel-team-view-add-existing'))).toExist().withTimeout(5000);85 });86 });87 describe('Channels', () => {88 it('should create new channel for team', async() => {89 await element(by.id('add-channel-team-view-create-channel')).tap();90 await element(by.id('select-users-view-search')).replaceText('rocket.cat');91 await element(by.id('select-users-view-item-rocket.cat')).tap();92 await waitFor(element(by.id('selected-user-rocket.cat'))).toBeVisible().withTimeout(10000);93 await element(by.id('selected-users-view-submit')).tap();94 await waitFor(element(by.id('create-channel-view'))).toExist().withTimeout(10000);95 await element(by.id('create-channel-name')).replaceText('');96 await element(by.id('create-channel-name')).typeText(room);97 await element(by.id('create-channel-submit')).tap();98 await waitFor(element(by.id('room-view'))).toExist().withTimeout(20000);99 await expect(element(by.id('room-view'))).toExist();100 await expect(element(by.id('room-view-header-team-channels'))).toExist();101 await element(by.id('room-view-header-team-channels')).tap();102 await waitFor(element(by.id('team-channels-view'))).toExist().withTimeout(5000);103 await waitFor(element(by.id(`rooms-list-view-item-${ room }`))).toExist().withTimeout(6000);104 await expect(element(by.id(`rooms-list-view-item-${ room }`))).toExist();105 await element(by.id(`rooms-list-view-item-${ room }`)).tap();106 await waitFor(element(by.id(`room-view-title-${ room }`))).toExist().withTimeout(60000);107 await expect(element(by.id(`room-view-title-${ room }`))).toExist();108 await expect(element(by.id('room-view-header-team-channels'))).toExist();109 await expect(element(by.id('room-view-header-threads'))).toExist();110 await expect(element(by.id('room-view-search'))).toExist();111 await tapBack();112 });113 it('should add existing channel to team', async() => {114 await element(by.id('team-channels-view-create')).tap();115 await waitFor(element(by.id('add-channel-team-view'))).toExist().withTimeout(5000);116 await element(by.id('add-channel-team-view-add-existing')).tap();117 await waitFor(element(by.id('add-existing-channel-view'))).toExist().withTimeout(60000);118 await expect(element(by.id(`add-existing-channel-view-item-${ existingRoom }`))).toExist();119 await element(by.id(`add-existing-channel-view-item-${ existingRoom }`)).tap();120 await waitFor(element(by.id('add-existing-channel-view-submit'))).toExist().withTimeout(6000);121 await element(by.id('add-existing-channel-view-submit')).tap();122 await waitFor(element(by.id('room-view'))).toExist().withTimeout(20000);123 await expect(element(by.id('room-view'))).toExist();124 await expect(element(by.id('room-view-header-team-channels'))).toExist();125 await element(by.id('room-view-header-team-channels')).tap();126 await waitFor(element(by.id(`rooms-list-view-item-${ existingRoom }`))).toExist().withTimeout(10000);127 });128 it('should activate/deactivate auto-join to channel', async() => {129 await element(by.id(`rooms-list-view-item-${ existingRoom }`)).atIndex(0).longPress();130 await waitFor(element(by.id('action-sheet-auto-join'))).toBeVisible().withTimeout(5000);131 await waitFor(element(by.id('auto-join-unchecked'))).toBeVisible().withTimeout(5000);132 await waitFor(element(by.id('action-sheet-remove-from-team'))).toBeVisible().withTimeout(5000);133 await waitFor(element(by.id('action-sheet-delete'))).toBeVisible().withTimeout(5000);134 await element(by.id('auto-join-unchecked')).tap();135 await waitFor(element(by.id('auto-join-tag'))).toBeVisible().withTimeout(5000);136 await element(by.id(`rooms-list-view-item-${ existingRoom }`)).atIndex(0).longPress();137 await waitFor(element(by.id('auto-join-checked'))).toBeVisible().withTimeout(5000);138 await element(by.id('auto-join-checked')).tap();139 await waitFor(element(by.id('auto-join-tag'))).toBeNotVisible().withTimeout(5000);140 await waitFor(element(by.id(`rooms-list-view-item-${ existingRoom }`))).toExist().withTimeout(6000);141 });142 });143 describe('Team actions', () => {144 before(async() => {145 await tapBack();146 await navigateToRoomActions();147 });148 it('should add users to the team', async() => {149 await waitFor(element(by.id('room-actions-add-user'))).toExist().withTimeout(10000);150 await element(by.id('room-actions-add-user')).tap();151 const rocketCat = 'rocket.cat';152 await element(by.id('select-users-view-search')).replaceText('rocket.cat');153 await waitFor(element(by.id(`select-users-view-item-${ rocketCat }`))).toExist().withTimeout(10000);154 await element(by.id(`select-users-view-item-${ rocketCat }`)).tap();155 await waitFor(element(by.id(`selected-user-${ rocketCat }`))).toExist().withTimeout(5000);156 await waitFor(element(by.id('select-users-view-search'))).toExist().withTimeout(4000);157 await element(by.id('select-users-view-search')).tap();158 await element(by.id('select-users-view-search')).replaceText(user.username);159 await waitFor(element(by.id(`select-users-view-item-${ user.username }`))).toExist().withTimeout(10000);160 await element(by.id(`select-users-view-item-${ user.username }`)).tap();161 await waitFor(element(by.id(`selected-user-${ user.username }`))).toExist().withTimeout(5000);162 await element(by.id('selected-users-view-submit')).tap();163 await sleep(300);164 await waitFor(element(by.id('room-actions-members'))).toExist().withTimeout(10000);165 await element(by.id('room-actions-members')).tap();166 await element(by.id('room-members-view-toggle-status')).tap();167 await waitFor(element(by.id(`room-members-view-item-${ user.username }`))).toExist().withTimeout(60000);168 await backToActions();169 });170 it('should try to leave to leave team and raise alert', async() => {171 await element(by.id('room-actions-scrollview')).scrollTo('bottom');172 await waitFor(element(by.id('room-actions-leave-channel'))).toExist().withTimeout(2000);173 await element(by.id('room-actions-leave-channel')).tap();174 await waitFor(element(by.id('select-list-view'))).toExist().withTimeout(2000);175 await waitFor(element(by.id(`select-list-view-item-${ room }`))).toExist().withTimeout(2000);176 await waitFor(element(by.id(`select-list-view-item-${ existingRoom }`))).toExist().withTimeout(2000);177 await element(by.id(`select-list-view-item-${ room }`)).tap();178 await waitFor(element(by.label('You are the last owner of this channel. Once you leave the team, the channel will be kept inside the team but you will be managing it from outside.'))).toExist().withTimeout(2000);179 await element(by.text('OK')).tap();180 await waitFor(element(by.id('select-list-view-submit'))).toExist().withTimeout(2000);181 await element(by.id('select-list-view-submit')).tap();182 await waitFor(element(by.text('Last owner cannot be removed'))).toExist().withTimeout(8000);183 await element(by.text('OK')).tap();184 await tapBack();185 await waitFor(element(by.id('room-actions-view'))).toExist().withTimeout(2000);186 });187 describe('Room Members', () => {188 before(async() => {189 await element(by.id('room-actions-members')).tap();190 await waitFor(element(by.id('room-members-view'))).toExist().withTimeout(2000);191 });192 it('should show all users', async() => {193 await element(by.id('room-members-view-toggle-status')).tap();194 await waitFor(element(by.id(`room-members-view-item-${ user.username }`))).toExist().withTimeout(60000);195 });196 it('should filter user', async() => {197 await waitFor(element(by.id(`room-members-view-item-${ user.username }`))).toExist().withTimeout(60000);198 await element(by.id('room-members-view-search')).replaceText('rocket');199 await waitFor(element(by.id(`room-members-view-item-${ user.username }`))).toBeNotVisible().withTimeout(60000);200 await element(by.id('room-members-view-search')).tap();201 await element(by.id('room-members-view-search')).clearText('');202 await waitFor(element(by.id(`room-members-view-item-${ user.username }`))).toExist().withTimeout(60000);203 });204 it('should remove member from team', async() => {205 await openActionSheet('rocket.cat');206 await element(by.id('action-sheet-remove-from-team')).tap();207 await waitFor(element(by.id('select-list-view'))).toExist().withTimeout(5000);208 await waitFor(element(by.id(`select-list-view-item-${ room }`))).toExist().withTimeout(5000);209 await element(by.id(`select-list-view-item-${ room }`)).tap();210 await waitFor(element(by.id(`${ room }-checked`))).toExist().withTimeout(5000);211 await element(by.id(`select-list-view-item-${ room }`)).tap();212 await waitFor(element(by.id(`${ room }-unchecked`))).toExist().withTimeout(5000);213 await element(by.id('select-list-view-submit')).tap();214 await waitFor(element(by.id('room-members-view-item-rocket.cat'))).toBeNotVisible().withTimeout(60000);215 });216 it('should set member as owner', async() => {217 await openActionSheet(user.username);218 await element(by.id('action-sheet-set-owner')).tap();219 await waitForToast();220 await openActionSheet(user.username);221 await waitFor(element(by.id('action-sheet-set-owner-checked'))).toBeVisible().withTimeout(6000);222 await closeActionSheet();223 });224 it('should leave team', async() => {225 await tapBack();226 await element(by.id('room-actions-scrollview')).scrollTo('bottom');227 await waitFor(element(by.id('room-actions-leave-channel'))).toExist().withTimeout(2000);228 await element(by.id('room-actions-leave-channel')).tap();229 await waitFor(element(by.id('select-list-view'))).toExist().withTimeout(2000);230 await waitFor(element(by.id(`select-list-view-item-${ room }`))).toExist().withTimeout(2000);231 await waitFor(element(by.id(`select-list-view-item-${ existingRoom }`))).toExist().withTimeout(2000);232 await element(by.id(`select-list-view-item-${ room }`)).tap();233 await waitFor(element(by.label('You are the last owner of this channel. Once you leave the team, the channel will be kept inside the team but you will be managing it from outside.'))).toExist().withTimeout(2000);234 await element(by.text('OK')).tap();235 await waitFor(element(by.id('select-list-view-submit'))).toExist().withTimeout(2000);236 await element(by.id('select-list-view-submit')).tap();237 await waitFor(element(by.id(`rooms-list-view-item-${ team }`))).toBeNotVisible().withTimeout(60000);238 });239 });240 });241 });...

Full Screen

Full Screen

01-e2eencryption.spec.js

Source:01-e2eencryption.spec.js Github

copy

Full Screen

1const {2 navigateToLogin, login, sleep, tapBack, mockMessage, searchRoom, logout3} = require('../../helpers/app');4const data = require('../../data');5const testuser = data.users.regular;6const otheruser = data.users.alternate;7const checkServer = async(server) => {8 const label = `Connected to ${ server }`;9 await element(by.id('rooms-list-view-sidebar')).tap();10 await waitFor(element(by.id('sidebar-view'))).toBeVisible().withTimeout(2000);11 await waitFor(element(by.label(label))).toBeVisible().withTimeout(60000);12 await element(by.id('sidebar-close-drawer')).tap();13};14const checkBanner = async() => {15 await waitFor(element(by.id('listheader-encryption').withDescendant(by.label('Save Your Encryption Password')))).toBeVisible().withTimeout(10000);16};17async function navigateToRoom(roomName) {18 await searchRoom(`${ roomName }`);19 await element(by.id(`rooms-list-view-item-${ roomName }`)).tap();20 await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(5000);21}22async function waitForToast() {23 await sleep(300);24}25async function navigateSecurityPrivacy() {26 await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(2000);27 await element(by.id('rooms-list-view-sidebar')).tap();28 await waitFor(element(by.id('sidebar-view'))).toBeVisible().withTimeout(2000);29 await waitFor(element(by.id('sidebar-settings'))).toBeVisible().withTimeout(2000);30 await element(by.id('sidebar-settings')).tap();31 await waitFor(element(by.id('settings-view'))).toBeVisible().withTimeout(2000);32 await element(by.id('settings-view-security-privacy')).tap();33 await waitFor(element(by.id('security-privacy-view'))).toBeVisible().withTimeout(2000);34}35describe('E2E Encryption', () => {36 const room = `encrypted${ data.random }`;37 const newPassword = 'abc';38 before(async() => {39 await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });40 await navigateToLogin();41 await login(testuser.username, testuser.password);42 });43 describe('Banner', () => {44 describe('Render', () => {45 it('should have encryption badge', async() => {46 await checkBanner();47 });48 });49 describe('Usage', () => {50 it('should tap encryption badge and open save password modal', async() => {51 await element(by.id('listheader-encryption')).tap();52 await waitFor(element(by.id('e2e-save-password-view'))).toBeVisible().withTimeout(2000);53 });54 it('should tap "How it works" and navigate', async() => {55 await element(by.id('e2e-save-password-view-how-it-works').and(by.label('How It Works'))).tap();56 await waitFor(element(by.id('e2e-how-it-works-view'))).toBeVisible().withTimeout(2000);57 await tapBack();58 });59 it('should tap "Save my password" and close modal', async() => {60 await element(by.id('e2e-save-password-view-saved-password').and(by.label('I Saved My E2E Password'))).tap();61 await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(2000);62 });63 it('should create encrypted room', async() => {64 await element(by.id('rooms-list-view-create-channel')).tap();65 await waitFor(element(by.id('new-message-view'))).toBeVisible().withTimeout(2000);66 await element(by.id('new-message-view-create-channel')).tap();67 await waitFor(element(by.id('select-users-view'))).toBeVisible().withTimeout(2000);68 await element(by.id('select-users-view-search')).replaceText(otheruser.username);69 await waitFor(element(by.id(`select-users-view-item-${ otheruser.username }`))).toBeVisible().withTimeout(60000);70 await element(by.id(`select-users-view-item-${ otheruser.username }`)).tap();71 await waitFor(element(by.id(`selected-user-${ otheruser.username }`))).toBeVisible().withTimeout(5000);72 await element(by.id('selected-users-view-submit')).tap();73 await waitFor(element(by.id('create-channel-view'))).toExist().withTimeout(5000);74 await element(by.id('create-channel-name')).replaceText(room);75 await element(by.id('create-channel-encrypted')).longPress();76 await element(by.id('create-channel-submit')).tap();77 await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(60000);78 await waitFor(element(by.id(`room-view-title-${ room }`))).toBeVisible().withTimeout(60000);79 });80 it('should send message and be able to read it', async() => {81 await mockMessage('message');82 await tapBack();83 });84 });85 });86 describe('Security and Privacy', () => {87 it('should navigate to security privacy', async() => {88 await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(2000);89 await element(by.id('rooms-list-view-sidebar')).tap();90 await waitFor(element(by.id('sidebar-view'))).toBeVisible().withTimeout(2000);91 await waitFor(element(by.id('sidebar-settings'))).toBeVisible().withTimeout(2000);92 await element(by.id('sidebar-settings')).tap();93 await waitFor(element(by.id('settings-view'))).toBeVisible().withTimeout(2000);94 await element(by.id('settings-view-security-privacy')).tap();95 await waitFor(element(by.id('security-privacy-view'))).toBeVisible().withTimeout(2000);96 });97 it('render', async() => {98 await expect(element(by.id('security-privacy-view-e2e-encryption'))).toExist();99 await expect(element(by.id('security-privacy-view-screen-lock'))).toExist();100 await expect(element(by.id('security-privacy-view-analytics-events'))).toExist();101 await expect(element(by.id('security-privacy-view-crash-report'))).toExist();102 });103 });104 describe('E2E Encryption Security', () => {105 it('should navigate to e2e encryption security', async() => {106 await element(by.id('security-privacy-view-e2e-encryption')).tap();107 await waitFor(element(by.id('e2e-encryption-security-view'))).toBeVisible().withTimeout(2000);108 });109 describe('Render', () => {110 it('should have items', async() => {111 await waitFor(element(by.id('e2e-encryption-security-view'))).toBeVisible().withTimeout(2000);112 await expect(element(by.id('e2e-encryption-security-view-password'))).toExist();113 await expect(element(by.id('e2e-encryption-security-view-change-password').and(by.label('Save Changes')))).toExist();114 await expect(element(by.id('e2e-encryption-security-view-reset-key').and(by.label('Reset E2E Key')))).toExist();115 });116 });117 describe('Change password', () => {118 it('should change password', async() => {119 await element(by.id('e2e-encryption-security-view-password')).typeText(newPassword);120 await element(by.id('e2e-encryption-security-view-change-password')).tap();121 await waitFor(element(by.text('Are you sure?'))).toExist().withTimeout(2000);122 await expect(element(by.text('Make sure you\'ve saved it carefully somewhere else.'))).toExist();123 await element(by.label('Yes, change it').and(by.type('_UIAlertControllerActionView'))).tap();124 await waitForToast();125 });126 it('should navigate to the room and messages should remain decrypted', async() => {127 await waitFor(element(by.id('e2e-encryption-security-view'))).toBeVisible().withTimeout(2000);128 await tapBack();129 await waitFor(element(by.id('security-privacy-view'))).toBeVisible().withTimeout(2000);130 await tapBack();131 await waitFor(element(by.id('settings-view'))).toBeVisible().withTimeout(2000);132 await element(by.id('settings-view-drawer')).tap();133 await waitFor(element(by.id('sidebar-view'))).toBeVisible().withTimeout(2000);134 await element(by.id('sidebar-chats')).tap();135 await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(2000);136 await navigateToRoom(room);137 await waitFor(element(by.label(`${ data.random }message`)).atIndex(0)).toExist().withTimeout(2000);138 });139 it('should logout, login and messages should be encrypted', async() => {140 await tapBack();141 await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(2000);142 await logout();143 await navigateToLogin();144 await login(testuser.username, testuser.password);145 await navigateToRoom(room);146 await waitFor(element(by.label(`${ data.random }message`)).atIndex(0)).not.toExist().withTimeout(2000);147 await expect(element(by.label('Encrypted message')).atIndex(0)).toExist();148 });149 it('should enter new e2e password and messages should be decrypted', async() => {150 await tapBack();151 await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(2000);152 await waitFor(element(by.id('listheader-encryption').withDescendant(by.label('Enter Your E2E Password')))).toBeVisible().withTimeout(2000);153 await element(by.id('listheader-encryption').withDescendant(by.label('Enter Your E2E Password'))).tap();154 await waitFor(element(by.id('e2e-enter-your-password-view'))).toBeVisible().withTimeout(2000);155 await element(by.id('e2e-enter-your-password-view-password')).typeText(newPassword);156 await element(by.id('e2e-enter-your-password-view-confirm')).tap();157 await waitFor(element(by.id('listheader-encryption'))).not.toExist().withTimeout(10000);158 await navigateToRoom(room);159 await waitFor(element(by.label(`${ data.random }message`)).atIndex(0)).toExist().withTimeout(2000);160 });161 });162 describe('Reset E2E key', () => {163 it('should reset e2e key', async() => {164 await tapBack();165 await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(2000);166 await navigateSecurityPrivacy();167 await element(by.id('security-privacy-view-e2e-encryption')).tap();168 await waitFor(element(by.id('e2e-encryption-security-view'))).toBeVisible().withTimeout(2000);169 await element(by.id('e2e-encryption-security-view-reset-key').and(by.label('Reset E2E Key'))).tap();170 await waitFor(element(by.text('Are you sure?'))).toExist().withTimeout(2000);171 await expect(element(by.text('You\'re going to be logged out.'))).toExist();172 await element(by.label('Yes, reset it').and(by.type('UILabel'))).tap();173 await sleep(2000);174 await waitFor(element(by.id('workspace-view'))).toBeVisible().withTimeout(10000);175 await waitFor(element(by.text('You\'ve been logged out by the server. Please log in again.'))).toExist().withTimeout(2000);176 await element(by.label('OK').and(by.type('_UIAlertControllerActionView'))).tap();177 await element(by.id('workspace-view-login')).tap();178 await waitFor(element(by.id('login-view'))).toBeVisible().withTimeout(2000);179 await login(testuser.username, testuser.password);180 await waitFor(element(by.id('listheader-encryption').withDescendant(by.label('Save Your Encryption Password')))).toBeVisible().withTimeout(2000);181 });182 });183 });184 describe('Persist Banner', () => {185 it('check save banner', async() => {186 await checkServer(data.server);187 await checkBanner();188 });189 it('should add server and create new user', async() => {190 await sleep(5000);191 await element(by.id('rooms-list-header-server-dropdown-button')).tap();192 await waitFor(element(by.id('rooms-list-header-server-dropdown'))).toBeVisible().withTimeout(5000);193 await element(by.id('rooms-list-header-server-add')).tap();194 // TODO: refactor195 await waitFor(element(by.id('new-server-view'))).toBeVisible().withTimeout(60000);196 await element(by.id('new-server-view-input')).typeText(`${ data.alternateServer }\n`);197 await waitFor(element(by.id('workspace-view'))).toBeVisible().withTimeout(60000);198 await element(by.id('workspace-view-register')).tap();199 await waitFor(element(by.id('register-view'))).toBeVisible().withTimeout(2000);200 // Register new user201 await element(by.id('register-view-name')).replaceText(data.registeringUser.username);202 await element(by.id('register-view-username')).replaceText(data.registeringUser.username);203 await element(by.id('register-view-email')).replaceText(data.registeringUser.email);204 await element(by.id('register-view-password')).typeText(data.registeringUser.password);205 await element(by.id('register-view-submit')).tap();206 await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(60000);207 await checkServer(data.alternateServer);208 });209 it('should change back', async() => {210 await element(by.id('rooms-list-header-server-dropdown-button')).tap();211 await waitFor(element(by.id('rooms-list-header-server-dropdown'))).toBeVisible().withTimeout(5000);212 await element(by.id(`rooms-list-header-server-${ data.server }`)).tap();213 await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(10000);214 await checkServer(data.server);215 await checkBanner();216 });217 it('should reopen the app and have banner', async() => {218 await device.launchApp({219 permissions: { notifications: 'YES' },220 newInstance: true221 });222 await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(10000);223 await checkBanner();224 });225 });...

Full Screen

Full Screen

4_my.js

Source:4_my.js Github

copy

Full Screen

1// import { View, Text, StyleSheet, TouchableOpacity, Platform, ScrollView, AlertIOS, Image, Linking } from "react-native";2//生成随机手机号3function getMobile() {4 var prefixArray = new Array("130", "131", "132", "133", "135", "137", "138", "170", "187", "185", "189");5 var i = parseInt(10 * Math.random());6 var prefix = prefixArray[i];7 for (var j = 0; j < 8; j++) {8 prefix = prefix + Math.floor(Math.random() * 10);9 }10 return prefix;11}12describe('我的', () => {13 beforeEach(async () => {14 await device.reloadReactNative();15 await waitFor(element(by.id('myTab_PersonScreen'))).toBeVisible().withTimeout(10000);16 await element(by.id('myTab_PersonScreen')).tap();17 });18 it('消息通知', async () => {19 await waitFor(element(by.id('message_PageHeader'))).toBeVisible().withTimeout(10000);20 await element(by.id('message_PageHeader')).tap();21 await expect(element(by.id('messageDetail_MessageNotifyScreen'))).toBeVisible();22 // ?验证逻辑23 });24 it('设置', async () => {25 await waitFor(element(by.id('setting_PageHeader'))).toBeVisible().withTimeout(10000);26 await element(by.id('setting_PageHeader')).tap();27 await expect(element(by.text('编辑个人资料'))).toBeVisible();28 // //编辑个人资料29 await waitFor(element(by.text('编辑个人资料'))).toBeVisible().withTimeout(10000);30 await element(by.text('编辑个人资料')).tap();31 // ?更换头像,定位相册元素32 await waitFor(element(by.id('changeImage_EditUserBaseInfoScreen'))).toBeVisible().withTimeout(10000);33 await element(by.id('changeImage_EditUserBaseInfoScreen')).tap();34 await waitFor(element(by.id('openImageSelection_EditUserbaseInfoScreen'))).toBeVisible().withTimeout(10000);35 await element(by.id('openImageSelection_EditUserbaseInfoScreen')).tap();36 // 编辑资料中的其他item已在我的履历编辑-基本信息实现37 // ?保存按钮定位38 // //身份管理39 await waitFor(element(by.text('身份管理'))).toBeVisible().withTimeout(10000);40 await element(by.text('身份管理')).tap();41 await expect(element(by.text('温馨提示'))).toBeVisible();42 await element(by.id('selectNor_IdentifyManageList')).tap();43 // ?验证逻辑44 // 返回按钮45 // //账号与安全46 await waitFor(element(by.text('账号与安全'))).toBeVisible().withTimeout(10000);47 await element(by.text('账号与安全')).tap();48 // 手机号码49 await waitFor(element(by.text('手机号码'))).toBeVisible().withTimeout(10000);50 await element(by.text('手机号码')).tap();51 await waitFor(element(by.id('setPwd_PhoneManageScreen'))).toBeVisible().withTimeout(10000);52 await element(by.id('setPwd_PhoneManageScreen')).tap();53 await waitFor(element(by.id('inputCode_SetPasswordScreen'))).toBeVisible().withTimeout(10000);54 await element(by.id('inputCode_SetPasswordScreen')).replaceText(Math.random().toString().slice(-4));55 await element(by.id('inputPassword_SetPasswordScreen')).replaceText('123456');56 await element(by.id('confirm_SetPasswordScreen')).tap();57 // 更换手机号58 await waitFor(element(by.id('changePhone_PhoneManageScreen'))).toBeVisible().withTimeout(10000);59 await element(by.id('changePhone_PhoneManageScreen')).tap();60 await waitFor(element(by.id('inputNewPhone_ChangePhoneScreen'))).toBeVisible().withTimeout(10000);61 await element(by.id('inputNewPhone_ChangePhoneScreen')).replaceText('13812345678');62 await element(by.id('inputMsgCode_ChangePhoneScreen')).replaceText(Math.random().toString().slice(-4));63 await element(by.id('confirm_ChangePhoneScreen')).tap();64 // ?微信测试65 // //隐私设置66 await element(by.traits(['button']).and(by.label('Back'))).tap();67 await element(by.traits(['button']).and(by.label('Back'))).tap();68 await waitFor(element(by.text('隐私设置'))).toBeVisible().withTimeout(10000);69 await element(by.text('隐私设置')).tap();70 // ?switch按钮定位,验证逻辑71 // //关于72 await element(by.traits(['button']).and(by.label('Back'))).tap();73 await waitFor(element(by.text('关于'))).toBeVisible().withTimeout(10000);74 await element(by.text('关于')).tap();75 await waitFor(element(by.text('版本说明'))).toBeVisible().withTimeout(10000);76 await element(by.text('版本说明')).tap();77 await expect(element(by.text('updateText_AboutVersionScreen'))).toBeVisible();78 await element(by.traits(['button']).and(by.label('Back'))).tap();79 await waitFor(element(by.text('去评分'))).toBeVisible().withTimeout(10000);80 await element(by.text('去评分')).tap();81 await expect(Linking.openURL("http://shandudata.com/"));82 await waitFor(element(by.text('服务协议'))).toBeVisible().withTimeout(10000);83 await element(by.text('服务协议')).tap();84 await waitFor(element(by.id('service_TosScreen'))).toBeVisible().withTimeout(10000);85 await element(by.id('service_TosScreen')).scrollTo('bottom');86 await expect(element(by.text('解释本条款'))).toBeVisible();87 await element(by.traits(['button']).and(by.label('Back'))).tap();88 await element(by.traits(['button']).and(by.label('Back'))).tap();89 // //退出当前账号90 await waitFor(element(by.id('exitAccount_UserSettingForm'))).toBeVisible().withTimeout(10000);91 await element(by.id('exitAccount_UserSettingForm')).tap();92 await waitFor(element(by.text('确定'))).toBeVisible().withTimeout(10000);93 await element(by.text('确定')).tap();94 await expect(element(by.id('loginPhone_LoginMainScreen'))).toBeVisible();95 });96 it('我的主页', async () => {97 await waitFor(element(by.id('gotoMyPage_PersonMainTOp'))).toBeVisible().withTimeout(10000);98 await element(by.id('gotoMyPage_PersonMainTOp')).tap();99 // 发布动态,?右上角发布按钮100 // 101 // 102 await waitFor(element(by.id('content_PostTrends'))).toBeVisible().withTimeout(10000);103 await element(by.id('content_PostTrends')).replaceText(Math.random().toString().slice(-6));104 await element(by.id('takePhoto_SDTakePhoto')).tap();105 // 定位相册元素106 // 关注107 await waitFor(element(by.text('关注'))).toBeVisible().withTimeout(10000);108 await element(by.text('关注')).tap();109 await expect(element(by.text('我的关注'))).toBeVisible();110 await element(by.traits(['button']).and(by.label('Back'))).tap();111 // 粉丝112 await waitFor(element(by.text('粉丝'))).toBeVisible().withTimeout(10000);113 await element(by.text('粉丝')).tap();114 await expect(element(by.text('我的粉丝'))).toBeVisible();115 await element(by.traits(['button']).and(by.label('Back'))).tap();116 // 动态117 await waitFor(element(by.text('动态'))).toBeVisible().withTimeout(10000);118 await element(by.text('动态')).tap();119 await element(by.text('完成')).scrollTo('bottom');120 // 所获证书121 });122 it('我的关注', async () => {123 await waitFor(element(by.id('myFallow_PersonMainTop'))).toBeVisible().withTimeout(10000);124 await element(by.id('myFallow_PersonMainTop')).tap();125 await expect(element(by.text('我的关注'))).toBeVisible();126 // ?关注用户的定位127 });128 it('我的粉丝', async () => {129 await waitFor(element(by.id('myFans_PersonMainTop'))).toBeVisible().withTimeout(10000);130 await element(by.id('myFans_PersonMainTop')).tap();131 await expect(element(by.text('我的粉丝'))).toBeVisible();132 // ?粉丝用户的定位133 });134 it('我的履历', async () => {135 await waitFor(element(by.id('myResume_MainPageButton'))).toBeVisible().withTimeout(10000);136 await element(by.id('myResume_MainPageButton')).tap();137 await expect(element(by.id('viewShot_TrackRecordScreen'))).toBeVisible();138 });139 it('我的收藏', async () => {140 await waitFor(element(by.id('myCollection_MainPageButton'))).toBeVisible().withTimeout(10000);141 await element(by.id('myCollection_MainPageButton')).tap();142 // ?内容/数据报告 收藏数量验证逻辑143 await expect(element(by.id('viewShot_TrackRecordScreen'))).toBeVisible();144 await waitFor(element(by.text('管理'))).toBeVisible().withTimeout(10000);145 await element(by.text('管理')).tap();146 // 点选item147 await element(by.text('删除')).tap();148 await waitFor(element(by.text('确定'))).toBeVisible().withTimeout(10000);149 await element(by.text('确定')).tap();150 await expect(element(by.id('viewShot_TrackRecordScreen'))).toBeVisible();151 });152 it('我的职通力', async () => {153 await waitFor(element(by.text('我的职通力'))).toBeVisible().withTimeout(10000);154 await element(by.text('我的职通力')).tap();155 await expect(element(by.text('职通力成长趋势'))).toBeVisible();156 });157 it('帮助中心', async () => {158 await waitFor(element(by.text('帮助中心'))).toBeVisible().withTimeout(10000);159 await element(by.text('帮助中心')).tap();160 await waitFor(element(by.text('什么是职通力'))).toBeVisible().withTimeout(10000);161 await element(by.text('什么是职通力')).tap();162 await waitFor(element(by.text('关闭'))).toBeVisible().withTimeout(10000);163 await element(by.text('关闭')).tap();164 await expect(element(by.text('什么是职通力'))).toBeVisible();165 });166 it('分享给好友', async () => {167 // 微信缺失168 });169 it('意见反馈', async () => {170 await waitFor(element(by.text('意见反馈'))).toBeVisible().withTimeout(10000);171 await element(by.text('意见反馈')).tap();172 await waitFor(element(by.id('suggestContent_FeedBackForm'))).toBeVisible().withTimeout(10000);173 await element(by.text('故障错误')).tap();174 await element(by.id('suggestContent_FeedBackForm')).replaceText(Math.random().toString().slice(-6));175 await element(by.id('contactInfo_FeedBackForm')).replaceText(getMobile());176 // 验证复制逻辑177 await element(by.id('copyGroup_FeedBackScreen')).tap();178 await element(by.id('submit_FeedBackForm')).tap();179 await expect(element(by.text('意见反馈'))).toBeVisible();180 });...

Full Screen

Full Screen

09-jumptomessage.spec.js

Source:09-jumptomessage.spec.js Github

copy

Full Screen

1const data = require('../../data');2const {3 navigateToLogin, tapBack, login, searchRoom4} = require('../../helpers/app');5async function navigateToRoom(roomName) {6 await searchRoom(`${ roomName }`);7 await element(by.id(`rooms-list-view-item-${ roomName }`)).tap();8 await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(5000);9}10async function clearCache() {11 await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(5000);12 await tapBack();13 await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(10000);14 await element(by.id('rooms-list-view-sidebar')).tap();15 await waitFor(element(by.id('sidebar-view'))).toBeVisible().withTimeout(2000);16 await element(by.id('sidebar-settings')).tap();17 await waitFor(element(by.id('settings-view'))).toBeVisible().withTimeout(2000);18 await element(by.id('settings-view-clear-cache')).tap();19 await waitFor(element(by.text('This will clear all your offline data.'))).toExist().withTimeout(2000);20 await element(by.label('Clear').and(by.type('_UIAlertControllerActionView'))).tap();21 await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(5000);22 await waitFor(element(by.id('rooms-list-view-item-jumping'))).toExist().withTimeout(10000);23}24async function waitForLoading() {25 await waitFor(element(by.id('loading'))).toBeVisible().withTimeout(5000);26 await waitFor(element(by.id('loading'))).toBeNotVisible().withTimeout(10000);27}28describe('Room', () => {29 before(async() => {30 await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });31 await navigateToLogin();32 await login(data.adminUser, data.adminPassword);33 });34 it('should jump to an old message and load its surroundings', async() => {35 await navigateToRoom('jumping');36 await waitFor(element(by.label('Quote first message'))).toExist().withTimeout(5000);37 await element(by.label('1')).atIndex(0).tap();38 await waitForLoading();39 await waitFor(element(by.label('1')).atIndex(0)).toExist().withTimeout(10000);40 await expect(element(by.label('2'))).toExist();41 });42 it('should tap FAB and scroll to bottom', async() => {43 await waitFor(element(by.id('nav-jump-to-bottom'))).toExist().withTimeout(5000);44 await element(by.id('nav-jump-to-bottom')).tap();45 await waitFor(element(by.label('Quote first message'))).toExist().withTimeout(5000);46 await clearCache();47 });48 it('should load messages on scroll', async() => {49 await navigateToRoom('jumping');50 await waitFor(element(by.id('room-view-messages'))).toExist().withTimeout(5000);51 await waitFor(element(by.label('300'))).toExist().withTimeout(5000);52 let found = false;53 while (!found) {54 await element(by.id('room-view-messages')).atIndex(0).scroll(500, 'up');55 try {56 await expect(element(by.label('249'))).toExist();57 found = true;58 } catch {59 //60 }61 }62 await clearCache();63 });64 it('should search for old message and load its surroundings', async() => {65 await navigateToRoom('jumping');66 await element(by.id('room-view-search')).tap();67 await waitFor(element(by.id('search-messages-view'))).toExist().withTimeout(5000);68 await element(by.id('search-message-view-input')).typeText('30\n');69 await waitFor(element(by.label('30')).atIndex(0)).toExist().withTimeout(5000);70 await element(by.label('30')).atIndex(0).tap();71 await waitForLoading();72 await expect(element(by.label('30'))).toExist();73 await expect(element(by.label('31'))).toExist();74 await expect(element(by.label('32'))).toExist();75 });76 it('should load newer and older messages', async() => {77 await element(by.id('room-view-messages')).atIndex(0).swipe('down', 'fast', 0.8);78 await waitFor(element(by.label('5'))).toExist().withTimeout(10000);79 await waitFor(element(by.label('Load Older'))).toExist().withTimeout(5000);80 await element(by.label('Load Older')).atIndex(0).tap();81 await waitFor(element(by.label('4'))).toExist().withTimeout(5000);82 await element(by.id('room-view-messages')).atIndex(0).swipe('down', 'fast', 0.5);83 await waitFor(element(by.label('1'))).toExist().withTimeout(5000);84 await element(by.id('room-view-messages')).atIndex(0).swipe('up', 'fast', 0.5);85 await waitFor(element(by.label('25'))).toExist().withTimeout(5000);86 await element(by.id('room-view-messages')).atIndex(0).swipe('up', 'fast', 0.5);87 await waitFor(element(by.label('50'))).toExist().withTimeout(5000);88 await element(by.id('room-view-messages')).atIndex(0).swipe('up', 'slow', 0.5);89 await waitFor(element(by.label('Load Newer'))).toExist().withTimeout(5000);90 await element(by.label('Load Newer')).atIndex(0).tap();91 await waitFor(element(by.label('104'))).toExist().withTimeout(5000);92 await waitFor(element(by.label('Load Newer'))).toExist().withTimeout(5000);93 await element(by.label('Load Newer')).atIndex(0).tap();94 await waitFor(element(by.label('154'))).toExist().withTimeout(5000);95 await waitFor(element(by.label('Load Newer'))).toExist().withTimeout(5000);96 await element(by.label('Load Newer')).atIndex(0).tap();97 await waitFor(element(by.label('Load Newer'))).toNotExist().withTimeout(5000);98 await expect(element(by.label('Load More'))).toNotExist();99 await expect(element(by.label('201'))).toExist();100 await expect(element(by.label('202'))).toExist();101 await tapBack();102 });103});104const expectThreadMessages = async(message) => {105 await waitFor(element(by.id('room-view-title-jumping-thread'))).toExist().withTimeout(5000);106 await expect(element(by.label(message))).toExist();107};108describe('Threads', () => {109 it('should navigate to a thread from another room', async() => {110 await navigateToRoom('jumping');111 await waitFor(element(by.label('Go to jumping-thread\'s thread')).atIndex(0)).toExist().withTimeout(5000);112 await element(by.label('Go to jumping-thread\'s thread')).atIndex(0).tap();113 await waitForLoading();114 await expectThreadMessages('Go to jumping-thread\'s thread');115 await tapBack();116 });117 it('should tap on thread message from main room', async() => {118 await waitFor(element(by.label('thread message sent to main room')).atIndex(0)).toExist().withTimeout(5000);119 await element(by.label('thread message sent to main room')).atIndex(0).tap();120 await expectThreadMessages('thread message sent to main room');121 await tapBack();122 });123 it('should tap on quote', async() => {124 await waitFor(element(by.label('quoted'))).toExist().withTimeout(5000);125 await element(by.label('quoted')).atIndex(0).tap();126 await expectThreadMessages('quoted');127 await tapBack();128 });129 it('should jump from search message', async() => {130 await waitFor(element(by.id('room-view-title-jumping-thread'))).toExist().withTimeout(5000);131 await element(by.id('room-view-search')).atIndex(0).tap();132 await waitFor(element(by.id('search-messages-view'))).toExist().withTimeout(5000);133 await element(by.id('search-message-view-input')).typeText('to be searched\n');134 await waitFor(element(by.label('to be searched'))).toExist().withTimeout(5000);135 await element(by.label('to be searched')).atIndex(1).tap();136 await expectThreadMessages('to be searched');137 });138 // TODO: Threads pagination...

Full Screen

Full Screen

3_rank.js

Source:3_rank.js Github

copy

Full Screen

1describe('排名', () => {2 beforeEach(async () => {3 await device.reloadReactNative();4 await waitFor(element(by.id('rankTab_RankScreen'))).toBeVisible().withTimeout(10000);5 await element(by.id('rankTab_RankScreen')).tap();6 });7 //// 关注榜8 it('登峰榜—关注榜', async () => {9 // 切换城市10 await waitFor(element(by.id('getCity_RankTabOne'))).toBeVisible().withTimeout(10000);11 await element(by.id('getCity_RankTabOne')).tap();12 await waitFor(element(by.text('北京市'))).toBeVisible().withTimeout(10000);13 await element(by.text('北京市')).tap();14 await expect(element(by.id('content_ScoreText'))).toHaveText('北京');15 // 同类院校排名16 await waitFor(element(by.text('关注榜'))).toBeVisible().withTimeout(10000);17 await element(by.text('关注榜')).tap();18 await waitFor(element(by.text('同类院校排名'))).toBeVisible().withTimeout(10000);19 await element(by.text('同类院校排名')).tap();20 await expect(element(by.id('content_ScoreText'))).toHaveText('211');21 // 本校排名22 await waitFor(element(by.text('同类院校排名'))).toBeVisible().withTimeout(10000);23 await element(by.text('同类院校排名')).tap();24 await waitFor(element(by.text('本校排名'))).toBeVisible().withTimeout(10000);25 await element(by.text('本校排名')).tap();26 await expect(element(by.id('content_ScoreText'))).toHaveText('北京航空');27 // 同类专业排名28 await waitFor(element(by.text('本校排名'))).toBeVisible().withTimeout(10000);29 await element(by.text('本校排名')).tap();30 await waitFor(element(by.text('同类专业排名'))).toBeVisible().withTimeout(10000);31 await element(by.text('同类专业排名')).tap();32 await expect(element(by.id('content_ScoreText'))).toHaveText('计算机类');33 // 本专业排名34 await waitFor(element(by.text('同类专业排名'))).toBeVisible().withTimeout(10000);35 await element(by.text('同类专业排名')).tap();36 await waitFor(element(by.text('本专业排名'))).toBeVisible().withTimeout(10000);37 await element(by.text('本专业排名')).tap();38 await expect(element(by.id('content_ScoreText'))).toHaveText('计算机科学');39 });40 it('登峰榜—TOP榜', async () => {41 await waitFor(element(by.text('关注榜'))).toBeVisible().withTimeout(10000);42 await element(by.text('关注榜')).scrollTo('bottom');43 await waitFor(element(by.text('努力'))).toBeVisible().withTimeout(10000);44 await element(by.text('努力')).scrollTo('bottom');45 // ? 个人主页46 // ?userlistItem定位47 });48 it('登峰榜—我的位次', async () => {49 await waitFor(element(by.text('关注榜'))).toBeVisible().withTimeout(10000);50 await element(by.text('关注榜')).scrollTo('bottom');51 await waitFor(element(by.text('登顶'))).toBeVisible().withTimeout(10000);52 await element(by.text('登顶')).scrollTo('bottom');53 // ? 个人主页54 // ?userlistItem定位55 });56 it('关注榜—发现动态', async () => {57 await waitFor(element(by.text('关注榜'))).toBeVisible().withTimeout(10000);58 await element(by.text('关注榜')).tap();59 await waitFor(element(by.id('findEvent_RankTabTwo'))).toBeVisible().withTimeout(10000);60 await element(by.id('findEvent_RankTabTwo')).tap();61 await expect(element(by.text('关注动态'))).toBeVisible();62 });63 it('关注榜—排名', async () => {64 await waitFor(element(by.text('关注榜'))).toBeVisible().withTimeout(10000);65 await element(by.text('关注榜')).tap();66 await waitFor(element(by.id('findEvent_RankTabTwo'))).toBeVisible().withTimeout(10000);67 await element(by.id('findEvent_RankTabTwo')).scrollTo('bottom');68 // ?我已领先69 });70 it('进步榜—排名', async () => {71 await waitFor(element(by.text('进步榜'))).toBeVisible().withTimeout(10000);72 await element(by.text('进步榜')).tap();73 await waitFor(element(by.text('我'))).toBeVisible().withTimeout(10000);74 await element(by.text('我')).scrollTo('bottom');75 // ?验证逻辑76 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import { WithTimeout } from 'storybook-root-provider';2export default class TestComponent extends Component {3 constructor(props) {4 super(props);5 this.state = {6 };7 }8 componentDidMount() {9 WithTimeout(() => {10 this.setState({ show: false });11 }, 2000);12 }13 render() {14 return (15 {this.state.show ? <div>Test Component</div> : null}16 );17 }18}19import React from 'react';20import { storiesOf } from '@storybook/react';21import { withRootProvider } from 'storybook-root-provider';22import TestComponent from '../test';23storiesOf('Test', module)24 .addDecorator(withRootProvider())25 .add('Test Component', () => <TestComponent />);26import { configure, addDecorator } from '@storybook/react';27import { withRootProvider } from 'storybook-root-provider';28import { setOptions } from '@storybook/addon-options';29import { setDefaults } from '@storybook/addon-info';30import { withInfo } from '@storybook/addon-info';31import { setDefaults as setA11yDefaults } from '@storybook/addon-a11y';32import { configureViewport } from '@storybook/addon-viewport';33setOptions({

Full Screen

Using AI Code Generation

copy

Full Screen

1import { WithTimeout } from 'storybook-root-provider';2const MyComponent = () => {3 const [timeout, setTimeout] = useState(false);4 useEffect(() => {5 WithTimeout(() => {6 setTimeout(true);7 }, 2000);8 }, []);9 return (10 {timeout ? <div>Timeout</div> : <div>Not Timeout</div>}11 );12};13export default MyComponent;14import { addDecorator } from '@storybook/react';15import { RootProvider } from 'storybook-root-provider';16addDecorator(RootProvider);17import { addDecorator } from '@storybook/react';18import { RootProvider } from 'storybook-root-provider';19addDecorator(RootProvider);20import { addDecorator } from '@storybook/react';21import { RootProvider } from 'storybook-root-provider';22addDecorator(RootProvider);23import { addDecorator } from '@storybook/react';24import { RootProvider } from 'storybook-root-provider';25addDecorator(RootProvider);26import { addDecorator } from '@storybook/react';27import { RootProvider } from 'storybook-root-provider';28addDecorator(RootProvider);29import { addDecorator } from '@storybook/react';30import { RootProvider } from 'storybook-root-provider';31addDecorator(RootProvider);32module.exports = {33 stories: ['../src/**/*.stories.@(js|jsx|ts|tsx|mdx)'],

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run storybook-root automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful