How to use existingSheet method in wpt

Best JavaScript code snippet using wpt

loadMetrics.gs

Source:loadMetrics.gs Github

copy

Full Screen

1let configs = {};2function loadMetrics_() {3 loadConfigs();4 var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();5 var sheet;6 let sheetName = configs.sheetName.length > 1 ? configs.sheetName : `${getLongFormatDate(configs.startDate)} - ${getLongFormatDate(configs.endDate)}`;7 let existingSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetName);8 if (existingSheet != null) {9 sheet = existingSheet;10 existingSheet.getRange(1, 1, existingSheet.getMaxRows(), existingSheet.getMaxColumns()).clearContent().clearFormat();11 existingSheet.getCharts().forEach(chart => existingSheet.removeChart(chart))12 } else {13 sheet = spreadsheet.insertSheet()14 sheet.setName(sheetName);15 }16 // Freezes header's row17 sheet.setFrozenRows(1);18 var response = getPullRequests();19 var headers = ["Repository", "Summary", "Owner", "Ticket", "Commits", "Updates", "Needs Work", "Comments", "Fixes", "Reviewers", "ReApprovals", "Duration in hours", "Duration", "Created Date", "Closed Date", "PR Link"];20 let headersRange = sheet.getRange(1, 1, 1, headers.length).setValues([headers]);21 headersRange.setBackground('#5b95f9');22 headersRange.setFontWeight('bold');23 headersRange.setHorizontalAlignment("center");24 for (let i = 0; i < response.length; i++) {25 let pr = [response[i].repository, response[i].summary, response[i].owner, `=HYPERLINK("${configs.jiraLink}/${response[i].ticket}","${response[i].ticket}")`, response[i].commitsCount, response[i].updatesCount, response[i].needsWorkCount, response[i].commentsCount, response[i].fixesCount, response[i].reviewers, response[i].reapprovalsCount, response[i].durationInHours, response[i].duration, response[i].createdDate, response[i].closedDate, response[i].link];26 let line = i + 2;27 let range = sheet.getRange(line, 1, 1, headers.length);28 range.setValues([pr]);29 range.setHorizontalAlignment("left");30 range.setBackground(line % 2 ? '#ffffff' : '#e8f0fe');31 let rangeTicketCell = sheet.getRange(line, 4, 1, 1);32 rangeTicketCell.setFontColor('red');33 rangeTicketCell.setFontWeight('bold');34 let rangeTitleCell = sheet.getRange(line, 3, 1, 1);35 rangeTitleCell.setWrap(true);36 };37 let nextAvailableLine = response.length + 3;38 let dataRows = response.length + 1;39 createColumnChart('red', 'F', nextAvailableLine, 1, 'Updates after PR opening', sheet, dataRows);40 createColumnChart('yellow', 'K', nextAvailableLine, 3, 'Number of re-approvals', sheet, dataRows);41 createColumnChart('green', 'H', nextAvailableLine + 19, 1, 'Number of comments', sheet, dataRows);42 createColumnChart('blue', 'I', nextAvailableLine + 19, 3, 'Number of fixes', sheet, dataRows);43 createColumnChart('orange', 'L', nextAvailableLine + 38, 1, 'PR life time', sheet, dataRows);44 createColumnChart('purple', 'J', nextAvailableLine + 38, 3, 'Number of reviewers', sheet, dataRows);45 SpreadsheetApp.flush();46 for (let i = 1; i <= headers.length; i++) {47 sheet.autoResizeColumn(i);48 }49 sheet.setColumnWidth(1, 180);50 sheet.setColumnWidth(2, 450);51 SpreadsheetApp.setActiveSheet(sheet);52 var sheets = spreadsheet.getSheets();53 spreadsheet.moveActiveSheet(sheets.length);54}55/**56 * Situation Wall Metrics57 * Update each 1 hour58 * Layout only "Table"59 * Period last 30 days60 */61function loadSWMetrics() {62 loadConfigs();63 var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();64 var sheet;65 let sheetName = "Situation Wall";66 let existingSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetName);67 if (existingSheet != null) {68 sheet = existingSheet;69 existingSheet.getRange(1, 1, existingSheet.getMaxRows(), existingSheet.getMaxColumns()).clearContent().clearFormat();70 } else {71 sheet = spreadsheet.insertSheet()72 sheet.setName(sheetName);73 }74 // Freezes header's row75 sheet.setFrozenRows(1);76 // Get today and last 15 days77 var today = new Date();78 var dateLimit = new Date(new Date().setDate(today.getDate() - 15));79 Logger.log(today);80 Logger.log(dateLimit);81 //var response = getPullRequests(dateLimit.getTime(), today.getTime());82 var response = getPullRequests();83 var headers = ["Repository", "Summary", "Owner", "Ticket", "Commits", "Updates", "Needs Work", "Comments", "Fixes", "Reviewers", "ReApprovals", "Duration in hours", "Duration", "Created Date", "Closed Date", "PR Link"];84 let headersRange = sheet.getRange(1, 1, 1, headers.length).setValues([headers]);85 headersRange.setBackground('#5b95f9');86 headersRange.setFontWeight('bold');87 headersRange.setHorizontalAlignment("center");88 for (let i = 0; i < response.length; i++) {89 let pr = [response[i].repository, response[i].summary, response[i].owner, `=HYPERLINK("${configs.jiraLink}/${response[i].ticket}","${response[i].ticket}")`, response[i].commitsCount, response[i].updatesCount, response[i].needsWorkCount, response[i].commentsCount, response[i].fixesCount, response[i].reviewers, response[i].reapprovalsCount, response[i].durationInHours, response[i].duration, response[i].createdDate, response[i].closedDate, response[i].link];90 let line = i + 2;91 let range = sheet.getRange(line, 1, 1, headers.length);92 range.setValues([pr]);93 range.setHorizontalAlignment("left");94 range.setBackground(line % 2 ? '#ffffff' : '#e8f0fe');95 let rangeTicketCell = sheet.getRange(line, 4, 1, 1);96 rangeTicketCell.setFontColor('red');97 rangeTicketCell.setFontWeight('bold');98 let rangeTitleCell = sheet.getRange(line, 3, 1, 1);99 rangeTitleCell.setWrap(true);100 };101 sheet.setColumnWidth(1, 180);102 sheet.setColumnWidth(2, 450);103 SpreadsheetApp.setActiveSheet(sheet);104 var sheets = spreadsheet.getSheets();105 spreadsheet.moveActiveSheet(sheets.length);106}107function getPullRequests(startDate = null, endDate = null) {108 Logger.log(configs.startDate.getTime());109 Logger.log(configs.endDate.getTime());110 var options = {111 'method': 'post',112 'contentType': 'application/json',113 // Convert the JavaScript object to a JSON string.114 'payload': JSON.stringify({115 "startDate": !startDate ? configs.startDate.getTime() : startDate,116 "endDate": !endDate ? configs.endDate.getTime() : endDate,117 "branchName": configs.branchName,118 "project": configs.project,119 "repositories": configs.repositories,120 "bitBucketKey": configs.bitBucketKey121 }),122 'headers': {123 "x-api-key": configs.apiKey124 }125 };126 var res = UrlFetchApp.fetch("https://LAMBDA-URL_TO_GET_BITBUCKET_PR_METRICS", options);127 var json = JSON.parse(res.getContentText());128 return json.pullRequests;129}130function createColumnChart(color, dataColumn, row, column, title, sheet, dataRows) {131 var rangeChart = sheet.getRange(dataColumn + '2:' + dataColumn + dataRows);132 var rangeTickets = sheet.getRange('D2:D' + dataRows);133 var chartBuilder = sheet.newChart();134 var chart = chartBuilder135 .addRange(rangeTickets)136 .addRange(rangeChart)137 .setPosition(row, column, 1, 1)138 .setChartType(Charts.ChartType.COLUMN)139 .setOption('title', title)140 .setOption('colors', [color])141 .build();142 sheet.insertChart(chart);143}144function loadConfigs() {145 var settingsSheet =146 SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Settings");147 configs.startDate = new Date(getCellValue(settingsSheet, "B2"));148 configs.endDate = new Date(getCellValue(settingsSheet, "B3"));149 configs.sheetName = getCellValue(settingsSheet, "B4");150 configs.jiraLink = getCellValue(settingsSheet, "B9");151 configs.project = getCellValue(settingsSheet, "B8");152 configs.branchName = getCellValue(settingsSheet, "B10");153 configs.repositories = getCellValue(settingsSheet, "B11").split(',');154 configs.apiKey = getCellValue(settingsSheet, "B12");155 configs.bitBucketKey = getCellValue(settingsSheet, "B13");156}157function getCellValue(sheet, pos) {158 return sheet.getRange(pos).getValue()159}160let getLongFormatDate = (date) =>161 date.toLocaleDateString("en-US", {162 year: "numeric",163 month: "numeric",164 day: "numeric",165 timeZone: 'UTC'...

Full Screen

Full Screen

link-load-error-events.sub.js

Source:link-load-error-events.sub.js Github

copy

Full Screen

...12var isHttps = location.protocol == "https:";13var tests = [14 // Basic tests15 {16 href: existingSheet(),17 success: true,18 description: "Basic load of stylesheet",19 },20 {21 href: nonexistentSheet(),22 success: false,23 description: "Attempted load of nonexistent stylesheet",24 },25 {26 href: `data:text/css,@import url("${existingSheet()}")`,27 success: true,28 description: "Import of stylesheet",29 },30 {31 href: `data:text/css,@import url("${nonexistentSheet()}")`,32 success: false,33 description: "Import of nonexistent stylesheet",34 },35 {36 href: `data:text/css,@import url("data:text/css,@import url('${existingSheet()}')")`,37 success: true,38 description: "Import of import of stylesheet",39 },40 {41 href: `data:text/css,@import url("data:text/css,@import url('${nonexistentSheet()}')")`,42 success: false,43 description: "Import of import of nonexistent stylesheet",44 },45 // Non-CSS-response tests.46 {47 href: makeUnique(""),48 success: false,49 description: "Load of non-CSS stylesheet",50 },51 {52 href: `data:text/css,@import url("${makeUnique("")}")`,53 success: false,54 description: "Import of non-CSS stylesheet",55 },56 {57 href: `data:text/css,@import url("data:text/css,@import url('${makeUnique("")}')")`,58 success: false,59 description: "Import of import of non-CSS stylesheet",60 },61 // http:// tests, to test what happens with mixed content blocking.62 {63 href: httpSheet(),64 success: !isHttps,65 description: "Load of http:// stylesheet",66 },67 {68 href: `data:text/css,@import url("${httpSheet()}")`,69 success: !isHttps,70 description: "Import of http:// stylesheet",71 },72 {73 href: `data:text/css,@import url("data:text/css,@import url('${httpSheet()}')")`,74 success: !isHttps,75 description: "Import of import of http:// stylesheet",76 },77 // https:// tests just as a control78 {79 href: httpsSheet(),80 success: true,81 description: "Load of https:// stylesheet",82 },83 {84 href: `data:text/css,@import url("${httpsSheet()}")`,85 success: true,86 description: "Import of https:// stylesheet",87 },88 {89 href: `data:text/css,@import url("data:text/css,@import url('${httpsSheet()}')")`,90 success: true,91 description: "Import of import of https:// stylesheet",92 },93 // Tests with multiple imports some of which are slow and some are fast.94 {95 href: `data:text/css,@import url("${slowResponse(existingSheet())}"); @import url("${nonexistentSheet()}");`,96 success: false,97 description: "Slow successful import, fast failing import",98 },99 {100 href: `data:text/css,@import url("${existingSheet()}"); @import url("${slowResponse(nonexistentSheet())}");`,101 success: false,102 description: "Fast successful import, slow failing import",103 }104];105// Note: Here we really do need to use "let" at least for the href,106// because we lazily evaluate it in the unreached cases.107for (var test of tests) {108 let {href, success, description} = test;109 var t = async_test(description);110 var link = document.createElement("link");111 link.rel = "stylesheet";112 hrefString = DEBUG_URLS ? `: ${href}` : "";113 if (success) {114 link.onload = t.step_func_done(() => {});115 link.onerror = t.step_func_done(() => assert_unreached(`error fired when load expected${hrefString}`) );116 } else {117 link.onerror = t.step_func_done(() => {});118 link.onload = t.step_func_done(() => assert_unreached(`load fired when error expected${hrefString}`) );119 }120 link.href = href;121 document.head.appendChild(link);122}123/* Utility function */124function makeUnique(url) {125 // Make sure we copy here, even if the thing coming in is a URL, so we don't126 // mutate our caller's data.127 url = new URL(url, location.href);128 // We want to generate a unique URI to avoid the various caches browsers have129 // for stylesheets. We don't want to just use a counter, because that would130 // not be robust to the test being reloaded or othewise run multiple times131 // without a browser restart. We don't want to use timstamps, because those132 // are not likely to be unique across calls to this function, especially given133 // the degraded timer resolution browsers have due to Spectre.134 //135 // So just fall back on Math.random() and assume it can't duplicate values.136 url.searchParams.append("r", Math.random());137 return url;138}139function existingSheet() {140 return makeUnique("resources/good.css");141}142/**143 * Function the add values to the "pipe" search param. See144 * http://wptserve.readthedocs.io/en/latest/pipes.html for why one would do145 * this. Because this param uses a weird '|'-separated syntax instead of just146 * using multiple params with the same name, we need some manual code to munge147 * the value properly.148 */149function addPipe(url, pipeVal) {150 url = new URL(url, location.href);151 var params = url.searchParams;152 var oldVal = params.get("pipe");153 if (oldVal) {154 params.set("pipe", oldVal + "|" + pipeVal);155 } else {156 params.set("pipe", pipeVal);157 }158 return url;159}160function nonexistentSheet() {161 return addPipe(existingSheet(), "status(404)");162}163function httpSheet() {164 var url = existingSheet();165 url.protocol = "http";166 url.port = {{ports[http][0]}};167 return url;168}169function httpsSheet() {170 var url = existingSheet();171 url.protocol = "https";172 url.port = {{ports[https][0]}};173 return url;174}175function slowResponse(url) {176 return addPipe(url, "trickle(d1)");...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3var options = {4};5wpt.getTesters(function (err, data) {6 if (err) {7 console.log(err);8 } else {9 console.log(data);10 }11});12 if (err) {13 console.log(err);14 } else {15 console.log(data);16 }17});18var wpt = require('webpagetest');19var wpt = new WebPageTest('www.webpagetest.org');20wpt.getTesters(function (err, data) {21 if (err) {22 console.log(err);23 } else {24 console.log(data);25 }26});27wpt.existingTest('170113_0J_6e5d6e7e6b1f9c9c3d3e7c3f6b8', function (err, data) {28 if (err) {29 console.log(err);30 } else {31 console.log(data);32 }33});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var fs = require('fs');3var Excel = require('exceljs');4var workbook = new Excel.Workbook();5var worksheet = workbook.addWorksheet('My Sheet');6var sheet = workbook.getWorksheet('My Sheet');7var i = 0;8var j = 0;9var k = 0;10var l = 0;11var m = 0;12var n = 0;13var o = 0;14var p = 0;15var q = 0;16var r = 0;17var s = 0;18var t = 0;19var u = 0;20var v = 0;21var w = 0;22var x = 0;23var y = 0;24var z = 0;25var a = 0;26var b = 0;27var c = 0;28var d = 0;29var e = 0;30var f = 0;31var g = 0;32var h = 0;33var i = 0;34var j = 0;35var k = 0;36var l = 0;37var m = 0;38var n = 0;39var o = 0;40var p = 0;41var q = 0;42var r = 0;43var s = 0;44var t = 0;45var u = 0;46var v = 0;47var w = 0;48var x = 0;49var y = 0;50var z = 0;51var a = 0;52var b = 0;53var c = 0;54var d = 0;55var e = 0;56var f = 0;57var g = 0;58var h = 0;59var i = 0;60var j = 0;61var k = 0;62var l = 0;63var m = 0;64var n = 0;65var o = 0;66var p = 0;67var q = 0;68var r = 0;69var s = 0;70var t = 0;71var u = 0;72var v = 0;73var w = 0;74var x = 0;75var y = 0;76var z = 0;77var a = 0;78var b = 0;79var c = 0;

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require("wptools");2var options = {3};4wptools.setOptions(options);5wptools.page("Barack Obama")6 .then(function(page) {7 return page.getWikiText();8 })9 .then(function(wikitext) {10 console.log(wikitext);11 })12 .catch(function(error) {13 console.log(error);14 });15var wptools = require("wptools");16var options = {17};18wptools.setOptions(options);19wptools.page("Barack Obama")20 .then(function(page) {21 return page.getWikiText();22 })23 .then(function(wikitext) {24 console.log(wikitext);25 })26 .catch(function(error) {27 console.log(error);28 });29var wptools = require("wptools");30var options = {31};32wptools.setOptions(options);33wptools.page("Barack Obama")34 .then(function(page) {35 return page.getWikiText();36 })37 .then(function(wikitext) {38 console.log(wikitext);39 })40 .catch(function(error) {41 console.log(error);42 });43var wptools = require("wptools");44var options = {45};46wptools.setOptions(options);47wptools.page("Barack Obama")48 .then(function(page) {49 return page.getWikiText();50 })51 .then(function(wikitext) {52 console.log(wikitext);53 })54 .catch(function(error) {55 console.log(error);56 });57var wptools = require("wptools");58var options = {59};60wptools.setOptions(options);61wptools.page("Barack Obama")

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2var existingSheet = wpt.existingSheet;3existingSheet('mysheet', function(err, sheet){4 if(err){5 console.log(err);6 }7 else{8 console.log(sheet);9 }10});11var wpt = require('wpt');12var createSheet = wpt.createSheet;13var sheetData = {14 {15 },16 {17 }18}19createSheet(sheetData, function(err, sheet){20 if(err){21 console.log(err);22 }23 else{24 console.log(sheet);25 }26});27var wpt = require('wpt');28var updateSheet = wpt.updateSheet;29var sheetData = {30 {31 },32 {33 }34}35updateSheet(sheetData, function(err, sheet){36 if(err){37 console.log(err);38 }39 else{40 console.log(sheet);41 }42});43var wpt = require('wpt');44var deleteSheet = wpt.deleteSheet;45deleteSheet('mysheet', function(err, sheet){46 if(err){47 console.log(err);48 }49 else{50 console.log(sheet);51 }52});53var wpt = require('wpt');54var getSheet = wpt.getSheet;55getSheet('mysheet', function(err, sheet){56 if(err){57 console.log(err);58 }59 else{60 console.log(sheet);61 }62});63var wpt = require('wpt');64var getSheets = wpt.getSheets;65getSheets(function(err, sheets){66 if(err){67 console.log(err);68 }69 else{70 console.log(sheets);71 }72});73var wpt = require('wpt');

Full Screen

Using AI Code Generation

copy

Full Screen

1var sheet = wptools.existingSheet({2});3console.log(sheet);4console.log(sheet.data);5console.log(sheet.headers);6console.log(sheet.headerNames);7console.log(sheet.headerKeys);8console.log(sheet.rows);9console.log(sheet.rowObjects);

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