How to use describeID method in Playwright Internal

Best JavaScript code snippet using playwright-internal

edit.js

Source:edit.js Github

copy

Full Screen

1require.config(config);2require(["jquery","validate","base","animation","pager","layer","select2","city.select"],function($,validate,base,animation,pager,layer,select2){3/* var attachmentIds = $("#attachmentIds").val();4 var option = {5 is_shade: true,6 real_delete: false,7 file_ids: attachmentIds,8 multi_selection: true,9 max_file_size: "20mb",10 prevent_duplicates: true,11 mime_types: "",12 upload_index:113 }*/14 function changeUpload(id,index){15 var option = {16 is_shade: true,17 real_delete: false,18 file_ids: id,19 multi_selection: true,20 max_file_size: "20mb",21 prevent_duplicates: true,22 mime_types: "",23 upload_index:index24 }25 return option;26 }2728 //省份数据29 var data=[{id:1000,name:"中盐"},{id:1100,name:"北京市"},{id:1200,name:"天津市"},{id:13,name:"河北省"},{id:1400,name:"山西省"},{id:1500,name:"内蒙古自治区"},{id:2100,name:"辽宁省"},{id:2200,name:"吉林省"},{id:2300,name:"黑龙江省"},{id:3100,name:"上海市"},{id:3200,name:"江苏省"},{id:3300,name:"浙江省"},{id:3400,name:"安徽省"},{id:3500,name:"福建"},{id:3600,name:"江西省"},{id:3700,name:"山东省"},{id:4100,name:"河南省"},{id:4200,name:"湖北省"},{id:4300,name:"湖南"},{id:4400,name:"广东省"},{id:4500,name:"广西壮族自治区"},{id:4600,name:"海南省"},{id:5000,name:"重庆"},{id:5100,name:"四川"},{id:5200,name:"贵州省"},{id:5300,name:"云南省"},{id:5400,name:"西藏自治区"},{id:6100,name:"陕西省"},{id:6200,name:"甘肃省"},{id:6300,name:"青海省"},{id:6400,name:"宁夏回族自治区"},{id:6500,name:"新疆维吾尔自治区"},{id:7100,name:"台湾省"},{id:81,name:"香港特别行政区"},{id:8200,name:"澳门特别行政区"}];30 function save(){31 var flag = true;32 var describeId=getFileIds(1).join(',');33 if(describeId==""){34 flag = false;35 /*layer.open({36 content: "请上传:质检报告(第三方检测报告)附件",37 scrollbar: false38 });*/39// return false;40 $("#describeId").val("");41 $("#describeId").show();42 }else{43 $("#describeId").val(describeId);44 $("#describeId").hide();45 };46 47 var qualityReportId=getFileIds(3).join(',');48 if(qualityReportId==""){49 flag = false;50 /*layer.open({51 content: "请上传:质检报告(第三方检测报告)附件",52 scrollbar: false53 });*/54// return false;55 $("#qualityReportId").val("");56 $("#qualityReportId").show();57 }else{58 $("#qualityReportId").val(qualityReportId);59 $("#qualityReportId").hide();60 };61 var standardFileId=getFileIds(4).join(',');62 if(standardFileId==""){63 flag = false;64 /*layer.open({65 content: "请上传:执行标准文件附件",66 scrollbar: false67 });*/68// return false;69 $("#standardFileId").val("");70 $("#standardFileId").show();71 }else{72 $("#standardFileId").val(standardFileId);73 $("#standardFileId").hide();74 };75 76 $(".form-list [name]").each(function() {77 if(!checkForm($(this))){78 $(this).focus();79 flag = false;80 return false;81 }82 });83 /*if($("#naturalParent[name='naturalParent']").find("option:selected").val()=="0"){84 flag = false;85 layer.open({86 content: "请选择食盐种类",87 scrollbar: false88 });89 return false;90 };91 if($("#naturalchild[name='naturalchild']").find("option:selected").val()=="1"){92 flag = false;93 layer.open({94 content: "请选择/新增食盐名称",95 scrollbar: false96 });97 return false;98 };*/99 100 if(flag){101 base.processStatus(1,'save','process_btn');102 var saltName = $("#saltName").val(); //食盐名称103 var remark = $("#remark").val(); //产品编号104 var remark2 = $("#remark2").val(); //产品主键ID105 var describeInfo = $("#describeInfo").val(); //食盐外观图案描述106 var cartonPackInfo = $("#cartonPackInfo").val(); //纸箱包装的样式描述107 var recognitionInfo = $("#recognitionInfo").val(); //防伪识别方法108 var productId = $("#productId").val(); //食盐产品生产标准109 var tradeMark = $("#tradeMark").val(); //产品商标110 var standard = $("#standard").val(); //执行标准111 112 //产品库需要字段113 var categoryId = $("#naturalParent[name='naturalParent']").find("option:selected").val();//产品库ID114 var nameNO=$("#naturalParent[name='naturalParent']").find("option:selected").attr("name");//产品库编号115 var province=$("#province[name='province']").find("option:selected").attr("name");//产品库编号116 var provinceName=$("#province[name='province']").find("option:selected").text();//产品库编号117 //end118 var saltNameChild="";119 if($("#saltNameChild")){120 saltNameChild = $("#saltNameChild").val();121 }122 var id=$("#id").val();123 if(id==null || id==""){124 id=""125 } 126 var describeId = getFileIds(1).join(','); //食盐外观图案Id集合127 var cartonPackId = getFileIds(2).join(','); //纸箱包装的样式Id集合128 var qualityReportId = getFileIds(3).join(','); //检验报告Id集合129 var standardFile = getFileIds(4).join(','); //执行标准文件Id集合130 var tradeFile = getFileIds(5).join(','); //产品商标文件131 var formDate = {132 id:id,//主键id133 saltName:saltName, //名称134 province:province, //省份编号135 provinceName:provinceName,136 saltNameChild:saltNameChild,137 remark:remark, //产品编号138 remark2:remark2, //产品主键ID139 categoryId:categoryId,140 nameNO:nameNO,141 describeInfo:describeInfo, //规格142 cartonPackInfo:cartonPackInfo, //品质等级143 recognitionInfo:recognitionInfo, //产品标准号144 describeId:describeId, //食盐定点生产证号145 cartonPackId:cartonPackId,//产地146 qualityReportId:qualityReportId, //有效期(从)147 productId:productId,148 productMark:"",149 tradeMark:tradeMark,150 standard:standard,151 standardFile:standardFile,152 tradeFile:tradeFile153 }154 var url = "/natural/save";155 $.ajax({156 url:url,157 data: {natural:JSON.stringify(formDate)},158 type: 'POST',159 dataType: "json",160 success: function(data) {161 if(data.result==1){162 layer.msg('操作成功', {163 icon: 1164 });165 //layer.close(index);166 jumbto("/natural/naturalindex");167 }else if(data.result==2){168 layer.msg('登录超时,请退出重新登录!', {169 icon: 1170 });171 }else{172 layer.msg('操作失败', {173 icon: 1174 });175 }176 177 },error:function(){178 layer.msg('操作失败', {179 icon: 2180 });181 base.processStatus(0,'save','process_btn');182 }183 184 });185 /*$.post(url,post,function(result){186 if(result=="success"){187 layer.msg('操作成功', {188 icon: 1189 });190 window.location.href="/prodlib/index"; 191 }else if(result=="error"){192 layer.msg('操作失败', {193 icon: 2194 });195 }196 base.processStatus(0,'save','process_btn');197 });*/198 }199 }200 201 $(function() {202 var id1 = $("#describeId").val();203 var id2 = $("#cartonPackId").val();204 var id3 = $("#qualityReportId").val();205 var id4 = $("#standardFile").val();206 var id5 = $("#tradeFile").val();207 $("#uploadDiv").load("/doc/index", changeUpload(id1,1));208 //option.upload_index=2;209 $("#uploadDiv2").load("/doc/index", changeUpload(id2,2));210 //option.upload_index=3;211 $("#uploadDiv3").load("/doc/index", changeUpload(id3,3));212 //option.upload_index=4;213 $("#uploadDiv4").load("/doc/index", changeUpload(id4,4));214 //option.upload_index=5;215 $("#uploadDiv5").load("/doc/index", changeUpload(id5,5));216 217 218 219 $(".form-list").on("blur", "input", function(){220 checkForm($(this));221 });222 223 224 /**225 * 省市初始化226 */227 $("#province").citylist({228 data: data,229 id: "id",230 name: 'name',231 metaTag: 'name',232 selected:$("#province").attr("provinceId")//$("#province").attr("provinceId")233 });234 235 236 function cityChange(province){237 var provCity="";238 if(province){239 for(var i=0,len=data.length;i<len;i++){240 var provinceObj=data[i];241 if(province==provinceObj["name"]){242 provCity=provinceObj["id"];243 }244 }245 }246 return provCity;247 }248 var provinceId=$("#province").attr("provinceId");249 if(provinceId!=""){250 var id = cityChange(provinceId);251 $("#province").find("option[name='"+id+"']").attr("selected","selected");252 }253 254 //编辑状态初始化食盐名称列表255 var nameno=$("#naturalParent[name='naturalParent']").val();256 if(nameno!="请选择" && nameno!=""){257 var province =$("#province[name='province']").find("option:selected").attr("name");258 var nameNO=$("#naturalParent[name='naturalParent']").find("option:selected").attr("name");259 var value;260 $.ajax({261 url: '/natural/caregary',262 type: "post",263 cache: false,264 data: {265 "nameNo": province+nameNO266 },267 dataType: "json",268 success: function(data) {269 if(data.status == 0) {270 $('#naturalchild[name="naturalchild"]').val("");271 var saltName = $("#naturalchild").attr("saltNameId");272 var naturalchild = data.naturalchild;273 var html;274 for(var i=0 ; i<naturalchild.length;i++){275 var name=naturalchild[i].name276 var id=naturalchild[i].id277 var nameNo=naturalchild[i].nameNo278 html+="<option value='"+id+"' name='"+nameNo+"'>"+name+"</option>";279 if(saltName==name){280 value=id;281 }282 }283 if($('#naturalParent[name="naturalParent"]').val()==""){284 var option="<option value=''>请选择</option>"285 }else{286 html+="<option value='0'>新增</option>"287 var option="<option value=''>请选择</option>"288 }289 $("#naturalchild").html(option+html).val(value);290 $("#naturalchild").select2();291 /* var obj=getLastSelect();292 if(obj!=""){293 var id = obj.find("option:selected").val();294 var nameNO=obj.find("option:selected").attr("name");295 var saltName=obj.find("option:selected").text();296 $("#saltName").val(saltName);297 $("#remark").val(nameNO);298 $("#remark2").val(id);299 }else{300 $("#saltName").val("");301 $("#remark").val("");302 $("#remark2").val("");303 }*/304 if($("#saltNameChild")){305 $("#saltNameChild").remove();306 }307 } else {308 $("input[name='model']").val("");309 $("input[name='equipmentName']").val("");310 layer.msg('获取失败,联系超管', {311 icon: 2312 });313 }314 },315 error: function(XMLHttpRequest, textStatus) {316 layer.msg('操作失败', {317 icon: 2318 });319 }320 });321 }322 323 324 $("#save").click(save);325 326 $('#naturalParent[name="naturalParent"]').change(function() {327 var province =$("#province[name='province']").find("option:selected").attr("name");328 var nameNO=$(this).find("option:selected").attr("name");329 $.ajax({330 url: '/natural/caregary',331 type: "post",332 cache: false,333 data: {334 "nameNo": province+nameNO335 },336 dataType: "json",337 success: function(data) {338 if(data.status == 0) {339 $('#naturalchild[name="naturalchild"]').val("");340 var naturalchild = data.naturalchild;341 var html;342 for(var i=0 ; i<naturalchild.length;i++){343 var name=naturalchild[i].name344 var id=naturalchild[i].id345 var nameNo=naturalchild[i].nameNo346 html+="<option value='"+id+"' name='"+nameNo+"'>"+name+"</option>"347 }348 if($('#naturalParent[name="naturalParent"]').val()==""){349 var option="<option value=''>请选择</option>"350 }else{351 html+="<option value='0'>新增</option>"352 var option="<option value=''>请选择</option>"353 }354 355 $("#naturalchild").html(option+html);356 $("#naturalchild").select2();357 var obj=getLastSelect();358 if(obj!=""){359 var id = obj.find("option:selected").val();360 var nameNO=obj.find("option:selected").attr("name");361 var saltName=obj.find("option:selected").text();362 $("#saltName").val(saltName);363 $("#remark").val(nameNO);364 $("#remark2").val(id);365 }else{366 $("#saltName").val("");367 $("#remark").val("");368 $("#remark2").val("");369 }370 if($("#saltNameChild")){371 $("#saltNameChild").remove();372 }373 } else {374 $("input[name='model']").val("");375 $("input[name='equipmentName']").val("");376 layer.msg('获取失败,联系超管', {377 icon: 2378 });379 }380 },381 error: function(XMLHttpRequest, textStatus) {382 layer.msg('操作失败', {383 icon: 2384 });385 }386 });387 });388389 $('#naturalchild[name="naturalchild"]').change(function() {390 var $this = $(this);391 var val = $this.val();392 if(val == 0){393 var input = $('<input type="text" style="width: 150px; vertical-align: top;" class="required illegalValidate" title="食盐名称" name="saltNameChild" id="saltNameChild" />');394 $(this).parent().append(input)395 }else{396 var obj=getLastSelect();397 if(obj!=""){398 var id = $(this).find("option:selected").val();399 var nameNO=$(this).find("option:selected").attr("name");400 var saltName=$(this).find("option:selected").text();401 $("#saltName").val(saltName);402 $("#remark").val(nameNO);403 $("#remark2").val(id);404 }else{405 $("#saltName").val("");406 $("#remark").val("");407 $("#remark2").val("");408 }409 if($("#saltNameChild")){410 $("#saltNameChild").remove();411 }412 }413 414 });415 416 417 /*$('#naturalchild[name="naturalchild"]').change(function() {418 var obj=getLastSelect();419 if(obj!=""){420 var id = obj.find("option:selected").val();421 var nameNO=obj.find("option:selected").attr("name");422 var saltName=obj.find("option:selected").text();423 $("#saltNameChild").val(saltName);424 $("#remark").val(nameNO);425 $("#remark2").val(id);426 }else{427 $("#saltNameChild").val("");428 $("#remark").val("");429 $("#remark2").val("");430 }431432 });*/433 434 $('#province[name="province"]').change(function() {435 //$('#naturalParent[name="naturalParent"]').find("option:selected").val();436 $('#naturalchild[name="naturalchild"]').empty().prepend("<option value=''>请选择</option>")437 $('#naturalParent[name="naturalParent"]').val("");438 });439 /* $('#naturalNodechild[name="naturalNodechild"]').change(function() {440 var id = $(this).find("option:selected").val();441 var nameNO=$(this).find("option:selected").attr("name");442 var saltName=$(this).find("option:selected").text();443 $.ajax({444 url: '/natural/caregary',445 type: "post",446 cache: false,447 data: {448 "id": id449 },450 dataType: "json",451 success: function(data) {452 if(data.status == 0) {453 $("#naturalNodelist").show();454 var naturalchild = data.naturalchild;455 var html;456 for(var i=0 ; i<naturalchild.length;i++){457 var name=naturalchild[i].name458 var nameNo=naturalchild[i].nameNo459 var id=naturalchild[i].id460 html+="<option value='"+id+"' name='"+nameNo+"'>"+name+"</option>"461 }462 var option="<option value=''>请选择</option>"463 $("#naturalNodelist").html(option+html);464 var obj=getLastSelect();465 if(obj!=""){466 var id = obj.find("option:selected").val();467 var nameNO=obj.find("option:selected").attr("name");468 var saltName=obj.find("option:selected").text();469 $("#saltName").val(saltName);470 $("#remark").val(nameNO);471 $("#remark2").val(id);472 }else{473 $("#saltName").val("");474 $("#remark").val("");475 $("#remark2").val("");476 }477 } else {478 $("input[name='model']").val("");479 $("input[name='equipmentName']").val("");480 layer.msg('获取失败,联系超管', {481 icon: 2482 });483 }484 },485 error: function(XMLHttpRequest, textStatus) {486 layer.msg('操作失败', {487 icon: 2488 });489 }490 });491 });492 $('#naturalNodelist[name="naturalNodelist"]').change(function() {493 var obj=getLastSelect();494 if(obj!=""){495 var id = obj.find("option:selected").val();496 var nameNO=obj.find("option:selected").attr("name");497 var saltName=obj.find("option:selected").text();498 $("#saltName").val(saltName);499 $("#remark").val(nameNO);500 $("#remark2").val(id);501 }else{502 $("#saltName").val("");503 $("#remark").val("");504 $("#remark2").val("");505 }506 });507 */508 509 });510 function getLastSelect(){511 if($("#naturalNodelist").val()!=""){512 return $("#naturalNodelist");513 }else{514 if($("#naturalNodechild").val()!=""){515 return $("#naturalNodechild");516 }else{517 if($("#naturalchild").val()!=""){518 return $("#naturalchild");519 }else{520 if($("#naturalParent").val()!=""){521 return $("#naturalParent");522 }else{523 return "";524 }525 }526 }527 }528 } ...

Full Screen

Full Screen

reactReducer.test.js

Source:reactReducer.test.js Github

copy

Full Screen

1import { reactTestCaseReducer, reactTestCaseState } from '../context/reducers/reactTestCaseReducer';2describe('React Reducer', () => {3 let initialState = {};4 beforeEach(() => {5 initialState = {6 describeId: 1,7 itId: 1,8 statementId: 3,9 propId: 1,10 describeBlocks: {11 byId: {12 describe0: {13 id: 'describe0',14 text: '',15 },16 },17 allIds: ['describe0'],18 },19 itStatements: {20 byId: {21 it0: {22 id: 'it0',23 describeId: 'describe0',24 text: '',25 },26 },27 allIds: ['it0'],28 },29 statements: {30 byId: {31 statement0: {32 id: 'statement0',33 itId: 'it0',34 describeId: 'describe0',35 type: 'render',36 props: [37 {38 id: 'prop0',39 statementId: 'statement0',40 propKey: '',41 propValue: '',42 },43 ],44 },45 statement1: {46 id: 'statement1',47 itId: 'it0',48 describeId: 'describe0',49 type: 'action',50 eventType: '',51 eventValue: null,52 queryVariant: '',53 querySelector: '',54 queryValue: '',55 suggestions: [],56 },57 statement2: {58 id: 'statement2',59 itId: 'it0',60 describeId: 'describe0',61 type: 'assertion',62 queryVariant: '',63 querySelector: '',64 queryValue: '',65 isNot: false,66 matcherType: '',67 matcherValue: '',68 suggestions: [],69 },70 },71 allIds: ['statement0', 'statement1', 'statement2'],72 componentPath: '',73 componentName: '',74 },75 };76 });77 it('should return the initial state', () => {78 expect(reactTestCaseReducer(initialState, {})).toEqual(initialState);79 });80 it('should handle TOGGLE_REACT', () => {81 expect(reactTestCaseReducer(initialState, { type: 'TOGGLE_REACT' })).toEqual({82 ...initialState,83 });84 });85 it('should handle ADD_DESCRIBE_BLOCK', () => {86 expect(reactTestCaseReducer(initialState, { type: 'ADD_DESCRIBE_BLOCK' })).toEqual({87 ...initialState,88 describeId: 2,89 describeBlocks: {90 byId: {91 ...initialState.describeBlocks.byId,92 describe1: {93 id: 'describe1',94 text: '',95 },96 },97 allIds: ['describe0', 'describe1'],98 },99 });100 });101 it('should handle UPDATE_DESCRIBE_TEXT', () => {102 const action = {103 type: 'UPDATE_DESCRIBE_TEXT',104 describeId: 'describe0',105 text: 'update describe text',106 };107 expect(reactTestCaseReducer(initialState, action)).toEqual({108 ...initialState,109 describeBlocks: {110 ...initialState.describeBlocks,111 byId: {112 describe0: {113 id: 'describe0',114 text: 'update describe text',115 },116 },117 },118 });119 });120 it('should handle DELETE_DESCRIBE_BLOCK', () => {121 const action = {122 type: 'DELETE_DESCRIBE_BLOCK',123 describeId: 'describe0',124 };125 expect(reactTestCaseReducer(initialState, action)).toEqual({126 ...initialState,127 describeBlocks: {128 byId: {},129 allIds: [],130 },131 itStatements: {132 byId: {},133 allIds: [],134 },135 statements: {136 ...initialState.statements,137 byId: {},138 allIds: [],139 },140 });141 });142 it('should handle ADD_ITSTATEMENT', () => {143 const action = {144 type: 'ADD_ITSTATEMENT',145 describeId: 'describe0',146 };147 expect(reactTestCaseReducer(initialState, action)).toEqual({148 ...initialState,149 itId: 2,150 itStatements: {151 byId: {152 ...initialState.itStatements.byId,153 it1: {154 id: 'it1',155 describeId: 'describe0',156 text: '',157 },158 },159 allIds: ['it0', 'it1'],160 },161 });162 });163 it('should handle UPDATE_ITSTATEMENT_TEXT', () => {164 const action = {165 type: 'UPDATE_ITSTATEMENT_TEXT',166 itId: 'it0',167 text: 'update itStatement text',168 };169 expect(reactTestCaseReducer(initialState, action)).toEqual({170 ...initialState,171 itStatements: {172 ...initialState.itStatements,173 byId: {174 it0: {175 id: 'it0',176 describeId: 'describe0',177 text: 'update itStatement text',178 },179 },180 },181 });182 });183 it('should handle DELETE_ITSTATEMENT', () => {184 const action = {185 type: 'DELETE_ITSTATEMENT',186 itId: 'it0',187 };188 expect(reactTestCaseReducer(initialState, action)).toEqual({189 ...initialState,190 itStatements: {191 byId: {},192 allIds: [],193 },194 statements: {195 ...initialState.statements,196 byId: {},197 allIds: [],198 },199 });200 });201 /* --------------------------------- Action --------------------------------- */202 it('should handle ADD_ACTION', () => {203 const action = {204 type: 'ADD_ACTION',205 describeId: 'describe0',206 itId: 'it0',207 };208 expect(reactTestCaseReducer(initialState, action)).toEqual({209 ...initialState,210 statementId: 4,211 statements: {212 ...initialState.statements,213 byId: {214 ...initialState.statements.byId,215 statement3: {216 id: 'statement3',217 itId: 'it0',218 describeId: 'describe0',219 type: 'action',220 eventType: '',221 eventValue: null,222 queryVariant: '',223 querySelector: '',224 queryValue: '',225 suggestions: [],226 },227 },228 allIds: [...initialState.statements.allIds, 'statement3'],229 },230 });231 });232 it('should handle UPDATE_ACTION', () => {233 const action = {234 type: 'UPDATE_ACTION',235 id: 'statement1',236 eventType: 'click',237 eventValue: null,238 queryVariant: 'getBy',239 querySelector: 'Role',240 queryValue: 'button',241 suggestions: [],242 };243 expect(reactTestCaseReducer(initialState, action)).toEqual({244 ...initialState,245 statements: {246 ...initialState.statements,247 byId: {248 ...initialState.statements.byId,249 statement1: {250 id: 'statement1',251 itId: 'it0',252 describeId: 'describe0',253 type: 'action',254 eventType: 'click',255 eventValue: null,256 queryVariant: 'getBy',257 querySelector: 'Role',258 queryValue: 'button',259 suggestions: [],260 },261 },262 },263 });264 });265 it('should handle DELETE_ACTION', () => {266 const action = {267 type: 'DELETE_ACTION',268 statementId: 'statement1',269 };270 expect(reactTestCaseReducer(initialState, action)).toEqual({271 ...initialState,272 statementId: 3,273 statements: {274 ...initialState.statements,275 byId: {276 statement0: {277 id: 'statement0',278 itId: 'it0',279 describeId: 'describe0',280 type: 'render',281 props: [282 {283 id: 'prop0',284 statementId: 'statement0',285 propKey: '',286 propValue: '',287 },288 ],289 },290 statement2: {291 id: 'statement2',292 itId: 'it0',293 describeId: 'describe0',294 type: 'assertion',295 queryVariant: '',296 querySelector: '',297 queryValue: '',298 isNot: false,299 matcherType: '',300 matcherValue: '',301 suggestions: [],302 },303 },304 allIds: ['statement0', 'statement2'],305 },306 });307 });308 /* -------------------------------- Assertion ------------------------------- */309 it('should handle ADD_ASSERTION', () => {310 const action = {311 type: 'ADD_ASSERTION',312 describeId: 'describe0',313 itId: 'it0',314 };315 expect(reactTestCaseReducer(initialState, action)).toEqual({316 ...initialState,317 statementId: 4,318 statements: {319 ...initialState.statements,320 byId: {321 ...initialState.statements.byId,322 statement3: {323 id: 'statement3',324 itId: 'it0',325 describeId: 'describe0',326 type: 'assertion',327 queryVariant: '',328 querySelector: '',329 queryValue: '',330 isNot: false,331 matcherType: '',332 matcherValue: '',333 suggestions: [],334 },335 },336 allIds: [...initialState.statements.allIds, 'statement3'],337 },338 });339 });340 it('should handle UPDATE_ASSERTION', () => {341 const action = {342 type: 'UPDATE_ASSERTION',343 id: 'statement2',344 queryVariant: 'getBy',345 querySelector: 'Role',346 queryValue: 'button',347 isNot: false,348 matcherType: 'toHaveTextContent',349 matcherValue: 'click me',350 suggestions: [],351 };352 expect(reactTestCaseReducer(initialState, action)).toEqual({353 ...initialState,354 statements: {355 ...initialState.statements,356 byId: {357 ...initialState.statements.byId,358 statement2: {359 id: 'statement2',360 itId: 'it0',361 describeId: 'describe0',362 type: 'assertion',363 queryVariant: 'getBy',364 querySelector: 'Role',365 queryValue: 'button',366 isNot: false,367 matcherType: 'toHaveTextContent',368 matcherValue: 'click me',369 suggestions: [],370 },371 },372 },373 });374 });375 it('should handle DELETE_ASSERTION', () => {376 const action = {377 type: 'DELETE_ASSERTION',378 statementId: 'statement2',379 };380 expect(reactTestCaseReducer(initialState, action)).toEqual({381 ...initialState,382 statementId: 3,383 statements: {384 ...initialState.statements,385 byId: {386 statement0: {387 id: 'statement0',388 itId: 'it0',389 describeId: 'describe0',390 type: 'render',391 props: [392 {393 id: 'prop0',394 statementId: 'statement0',395 propKey: '',396 propValue: '',397 },398 ],399 },400 statement1: {401 id: 'statement1',402 itId: 'it0',403 describeId: 'describe0',404 type: 'action',405 eventType: '',406 eventValue: null,407 queryVariant: '',408 querySelector: '',409 queryValue: '',410 suggestions: [],411 },412 },413 allIds: ['statement0', 'statement1'],414 },415 });416 });417 /* --------------------------------- Render --------------------------------- */418 it('should handle ADD_RENDER', () => {419 const action = {420 type: 'ADD_RENDER',421 describeId: 'describe0',422 itId: 'it0',423 };424 expect(reactTestCaseReducer(initialState, action)).toEqual({425 ...initialState,426 statementId: 4,427 statements: {428 ...initialState.statements,429 byId: {430 ...initialState.statements.byId,431 statement3: {432 id: 'statement3',433 itId: 'it0',434 describeId: 'describe0',435 type: 'render',436 props: [],437 },438 },439 allIds: [...initialState.statements.allIds, 'statement3'],440 },441 });442 });443 it('should handle UPDATE_RENDER_COMPONENT', () => {444 const action = {445 type: 'UPDATE_RENDER_COMPONENT',446 componentName: 'Button',447 filePath:448 '/Users/charliemaloney/code/codesmith/projects/production-project/spearmint/src/components/Action/Action.jsx',449 };450 expect(reactTestCaseReducer(initialState, action)).toEqual({451 ...initialState,452 statements: {453 ...initialState.statements,454 componentName: 'Button',455 componentPath:456 '/Users/charliemaloney/code/codesmith/projects/production-project/spearmint/src/components/Action/Action.jsx',457 },458 });459 });460 it('should handle DELETE_RENDER', () => {461 const action = {462 type: 'DELETE_RENDER',463 statementId: 'statement0',464 };465 expect(reactTestCaseReducer(initialState, action)).toEqual({466 ...initialState,467 statementId: 3,468 statements: {469 ...initialState.statements,470 byId: {471 statement1: {472 id: 'statement1',473 itId: 'it0',474 describeId: 'describe0',475 type: 'action',476 eventType: '',477 eventValue: null,478 queryVariant: '',479 querySelector: '',480 queryValue: '',481 suggestions: [],482 },483 statement2: {484 id: 'statement2',485 itId: 'it0',486 describeId: 'describe0',487 type: 'assertion',488 queryVariant: '',489 querySelector: '',490 queryValue: '',491 isNot: false,492 matcherType: '',493 matcherValue: '',494 suggestions: [],495 },496 },497 allIds: ['statement1', 'statement2'],498 },499 });500 });501 it('should handle ADD_PROP', () => {502 const action = {503 type: 'ADD_PROP',504 statementId: 'statement0',505 };506 expect(reactTestCaseReducer(initialState, action)).toEqual({507 ...initialState,508 propId: 2,509 statements: {510 ...initialState.statements,511 byId: {512 ...initialState.statements.byId,513 statement0: {514 id: 'statement0',515 itId: 'it0',516 describeId: 'describe0',517 type: 'render',518 props: [519 ...initialState.statements.byId.statement0.props,520 {521 id: 'prop1',522 statementId: 'statement0',523 propKey: '',524 propValue: '',525 },526 ],527 },528 },529 },530 });531 });532 it('should handle UPDATE_PROP', () => {533 const action = {534 type: 'UPDATE_PROP',535 id: 'prop0',536 statementId: 'statement0',537 propKey: 'name',538 propValue: 'bob',539 };540 expect(reactTestCaseReducer(initialState, action)).toEqual({541 ...initialState,542 propId: 1,543 statements: {544 ...initialState.statements,545 byId: {546 ...initialState.statements.byId,547 statement0: {548 id: 'statement0',549 itId: 'it0',550 describeId: 'describe0',551 type: 'render',552 props: [553 {554 id: 'prop0',555 statementId: 'statement0',556 propKey: 'name',557 propValue: 'bob',558 },559 ],560 },561 },562 },563 });564 });565 it('should handle DELETE_PROP', () => {566 const action = {567 type: 'DELETE_PROP',568 id: 'prop0',569 statementId: 'statement0',570 };571 expect(reactTestCaseReducer(initialState, action)).toEqual({572 ...initialState,573 propId: 1,574 statements: {575 ...initialState.statements,576 byId: {577 ...initialState.statements.byId,578 statement0: {579 id: 'statement0',580 itId: 'it0',581 describeId: 'describe0',582 type: 'render',583 props: [],584 },585 },586 },587 });588 });589 it('should handle CREATE_NEW_TEST', () => {590 const action = { type: 'CREATE_NEW_TEST' };591 expect(reactTestCaseReducer(initialState, action)).toEqual({592 ...initialState,593 describeBlocks: {594 byId: {},595 allIds: [],596 },597 itStatements: {598 byId: {},599 allIds: [],600 },601 statements: {602 byId: {},603 allIds: [],604 },605 });606 });...

Full Screen

Full Screen

reactTestCaseReducer.js

Source:reactTestCaseReducer.js Github

copy

Full Screen

1import { createContext } from 'react';2import { actionTypes } from '../actions/reactTestCaseActions';3export const ReactTestCaseContext = createContext([]);4export const reactTestCaseState = {5 modalOpen: false,6 describeId: 1,7 itId: 1,8 statementId: 1,9 propId: 1,10 describeBlocks: {11 byId: {12 describe0: {13 id: 'describe0',14 text: '',15 },16 },17 allIds: ['describe0'],18 },19 itStatements: {20 byId: {21 it0: {22 id: 'it0',23 describeId: 'describe0',24 text: '',25 },26 },27 allIds: {28 describe0: ['it0'],29 },30 },31 statements: {32 byId: {33 statement0: {34 id: 'statement0',35 itId: 'it0',36 describeId: 'describe0',37 type: 'render',38 props: [],39 },40 },41 allIds: ['statement0'],42 componentPath: '',43 componentName: '',44 },45};46/* ---------------------------- Helper Functions ---------------------------- */47const createDescribeBlock = (describeId) => {48 return {49 id: describeId,50 text: '',51 };52};53const createItStatement = (describeId, itId) => ({54 id: itId,55 describeId,56 text: '',57});58const createAction = (describeId, itId, statementId) => ({59 id: statementId,60 itId,61 describeId,62 type: 'action',63 eventType: '',64 eventValue: null,65 queryVariant: '',66 querySelector: '',67 queryValue: '',68 suggestions: [],69});70const createAssertion = (describeId, itId, statementId) => ({71 id: statementId,72 itId,73 describeId,74 type: 'assertion',75 queryVariant: '',76 querySelector: '',77 queryValue: '',78 isNot: false,79 matcherType: '',80 matcherValue: '',81 suggestions: [],82});83const createRender = (describeId, itId, statementId) => ({84 id: statementId,85 itId,86 describeId,87 type: 'render',88 props: [],89});90const createProp = (propId, statementId) => ({91 id: propId,92 statementId,93 propKey: '',94 propValue: '',95});96const deleteChildren = (object, deletionId, lookup, it) => {97 let allIdCopy;98 if (it) {99 // delete everything appropriate in itStatements.byId object100 object.allIds[deletionId].forEach((id) => {101 delete object.byId[id];102 });103 // delete everything appropriate in itStatements.allIds object104 delete object.allIds[deletionId];105 allIdCopy = object.allIds;106 } else {107 // use .filter to delete from statements.allIds array108 allIdCopy = object.allIds.filter((id) => object.byId[id][lookup] !== deletionId);109 // delete from statements.byId object110 object.allIds.forEach((id) => {111 if (object.byId[id][lookup] === deletionId) {112 delete object.byId[id];113 }114 });115 }116 return allIdCopy;117};118/* ------------------------- React Test Case Reducer ------------------------ */119export const reactTestCaseReducer = (state, action) => {120 Object.freeze(state);121 let describeBlocks;122 let itStatements;123 let statements;124 if (state && action) {125 describeBlocks = { ...state.describeBlocks };126 itStatements = { ...state.itStatements };127 statements = { ...state.statements };128 }129 switch (action.type) {130 case actionTypes.ADD_DESCRIBE_BLOCK: {131 let updatedDescribeId = state.describeId;132 const describeId = `describe${state.describeId}`;133 return {134 ...state,135 describeId: ++updatedDescribeId,136 describeBlocks: {137 ...describeBlocks,138 byId: {139 ...describeBlocks.byId,140 [describeId]: createDescribeBlock(describeId),141 },142 allIds: [...(describeBlocks.allIds || []), describeId],143 },144 itStatements: {145 ...itStatements,146 allIds: {147 ...itStatements.allIds,148 [describeId]: [],149 },150 },151 };152 }153 case actionTypes.DELETE_DESCRIBE_BLOCK: {154 const { describeId } = action;155 const byId = { ...describeBlocks.byId };156 delete byId[describeId];157 const allIds = describeBlocks.allIds.filter((id) => id !== describeId);158 const itStatementAllIds = deleteChildren(itStatements, describeId, 'describeId', 'it');159 const statementAllIds = deleteChildren(statements, describeId, 'describeId');160 return {161 ...state,162 describeBlocks: {163 ...describeBlocks,164 byId: {165 ...byId,166 },167 allIds: [...allIds],168 },169 itStatements: {170 ...itStatements,171 byId: {172 ...itStatements.byId,173 },174 allIds: itStatementAllIds,175 },176 statements: {177 ...statements,178 byId: {179 ...statements.byId,180 },181 allIds: [...statementAllIds],182 },183 };184 }185 case actionTypes.UPDATE_DESCRIBE_TEXT: {186 const { describeId, text } = action;187 const byIds = { ...describeBlocks.byId };188 const block = { ...describeBlocks.byId[describeId] };189 return {190 ...state,191 describeBlocks: {192 ...describeBlocks,193 byId: {194 ...byIds,195 [describeId]: {196 ...block,197 text,198 },199 },200 },201 };202 }203 case actionTypes.UPDATE_DESCRIBE_ORDER: {204 const { reorderedDescribe } = action;205 return {206 ...state,207 describeBlocks: {208 ...describeBlocks,209 allIds: reorderedDescribe,210 },211 };212 }213 case actionTypes.ADD_ITSTATEMENT: {214 const { describeId } = action;215 const itId = `it${state.itId}`;216 let updatedItId = state.itId;217 return {218 ...state,219 itId: ++updatedItId,220 itStatements: {221 ...itStatements,222 byId: {223 ...itStatements.byId,224 [itId]: createItStatement(describeId, itId),225 },226 allIds: {227 ...itStatements.allIds,228 [describeId]: [...itStatements.allIds[describeId], itId],229 },230 },231 };232 }233 case actionTypes.UPDATE_ITSTATEMENT_TEXT: {234 const { itId, text } = action;235 const byIds = { ...itStatements.byId };236 const block = { ...itStatements.byId[itId] };237 return {238 ...state,239 itStatements: {240 ...itStatements,241 byId: {242 ...byIds,243 [itId]: {244 ...block,245 text,246 },247 },248 },249 };250 }251 case actionTypes.DELETE_ITSTATEMENT: {252 const { itId } = action;253 const { describeId } = itStatements.byId[itId];254 const byId = { ...itStatements.byId };255 delete byId[itId];256 const allIds = itStatements.allIds[describeId].filter((id) => id !== itId);257 const statementAllIds = deleteChildren(statements, itId, 'itId');258 return {259 ...state,260 itStatements: {261 ...itStatements,262 byId: {263 ...byId,264 },265 allIds: {266 ...itStatements.allIds,267 [describeId]: [...allIds],268 },269 },270 statements: {271 ...statements,272 byId: {273 ...statements.byId,274 },275 allIds: [...statementAllIds],276 },277 };278 }279 case actionTypes.UPDATE_ITSTATEMENT_ORDER: {280 const { reorderedIt, describeId } = action;281 return {282 ...state,283 itStatements: {284 ...itStatements,285 allIds: {286 ...itStatements.allIds,287 [describeId]: reorderedIt,288 },289 },290 };291 }292 case actionTypes.ADD_ACTION: {293 const { describeId, itId } = action;294 const byIds = { ...statements.byId };295 const allIds = [...statements.allIds];296 const statementId = `statement${state.statementId}`;297 let updatedStatementId = state.statementId;298 return {299 ...state,300 statementId: ++updatedStatementId,301 statements: {302 ...statements,303 byId: {304 ...byIds,305 [statementId]: createAction(describeId, itId, statementId),306 },307 allIds: [...allIds, statementId],308 },309 };310 }311 case actionTypes.DELETE_ACTION: {312 const { statementId } = action;313 const byId = { ...statements.byId };314 delete byId[statementId];315 const allIds = [...statements.allIds].filter((statement) => statement !== statementId);316 return {317 ...state,318 statements: {319 ...statements,320 byId: {321 ...byId,322 },323 allIds: [...allIds],324 },325 };326 }327 case actionTypes.UPDATE_ACTION: {328 const { id, eventType, eventValue, queryVariant, querySelector, queryValue, suggestions } =329 action;330 const byId = { ...statements.byId };331 const oldStatement = { ...statements.byId[id] };332 const newStatement = {333 ...oldStatement,334 eventType,335 eventValue,336 queryVariant,337 querySelector,338 queryValue,339 suggestions,340 };341 return {342 ...state,343 statements: {344 ...statements,345 byId: {346 ...byId,347 [id]: {348 ...newStatement,349 },350 },351 },352 };353 }354 case actionTypes.ADD_ASSERTION: {355 const { describeId, itId } = action;356 const byIds = { ...statements.byId };357 const allIds = [...statements.allIds];358 const statementId = `statement${state.statementId}`;359 let updatedStatementId = state.statementId;360 return {361 ...state,362 statementId: ++updatedStatementId,363 statements: {364 ...statements,365 byId: {366 ...byIds,367 [statementId]: createAssertion(describeId, itId, statementId),368 },369 allIds: [...allIds, statementId],370 },371 };372 }373 case actionTypes.DELETE_ASSERTION: {374 const { statementId } = action;375 const byId = { ...statements.byId };376 delete byId[statementId];377 const allIds = [...statements.allIds].filter((statement) => statement !== statementId);378 return {379 ...state,380 statements: {381 ...statements,382 byId: {383 ...byId,384 },385 allIds: [...allIds],386 },387 };388 }389 case actionTypes.UPDATE_ASSERTION: {390 const {391 id,392 queryVariant,393 querySelector,394 queryValue,395 isNot,396 matcherType,397 matcherValue,398 suggestions,399 } = action;400 const oldStatement = { ...statements.byId[id] };401 const byId = { ...statements.byId };402 const newStatement = {403 ...oldStatement,404 queryVariant,405 querySelector,406 queryValue,407 isNot,408 matcherType,409 matcherValue,410 suggestions,411 };412 return {413 ...state,414 statements: {415 ...statements,416 byId: {417 ...byId,418 [id]: {419 ...newStatement,420 },421 },422 },423 };424 }425 case actionTypes.ADD_RENDER: {426 const { describeId, itId } = action;427 const byIds = { ...statements.byId };428 const allIds = [...statements.allIds];429 const statementId = `statement${state.statementId}`;430 let updatedStatementId = state.statementId;431 return {432 ...state,433 statementId: ++updatedStatementId,434 statements: {435 ...statements,436 byId: {437 ...byIds,438 [statementId]: createRender(describeId, itId, statementId),439 },440 allIds: [...allIds, statementId],441 },442 };443 }444 case actionTypes.DELETE_RENDER: {445 const { statementId } = action;446 const byId = { ...statements.byId };447 delete byId[statementId];448 const allIds = [...statements.allIds].filter((statement) => statement !== statementId);449 return {450 ...state,451 statements: {452 ...statements,453 byId: {454 ...byId,455 },456 allIds: [...allIds],457 },458 };459 }460 case actionTypes.UPDATE_RENDER_COMPONENT: {461 const { componentName, filePath } = action;462 statements.componentName = componentName;463 statements.componentPath = filePath;464 return {465 ...state,466 statements,467 };468 }469 case actionTypes.ADD_PROP: {470 const { statementId } = action;471 const propId = `prop${state.propId}`;472 const { byId } = statements;473 let updatedPropId = state.propId;474 return {475 ...state,476 propId: ++updatedPropId,477 statements: {478 ...statements,479 byId: {480 ...byId,481 [statementId]: {482 ...statements.byId[statementId],483 props: [...statements.byId[statementId].props, createProp(propId, statementId)],484 },485 },486 },487 };488 }489 case actionTypes.DELETE_PROP: {490 const { id, statementId } = action;491 const props = statements.byId[statementId].props.filter((prop) => prop.id !== id);492 return {493 ...state,494 statements: {495 ...statements,496 byId: {497 ...statements.byId,498 [statementId]: {499 ...statements.byId[statementId],500 props,501 },502 },503 },504 };505 }506 case actionTypes.UPDATE_PROP: {507 const { id, statementId, propKey, propValue } = action;508 const updatedProps = [...statements.byId[statementId].props];509 updatedProps.forEach((prop) => {510 if (prop.id === id) {511 prop.propKey = propKey;512 prop.propValue = propValue;513 }514 });515 return {516 ...state,517 statements: {518 ...statements,519 byId: {520 ...statements.byId,521 [statementId]: {522 ...statements.byId[statementId],523 props: updatedProps,524 },525 },526 },527 };528 }529 case actionTypes.CREATE_NEW_TEST: {530 return {531 ...state,532 describeBlocks: {533 byId: {},534 allIds: [],535 },536 itStatements: {537 byId: {},538 allIds: {},539 },540 statements: {541 byId: {},542 allIds: [],543 },544 };545 }546 case actionTypes.OPEN_INFO_MODAL: {547 return {548 ...state,549 modalOpen: true,550 };551 }552 case actionTypes.CLOSE_INFO_MODAL: {553 return {554 ...state,555 modalOpen: false,556 };557 }558 case actionTypes.REPLACE_TEST: {559 return action.testState;560 }561 default:562 return state;563 }...

Full Screen

Full Screen

stageView.js

Source:stageView.js Github

copy

Full Screen

1var allDataObj={2 stageView : "",3 describeId : "", 4} 5$( document ).ready(function(){ 6 $("#moveRun .remove").on("click",function (){7 $("#moveRun").css("display","none"); 8 })9 $("#moveRun .btn").on("click",function (){10 var self = this; 11 $.ajax({12 type:"POST",13 url:"/devManage/structure/getNextPendingInputAction",14 dataType:"json",15 data:{16 "toolId":allDataObj.stageView.toolId,17 "jobName":allDataObj.stageView.jobName,18 "jenkinsId":allDataObj.stageView.jenkinsId, 19 }, 20 success:function(data){21 var flag = "";22 if( $(self).hasClass( "Continuebutton" ) ){23 flag = 1; 24 }else if( $(self).hasClass( "Abortbutton" ) ){25 flag = 2; 26 } 27 goContinueLogfun( flag ,data.nextPendingInput.id );28 $("#moveRun").css("display","none"); 29 }30 }); 31 32 }) 33})34function goContinueLogfun( flag ,id ){35 $.ajax({36 type: "post",37 url: "/devManage/structure/getStageViewNextPending",38 dataType: "json",39 data: {40 "toolId":allDataObj.stageView.toolId,41 "jobName":allDataObj.stageView.jobName,42 "jenkinsId":allDataObj.stageView.jenkinsId, 43 'interruptId': id,44 "flag": flag45 },46 success: function (data) { 47 createStageView( allDataObj.stageView ); 48 }49 });50}51function createStageView( row ){ 52 allDataObj.stageView = row; 53 $.ajax({54 url:"/devManage/structure/getStageView",55 method:"post",56 data:{57 "toolId":row.toolId,58 "jobName":row.jobName,59 "jenkinsId":row.jenkinsId, 60 },61 success:function(data){ 62 if(data.status == 2){63 layer.alert(data.message, {64 icon: 2,65 title: "提示信息"66 });67 }else{68 if( data.stageView == null ){69 $("#loadingData").css( "display","block" );70 $("#JenkinsJobsTable").css( "display","none" ); 71 return ;72 }else{ 73 $("#loadingData").css( "display","none" );74 $("#JenkinsJobsTable").css( "display","inline-block" ); 75 76 var strhead = '';77 var strbody = ''; 78 stageViewStats = '';79 if( data.stageView.status == "FAILED" || data.stageView.status == "ABORTED" ){80 stageViewStats = 'headBodyBg_fail'; 81 } 82 strbody += '<div class="headBody '+ stageViewStats +'">'; 83 for( var i=0;i<data.stageView.stages.length;i++ ){ 84 var content = '';85 var pausedTime = '';86 var describeId ='';87 88 strhead +='<div class="stage-header"><div>'+ data.stageView.stages[i].name +'</div></div>'; 89 describeId = "describeId="+data.stageView.stages[i].id;90 if( data.stageView.stages[i].pauseDurationMillis != 0 ){91 pausedTime = '<div class="promptInfo"><span>(paused for '+ setTimefun( Math.abs( data.stageView.stages[i].pauseDurationMillis ) ) +')</span></div>';92 }93 94 if( data.stageView.stages[i].status == "SUCCESS" ){95 content = '<div class="duration durationBg_success" '+ describeId +' >'+ 96 setTimefun( data.stageView.stages[i].durationMillis ) + pausedTime + '</div>'; 97 }else if( data.stageView.stages[i].status == "IN_PROGRESS" ){98 content = '<div class="duration progress progress-striped active" '+ describeId +' >'+99 '<div class="progress-bar progress-bar-striped " role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 100%">'+100 '<span class="sr-only">100% Complete</span>loading...'+101 '</div></div>';102 }else if( data.stageView.stages[i].status == "FAILED" ){103 content = '<div class="duration durationBg_fail" '+ describeId +' >'+104 setTimefun( data.stageView.stages[i].durationMillis )+ pausedTime + '<div class="cornerMark">failed</div></div>';105 }else if( data.stageView.stages[i].status == "PAUSED_PENDING_INPUT" ){106 content = '<div class="progress progress-striped active paused" '+ describeId +' >'+107 '<div class="progress-bar progress-bar-striped " role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 100%">'+108 '<span class="sr-only">100% Complete</span>paused'+109 '</div>'+ pausedTime +'</div>';110 } 111 strbody += '<div class="stage-body">'+ content +'</div>'; 112 } 113 strbody += '</div>'; 114 $("#headDiv").empty().append( strhead ); 115 $("#stageBodyDiv").empty().append(strbody); 116 if( data.stageView.status == "FAILED" || data.stageView.status == "SUCCESS" ){117 autoSearchInfo(); 118 }119 }120 }121 122 $(".duration").on("click",function (){123 $("#loading").css("display","block");124 $.ajax({125 url:"/devManage/structure/getStageViewLog",126 method:"post",127 data:{128 "toolId":allDataObj.stageView.toolId,129 "jobName":allDataObj.stageView.jobName,130 "jenkinsId":allDataObj.stageView.jenkinsId, 131 "describeId":$(this).attr("describeId")132 },133 success:function(data){ 134 $("#loading").css("display","none");135 $('#StageLogsInfo').empty();136 for( var i=0;i< data.stageView.stageFlowNodes.length;i++ ){137 var str = '<div class="StageLogsDiv"><div class="StageLogsTit" executionId='+ data.stageView.stageFlowNodes[i].id +' >'+138 '<span class="fa fa-caret-square-o-down"></span>'+139 data.stageView.stageFlowNodes[i].name+'(self time '+setTimefun( data.stageView.stageFlowNodes[i].durationMillis )+')'+'</div><div class="StageLogsCont"></div></div>';140 $('#StageLogsInfo').append( str );141 }142 $(".StageLogsTit").on("click",function (){143 if( $(this).children(".fa").hasClass( "fa-caret-square-o-down" ) ){144 $(".StageLogsTit").children(".fa").addClass( "fa-caret-square-o-down" );145 $(".StageLogsTit").children(".fa").removeClass( "fa-caret-square-o-up" );146 $(".StageLogsCont").slideUp();147 $(this).children(".fa").removeClass( "fa-caret-square-o-down" );148 $(this).children(".fa").addClass( "fa-caret-square-o-up" );149 if( $(this).attr("flag")=="1" ){150 $( this ).next(".StageLogsCont").slideDown();151 }else{152 var self = this;153 $("#loading").css("display","block");154 $.ajax({155 url:"/devManage/structure/getStageViewLogDetail",156 method:"post",157 data:{158 "toolId":allDataObj.stageView.toolId,159 "jobName":allDataObj.stageView.jobName,160 "jenkinsId":allDataObj.stageView.jenkinsId, 161 "executionId":$(self).attr("executionId")162 },163 success:function(data){164 $("#loading").css("display","none");165 $( self ).attr("flag","1"); 166 var str = "<pre >"+ data.stageView.text +"</pre>";167 $( self ).next(".StageLogsCont").append( str );168 $( self ).next(".StageLogsCont").slideDown(); 169 }170 }); 171 }172 }else{173 $(this).children(".fa").addClass( "fa-caret-square-o-down" );174 $(this).children(".fa").removeClass( "fa-caret-square-o-up" );175 $( this ).next(".StageLogsCont").slideUp();176 }177 });178 layer.open({179 type: 1,180 area: '80%',181 offset: '40px',182 title:'Stage Logs (build eureka)',183 content: $('#StageLogsInfo'), //这里content是一个DOM,注意:最好该元素要存放在body最外层,否则可能被其它的相对元素所影响184 cancel: function(index, layero){185 $('#StageLogsInfo').empty();186 layer.closeAll();187 }188 });189 }190 }) 191 }); 192 $(".paused").on("click",function (){193 allDataObj.describeId = $( this ).attr("describeId"); 194 var top = $(this).offset().top;195 var left = $(this).offset().left; 196 $("#moveRun").css( {"display":"block","left":( left - 44 )+"px","top":( top - 90 )+"px"} );197 }) 198 }199 }); 200}201function createNotes( row ){202 count = count + 1;203 var url = ""204 var data = "";205 url = "/devManage/structure/getLog";206 data = {207 "toolId": row.toolId,208 "jobName": row.jobName,209 "jenkinsId": row.jenkinsId,210 "count": count,211 "line": line212 };213 $.ajax({214 url: url,215 method: "post",216 data: data,217 success: function (data) { 218 var scrollIsBottom;219 if( $("#profile").outerHeight() + 37 + 40 -$("#scrollTop").scrollTop() <= $("#scrollTop").outerHeight() ){220 scrollIsBottom = true;221 } else{222 scrollIsBottom = false; 223 } 224 225 if( data.building == "false" ){226 autoSearchInfo();227 }; 228 line = data.line;229 $("#logId").append( data.log ); 230 if( scrollIsBottom ){231 //37是 上方 小标签的高度,40 是 $('#scrollTop') 的 padding232 $('#scrollTop').scrollTop( $("#profile").outerHeight() + 37 + 40 );233 }234 /*235 if (data.flag == "false" || end == "true") {236 return false;237 }238 //为了避免异步造成问题239 if ((data.building == "false" && lastbuilding == "true") || (data.building == "false" && lastbuilding == "false" && count > 30)) {240 clearInterval(timer);//结束循环241 }242 line = data.line;243 num = "";244 if (data.building == "false" && ((lastbuilding == "false" || lastbuilding == "") && count <= 30)) {245 if (end != "true") {246 notes = "正在获取实时日志中请等待.....";247 line = 0;248 }249 } else if (data.building == "false" && (lastbuilding == "false" && count > 30)) {250 notes = "该系统处于排队中或运行错误请稍后查看!";251 line = 0;252 } else {253 if (notes == "正在获取实时日志中请等待....." || notes == "正在初始化请等待.....") {254 var a = $("#logId");255 a.empty();256 notes = "";257 num = "";258 }259 num = data.log;260 }261 if (data.building == "false") {262 //判断上一次是否为true263 if ((lastbuilding == "true") || (lastbuilding == "false" && count > 30)) { //正常结束 或者是一直静默期结束循环264 lastbuilding = "";265 end = "";266 }267 if (count == 1) {268 lastbuilding = data.building;269 }270 } else {271 lastbuilding = data.building;272 }273 appendTo();274*/275 } 276 }); 277}278//传入毫秒 专换 时分秒279function setTimefun( time ){280 time = Math.abs( time );281 if( time < 1000 ){282 return time+"ms"283 }else if( time < 60 * 1000 ){284 return Math.round(time/1000)+"s";285 }else if( time < 60 * 60 * 1000 ){286 return parseInt(time/( 60 * 1000 ))+"min " + Math.round( (time%( 60 * 1000 )) /1000)+"s";287 }else{288 return parseInt(time/( 60 * 60 * 1000 ))+"h " +parseInt( ( time%( 60 * 60 * 1000 ) ) /( 60 * 1000 ))+"min " + Math.round( (time%( 60 * 1000 )) /1000)+"s";289 }290 return time;...

Full Screen

Full Screen

reactTestCaseActions.js

Source:reactTestCaseActions.js Github

copy

Full Screen

1/* ------------------------------ Action Types ------------------------------ */2export const actionTypes = {3 ADD_DESCRIBE_BLOCK: 'ADD_DESCRIBE_BLOCK',4 DELETE_DESCRIBE_BLOCK: 'DELETE_DESCRIBE_BLOCK',5 UPDATE_DESCRIBE_TEXT: 'UPDATE_DESCRIBE_TEXT',6 UPDATE_DESCRIBE_ORDER: 'UPDATE_DESCRIBE_ORDER',7 ADD_ITSTATEMENT: 'ADD_ITSTATEMENT',8 DELETE_ITSTATEMENT: 'DELETE_ITSTATEMENT',9 UPDATE_ITSTATEMENT_TEXT: 'UPDATE_ITSTATEMENT_TEXT',10 UPDATE_ITSTATEMENT_ORDER: 'UPDATE_ITSTATEMENT_ORDER',11 ADD_ACTION: 'ADD_ACTION',12 DELETE_ACTION: 'DELETE_ACTION',13 UPDATE_ACTION: 'UPDATE_ACTION',14 ADD_ASSERTION: 'ADD_ASSERTION',15 DELETE_ASSERTION: 'DELETE_ASSERTION',16 UPDATE_ASSERTION: 'UPDATE_ASSERTION',17 ADD_RENDER: 'ADD_RENDER',18 DELETE_RENDER: 'DELETE_RENDER',19 UPDATE_RENDER_COMPONENT: 'UPDATE_RENDER_COMPONENT',20 ADD_PROP: 'ADD_PROP',21 DELETE_PROP: 'DELETE_PROP',22 UPDATE_PROP: 'UPDATE_PROP',23 CREATE_NEW_TEST: 'CREATE_NEW_TEST',24 OPEN_INFO_MODAL: 'OPEN_INFO_MODAL',25 CLOSE_INFO_MODAL: 'CLOSE_INFO_MODAL',26 REPLACE_TEST: 'REPLACE_TEST',27};28/* --------------------------------- Actions -------------------------------- */29export const addDescribeBlock = () => {30 return {31 type: actionTypes.ADD_DESCRIBE_BLOCK,32 };33};34export const deleteDescribeBlock = (describeId) => {35 return {36 type: actionTypes.DELETE_DESCRIBE_BLOCK,37 describeId,38 };39};40export const updateDescribeText = (text, describeId) => ({41 type: actionTypes.UPDATE_DESCRIBE_TEXT,42 text,43 describeId,44});45export const updateDescribeOrder = (reorderedDescribe) => ({46 type: actionTypes.UPDATE_DESCRIBE_ORDER,47 reorderedDescribe,48});49export const addItstatement = (describeId) => ({50 type: actionTypes.ADD_ITSTATEMENT,51 describeId,52});53export const deleteItStatement = (describeId, itId) => ({54 type: actionTypes.DELETE_ITSTATEMENT,55 describeId,56 itId,57});58export const updateItStatementText = (text, itId) => ({59 type: actionTypes.UPDATE_ITSTATEMENT_TEXT,60 itId,61 text,62});63export const updateItStatementOrder = (reorderedIt, describeId) => ({64 type: actionTypes.UPDATE_ITSTATEMENT_ORDER,65 reorderedIt,66 describeId,67});68export const addAction = (describeId, itId) => ({69 type: actionTypes.ADD_ACTION,70 describeId,71 itId,72});73export const deleteAction = (statementId) => ({74 type: actionTypes.DELETE_ACTION,75 statementId,76});77export const updateAction = ({78 id,79 eventType,80 eventValue,81 queryVariant,82 querySelector,83 queryValue,84 suggestions,85}) => ({86 type: actionTypes.UPDATE_ACTION,87 id,88 eventType,89 eventValue,90 queryVariant,91 querySelector,92 queryValue,93 suggestions,94});95export const addAssertion = (describeId, itId) => ({96 type: actionTypes.ADD_ASSERTION,97 describeId,98 itId,99});100export const deleteAssertion = (statementId) => ({101 type: actionTypes.DELETE_ASSERTION,102 statementId,103});104export const updateAssertion = ({105 id,106 queryVariant,107 querySelector,108 queryValue,109 isNot,110 matcherType,111 matcherValue,112 suggestions,113}) => ({114 type: actionTypes.UPDATE_ASSERTION,115 id,116 queryVariant,117 querySelector,118 queryValue,119 isNot,120 matcherType,121 matcherValue,122 suggestions,123});124export const addRender = (describeId, itId) => ({125 type: actionTypes.ADD_RENDER,126 describeId,127 itId,128});129export const deleteRender = (statementId) => ({130 type: actionTypes.DELETE_RENDER,131 statementId,132});133export const updateRenderComponent = (componentName, filePath) => ({134 type: actionTypes.UPDATE_RENDER_COMPONENT,135 componentName,136 filePath,137});138export const addProp = (statementId) => ({139 type: actionTypes.ADD_PROP,140 statementId,141});142export const deleteProp = (statementId, id) => {143 return {144 type: actionTypes.DELETE_PROP,145 id,146 statementId,147 };148};149export const updateProp = (statementId, id, propKey, propValue) => ({150 type: actionTypes.UPDATE_PROP,151 id,152 statementId,153 propKey,154 propValue,155});156export const createNewTest = () => ({157 type: actionTypes.CREATE_NEW_TEST,158});159export const openInfoModal = () => {160 return { type: actionTypes.OPEN_INFO_MODAL };161};162export const closeInfoModal = () => {163 return { type: actionTypes.CLOSE_INFO_MODAL };164};165export const reactReplaceTest = (testState) => ({166 type: actionTypes.REPLACE_TEST,167 testState,...

Full Screen

Full Screen

ItRenderer.jsx

Source:ItRenderer.jsx Github

copy

Full Screen

1import React, { useContext } from 'react';2import cn from 'classnames';3import { Draggable } from 'react-beautiful-dnd';4import ReactTestStatements from '../../TestCase/ReactTestStatements';5import CustomInput from '../CustomInput/CustomInput';6import {7 addRender,8 addAction,9 addAssertion,10 deleteItStatement,11} from '../../../context/actions/reactTestCaseActions';12import { ReactTestCaseContext } from '../../../context/reducers/reactTestCaseReducer';13import styles from './ItRenderer.module.scss';14const ItRenderer = ({15 type,16 itStatements,17 describeId,18 statements,19 handleChangeItStatementText,20}) => {21 const [, dispatchToReactTestCase] = useContext(ReactTestCaseContext);22 const addRenderHandleClick = (e) => {23 const itId = e.target.id;24 dispatchToReactTestCase(addRender(describeId, itId));25 };26 const deleteItStatementHandleClick = (e) => {27 const itId = e.target.id;28 dispatchToReactTestCase(deleteItStatement(describeId, itId));29 };30 const deleteReactItStatementOnKeyUp = (e) => {31 if (e.charCode === 13) {32 const itId = e.target.id;33 dispatchToReactTestCase(deleteItStatement(describeId, itId));34 }35 }36 const addActionHandleClick = (e) => {37 const itId = e.target.id;38 dispatchToReactTestCase(addAction(describeId, itId));39 };40 const addAssertionHandleClick = (e) => {41 const itId = e.target.id;42 dispatchToReactTestCase(addAssertion(describeId, itId));43 };44 return itStatements.allIds[describeId].map((id, i) => (45 <Draggable46 key={id}47 draggableId={id}48 index={i}49 >50 {(provided) => (51 <div52 id={styles.ItRenderer}53 ref={provided.innerRef}54 {...provided.draggableProps}55 {...provided.dragHandleProps}56 >57 <i58 tabIndex={0}59 onKeyPress={deleteReactItStatementOnKeyUp}60 onClick={deleteItStatementHandleClick}61 id={id}62 className={cn(styles.itClose, 'far fa-window-close')}63 ></i>64 <CustomInput65 key={`input-${id}-${i}`}66 id={id}67 label={'The component should...'}68 placeholder={'Button component renders correctly...'}69 value={itStatements.byId[id].text}70 handleChange={handleChangeItStatementText}71 />72 <hr />73 <ReactTestStatements74 key={`statement-${id}-${i}`}75 statements={statements}76 itId={id}77 describeId={describeId}78 />79 <div>80 {type === 'react' && (81 <div className={styles.buttonsContainer}>82 <button id={id} onClick={addRenderHandleClick} className={styles.reactButton}>83 <i className='fas fa-plus'></i>84 Render85 </button>86 <button id={id} onClick={addActionHandleClick} className={styles.reactButton}>87 <i className='fas fa-plus'></i>88 Action89 </button>90 <button id={id} onClick={addAssertionHandleClick} className={styles.reactButton}>91 <i className='fas fa-plus'></i>92 Assertion93 </button>94 </div>95 )}96 </div>97 </div>98 )}99 </Draggable>100 ));101};...

Full Screen

Full Screen

DescribeRenderer.jsx

Source:DescribeRenderer.jsx Github

copy

Full Screen

1import React, { useRef, useEffect } from 'react';2import cn from 'classnames';3import { Draggable, Droppable } from 'react-beautiful-dnd';4import ItRenderer from '../ItRenderer/ItRenderer';5import styles from './DescribeRenderer.module.scss';6import { deleteDescribeBlock, addItstatement } from '../../../context/actions/reactTestCaseActions';7const DescribeRenderer = ({8 dispatcher,9 describeBlocks,10 itStatements,11 statements,12 handleChangeDescribeText,13 handleChangeItStatementText,14 type,15}) => {16 const deleteDescribeBlockHandleClick = (e) => {17 e.stopPropagation();18 const describeId = e.target.id;19 dispatcher(deleteDescribeBlock(describeId));20 };21 const deleteReactDescribeBlockOnKeyUp = (e) => {22 if (e.charCode === 13) {23 const describeId = e.target.id;24 dispatcher(deleteDescribeBlock(describeId));25 }26 };27 const addItStatementHandleClick = (e) => {28 const describeId = e.target.id;29 dispatcher(addItstatement(describeId));30 };31 return describeBlocks.allIds.map((id, i) => (32 <Draggable key={id} draggableId={id} index={i} type='describe'>33 {(provided) => (34 <div35 id={styles.describeBlock}36 ref={provided.innerRef}37 {...provided.draggableProps}38 {...provided.dragHandleProps}39 >40 <label htmlFor='describe-label' className={styles.describeLabel}>41 Describe Block42 </label>43 <i44 tabIndex={0}45 onKeyPress={deleteReactDescribeBlockOnKeyUp}46 onClick={deleteDescribeBlockHandleClick}47 id={id}48 className={cn('far fa-window-close', styles.describeClose)}49 ></i>50 <input51 id={id}52 className={styles.describeInput}53 name='describe-label'54 type='text'55 placeholder={'The component has basic functionality'}56 value={describeBlocks.byId['describe0']?.text}57 onChange={handleChangeDescribeText}58 />59 <div className={styles.separator}></div>60 <Droppable droppableId={'droppableReactIt' + id} type={id}>61 {(innerProvided) => (62 <div ref={innerProvided.innerRef} {...innerProvided.droppableProps}>63 <ItRenderer64 type={type}65 key={`it-${id}-${i}`}66 itStatements={itStatements}67 statements={statements}68 describeId={id}69 handleChangeItStatementText={handleChangeItStatementText}70 />71 {innerProvided.placeholder}72 </div>73 )}74 </Droppable>75 <div className={styles.buttonContainer}>76 <button className={styles.addIt} id={id} onClick={addItStatementHandleClick}>77 +It Statement78 </button>79 </div>80 </div>81 )}82 </Draggable>83 ));84};...

Full Screen

Full Screen

ReactTestStatements.jsx

Source:ReactTestStatements.jsx Github

copy

Full Screen

1import React from 'react';2import Action from '../ReactTestComponent/Action/Action';3import Assertion from '../ReactTestComponent/Assertion/Assertion';4import Render from '../ReactTestComponent/Render/Render';5const ReactTestStatements = ({ statements, itId, describeId }) => {6 // filter out ids not belonging to the correct describe block and itStatement7 const filterStatements = statements.allIds.filter((id) => {8 return statements.byId[id].describeId === describeId && statements.byId[id].itId === itId;9 });10 return filterStatements.map((id, i) => {11 switch (statements.byId[id].type) {12 case 'action':13 return (14 <Action15 key={`action-${id}-${i}`}16 statementId={id}17 describeId={describeId}18 itId={itId}19 statement={statements.byId[id]}20 />21 );22 case 'assertion':23 return (24 <Assertion25 key={`assertion-${id}-${i}`}26 statementId={id}27 describeId={describeId}28 itId={itId}29 statement={statements.byId[id]}30 />31 );32 case 'render':33 return (34 <Render35 key={`render-${id}-${i}`}36 statementId={id}37 describeId={describeId}38 itId={itId}39 statement={statements.byId[id]}40 />41 );42 default:43 return <></>;44 }45 });46};...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const playwright = require('playwright');2(async () => {3 const browser = await playwright['chromium'].launch({ headless: false });4 const page = await browser.newPage();5 await page.click('text=Google apps');6 await page.click('text=YouTube');7 await page.click('text=Sign in');8 await page.click('input[aria-label="Email or phone"]');9 await page.fill('input[aria-label="Email or phone"]', '

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const page = await browser.newPage();5 await page.hover('text=Docs');6 const element = await page.$('text=Docs');7 const id = await element.describeID();8 console.log(id);9 await browser.close();10})();11{ id: 'node-1', framework: 'playwright' }12const input = await page.$('input[type="file"]');13await input.setInputFiles('C:\\Users\\user\\Desktop\\test.txt');14const [fileChooser] = await Promise.all([15 page.waitForEvent('filechooser'),16 page.click('input[type="file"]'),17]);18await fileChooser.setFiles('C:\\Users\\user\\Desktop\\test.txt');19const page = await browser.newPage();20await page.addInitScript({21});22await page.click('text=Docs');23const page = await browser.newPage();24await page.addInitScript({25});26await page.click('text=Docs');

Full Screen

Using AI Code Generation

copy

Full Screen

1const { describeID } = require('playwright/lib/server/domDebugging');2const { chromium } = require('playwright');3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 const element = await page.$('h1');8 console.log(await describeID(element._id));9 await browser.close();10})();11{ tagName: 'H1',12 { id: '0',13 style: 'font-size: 3em; font-weight: 600; color: rgb(51, 51, 51);' },14 shadowRoots: [] }

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 const element = await page.$('text=Get started');7 console.log(await element.describeID());8 await browser.close();9})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const {describeID} = require('playwright-core/lib/server/chromium/crPage');2const {chromium} = require('playwright-core');3(async () => {4 const browser = await chromium.launch();5 const page = await browser.newPage();6 const element = await page.$('text=Get started');7 const id = await describeID(page, element);8 console.log(id);9 await browser.close();10})();11{12}13The describeID() method returns an object with the following properties:

Full Screen

Using AI Code Generation

copy

Full Screen

1const { describeID } = require('@playwright/test');2describeID('test', () => {3 test('test', async ({ page }) => {4 });5});6 ✓ test (test.js:6:5)7 1 passed (2s)

Full Screen

Using AI Code Generation

copy

Full Screen

1const { describeID } = require('@playwright/test');2const { test, expect } = require('@playwright/test');3const { chromium } = require('playwright');4test.describe('My test', () => {5 let browser;6 test.beforeAll(async () => {7 browser = await chromium.launch();8 });9 test.afterAll(async () => {10 await browser.close();11 });12 test('My test', async ({ page }) => {13 await page.waitForSelector('text=Get started');14 await describeID(page, 'Get started');15 await page.click('text=Get started');16 await page.waitForSelector('text=Create a test');17 await describeID(page, 'Create a test');18 await page.click('text=Create a test');19 await page.waitForSelector('text=Next');20 await describeID(page, 'Next');21 await page.click('text=Next');22 await page.waitForSelector('text=Next');23 await describeID(page, 'Next');24 await page.click('text=Next');25 await page.waitForSelector('text=Run your test');26 await describeID(page, 'Run your test');27 await page.click('text=Run your test');28 await page.waitForSelector('text=Run your test');29 await describeID(page, 'Run your test');30 await page.click('text=Run your test');31 await page.waitForSelector('text=Run your test');32 await describeID(page, 'Run your test');33 await page.click('text=Run your test');34 await page.waitForSelector('text=Run your test');35 await describeID(page, 'Run your test');36 await page.click('text=Run your test');37 await page.waitForSelector('text=Run your test');38 await describeID(page, 'Run your test');39 await page.click('text=Run your test');40 await page.waitForSelector('text=Run your test');41 await describeID(page, 'Run your test');42 await page.click('text=Run your test');43 await page.waitForSelector('text=Run your test');44 await describeID(page, 'Run your test');45 await page.click('text=Run your test');46 await page.waitForSelector('text=Run your test');47 await describeID(page, 'Run your test');48 await page.click('text=Run your test');

Full Screen

Using AI Code Generation

copy

Full Screen

1const { describeID } = require('playwright/lib/server/dom.js');2const { chromium, webkit, firefox } = require('playwright');3const { expect } = require('chai');4(async () => {5 const browser = await chromium.launch();6 const context = await browser.newContext();7 const page = await context.newPage();8 const element = await page.$('#docs');9 const id = await describeID(element);10 expect(id).to.equal('docs');11 await browser.close();12})();13const { describeID } = require('playwright/lib/server/dom.js');14const { chromium, webkit, firefox } = require('playwright');15const { expect } = require('chai');16(async () => {17 const browser = await chromium.launch();18 const context = await browser.newContext();19 const page = await context.newPage();20 const element = await page.$('#docs');21 const id = await describeID(element);22 expect(id).to.equal('docs');23 await browser.close();24})();25const { describeID } = require('playwright/lib/server/dom.js');26const { chromium, webkit, firefox } = require('playwright');27const { expect } = require('chai');28(async () => {29 const browser = await chromium.launch();30 const context = await browser.newContext();31 const page = await context.newPage();32 const element = await page.$('#docs');33 const id = await describeID(element);34 expect(id).to.equal('docs');35 await browser.close();36})();37const { describeID } = require('playwright/lib/server/dom.js');38const { chromium, webkit, firefox } = require('playwright');39const { expect } = require('chai');40(async () => {41 const browser = await chromium.launch();42 const context = await browser.newContext();43 const page = await context.newPage();44 const element = await page.$('#docs');45 const id = await describeID(element

Full Screen

Using AI Code Generation

copy

Full Screen

1import { chromium, devices } from "playwright";2import { describeID } from "playwright/lib/server/injected/injectedScript";3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 const elementHandle = await page.$("text=Docs");8 const id = await page.evaluate((elementHandle) => describeID(elementHandle), elementHandle);9 console.log(id);10 await browser.close();11})();12{ id: 0, name: 'text=Docs', frameId: '0x1' }13import { chromium, devices } from "playwright";14import { describeID } from "playwright/lib/server/injected/injectedScript";15(async () => {16 const browser = await chromium.launch();17 const context = await browser.newContext();18 const page = await context.newPage();19 const elementHandle = await page.$("text=Docs");20 const id = await page.evaluateHandle((elementHandle) => describeID(elementHandle), elementHandle);21 console.log(id);22 await browser.close();23})();24import { chromium, devices } from "playwright";25import { describeID } from "playwright/lib/server/injected/injectedScript";26(async () => {27 const browser = await chromium.launch();28 const context = await browser.newContext();29 const page = await context.newPage();30 const elementHandle = await page.$("

Full Screen

Using AI Code Generation

copy

Full Screen

1const { describeID } = require('@playwright/test');2const { test, expect } = require('@playwright/test');3test('test', async () => {4 await describeID('test');5});6const { test, expect } = require('@playwright/test');7test.describe('test', () => {8 test('test', async ({ page }) => {9 await page.describeID('test');10 });11});12test('test', async ({ page }) => {13 await page.describeID('test');14});15test.describe('test', () => {16 test('test', async ({ page }) => {17 await page.describeID('test');18 });19});20test.describe('test', () => {21 test('test', async ({ page }) => {22 await page.describeID('test');23 });24});25test.describe('test', () => {26 test('test', async ({ page }) => {27 await page.describeID('test');28 });29});30test.describe('test', () => {31 test('test', async ({ page }) => {32 await page.describeID('test');33 });34});35test.describe('test', () => {36 test('test', async ({ page }) => {37 await page.describeID('test');38 });39});40test.describe('test', () => {41 test('test', async ({ page }) => {42 await page.describeID('test');43 });44});45test.describe('test', () => {46 test('test', async ({ page }) => {47 await page.describeID('test');48 });49});50test.describe('test', () => {51 test('test', async ({ page }) => {52 await page.describeID('test');53 });54});55test.describe('test', () => {56 test('test', async ({ page }) => {57 await page.describeID('test');58 });59});60test.describe('test', () => {61 test('test', async ({ page }) => {62 await page.describeID('test');63 });64});65test.describe('test', () => {66 test('test', async ({ page }) => {67 await page.describeID('test');68 });69});70test.describe('test', () => {71 test('test', async ({ page }) => {72 await page.describeID('test');73 });74});75test.describe('test', () => {76 test('test', async ({ page }) => {77 await page.describeID('test');

Full Screen

Playwright tutorial

LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.

Chapters:

  1. What is Playwright : Playwright is comparatively new but has gained good popularity. Get to know some history of the Playwright with some interesting facts connected with it.
  2. How To Install Playwright : Learn in detail about what basic configuration and dependencies are required for installing Playwright and run a test. Get a step-by-step direction for installing the Playwright automation framework.
  3. Playwright Futuristic Features: Launched in 2020, Playwright gained huge popularity quickly because of some obliging features such as Playwright Test Generator and Inspector, Playwright Reporter, Playwright auto-waiting mechanism and etc. Read up on those features to master Playwright testing.
  4. What is Component Testing: Component testing in Playwright is a unique feature that allows a tester to test a single component of a web application without integrating them with other elements. Learn how to perform Component testing on the Playwright automation framework.
  5. Inputs And Buttons In Playwright: Every website has Input boxes and buttons; learn about testing inputs and buttons with different scenarios and examples.
  6. Functions and Selectors in Playwright: Learn how to launch the Chromium browser with Playwright. Also, gain a better understanding of some important functions like “BrowserContext,” which allows you to run multiple browser sessions, and “newPage” which interacts with a page.
  7. Handling Alerts and Dropdowns in Playwright : Playwright interact with different types of alerts and pop-ups, such as simple, confirmation, and prompt, and different types of dropdowns, such as single selector and multi-selector get your hands-on with handling alerts and dropdown in Playright testing.
  8. Playwright vs Puppeteer: Get to know about the difference between two testing frameworks and how they are different than one another, which browsers they support, and what features they provide.
  9. Run Playwright Tests on LambdaTest: Playwright testing with LambdaTest leverages test performance to the utmost. You can run multiple Playwright tests in Parallel with the LammbdaTest test cloud. Get a step-by-step guide to run your Playwright test on the LambdaTest platform.
  10. Playwright Python Tutorial: Playwright automation framework support all major languages such as Python, JavaScript, TypeScript, .NET and etc. However, there are various advantages to Python end-to-end testing with Playwright because of its versatile utility. Get the hang of Playwright python testing with this chapter.
  11. Playwright End To End Testing Tutorial: Get your hands on with Playwright end-to-end testing and learn to use some exciting features such as TraceViewer, Debugging, Networking, Component testing, Visual testing, and many more.
  12. Playwright Video Tutorial: Watch the video tutorials on Playwright testing from experts and get a consecutive in-depth explanation of Playwright automation testing.

Run Playwright Internal 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