How to use pr method in wpt

Best JavaScript code snippet using wpt

server-integration.e2e.ts

Source:server-integration.e2e.ts Github

copy

Full Screen

1// Imports2import {AIO_NGINX_HOSTNAME} from '../common/env-variables';3import {computeShortSha} from '../common/utils';4import {ALT_SHA, BuildNums, PrNums, SHA} from './constants';5import {helper as h, makeCurl, payload} from './helper';6import {customMatchers} from './jasmine-custom-matchers';7// Tests8h.runForAllSupportedSchemes((scheme, port) => describe(`integration (on ${scheme.toUpperCase()})`, () => {9 const hostname = AIO_NGINX_HOSTNAME;10 const host = `${hostname}:${port}`;11 const curlPrUpdated = makeCurl(`${scheme}://${host}/pr-updated`);12 const getFile = (pr: number, sha: string, file: string) =>13 h.runCmd(`curl -iL ${scheme}://pr${pr}-${computeShortSha(sha)}.${host}/${file}`);14 const prUpdated = (prNum: number, action?: string) => curlPrUpdated({ data: { number: prNum, action } });15 const circleBuild = makeCurl(`${scheme}://${host}/circle-build`);16 beforeEach(() => {17 jasmine.DEFAULT_TIMEOUT_INTERVAL = 5000;18 jasmine.addMatchers(customMatchers);19 });20 afterEach(() => h.cleanUp());21 describe('for a new/non-existing PR', () => {22 it('should be able to create and serve a public preview', async () => {23 const BUILD = BuildNums.TRUST_CHECK_ACTIVE_TRUSTED_USER;24 const PR = PrNums.TRUST_CHECK_ACTIVE_TRUSTED_USER;25 const regexPrefix = `^BUILD: ${BUILD} \\| PR: ${PR} \\| SHA: ${SHA} \\| File:`;26 const idxContentRegex = new RegExp(`${regexPrefix} \\/index\\.html$`);27 const barContentRegex = new RegExp(`${regexPrefix} \\/foo\\/bar\\.js$`);28 await circleBuild(payload(BUILD)).then(h.verifyResponse(201));29 await Promise.all([30 getFile(PR, SHA, 'index.html').then(h.verifyResponse(200, idxContentRegex)),31 getFile(PR, SHA, 'foo/bar.js').then(h.verifyResponse(200, barContentRegex)),32 ]);33 expect({ prNum: PR }).toExistAsABuild();34 expect({ prNum: PR, isPublic: false }).not.toExistAsABuild();35 });36 it('should be able to create but not serve a hidden preview', async () => {37 const BUILD = BuildNums.TRUST_CHECK_UNTRUSTED;38 const PR = PrNums.TRUST_CHECK_UNTRUSTED;39 await circleBuild(payload(BUILD)).then(h.verifyResponse(202));40 await Promise.all([41 getFile(PR, SHA, 'index.html').then(h.verifyResponse(404)),42 getFile(PR, SHA, 'foo/bar.js').then(h.verifyResponse(404)),43 ]);44 expect({ prNum: PR }).not.toExistAsABuild();45 expect({ prNum: PR, isPublic: false }).toExistAsABuild();46 });47 it('should reject if verification fails', async () => {48 const BUILD = BuildNums.TRUST_CHECK_ERROR;49 const PR = PrNums.TRUST_CHECK_ERROR;50 await circleBuild(payload(BUILD)).then(h.verifyResponse(500));51 expect({ prNum: PR }).toExistAsAnArtifact();52 expect({ prNum: PR }).not.toExistAsABuild();53 expect({ prNum: PR, isPublic: false }).not.toExistAsABuild();54 });55 it('should be able to notify that a PR has been updated (and do nothing)', async () => {56 await prUpdated(PrNums.TRUST_CHECK_ACTIVE_TRUSTED_USER).then(h.verifyResponse(200));57 // The PR should still not exist.58 expect({ prNum: PrNums.TRUST_CHECK_ACTIVE_TRUSTED_USER, isPublic: false }).not.toExistAsABuild();59 expect({ prNum: PrNums.TRUST_CHECK_ACTIVE_TRUSTED_USER, isPublic: true }).not.toExistAsABuild();60 });61 });62 describe('for an existing PR', () => {63 it('should be able to create and serve a public preview', async () => {64 const BUILD = BuildNums.TRUST_CHECK_ACTIVE_TRUSTED_USER;65 const PR = PrNums.TRUST_CHECK_ACTIVE_TRUSTED_USER;66 const regexPrefix1 = `^PR: ${PR} \\| SHA: ${ALT_SHA} \\| File:`;67 const idxContentRegex1 = new RegExp(`${regexPrefix1} \\/index\\.html$`);68 const barContentRegex1 = new RegExp(`${regexPrefix1} \\/foo\\/bar\\.js$`);69 const regexPrefix2 = `^BUILD: ${BUILD} \\| PR: ${PR} \\| SHA: ${SHA} \\| File:`;70 const idxContentRegex2 = new RegExp(`${regexPrefix2} \\/index\\.html$`);71 const barContentRegex2 = new RegExp(`${regexPrefix2} \\/foo\\/bar\\.js$`);72 h.createDummyBuild(PR, ALT_SHA);73 await circleBuild(payload(BUILD)).then(h.verifyResponse(201));74 await Promise.all([75 getFile(PR, ALT_SHA, 'index.html').then(h.verifyResponse(200, idxContentRegex1)),76 getFile(PR, ALT_SHA, 'foo/bar.js').then(h.verifyResponse(200, barContentRegex1)),77 getFile(PR, SHA, 'index.html').then(h.verifyResponse(200, idxContentRegex2)),78 getFile(PR, SHA, 'foo/bar.js').then(h.verifyResponse(200, barContentRegex2)),79 ]);80 expect({ prNum: PR, sha: SHA }).toExistAsABuild();81 expect({ prNum: PR, sha: ALT_SHA }).toExistAsABuild();82 });83 it('should be able to create but not serve a hidden preview', async () => {84 const BUILD = BuildNums.TRUST_CHECK_UNTRUSTED;85 const PR = PrNums.TRUST_CHECK_UNTRUSTED;86 h.createDummyBuild(PR, ALT_SHA, false);87 await circleBuild(payload(BUILD)).then(h.verifyResponse(202));88 await Promise.all([89 getFile(PR, ALT_SHA, 'index.html').then(h.verifyResponse(404)),90 getFile(PR, ALT_SHA, 'foo/bar.js').then(h.verifyResponse(404)),91 getFile(PR, SHA, 'index.html').then(h.verifyResponse(404)),92 getFile(PR, SHA, 'foo/bar.js').then(h.verifyResponse(404)),93 ]);94 expect({ prNum: PR, sha: SHA }).not.toExistAsABuild();95 expect({ prNum: PR, sha: SHA, isPublic: false }).toExistAsABuild();96 expect({ prNum: PR, sha: ALT_SHA }).not.toExistAsABuild();97 expect({ prNum: PR, sha: ALT_SHA, isPublic: false }).toExistAsABuild();98 });99 it('should reject if verification fails', async () => {100 const BUILD = BuildNums.TRUST_CHECK_ERROR;101 const PR = PrNums.TRUST_CHECK_ERROR;102 h.createDummyBuild(PR, ALT_SHA, false);103 await circleBuild(payload(BUILD)).then(h.verifyResponse(500));104 expect({ prNum: PR }).toExistAsAnArtifact();105 expect({ prNum: PR }).not.toExistAsABuild();106 expect({ prNum: PR, isPublic: false }).not.toExistAsABuild();107 expect({ prNum: PR, sha: ALT_SHA, isPublic: false }).toExistAsABuild();108 });109 it('should not be able to overwrite an existing public preview', async () => {110 const BUILD = BuildNums.TRUST_CHECK_ACTIVE_TRUSTED_USER;111 const PR = PrNums.TRUST_CHECK_ACTIVE_TRUSTED_USER;112 const regexPrefix = `^PR: ${PR} \\| SHA: ${SHA} \\| File:`;113 const idxContentRegex = new RegExp(`${regexPrefix} \\/index\\.html$`);114 const barContentRegex = new RegExp(`${regexPrefix} \\/foo\\/bar\\.js$`);115 h.createDummyBuild(PR, SHA);116 await circleBuild(payload(BUILD)).then(h.verifyResponse(409));117 await Promise.all([118 getFile(PrNums.TRUST_CHECK_ACTIVE_TRUSTED_USER, SHA, 'index.html').then(h.verifyResponse(200, idxContentRegex)),119 getFile(PrNums.TRUST_CHECK_ACTIVE_TRUSTED_USER, SHA, 'foo/bar.js').then(h.verifyResponse(200, barContentRegex)),120 ]);121 expect({ prNum: PR }).toExistAsAnArtifact();122 expect({ prNum: PR }).toExistAsABuild();123 });124 it('should not be able to overwrite an existing hidden preview', async () => {125 const BUILD = BuildNums.TRUST_CHECK_UNTRUSTED;126 const PR = PrNums.TRUST_CHECK_UNTRUSTED;127 h.createDummyBuild(PR, SHA, false);128 await circleBuild(payload(BUILD)).then(h.verifyResponse(409));129 expect({ prNum: PR }).toExistAsAnArtifact();130 expect({ prNum: PR, isPublic: false }).toExistAsABuild();131 });132 it('should be able to request re-checking visibility (if outdated)', async () => {133 const publicPr = PrNums.TRUST_CHECK_ACTIVE_TRUSTED_USER;134 const hiddenPr = PrNums.TRUST_CHECK_UNTRUSTED;135 h.createDummyBuild(publicPr, SHA, false);136 h.createDummyBuild(hiddenPr, SHA, true);137 // PR visibilities are outdated (i.e. the opposte of what the should).138 expect({ prNum: publicPr, sha: SHA, isPublic: false }).toExistAsABuild(false);139 expect({ prNum: publicPr, sha: SHA, isPublic: true }).not.toExistAsABuild(false);140 expect({ prNum: hiddenPr, sha: SHA, isPublic: false }).not.toExistAsABuild(false);141 expect({ prNum: hiddenPr, sha: SHA, isPublic: true }).toExistAsABuild(false);142 await Promise.all([143 prUpdated(publicPr).then(h.verifyResponse(200)),144 prUpdated(hiddenPr).then(h.verifyResponse(200)),145 ]);146 // PR visibilities should have been updated.147 expect({ prNum: publicPr, isPublic: false }).not.toExistAsABuild();148 expect({ prNum: publicPr, isPublic: true }).toExistAsABuild();149 expect({ prNum: hiddenPr, isPublic: false }).toExistAsABuild();150 expect({ prNum: hiddenPr, isPublic: true }).not.toExistAsABuild();151 });152 it('should be able to request re-checking visibility (if up-to-date)', async () => {153 const publicPr = PrNums.TRUST_CHECK_ACTIVE_TRUSTED_USER;154 const hiddenPr = PrNums.TRUST_CHECK_UNTRUSTED;155 h.createDummyBuild(publicPr, SHA, true);156 h.createDummyBuild(hiddenPr, SHA, false);157 // PR visibilities are already up-to-date.158 expect({ prNum: publicPr, sha: SHA, isPublic: false }).not.toExistAsABuild(false);159 expect({ prNum: publicPr, sha: SHA, isPublic: true }).toExistAsABuild(false);160 expect({ prNum: hiddenPr, sha: SHA, isPublic: false }).toExistAsABuild(false);161 expect({ prNum: hiddenPr, sha: SHA, isPublic: true }).not.toExistAsABuild(false);162 await Promise.all([163 prUpdated(publicPr).then(h.verifyResponse(200)),164 prUpdated(hiddenPr).then(h.verifyResponse(200)),165 ]);166 // PR visibilities are still up-to-date.167 expect({ prNum: publicPr, isPublic: true }).toExistAsABuild();168 expect({ prNum: publicPr, isPublic: false }).not.toExistAsABuild();169 expect({ prNum: hiddenPr, isPublic: true }).not.toExistAsABuild();170 expect({ prNum: hiddenPr, isPublic: false }).toExistAsABuild();171 });172 it('should reject a request if re-checking visibility fails', async () => {173 const errorPr = PrNums.TRUST_CHECK_ERROR;174 h.createDummyBuild(errorPr, SHA, true);175 expect({ prNum: errorPr, isPublic: false }).not.toExistAsABuild(false);176 expect({ prNum: errorPr, isPublic: true }).toExistAsABuild(false);177 await prUpdated(errorPr).then(h.verifyResponse(500, /TRUST_CHECK_ERROR/));178 // PR visibility should not have been updated.179 expect({ prNum: errorPr, isPublic: false }).not.toExistAsABuild();180 expect({ prNum: errorPr, isPublic: true }).toExistAsABuild();181 });182 it('should reject a request if updating visibility fails', async () => {183 // One way to cause an error is to have both a public and a hidden directory for the same PR.184 h.createDummyBuild(PrNums.TRUST_CHECK_ACTIVE_TRUSTED_USER, SHA, false);185 h.createDummyBuild(PrNums.TRUST_CHECK_ACTIVE_TRUSTED_USER, SHA, true);186 const hiddenPrDir = h.getPrDir(PrNums.TRUST_CHECK_ACTIVE_TRUSTED_USER, false);187 const publicPrDir = h.getPrDir(PrNums.TRUST_CHECK_ACTIVE_TRUSTED_USER, true);188 const bodyRegex = new RegExp(`Request to move '${hiddenPrDir}' to existing directory '${publicPrDir}'`);189 expect({ prNum: PrNums.TRUST_CHECK_ACTIVE_TRUSTED_USER, isPublic: false }).toExistAsABuild(false);190 expect({ prNum: PrNums.TRUST_CHECK_ACTIVE_TRUSTED_USER, isPublic: true }).toExistAsABuild(false);191 await prUpdated(PrNums.TRUST_CHECK_ACTIVE_TRUSTED_USER).then(h.verifyResponse(409, bodyRegex));192 // PR visibility should not have been updated.193 expect({ prNum: PrNums.TRUST_CHECK_ACTIVE_TRUSTED_USER, isPublic: false }).toExistAsABuild();194 expect({ prNum: PrNums.TRUST_CHECK_ACTIVE_TRUSTED_USER, isPublic: true }).toExistAsABuild();195 });196 });...

Full Screen

Full Screen

lang-dart.js

Source:lang-dart.js Github

copy

Full Screen

1// Copyright (C) 2013 Google Inc.2//3// Licensed under the Apache License, Version 2.0 (the "License");4// you may not use this file except in compliance with the License.5// You may obtain a copy of the License at6//7// http://www.apache.org/licenses/LICENSE-2.08//9// Unless required by applicable law or agreed to in writing, software10// distributed under the License is distributed on an "AS IS" BASIS,11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12// See the License for the specific language governing permissions and13// limitations under the License.14/**15 * @fileoverview16 * Registers a language handler Dart.17 * Loosely structured based on the DartLexer in Pygments: http://pygments.org/.18 *19 * To use, include prettify.js and this file in your HTML page.20 * Then put your code in an HTML tag like21 * <pre class="prettyprint lang-dart">(Dart code)</pre>22 *23 * @author armstrong.timothy@gmail.com24 */25PR['registerLangHandler'](26 PR['createSimpleLexer'](27 [28 // Whitespace.29 [PR['PR_PLAIN'], /^[\t\n\r \xA0]+/, null, '\t\n\r \xA0']30 ],31 [32 // Script tag.33 [PR['PR_COMMENT'], /^#!(?:.*)/],34 // `import`, `library`, `part of`, `part`, `as`, `show`, and `hide`35 // keywords.36 [PR['PR_KEYWORD'], /^\b(?:import|library|part of|part|as|show|hide)\b/i],37 // Single-line comments.38 [PR['PR_COMMENT'], /^\/\/(?:.*)/],39 // Multiline comments.40 [PR['PR_COMMENT'], /^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//], // */41 // `class` and `interface` keywords.42 [PR['PR_KEYWORD'], /^\b(?:class|interface)\b/i],43 // General keywords.44 [PR['PR_KEYWORD'], /^\b(?:assert|break|case|catch|continue|default|do|else|finally|for|if|in|is|new|return|super|switch|this|throw|try|while)\b/i],45 // Declaration keywords.46 [PR['PR_KEYWORD'], /^\b(?:abstract|const|extends|factory|final|get|implements|native|operator|set|static|typedef|var)\b/i],47 // Keywords for types.48 [PR['PR_TYPE'], /^\b(?:bool|double|Dynamic|int|num|Object|String|void)\b/i],49 // Keywords for constants.50 [PR['PR_KEYWORD'], /^\b(?:false|null|true)\b/i],51 // Multiline strings, single- and double-quoted.52 [PR['PR_STRING'], /^r?[\']{3}[\s|\S]*?[^\\][\']{3}/],53 [PR['PR_STRING'], /^r?[\"]{3}[\s|\S]*?[^\\][\"]{3}/],54 // Normal and raw strings, single- and double-quoted.55 [PR['PR_STRING'], /^r?\'(\'|(?:[^\n\r\f])*?[^\\]\')/],56 [PR['PR_STRING'], /^r?\"(\"|(?:[^\n\r\f])*?[^\\]\")/],57 // Identifiers.58 [PR['PR_PLAIN'], /^[a-z_$][a-z0-9_]*/i],59 60 // Operators.61 [PR['PR_PUNCTUATION'], /^[~!%^&*+=|?:<>/-]/],62 // Hex numbers.63 [PR['PR_LITERAL'], /^\b0x[0-9a-f]+/i],64 // Decimal numbers.65 [PR['PR_LITERAL'], /^\b\d+(?:\.\d*)?(?:e[+-]?\d+)?/i],66 [PR['PR_LITERAL'], /^\b\.\d+(?:e[+-]?\d+)?/i],67 // Punctuation.68 [PR['PR_PUNCTUATION'], /^[(){}\[\],.;]/]69 ]),...

Full Screen

Full Screen

review-pr

Source:review-pr Github

copy

Full Screen

1#!/usr/bin/env node2const shell = require('shelljs');3shell.config.fatal = true;4const util = require('./utils/git_util');5if (require.main === module) {6 main(process.argv.splice(2)).then(7 (v) => process.exitCode = v, 8 (e) => console.error(process.exitCode = 1, e)9 );10}11async function main(args) {12 let prNumber = 0;13 args.forEach((arg) => {14 if (prNumber == 0 && arg > 0) {15 prNumber = arg;16 } else {17 shell.echo('Unexpected argument: ', arg);18 }19 });20 if (prNumber === 0) {21 shell.echo('Bring github pull request onto your local repo for review and edit');22 shell.echo('');23 shell.echo(`${process.argv[1]} PR_NUMBER`);24 shell.echo('');25 return 1;26 }27 if (util.gitHasLocalModifications()) {28 shell.echo('Local modification detected. exiting...');29 return 1;30 }31 let prShaCount = (await util.githubPrInfo(prNumber)).commits;32 shell.exec(`git checkout master`);33 if (util.execNoFatal(`git rev-parse --verify --quiet pr/${prNumber}`).code == 0) {34 shell.exec(`git branch -D pr/${prNumber}`);35 }36 shell.echo(`Fetching pull request #${prNumber} with ${prNumber} SHA(s) into branch range: pr/${prNumber}_base..pr/${prNumber}_top`);37 shell.exec(`git fetch -f git@github.com:angular/angular.git pull/${prNumber}/head:pr/${prNumber}_top`);38 shell.exec(`git branch -f pr/${prNumber}_bottom pr/${prNumber}_top~${prShaCount - 1}`);39 shell.exec(`git branch -f pr/${prNumber}_base pr/${prNumber}_top~${prShaCount}`);40 // Create aliases41 shell.exec(`git branch -f pr/TOP pr/${prNumber}_top`);42 shell.exec(`git branch -f pr/BASE pr/${prNumber}_base`);43 shell.exec(`git branch -f pr/BOTTOM pr/${prNumber}_bottom`);44 shell.echo(`======================================================================================`);45 shell.exec(`git log --oneline --color pr/${prNumber}_base..pr/${prNumber}_top`);46 shell.echo(`======================================================================================`);47 // Reset the HEAD so that we can see changed files for review48 shell.exec(`git checkout --force -b pr/${prNumber} pr/${prNumber}_top`);49 shell.exec(`git reset pr/${prNumber}_base`);50 shell.exec(`git status`);51 return 0;...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var pr = require('webpagetest');2var wpt = new pr('www.webpagetest.org');3 if (err) return console.error(err);4 console.log(data);5});6var pr = require('webpagetest');7var wpt = new pr('www.webpagetest.org');8 if (err) return console.error(err);9 console.log(data);10});11var pr = require('webpagetest');12var wpt = new pr('www.webpagetest.org');13 if (err) return console.error(err);14 console.log(data);15});16var pr = require('webpagetest');17var wpt = new pr('www.webpagetest.org');18 if (err) return console.error(err);19 console.log(data);20});21var pr = require('webpagetest');22var wpt = new pr('www.webpagetest.org');23 if (err) return console.error(err);24 console.log(data);25});26var pr = require('webpagetest');27var wpt = new pr('www.webpagetest.org');28 if (err) return console.error(err);29 console.log(data);30});31var pr = require('webpagetest');32var wpt = new pr('www.webpagetest.org');33 if (err) return console.error(err);34 console.log(data);35});36var pr = require('webpagetest');37var wpt = new pr('www.webpagetest.org');38 if (err

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var test = new wpt('www.webpagetest.org');3}, function(err, data) {4 if (err) {5 console.log(err);6 } else {7 test.getTestResults(data.data.testId, function(err, data) {8 if (err) {9 console.log(err);10 } else {11 console.log(data.data.testUrl);12 }13 });14 }15});

Full Screen

Using AI Code Generation

copy

Full Screen

1var pr = require('wpt').pr;2 if (err) {3 throw err;4 }5 console.log(result);6});7{ statusCode: 200,8 { responseCode: 200,

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptool = require('wptool');2var pr = wptool.pr;3var path = require('path');4var file = path.join(__dirname, 'test.txt');5pr(file, function(err, data){6 if(err){7 console.log(err);8 } else {9 console.log(data);10 }11});12var path = require('path');

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