How to use addConfiguration method in wpt

Best JavaScript code snippet using wpt

notification-module-spec.ts

Source:notification-module-spec.ts Github

copy

Full Screen

...219 it(`should return only the latest project scoped configuration per type`, async () => {220 // Arrange221 const { instance } = arrangements;222 // Act223 await instance.addConfiguration(configurations.flowdock);224 await instance.addConfiguration({225 ...configurations.flowdock,226 flowToken: configurations.flowdock.flowToken + '1',227 });228 const found = await instance.getProjectConfigurations(projectId);229 expect(found.length).to.eq(1);230 expect(found[0].type).to.eq('flowdock');231 expect((found[0] as any).flowToken).to.eq(232 configurations.flowdock.flowToken + '1',233 );234 });235 it(`should be able to fetch project scoped configurations given only a projectId`, async () => {236 // Arrange237 const { instance } = arrangements;238 // Act239 await instance.addConfiguration(configurations.flowdock);240 await instance.addConfiguration(configurations.hipchat);241 const found = await instance.getProjectConfigurations(projectId);242 expect(found.length).to.eq(2);243 expect(found[0].type).to.eq('flowdock');244 expect(found[1].type).to.eq('hipchat');245 });246 it(`should not find project scoped configurations given only a teamId`, async () => {247 // Arrange248 const { instance } = arrangements;249 // Act250 await instance.addConfiguration(configurations.flowdock);251 await instance.addConfiguration(configurations.hipchat);252 const found = await instance.getTeamConfigurations(teamId);253 expect(found.length).to.eq(0);254 });255 it(`should be able to fetch project scoped configurations given a projectId and a teamId`, async () => {256 // Arrange257 const { instance } = arrangements;258 // Act259 await instance.addConfiguration(configurations.flowdock);260 await instance.addConfiguration(configurations.hipchat);261 const found = await instance.getConfigurations(projectId, teamId);262 expect(found.length).to.eq(2);263 expect(found[0].type).to.eq('flowdock');264 expect(found[1].type).to.eq('hipchat');265 });266 it(`should return only the latest team scoped configuration per type`, async () => {267 // Arrange268 const { instance } = arrangements;269 // Act270 await instance.addConfiguration({271 ...configurations.flowdock,272 projectId: null,273 teamId,274 });275 await instance.addConfiguration({276 ...configurations.flowdock,277 flowToken: configurations.flowdock.flowToken + '1',278 projectId: null,279 teamId,280 });281 const found = await instance.getTeamConfigurations(teamId);282 expect(found.length).to.eq(1);283 expect(found[0].type).to.eq('flowdock');284 expect((found[0] as any).flowToken).to.eq(285 configurations.flowdock.flowToken + '1',286 );287 });288 it(`should be able to fetch team scoped configurations given only a teamId`, async () => {289 // Arrange290 const { instance } = arrangements;291 // Act292 await instance.addConfiguration({293 ...configurations.flowdock,294 projectId: null,295 teamId,296 });297 await instance.addConfiguration({298 ...configurations.hipchat,299 projectId: null,300 teamId,301 });302 const found = await instance.getTeamConfigurations(teamId);303 expect(found.length).to.eq(2);304 expect(found[0].type).to.eq('flowdock');305 expect(found[1].type).to.eq('hipchat');306 });307 it(`should not find team scoped configurations given only a projectId`, async () => {308 // Arrange309 const { instance } = arrangements;310 // Act311 await instance.addConfiguration({312 ...configurations.flowdock,313 projectId: null,314 teamId,315 });316 await instance.addConfiguration({317 ...configurations.hipchat,318 projectId: null,319 teamId,320 });321 const found = await instance.getProjectConfigurations(projectId);322 expect(found.length).to.eq(0);323 });324 it(`should be able to fetch team scoped configurations given a projectId and a teamId`, async () => {325 // Arrange326 const { instance } = arrangements;327 // Act328 await instance.addConfiguration({329 ...configurations.flowdock,330 projectId: null,331 teamId,332 });333 await instance.addConfiguration({334 ...configurations.hipchat,335 projectId: null,336 teamId,337 });338 const found = await instance.getConfigurations(projectId, teamId);339 expect(found.length).to.eq(2);340 expect(found[0].type).to.eq('flowdock');341 expect(found[1].type).to.eq('hipchat');342 });343 it(`should be able to fetch mixed scoped configurations given a projectId and a teamId`, async () => {344 // Arrange345 const { instance } = arrangements;346 // Act347 await instance.addConfiguration({348 ...configurations.github,349 projectId: undefined,350 githubOwner: 'foo',351 githubRepo: undefined,352 githubInstallationId: undefined,353 teamId,354 });355 await instance.addConfiguration({356 ...configurations.github,357 teamId: undefined,358 githubAppId: configurations.github.githubAppId! + 1,359 githubAppPrivateKey: undefined,360 projectId,361 });362 const found = await instance.getConfigurations(projectId, teamId);363 expect(found.length).to.eq(1);364 const config = found[0] as GitHubNotificationConfiguration;365 expect(config.type).to.eq('github');366 expect(config.githubOwner).to.eq(configurations.github.githubOwner);367 expect(config.githubAppId).to.eq(configurations.github.githubAppId! + 1);368 });369 });370 describe('per type tests', () => {371 const notificationTypes = Object.keys(372 configurations,373 ) as (keyof Configurations)[];374 for (const notificationType of notificationTypes) {375 it(`should be able to add, get and delete project scoped ${notificationType} configurations`, async () => {376 // Arrange377 const { instance } = arrangements;378 const config = configurations[notificationType];379 // Act380 const id = await instance.addConfiguration(config);381 const existing = await instance.getConfiguration(id);382 const existingForProject = await instance.getProjectConfigurations(383 projectId,384 );385 await instance.deleteConfiguration(id);386 const deleted = await instance.getConfiguration(id);387 const deletedForProject = await instance.getProjectConfigurations(388 projectId,389 );390 // Assert391 expect(existing).to.deep.equal({ ...config, id });392 expect(existingForProject).to.have.length(1);393 expect(existingForProject[0]).to.deep.equal({ ...config, id });394 expect(deleted).to.equal(undefined);395 expect(deletedForProject).to.have.length(0);396 });397 it(`should be able to add, get and delete team scoped ${notificationType} configurations`, async () => {398 // Arrange399 const { instance } = arrangements;400 const config = omitBy<NC, NC>(401 { ...configurations[notificationType], projectId: null, teamId },402 isNil,403 );404 // Act405 const id = await instance.addConfiguration(config);406 const existing = await instance.getConfiguration(id);407 const existingForTeam = await instance.getTeamConfigurations(teamId);408 await instance.deleteConfiguration(id);409 const deleted = await instance.getConfiguration(id);410 const deletedForTeam = await instance.getTeamConfigurations(teamId);411 // Assert412 expect(existing).to.deep.equal({ ...config, id });413 expect(existingForTeam).to.have.length(1);414 expect(existingForTeam[0]).to.deep.equal({ ...config, id });415 expect(deleted).to.equal(undefined);416 expect(deletedForTeam).to.have.length(0);417 });418 // tslint:disable-next-line:max-line-length419 it(`should trigger ${notificationType} notification with a matching project scoped configuration`, async () => {420 // Arrange421 const { instance, bus } = arrangements;422 await instance.addConfiguration(configurations[notificationType]);423 const promise = instance.handledEvents.take(1).toPromise();424 // Act425 bus.post(projectDeploymentEvent);426 await promise;427 // Assert428 const stub = arrangements[notificationType];429 expect(stub).to.have.been.calledOnce;430 });431 it(`should trigger ${notificationType} notification with a matching team scoped configuration`, async () => {432 // Arrange433 const { instance, bus } = arrangements;434 const config = omitBy<NC, NC>(435 { ...configurations[notificationType], projectId: null, teamId },436 isNil,437 );438 await instance.addConfiguration(config);439 const promise = instance.handledEvents.take(1).toPromise();440 // Act441 bus.post(teamDeploymentEvent);442 await promise;443 // Assert444 const stub = arrangements[notificationType];445 expect(stub).to.have.been.calledOnce;446 });447 // tslint:disable-next-line:max-line-length448 it(`should not trigger ${notificationType} notification when no matching configurations exist`, async () => {449 // Arrange450 const { instance, bus } = arrangements;451 await instance.addConfiguration({452 ...configurations[notificationType],453 projectId: projectId + 1,454 teamId: teamId + 1,455 });456 const promise = instance.handledEvents.take(1).toPromise();457 // Act458 bus.post(projectDeploymentEvent);459 const response = await promise;460 // Assert461 const stub = arrangements[notificationType];462 expect(stub).to.not.have.been.called;463 expect(response.results.length).to.eq(0);464 });465 }466 for (const notificationType of notificationTypes.filter(467 t => t !== 'flowdock',468 )) {469 it(`should not trigger ${notificationType} notification if deployment has not succeeded`, async () => {470 // Arrange471 const { instance, bus } = arrangements;472 await instance.addConfiguration(configurations[notificationType]);473 const promise = instance.handledEvents.take(1).toPromise();474 // Act475 bus.post(runningDeploymentEvent);476 const response = await promise;477 // Assert478 const stub = arrangements[notificationType];479 expect(stub).to.not.have.been.called;480 expect(response.results.length).to.eq(1);481 expect(response.results[0].type).to.eq(notificationType);482 expect(response.results[0].result).to.be.false;483 });484 }485 });486});

Full Screen

Full Screen

autorest.js

Source:autorest.js Github

copy

Full Screen

1import * as fs from "fs";2import * as path from "path";3import { RealFileSystem } from '@azure-tools/datastore';4import { ConsoleLogger } from '@autorest/common';5import { AutoRest } from '@autorest/core';6import { resolveUri, 7 createFolderUri,8} from '@azure-tools/uri';9import { ArtifactWriter } from "./lib/artifact-writer";10const logger = new ConsoleLogger();11const resolveAppRoot = () => {12 let current = path.resolve(__dirname);13 while (!fs.existsSync(path.join(current, "package.json"))) {14 current = path.dirname(current);15 }16 return current;17};18function printCompleteSummary(logger, artifactWriter) {19 const runtime = Math.round(process.uptime() * 100) / 100;20 logger.info(`Autorest completed in ${runtime}s. ${artifactWriter.stats.writeCompleted} files generated.`);21}22export async function processSpecs(azureRestApiSpecsDir, generatedDir, dirName, options) {23 if (!fs.existsSync(`${azureRestApiSpecsDir}/specification/${dirName}/resource-manager`)) {24 return;25 }26 const serviceRootDir = `${azureRestApiSpecsDir}/specification/${dirName}`;27 28 if (fs.existsSync(`${serviceRootDir}/resource-manager/readme.md`)) {29 await processSpec(30 dirName, 31 `${serviceRootDir}/resource-manager/readme.md`, 32 `${generatedDir}/${dirName}`, 33 options.debug, 34 options.dryrun);35 } else {36 // readme not found, recurse subdirectories37 const subdirs = fs.readdirSync(`${azureRestApiSpecsDir}/specification/${dirName}/resource-manager`, { withFileTypes: true }).filter(dirent => dirent.isDirectory());38 for (const subdir of subdirs) {39 await processSpec(40 `${dirName}_${subdir.name}`, 41 `${serviceRootDir}/resource-manager/${subdir.name}/readme.md`, 42 `${generatedDir}/${dirName}_${subdir.name}`, 43 options.debug, 44 options.dryrun);45 }46 }47}48export async function processSpec(serviceName, configFile, outputFolder, debug, dryrun) {49 50 console.log(`processing ${serviceName}...`);51 const AppRoot = resolveAppRoot();52 const f = new RealFileSystem();53 const autorest = new AutoRest(54 logger,55 f,56 resolveUri(createFolderUri(AppRoot), configFile),57 );58 autorest.AddConfiguration({ "azure-arm": true });59 autorest.AddConfiguration({ "output-converted-oai3": true });60 autorest.AddConfiguration({ "include-x-ms-examples-original-file": false });61 autorest.AddConfiguration({ "openapi-type": "arm" });62 autorest.AddConfiguration({ "output-folder": `${createFolderUri(AppRoot)}${outputFolder}` });63 autorest.AddConfiguration({ "verbose": debug });64 autorest.AddConfiguration({ "debug": debug });65 autorest.AddConfiguration({ "allow-no-input": dryrun });66 autorest.AddConfiguration({ "level": "error" });67 autorest.AddConfiguration({ "skip-semantics-validation": true });68 autorest.AddConfiguration({ "model-validator": false });69 if (serviceName === 'machinelearning'){70 autorest.AddConfiguration({ "tag": "package-webservices-2017-01" });71 }72 if (serviceName === 'policyinsights'){73 console.log('skipping policyinsights...');74 return;75 }76 const context = await autorest.view;77 const cfg = context.config;78 const artifactWriter = new ArtifactWriter(cfg);79 80 // listen for output messages and file writes81 let artifacts = [];82 autorest.GeneratedFile.Subscribe((_, artifact) => {83 if (context.config.help) {84 artifacts.push(artifact);85 return;86 }87 artifactWriter.writeArtifact(artifact);88 });89 const result = await autorest.Process().finish;90 if (result !== true) {91 throw result;92 }93 // perform file system operations.94 // clear folders here if you want...95 if (dryrun){96 logger.info("No output, dryrun mode selected.");97 } else {98 logger.info("Writing outputs.");99 await artifactWriter.wait();100 }101 102 printCompleteSummary(logger, artifactWriter);103 return 0;104 ...

Full Screen

Full Screen

addconfiguration.component.spec.ts

Source:addconfiguration.component.spec.ts Github

copy

Full Screen

1import { async, ComponentFixture, TestBed } from '@angular/core/testing';2import { AddconfigurationComponent } from './addconfiguration.component';3describe('AddconfigurationComponent', () => {4 let component: AddconfigurationComponent;5 let fixture: ComponentFixture<AddconfigurationComponent>;6 beforeEach(async(() => {7 TestBed.configureTestingModule({8 declarations: [ AddconfigurationComponent ]9 })10 .compileComponents();11 }));12 beforeEach(() => {13 fixture = TestBed.createComponent(AddconfigurationComponent);14 component = fixture.componentInstance;15 fixture.detectChanges();16 });17 it('should create', () => {18 expect(component).toBeTruthy();19 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wptService = new wpt('www.webpagetest.org');3wptService.addConfiguration({4}, function(err, data) {5 if (err) throw err;6 console.log(data);7});8var wpt = require('webpagetest');9var wptService = new wpt('www.webpagetest.org');10wptService.addConfiguration({11}, function(err, data) {12 if (err) throw err;13 console.log(data);14});15{ statusCode: 200,16 { statusCode: 400,17 data: 'Error: The configuration you are trying to add already exists.' } }

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2wpt.addConfiguration('myConfig', {3}, function(err, data) {4 if (err) return console.error(err);5 console.log(data);6});

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