How to use expected_status method in wpt

Best JavaScript code snippet using wpt

prj-requests.js

Source:prj-requests.js Github

copy

Full Screen

1/**2 * Created by Vlad on 12.06.2015.3 */4var my = require('./../Common/ghap-lib');5var ghapFrisby = require('./../Common/ghap-frisby');6var prjUrls = require('./prj-prov_urls');7var prjResources = require('./prj-prov_resources');8module.exports.createProject = function(authHeader, prj_resource, callback){9 const EXPECTED_STATUS = 200;10 var start = new Date();11 return ghapFrisby.create(authHeader, ' Create Project', EXPECTED_STATUS)12 .post(prjUrls.getCreateProject_Url(), prj_resource.getCreateProject_json(),{json: true})13 .setLogMessage("Create project '%s'", prj_resource.name)14 .onSuccess(function (body) {15 expect(typeof body).toBe('object');16 my.copyProperties(body, prj_resource);17 })18 .next(callback)19 .returnPromise();20};21module.exports.deleteProject = function(authHeader, prj_resource, callback) {22 const EXPECTED_STATUS = 204;23 return ghapFrisby.create(authHeader, 'Delete Project', EXPECTED_STATUS)24 .delete(prjUrls.getDeleteProject_Url(prj_resource.id))25 .addHeader('content-type', 'application/json')26 .setLogMessage("Delete project '%s'", prj_resource.name)27 .next(callback)28 .returnPromise();29};30module.exports.getAllProjects = function(authHeader, all_projects, callback){31 const EXPECTED_STATUS = 200;32 return ghapFrisby.create(authHeader, 'Get All Projects', EXPECTED_STATUS)33 .get(prjUrls.getAllProjects_Url())34 .addHeader('content-type', 'application/json')35 .onSuccess(function (body) {36 var parsed_array = my.jsonParse(body);37 expect(parsed_array instanceof Array).toBe(true);38 if (parsed_array instanceof Array) {39 all_projects.length = 0;40 var element = parsed_array.shift();41 while(element) {42 var prj_res = prjResources.makeProject();43 my.copyProperties(element, prj_res);44 all_projects.push( prj_res );45 element = parsed_array.shift();46 }47 }48 })49 .next(callback)50 .returnPromise();51};52module.exports.getAllProjects4User = function(authHeader, ums_user, callback, error_handler){53 const EXPECTED_STATUS = 200;54 return ghapFrisby.create(authHeader, 'Get All Projects For User', EXPECTED_STATUS)55 .get(prjUrls.getAllProjects4User_Url(ums_user.getGuid()))56 .addHeader('content-type', 'application/json')57 .setLogMessage("Get All Projects For User '%s'", ums_user.getName())58 .onSuccess(function (body) {59 var parsed_array = my.jsonParse(body);60 expect(parsed_array instanceof Array).toBe(true);61 my.moveArray(parsed_array,ums_user.projects);62 })63 .onError(function(response_status, body){64 if(typeof error_handler === 'function') return error_handler(response_status, body);65 return false;66 })67 .next(callback)68 .returnPromise();69};70module.exports.getAllGrantsOfProject4User = function(authHeader, prj, ums_user){71 const EXPECTED_STATUS = 200;72 return ghapFrisby.create(authHeader, 'Get All Grants Of Project For User', EXPECTED_STATUS)73 .get(prjUrls.getAllGrantsOfProject4User_Url(prj.id, ums_user.getGuid()))74 .addHeader('content-type', 'application/json')75 .setLogMessage("Get All Grants of Project '%s' For User '%s'", prj.name, ums_user.getName())76 .onSuccess(function (body) {77 var parsed_array = my.jsonParse(body);78 expect(parsed_array instanceof Array).toBe(true);79 return parsed_array;80 })81 .returnPromise();82};83function UmsEntry(ums_object){84 if (ums_object.hasOwnProperty('objectClass') && (ums_object.objectClass === 'group')) {85 this.guid = ums_object.guid;86 this.name = 'group ' + ums_object.name;87 } else {88 this.guid = ums_object.getGuid();89 this.name = 'user ' + ums_object.getName();90 }91}92/**93 * @param {GhapAuthHeader} authHeader94 * @param {Object} prj_res95 * @param {Object} ums_object - UmsUser or UmsGroup96 * @param {string[]} permissions97 * @param {function} [callback]98 */99module.exports.grantPermissionsOnProject = function(authHeader, prj_res, ums_object, permissions, callback){100 const EXPECTED_STATUS = 200;101 var ums_entry = new UmsEntry(ums_object);102 return ghapFrisby.create(authHeader, 'Grant Project Permissions', EXPECTED_STATUS)103 .post( prjUrls.getGrantProjectPermissions_Url(prj_res.id, ums_entry.guid), permissions, {json: true} )104 .setLogMessage("Grant [%s] permissions to program '%s' for %s", permissions.toString(), prj_res.name, ums_entry.name)105 .next(callback)106 .returnPromise();107};108/**109 * @param {GhapAuthHeader} authHeader110 * @param {Object} prj_res111 * @param {Object} ums_object - UmsUser or UmsGroup112 * @param {string[]} permissions113 * @param {function} [callback]114 */115module.exports.revokeProjectPermissions = function(authHeader, prj_res, ums_object, permissions, callback){116 const EXPECTED_STATUS = 200;117 var ums_entry = new UmsEntry(ums_object);118 return ghapFrisby.create(authHeader, 'Grant Project Permissions', EXPECTED_STATUS)119 .post( prjUrls.getRevokeProjectPermissions_Url(prj_res.id, ums_entry.guid), permissions, {json: true} )120 .setLogMessage("Revoke [%s] permissions from program '%s' for %s", permissions.toString(), prj_res.name, ums_entry.name)121 .next(callback)122 .returnPromise();123};124module.exports.createGrant = function(authHeader, prj_res, grant_res, callback) {125 const EXPECTED_STATUS = 200;126 return ghapFrisby.create(authHeader,' Create Grant', EXPECTED_STATUS)127 .post(prjUrls.getCreateGrant_Url(prj_res.id), grant_res.getCreateGrant_json(), {json: true})128 //.addHeader('content-type', 'application/json')129 .setLogMessage("Create grant '%s' in project '%s'", grant_res.name, prj_res.name)130 .onSuccess(function(body){131 expect(typeof body).toBe('object');132 my.copyProperties(body, grant_res);133 prj_res.addGrant(grant_res)134 })135 .next(callback)136 .returnPromise();137};138module.exports.deleteGrant = function(authHeader, grant_res, callback) {139 const EXPECTED_STATUS = 204;140 return ghapFrisby.create(authHeader,' Delete Grant', EXPECTED_STATUS)141 .delete(prjUrls.getDeleteGrant_Url(grant_res.id))142 .addHeader('content-type', 'application/json')143 .setLogMessage("Delete grant '%s' in project '%s'", grant_res.name)144 .next(callback)145 .returnPromise();146/* var start = new Date();147 frisby.create(my.getStepNumStr()+' Delete Grant')148 .delete(prjUrls.getDeleteGrant_Url(grant_res.id))149 .addHeader(authHeader.Name, authHeader.Value)150 .addHeader('content-type', 'application/json')151 .expectStatus(EXPECTED_STATUS)152 .after(function (err, response, body) {153 console.log(my.endOfLine + 'Delete Grant ' + grant_res.name + ' - check response status code.');154 my.logExecutionTime(start);155 if (err) console.log(err);156 var response_status = this.current.response.status;157 if(response_status != EXPECTED_STATUS)158 console.log ("Unexpected status code '%d' in Delete Grant request. Body:\n<%s>", response_status, body);159 if (typeof callback === 'function')160 callback( jasmine.getEnv().currentSpec.results().failedCount );161 })162 .toss();*/163};164/**165 *166 * @param {GhapAuthHeader} authHeader167 * @param {Object} prj_resource168 * @param {Function} [callback]169 */170module.exports.getAllGrants = function(authHeader, prj_resource, callback){171 const EXPECTED_STATUS = 200;172 return ghapFrisby.create(authHeader, 'Get All Grants', EXPECTED_STATUS)173 .get(prjUrls.getAllGrants_Url(prj_resource.id))174 .addHeader('content-type', 'application/json')175 .setLogMessage("Get all grants for program '%s'", prj_resource.name)176 .onSuccess(function (body) {177 var parsed_array = my.jsonParse(body);178 if (parsed_array instanceof Array) {179 prj_resource.grants.length = 0;180 var element = parsed_array.shift();181 while(element) {182 var grant_res = prjResources.makeGrant();183 my.copyProperties(element,grant_res);184 prj_resource.addGrant( grant_res );185 element = parsed_array.shift();186 }187 }188 })189 .next(callback)190 .returnPromise();191};192module.exports.getAllUsers4Grant = function(authHeader, grant_res, all_grant_users, callback){193 const EXPECTED_STATUS = 200;194 return ghapFrisby.create(authHeader, 'Get All Grants', EXPECTED_STATUS)195 .get(prjUrls.getAllUsers4Grant_Url(grant_res.id))196 .addHeader('content-type', 'application/json')197 .setLogMessage("Get all users for grant '%s'", grant_res.name)198 .onSuccess(function (body) {199 var parsed_array = my.jsonParse(body);200 expect(parsed_array instanceof Array).toBe(true);201 my.moveArray(parsed_array, all_grant_users);202 })203 .next(callback)204 .returnPromise();205};206module.exports.grantPermissionsOnGrant = function(authHeader, grant_res, ums_user, permissions, callback){207 const EXPECTED_STATUS = 200;208 return ghapFrisby.create(authHeader, 'Grant Grant Permissions', EXPECTED_STATUS)209 .post(prjUrls.getGrantGrantPermissions_Url(grant_res.id, ums_user.getGuid()), permissions,{json: true})210 .setLogMessage("Grant [%s] permissions to grant '%s' for user '%s'",211 permissions.toString(), grant_res.name, ums_user.getName())212 .next(callback)213 .returnPromise();214};215module.exports.revokeGrantPermissions = function(authHeader, grant_res, ums_user, permissions, callback){216 const EXPECTED_STATUS = 200;217 return ghapFrisby.create(authHeader, 'Grant Grant Permissions', EXPECTED_STATUS)218 .post(prjUrls.getRevokeGrantPermissions_Url(grant_res.id, ums_user.getGuid()), permissions,{json: true})219 .setLogMessage("Revoke [%s] permissions from grant '%s' for user '%s'",220 permissions.toString(), grant_res.name, ums_user.getName())221 .next(callback)222 .returnPromise();223};224module.exports.getProjectUsersPermissions = function(authHeader, project, all_users){225 const EXPECTED_STATUS = 200;226 return ghapFrisby.create(authHeader, 'Get Project Users Permissions', EXPECTED_STATUS)227 .get(prjUrls.getProjectUsersPermissions_Url(project.id))228 .setLogMessage("Get users permissions for project '%s'", project.name)229 .addHeader('content-type', 'application/json')230 .onSuccess(function (body) {231 var parsed_array = my.jsonParse(body);232 expect(parsed_array instanceof Array).toBe(true);233 if (parsed_array instanceof Array) {234 project.permissions = parsed_array.map(function(obj){235 var user_name = null;236 if (all_users) {237 var user = my.findElementInArray(all_users, 'guid', obj.guid);238 if (user) user_name = user.name;239 }240 return {241 "guid" : obj.guid,242 "username" : user_name,243 "permission" : obj.permissions.toString()244 }245 });246 }247 })248 .returnPromise();249};250module.exports.getGrantUsersPermissions = function(authHeader, grant, all_users){251 const EXPECTED_STATUS = 200;252 return ghapFrisby.create(authHeader, 'Get Grant Users Permissions', EXPECTED_STATUS)253 .get(prjUrls.getAllUsers4Grant_Url( grant.id))254 .setLogMessage("Get users permissions for grant '%s'", grant.name)255 .addHeader('content-type', 'application/json')256 .onSuccess(function (body) {257 var parsed_array = my.jsonParse(body);258 expect(parsed_array instanceof Array).toBe(true);259 if (parsed_array instanceof Array) {260 grant.permissions = parsed_array.map(function(obj){261 var user_name = null;262 if (all_users) {263 var user = my.findElementInArray(all_users, 'guid', obj.guid);264 if (user) user_name = user.name;265 }266 return {267 "guid" : obj.guid,268 "username" : user_name,269 "permission" : obj.permissions.toString()270 }271 });272 }273 })274 .returnPromise();275};276/*------------------------------------------------------------------------------------------------------277DIRECT STASH REQUESTS278--------------------------------------------------------------------------------------------------------*/279/* @Path("/get") - get all projects */280 module.exports.getAllStashProjects = function(authHeader, all_stash_projects, callback){281 const EXPECTED_STATUS = 200;282 return ghapFrisby.create(authHeader, 'Get All Stash Projects', EXPECTED_STATUS)283 .get(prjUrls.getAllStashProjects_Url())284 .addHeader('content-type', 'application/json')285 .onSuccess(function (body) {286 var parsed_array = my.jsonParse(body);287 expect(parsed_array instanceof Array).toBe(true);288 if (parsed_array instanceof Array) {289 my.moveArray(parsed_array, all_stash_projects);290 }291 })292 .next(callback)293 .returnPromise();294};295/*296 @Path("/get/297 {projectKey}") - get all grants298 */299module.exports.getAllStashGrants4Project = function(authHeader, stash_project, callback){300 const EXPECTED_STATUS = 200;301 return ghapFrisby.create(authHeader, 'Get All Stash Grants For ' + stash_project.key + ' project', EXPECTED_STATUS)302 .get(prjUrls.getAllStashGrants4Project_Url(stash_project.key))303 .addHeader('content-type', 'application/json')304 .onSuccess(function (body) {305 var parsed_array = my.jsonParse(body);306 expect(parsed_array instanceof Array).toBe(true);307 if (parsed_array instanceof Array) {308 stash_project.grants = [];309 my.moveArray(parsed_array, stash_project.grants);310 }311 })312 .next(callback)313 .returnPromise();314};315/* @Path("/get/{projectKey}/permissions") */316module.exports.getStashProjectUsersPermissions = function(authHeader, stash_project){317 const EXPECTED_STATUS = 200;318 return ghapFrisby.create(authHeader, 'Get Stash Project Permissions', EXPECTED_STATUS)319 .get(prjUrls.getStashProjectUsersPermissions_Url(stash_project.key))320 .setLogMessage("Get Stash permissions for Project '%s'", stash_project.key)321 .addHeader('content-type', 'application/json')322 .onSuccess(function (body) {323 var parsed_array = my.jsonParse(body);324 expect(parsed_array instanceof Array).toBe(true);325 if (parsed_array instanceof Array) {326 stash_project.permissions = parsed_array.map(function(obj){327 return {328 "username" : obj.user.name,329 "permission" : obj.permission330 }331 });332 }333 })334 .returnPromise();335};336/* @Path("/get/{projectKey}/permissions/repo/{slug}") */337module.exports.getStashGrantUsersPermissions = function(authHeader, stash_project, stash_grant){338 const EXPECTED_STATUS = 200;339 return ghapFrisby.create(authHeader, 'Get Stash Grant Permissions', EXPECTED_STATUS)340 .get(prjUrls.getStashGrantUsersPermissions_Url( stash_project.key, stash_grant.slug))341 .setLogMessage("Get Stash permissions for Grant '%s/%s'", stash_project.key, stash_grant.name)342 .addHeader('content-type', 'application/json')343 .onSuccess(function (body) {344 var parsed_array = my.jsonParse(body);345 expect(parsed_array instanceof Array).toBe(true);346 if (parsed_array instanceof Array) {347 stash_grant.permissions = parsed_array.map(function(obj){348 return {349 "username" : obj.user.name,350 "permission" : obj.permission351 }352 });353 }354 })355 .returnPromise();356};357/*358 @Path("/get/{projectKey}359 /permissions/360 {username}") - project permissions for user361 */362/**363 * Get project permissions for the user directly from STASH364 * @param {GhapAuthHeader} authHeader365 * @param {string} stash_project_key366 * @param {string} stash_username367 * @return {Q.Promise} promise that will be resolved with permissions array of string368 */369module.exports.getStashProjectPermissions4User = function(authHeader, stash_project_key, stash_username){370 const EXPECTED_STATUS = 200;371 return ghapFrisby.create(authHeader, 'Get Stash Project Permissions For User', EXPECTED_STATUS)372 .get(prjUrls.getStashProjectPermissions4User_Url(stash_project_key, stash_username))373 .setLogMessage("Get Stash permissions: project '%s' user '%s'", stash_project_key, stash_username)374 .addHeader('content-type', 'application/json')375 .onSuccess(function (body) {376 var parsed_array = my.jsonParse(body);377 expect(parsed_array instanceof Array).toBe(true);378 if (parsed_array instanceof Array) {379 //console.log(body);380 if (parsed_array.length === 0) {381 return '';382 } else {383 expect(parsed_array.length).toBe(1);384 expect(parsed_array[0].user.name).toBe(stash_username);385 return parsed_array[0].permission;386 }387 }388 return null;389 })390 .returnPromise();391};392/* @Path("/get/{projectKey}/permissions/{username}/repo/{slug}") - grant permissions for user */393/*394 Response example:395 [{ "permission":"REPO_READ",396 "user": {397 "name":"A150829-0",398 "emailAddress":"andrew.krasnoff+3@gmail.com",399 "id":29,400 "displayName":"A150829 0",401 "active":true,402 "slug":"a150829-0",403 "type":"NORMAL"404 }405 }]406 */407module.exports.getStashGrantsPermissions4User = function (authHeader, stash_project_key, stash_username, stash_slug) {408 const EXPECTED_STATUS = 200;409 return ghapFrisby.create(authHeader, 'Get Stash Grant Permissions For User', EXPECTED_STATUS)410 .get(prjUrls.getStashGrantPermissions4User_Url(stash_project_key, stash_username, stash_slug))411 .setLogMessage("Get Stash permissions: project '%s' user '%s' repo '%s'", stash_project_key,412 stash_username, stash_slug)413 .addHeader('content-type', 'application/json')414 .onSuccess(function (body) {415 var parsed_array = my.jsonParse(body);416 expect(parsed_array instanceof Array).toBe(true);417 if (parsed_array instanceof Array) {418 //console.log(body);419 if (parsed_array.length === 0) {420 return '';421 } else {422 expect(parsed_array.length).toBe(1);423 expect(parsed_array[0].user.name).toBe(stash_username);424 return parsed_array[0].permission;425 }426 }427 return null;428 })429 .returnPromise();430};431module.exports.isFileExistsInStash = function (authHeader, fileName) {432 const EXPECTED_STATUS = 200;433 return ghapFrisby.create(authHeader, 'Check File In Stash', EXPECTED_STATUS)434 .get(prjUrls.isFileExistsInStash_Url(fileName))435 .setLogMessage("Check if file '%s' exists in Stash master branch", fileName)436 .addHeader('content-type', 'application/json')437 .onSuccess(function (body) {438 console.log(body)439 })440 .returnPromise();...

Full Screen

Full Screen

partial.any.js

Source:partial.any.js Github

copy

Full Screen

1// META: global=window,worker2// META: title=HTTP Cache - Partial Content3// META: timeout=long4// META: script=/common/utils.js5// META: script=/common/get-host-info.sub.js6// META: script=http-cache.js7var tests = [8 {9 name: "HTTP cache stores partial content and reuses it",10 requests: [11 {12 request_headers: [13 ['Range', "bytes=-5"]14 ],15 response_status: [206, "Partial Content"],16 response_headers: [17 ["Cache-Control", "max-age=3600"],18 ["Content-Range", "bytes 4-9/10"]19 ],20 response_body: "01234",21 expected_request_headers: [22 ["Range", "bytes=-5"]23 ]24 },25 {26 request_headers: [27 ["Range", "bytes=-5"]28 ],29 expected_type: "cached",30 expected_status: 206,31 expected_response_text: "01234"32 }33 ]34 },35 {36 name: "HTTP cache stores complete response and serves smaller ranges from it (byte-range-spec)",37 requests: [38 {39 response_headers: [40 ["Cache-Control", "max-age=3600"]41 ],42 response_body: "01234567890"43 },44 {45 request_headers: [46 ['Range', "bytes=0-1"]47 ],48 expected_type: "cached",49 expected_status: 206,50 expected_response_text: "01"51 },52 ]53 },54 {55 name: "HTTP cache stores complete response and serves smaller ranges from it (absent last-byte-pos)",56 requests: [57 {58 response_headers: [59 ["Cache-Control", "max-age=3600"],60 ],61 response_body: "01234567890"62 },63 {64 request_headers: [65 ['Range', "bytes=1-"]66 ],67 expected_type: "cached",68 expected_status: 206,69 expected_response_text: "1234567890"70 }71 ]72 },73 {74 name: "HTTP cache stores complete response and serves smaller ranges from it (suffix-byte-range-spec)",75 requests: [76 {77 response_headers: [78 ["Cache-Control", "max-age=3600"],79 ],80 response_body: "0123456789A"81 },82 {83 request_headers: [84 ['Range', "bytes=-1"]85 ],86 expected_type: "cached",87 expected_status: 206,88 expected_response_text: "A"89 }90 ]91 },92 {93 name: "HTTP cache stores partial response and serves smaller ranges from it (byte-range-spec)",94 requests: [95 {96 request_headers: [97 ['Range', "bytes=-5"]98 ],99 response_status: [206, "Partial Content"],100 response_headers: [101 ["Cache-Control", "max-age=3600"],102 ["Content-Range", "bytes 4-9/10"]103 ],104 response_body: "01234"105 },106 {107 request_headers: [108 ['Range', "bytes=6-8"]109 ],110 expected_type: "cached",111 expected_status: 206,112 expected_response_text: "234"113 }114 ]115 },116 {117 name: "HTTP cache stores partial response and serves smaller ranges from it (absent last-byte-pos)",118 requests: [119 {120 request_headers: [121 ['Range', "bytes=-5"]122 ],123 response_status: [206, "Partial Content"],124 response_headers: [125 ["Cache-Control", "max-age=3600"],126 ["Content-Range", "bytes 4-9/10"]127 ],128 response_body: "01234"129 },130 {131 request_headers: [132 ["Range", "bytes=6-"]133 ],134 expected_type: "cached",135 expected_status: 206,136 expected_response_text: "234"137 }138 ]139 },140 {141 name: "HTTP cache stores partial response and serves smaller ranges from it (suffix-byte-range-spec)",142 requests: [143 {144 request_headers: [145 ['Range', "bytes=-5"]146 ],147 response_status: [206, "Partial Content"],148 response_headers: [149 ["Cache-Control", "max-age=3600"],150 ["Content-Range", "bytes 4-9/10"]151 ],152 response_body: "01234"153 },154 {155 request_headers: [156 ['Range', "bytes=-1"]157 ],158 expected_type: "cached",159 expected_status: 206,160 expected_response_text: "4"161 }162 ]163 },164 {165 name: "HTTP cache stores partial content and completes it",166 requests: [167 {168 request_headers: [169 ['Range', "bytes=-5"]170 ],171 response_status: [206, "Partial Content"],172 response_headers: [173 ["Cache-Control", "max-age=3600"],174 ["Content-Range", "bytes 0-4/10"]175 ],176 response_body: "01234"177 },178 {179 expected_request_headers: [180 ["range", "bytes=5-"]181 ]182 }183 ]184 },185];...

Full Screen

Full Screen

main.js

Source:main.js Github

copy

Full Screen

1/* globals $ */2'use strict';3$(document).ready(function() {4 var time = 60,5 time_span = $('.refresh-time');6 setInterval(function () {7 time_span.html(time);8 time--;9 if (!time) {10 location.reload();11 }12 }, 1000);13 $('.services-item > .collapsible-header').click(function(){14 var icon = ($(this).hasClass('active')) ? 'remove' : 'add';15 $('.material-icons.sub-item').text(icon);16 });17 var services = [18 {19 name: 'Heartbeat/HeartbeatTM server',20 url: 'https://www.you1tube.com',21 test_url: 'https://www.you1tube.com',22 expected_status: [200]23 },24 {25 name: 'Partnership status checker',26 url: 'http://api2.freedom.tm:8000',27 test_url: 'http://api2.freedom.tm:8000',28 expected_status: 40429 },30 {31 name: 'Gamers.tm',32 url: 'http://gamers.tm/',33 test_url: 'http://gamers.tm/',34 expected_status: [200]35 },36 {37 name: 'Freedom! Dashboard',38 url: 'https://www.freedom.tm/',39 test_url: 'https://www.freedom.tm/',40 expected_status: [200]41 },42 {43 name: 'Freedom! Community Site',44 url: 'https://www.community.tm/',45 test_url: 'https://www.community.tm/',46 expected_status: [200]47 },48 {49 name: 'Freedom! Reuter Server',50 url: 'http://52.12.82.102:3000',51 test_url: 'http://52.12.82.102:3000',52 expected_status: [404]53 },54 {55 name: 'Earnings Module',56 url: 'https://earnings.freedom.tm',57 test_url: 'https://earnings.freedom.tm',58 expected_status: [200, 400, 403, 404]59 },60 {61 name: 'Spam.tm',62 url: 'http://www.spam.tm',63 test_url: 'http://www.spam.tm',64 expected_status: [200, 304]65 },66 {67 name: 'Universal Uploader',68 url: 'http://www.upload.tm',69 test_url: 'http://www.upload.tm',70 expected_status: [200, 304]71 }72 ];73 services.forEach(function (a) {74 $.get(a.test_url)75 .always(function (b) {76 $('#list').append(' \77 <li class="collection-item dismissable">\78 <div>' + a.name + ' (<a href="' + a.url + '" target="_blank">' + a.url + '</a>)\79 <span class="secondary-content status-text-' + ((Array.isArray(a.expected_status) && a.expected_status.indexOf(b.status)) || b.status === a.expected_status ? 'normal' : 'rekt') + '">' + ((Array.isArray(a.expected_status) && a.expected_status.indexOf(b.status)) || b.status === a.expected_status ? 'GOOD' : 'REKT') + '</span>\80 </div>\81 </li>\82 ');83 }84 );85 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3 if (err) return console.error(err);4 wpt.getTestStatus(data.data.testId, function(err, data) {5 if (err) return console.error(err);6 console.log(data.statusCode);7 });8});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2var wpt = new WebPageTest('www.webpagetest.org', 'API_KEY');3 if (err) {4 console.log(err);5 } else {6 console.log(data);7 wpt.expected_status(data.data.testId, function(err, data) {8 if (err) {9 console.log(err);10 } else {11 console.log(data);12 }13 });14 }15});16var wpt = require('wpt');17var wpt = new WebPageTest('www.webpagetest.org', 'API_KEY');18wpt.getLocations(function(err, data) {19 if (err) {20 console.log(err);21 } else {22 console.log(data);23 }24});25var wpt = require('wpt');26var wpt = new WebPageTest('www.webpagetest.org', 'API_KEY');27wpt.getTesters(function(err, data) {28 if (err) {29 console.log(err);30 } else {31 console.log(data);32 }33});34var wpt = require('wpt');35var wpt = new WebPageTest('www.webpagetest.org', 'API_KEY');36wpt.getTesters(function(err, data) {37 if (err) {38 console.log(err);39 } else {40 console.log(data);41 }42});43var wpt = require('wpt');44var wpt = new WebPageTest('www.webpagetest.org', 'API_KEY');45wpt.getTesters(function(err, data) {46 if (err) {47 console.log(err);48 } else {49 console.log(data);50 }51});52var wpt = require('wpt');53var wpt = new WebPageTest('www.webpagetest.org', 'API_KEY');54wpt.getTesters(function(err, data) {

Full Screen

Using AI Code Generation

copy

Full Screen

1const wpt = require('webpagetest');2const test = wpt('API_KEY');3}, (err, data) => {4 if (err) {5 console.error(err);6 } else {7 console.log(data);8 }9});10const wpt = require('webpagetest');11const test = wpt('API_KEY');12}, (err, data) => {13 if (err) {14 console.error(err);15 } else {16 console.log(data);17 }18});19const wpt = require('webpagetest');20const test = wpt('API_KEY');21}, (err, data) => {22 if (err) {23 console.error(err);24 } else {25 console.log(data);26 }27});28const wpt = require('webpagetest');29const test = wpt('API_KEY');30}, (err, data)

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3var wptOptions = {4};5wpt.runTest(url, wptOptions, function(err, data) {6 if (err) return console.error(err);7 console.log('Test initiated for %s. Polling results...', url);8 wpt.getTestResults(data.data.testId, function(err, data) {9 if (err) return console.error(err);10 console.log('Test completed for %s', url);11 console.log('First View (ms):', data.data.average.firstView.loadTime);12 });13});14var wpt = require('webpagetest');15var wpt = new WebPageTest('www.webpagetest.org');16var wptOptions = {17};18wpt.runTest(url, wptOptions, function(err, data) {19 if (err) return console.error(err);20 console.log('Test initiated for %s. Polling results...', url);21 wpt.getTestResults(data.data.testId, function(err, data) {22 if (err) return console.error(err);23 console.log('Test completed for %s', url);24 console.log('First View (ms):', data.data.average.firstView.loadTime);25 });26});27var wpt = require('webpagetest');28var wpt = new WebPageTest('www.webpagetest.org');29var wptOptions = {30};31wpt.runTest(url, wptOptions, function(err, data) {32 if (err) return console.error(err);

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org', 'A.1e4c4a4ae4c4a4ae4c4a4ae4c4a4ae4');3wpt.runTest('www.google.com', function(err, data) {4 if (err) return console.error(err);5 console.log('Test submitted for: ' + data.data.url);6 console.log('Test ID: ' + data.data.testId);7 wpt.expected_status(data.data.testId, function(err, data) {8 if (err) return console.error(err);9 console.log('Test status: ' + data.data.statusText);10 });11});12var wpt = require('webpagetest');13var wpt = new WebPageTest('www.webpagetest.org', 'A.1e4c4a4ae4c4a4ae4c4a4ae4c4a4ae4');14async function runTest() {15 const data = await wpt.runTest('www.google.com');16 console.log('Test submitted for: ' + data.data.url);17 console.log('Test ID: ' + data.data.testId);18 const data = await wpt.expected_status(data.data.testId);19 console.log('Test status: ' + data.data.statusText);20}21runTest();22You can also use the .then() method to chain asynchronous calls:23var wpt = require('webpagetest');24var wpt = new WebPageTest('www.webpagetest.org', 'A.1e4c4a4ae4c4a4ae4c4a4ae4c4a4ae4');25wpt.runTest('www.google.com')26.then(function(data) {27 console.log('Test submitted for: ' + data.data.url);28 console.log('Test ID: ' + data.data.testId);29 return wpt.expected_status(data.data.testId);30})31.then(function(data) {

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 wpt 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