How to use endRun method in ava

Best JavaScript code snippet using ava

privileged-api-create-analysis-task-tests.js

Source:privileged-api-create-analysis-task-tests.js Github

copy

Full Screen

1'use strict';2let assert = require('assert');3let MockData = require('./resources/mock-data.js');4let TestServer = require('./resources/test-server.js');5const addBuilderForReport = require('./resources/common-operations.js').addBuilderForReport;6const prepareServerTest = require('./resources/common-operations.js').prepareServerTest;7const reportWithRevision = [{8 "buildNumber": "124",9 "buildTime": "2015-10-27T15:34:51",10 "revisions": {11 "WebKit": {12 "revision": "191622",13 "timestamp": '2015-10-27T11:36:56.878473Z',14 },15 },16 "builderName": "someBuilder",17 "builderPassword": "somePassword",18 "platform": "some platform",19 "tests": {20 "Suite": {21 "metrics": {22 "Time": ["Arithmetic"],23 },24 "tests": {25 "test1": {26 "metrics": {"Time": { "current": [11] }},27 }28 }29 },30 }}];31const reportWithRevisionNoTimestamp = [{32 "buildNumber": "124",33 "buildTime": "2015-10-27T15:34:51",34 "revisions": {35 "WebKit": {36 "revision": "191622",37 },38 },39 "builderName": "someBuilder",40 "builderPassword": "somePassword",41 "platform": "some platform",42 "tests": {43 "Suite": {44 "metrics": {45 "Time": ["Arithmetic"],46 },47 "tests": {48 "test1": {49 "metrics": {"Time": { "current": [11] }},50 }51 }52 },53 }}];54const anotherReportWithRevision = [{55 "buildNumber": "125",56 "buildTime": "2015-10-27T17:27:41",57 "revisions": {58 "WebKit": {59 "revision": "191623",60 "timestamp": '2015-10-27T16:38:10.768995Z',61 },62 },63 "builderName": "someBuilder",64 "builderPassword": "somePassword",65 "platform": "some platform",66 "tests": {67 "Suite": {68 "metrics": {69 "Time": ["Arithmetic"],70 },71 "tests": {72 "test1": {73 "metrics": {"Time": { "current": [12] }},74 }75 }76 },77 }}];78const anotherReportWithRevisionNoTimestamp = [{79 "buildNumber": "125",80 "buildTime": "2015-10-27T17:27:41",81 "revisions": {82 "WebKit": {83 "revision": "191623",84 },85 },86 "builderName": "someBuilder",87 "builderPassword": "somePassword",88 "platform": "some platform",89 "tests": {90 "Suite": {91 "metrics": {92 "Time": ["Arithmetic"],93 },94 "tests": {95 "test1": {96 "metrics": {"Time": { "current": [12] }},97 }98 }99 },100 }}];101describe('/privileged-api/create-analysis-task with browser privileged api', function () {102 prepareServerTest(this);103 it('should return "MissingName" on an empty request', () => {104 return PrivilegedAPI.sendRequest('create-analysis-task', {}).then((content) => {105 assert(false, 'should never be reached');106 }, (error) => {107 assert.equal(error, 'MissingName');108 });109 });110 it('should return "InvalidStartRun" when startRun is missing but endRun is set', () => {111 return PrivilegedAPI.sendRequest('create-analysis-task', {name: 'hi', endRun: 1}).then((content) => {112 assert(false, 'should never be reached');113 }, (error) => {114 assert.equal(error, 'InvalidStartRun');115 });116 });117 it('should return "InvalidEndRun" when endRun is missing but startRun is set', () => {118 return PrivilegedAPI.sendRequest('create-analysis-task', {name: 'hi', startRun: 1}).then((content) => {119 assert(false, 'should never be reached');120 }, (error) => {121 assert.equal(error, 'InvalidEndRun');122 });123 });124 it('should return "InvalidStartRun" when startRun is not a valid integer', () => {125 return PrivilegedAPI.sendRequest('create-analysis-task', {name: 'hi', startRun: "foo", endRun: 1}).then((content) => {126 assert(false, 'should never be reached');127 }, (error) => {128 assert.equal(error, 'InvalidStartRun');129 });130 });131 it('should return "InvalidEndRun" when endRun is not a valid integer', () => {132 return PrivilegedAPI.sendRequest('create-analysis-task', {name: 'hi', startRun: 1, endRun: "foo"}).then((content) => {133 assert(false, 'should never be reached');134 }, (error) => {135 assert.equal(error, 'InvalidEndRun');136 });137 });138 it('should return "InvalidStartRun" when startRun is invalid', () => {139 return addBuilderForReport(reportWithRevision[0]).then(() => {140 return TestServer.remoteAPI().postJSON('/api/report/', reportWithRevision);141 }).then(() => {142 return PrivilegedAPI.sendRequest('create-analysis-task', {name: 'hi', startRun: 100, endRun: 1}).then((content) => {143 assert(false, 'should never be reached');144 }, (error) => {145 assert.equal(error, 'InvalidStartRun');146 });147 });148 });149 it('should return "InvalidEndRun" when endRun is invalid', () => {150 return addBuilderForReport(reportWithRevision[0]).then(() => {151 return TestServer.remoteAPI().postJSON('/api/report/', reportWithRevision);152 }).then(() => {153 return PrivilegedAPI.sendRequest('create-analysis-task', {name: 'hi', startRun: 1, endRun: 100}).then((content) => {154 assert(false, 'should never be reached');155 }, (error) => {156 assert.equal(error, 'InvalidEndRun');157 });158 });159 });160 it('should return "InvalidTimeRange" when startRun and endRun are identical', () => {161 return addBuilderForReport(reportWithRevision[0]).then(() => {162 return TestServer.remoteAPI().postJSON('/api/report/', reportWithRevision);163 }).then(() => {164 return PrivilegedAPI.sendRequest('create-analysis-task', {name: 'hi', startRun: 1, endRun: 1}).then((content) => {165 assert(false, 'should never be reached');166 }, (error) => {167 assert.equal(error, 'InvalidTimeRange');168 });169 });170 });171 it('should return "RunConfigMismatch" when startRun and endRun come from a different test configurations', () => {172 return addBuilderForReport(reportWithRevision[0]).then(() => {173 return TestServer.remoteAPI().postJSON('/api/report/', reportWithRevision);174 }).then(() => {175 return PrivilegedAPI.sendRequest('create-analysis-task', {name: 'hi', startRun: 1, endRun: 2}).then((content) => {176 assert(false, 'should never be reached');177 }, (error) => {178 assert.equal(error, 'RunConfigMismatch');179 });180 });181 });182 it('should create an analysis task when name, startRun, and endRun are set properly', () => {183 const db = TestServer.database();184 return addBuilderForReport(reportWithRevision[0]).then(() => {185 return TestServer.remoteAPI().postJSON('/api/report/', reportWithRevision);186 }).then(() => {187 return TestServer.remoteAPI().postJSON('/api/report/', anotherReportWithRevision);188 }).then(() => {189 return Manifest.fetch();190 }).then(() => {191 const test1 = Test.findByPath(['Suite', 'test1']);192 const platform = Platform.findByName('some platform');193 return db.selectFirstRow('test_configurations', {metric: test1.metrics()[0].id(), platform: platform.id()});194 }).then((configRow) => {195 return db.selectRows('test_runs', {config: configRow['id']});196 }).then((testRuns) => {197 assert.equal(testRuns.length, 2);198 return PrivilegedAPI.sendRequest('create-analysis-task', {name: 'hi', startRun: testRuns[0]['id'], endRun: testRuns[1]['id']});199 }).then((content) => {200 return AnalysisTask.fetchById(content['taskId']);201 }).then((task) => {202 assert.equal(task.name(), 'hi');203 assert(!task.hasResults());204 assert(!task.hasPendingRequests());205 assert.deepEqual(task.bugs(), []);206 assert.deepEqual(task.causes(), []);207 assert.deepEqual(task.fixes(), []);208 assert.equal(task.changeType(), null);209 assert.equal(task.platform().label(), 'some platform');210 assert.equal(task.metric().test().label(), 'test1');211 });212 });213 it('should create an analysis task and use build time as fallback when commit time is not available', () => {214 const db = TestServer.database();215 return addBuilderForReport(reportWithRevisionNoTimestamp[0]).then(() => {216 return TestServer.remoteAPI().postJSON('/api/report/', reportWithRevisionNoTimestamp);217 }).then(() => {218 return TestServer.remoteAPI().postJSON('/api/report/', anotherReportWithRevisionNoTimestamp);219 }).then(() => {220 return Manifest.fetch();221 }).then(() => {222 const test1 = Test.findByPath(['Suite', 'test1']);223 const platform = Platform.findByName('some platform');224 return db.selectFirstRow('test_configurations', {metric: test1.metrics()[0].id(), platform: platform.id()});225 }).then((configRow) => {226 return db.selectRows('test_runs', {config: configRow['id']});227 }).then((testRuns) => {228 assert.equal(testRuns.length, 2);229 return PrivilegedAPI.sendRequest('create-analysis-task', {name: 'hi', startRun: testRuns[0]['id'], endRun: testRuns[1]['id']});230 }).then((content) => {231 return AnalysisTask.fetchById(content['taskId']);232 }).then((task) => {233 assert.equal(task.name(), 'hi');234 assert(!task.hasResults());235 assert(!task.hasPendingRequests());236 assert.deepEqual(task.bugs(), []);237 assert.deepEqual(task.causes(), []);238 assert.deepEqual(task.fixes(), []);239 assert.equal(task.changeType(), null);240 assert.equal(task.platform().label(), 'some platform');241 assert.equal(task.metric().test().label(), 'test1');242 assert.equal(task.startTime(), 1445960091000);243 assert.equal(task.endTime(), 1445966861000);244 });245 });246 it('should return "DuplicateAnalysisTask" when there is already an analysis task for the specified range', () => {247 const db = TestServer.database();248 let startId;249 let endId;250 return addBuilderForReport(reportWithRevision[0]).then(() => {251 return TestServer.remoteAPI().postJSON('/api/report/', reportWithRevision);252 }).then(() => {253 return TestServer.remoteAPI().postJSON('/api/report/', anotherReportWithRevision);254 }).then(() => {255 return Manifest.fetch();256 }).then(() => {257 const test1 = Test.findByPath(['Suite', 'test1']);258 const platform = Platform.findByName('some platform');259 return db.selectFirstRow('test_configurations', {metric: test1.metrics()[0].id(), platform: platform.id()});260 }).then((configRow) => {261 return db.selectRows('test_runs', {config: configRow['id']});262 }).then((testRuns) => {263 assert.equal(testRuns.length, 2);264 startId = testRuns[0]['id'];265 endId = testRuns[1]['id'];266 return PrivilegedAPI.sendRequest('create-analysis-task', {name: 'hi', startRun: startId, endRun: endId});267 }).then((content) => {268 return PrivilegedAPI.sendRequest('create-analysis-task', {name: 'hi', startRun: startId, endRun: endId}).then(() => {269 assert(false, 'should never be reached');270 }, (error) => {271 assert.equal(error, 'DuplicateAnalysisTask');272 });273 }).then(() => {274 return db.selectAll('analysis_tasks');275 }).then((tasks) => {276 assert.equal(tasks.length, 1);277 });278 });279 it('should create an analysis task with analysis strategies when they are specified', () => {280 const db = TestServer.database();281 return addBuilderForReport(reportWithRevision[0]).then(() => {282 return TestServer.remoteAPI().postJSON('/api/report/', reportWithRevision);283 }).then(() => {284 return TestServer.remoteAPI().postJSON('/api/report/', anotherReportWithRevision);285 }).then(() => {286 return Manifest.fetch();287 }).then(() => {288 const test1 = Test.findByPath(['Suite', 'test1']);289 const platform = Platform.findByName('some platform');290 return db.selectFirstRow('test_configurations', {metric: test1.metrics()[0].id(), platform: platform.id()});291 }).then((configRow) => {292 return db.selectRows('test_runs', {config: configRow['id']});293 }).then((testRuns) => {294 assert.equal(testRuns.length, 2);295 return PrivilegedAPI.sendRequest('create-analysis-task', {296 name: 'hi',297 startRun: testRuns[0]['id'],298 endRun: testRuns[1]['id'],299 segmentationStrategy: "time series segmentation",300 testRangeStrategy: "student's t-test"});301 }).then(() => {302 return Promise.all([db.selectFirstRow('analysis_tasks'), db.selectAll('analysis_strategies')]);303 }).then((results) => {304 const [taskRow, strategies] = results;305 assert(taskRow['segmentation']);306 assert(taskRow['test_range']);307 const strategyIdMap = {};308 for (let strategy of strategies)309 strategyIdMap[strategy['id']] = strategy;310 assert.equal(strategyIdMap[taskRow['segmentation']]['name'], "time series segmentation");311 assert.equal(strategyIdMap[taskRow['test_range']]['name'], "student's t-test");312 });313 });314 it('should failed with "TriggerableNotFoundForTask" when there is no matching triggerable', async () => {315 const db = TestServer.database();316 await addBuilderForReport(reportWithRevision[0]);317 await TestServer.remoteAPI().postJSON('/api/report/', reportWithRevision);318 await TestServer.remoteAPI().postJSON('/api/report/', anotherReportWithRevision);319 await Manifest.fetch();320 const test1 = Test.findByPath(['Suite', 'test1']);321 const somePlatform = Platform.findByName('some platform');322 const configRow = await db.selectFirstRow('test_configurations', {metric: test1.metrics()[0].id(), platform: somePlatform.id()});323 const testRuns = await db.selectRows('test_runs', {config: configRow['id']});324 assert.equal(testRuns.length, 2);325 const webkitRepositoryRow = await db.selectFirstRow('repositories', {name: 'WebKit'});326 const webkitId = webkitRepositoryRow.id;327 const oneRevisionSet = {[webkitId]: {revision: '191622'}};328 const anotherRevisionSet = {[webkitId]: {revision: '191623'}};329 let raiseException = false;330 try {331 await PrivilegedAPI.sendRequest('create-analysis-task', {name: 'confirm', repetitionCount: 1,332 revisionSets: [oneRevisionSet, anotherRevisionSet],333 startRun: testRuns[0]['id'], endRun: testRuns[1]['id']});334 } catch (error) {335 assert.equal(error, 'TriggerableNotFoundForTask');336 raiseException = true;337 }338 assert.ok(raiseException);339 });340 it('should create an analysis task with no test group when repetition count is 0', async () => {341 const db = TestServer.database();342 await addBuilderForReport(reportWithRevision[0]);343 await TestServer.remoteAPI().postJSON('/api/report/', reportWithRevision);344 await TestServer.remoteAPI().postJSON('/api/report/', anotherReportWithRevision);345 await Manifest.fetch();346 const test1 = Test.findByPath(['Suite', 'test1']);347 const platform = Platform.findByName('some platform');348 const configRow = await db.selectFirstRow('test_configurations', {metric: test1.metrics()[0].id(), platform: platform.id()});349 const testRuns = await db.selectRows('test_runs', {config: configRow['id']});350 assert.equal(testRuns.length, 2);351 const webkitRepositoryRow = await db.selectFirstRow('repositories', {name: 'WebKit'});352 const webkitId = webkitRepositoryRow.id;353 const oneRevisionSet = {[webkitId]: {revision: '191622'}};354 const anotherRevisionSet = {[webkitId]: {revision: '191623'}};355 const content = await PrivilegedAPI.sendRequest('create-analysis-task', {name: 'confirm', repetitionCount: 0,356 revisionSets: [oneRevisionSet, anotherRevisionSet],357 startRun: testRuns[0]['id'], endRun: testRuns[1]['id']});358 TestServer.cleanDataDirectory();359 await Manifest.fetch();360 const task = await AnalysisTask.fetchById(content['taskId']);361 assert.equal(task.name(), 'confirm');362 assert(!task.hasResults());363 assert(!task.hasPendingRequests());364 assert.deepEqual(task.bugs(), []);365 assert.deepEqual(task.causes(), []);366 assert.deepEqual(task.fixes(), []);367 assert.equal(task.changeType(), null);368 assert.equal(task.platform().label(), 'some platform');369 assert.equal(task.metric().test().label(), 'test1');370 const testGroups = await TestGroup.fetchForTask(task.id());371 assert.equal(testGroups.length, 0);372 });373 it('should create an analysis task with test group when commit set list and a positive repetition count is specified', async () => {374 const webkitId = 1;375 const platformId = 1;376 const test1Id = 2;377 const triggerableId = 1234;378 const db = TestServer.database();379 await db.insert('tests', {id: 1, name: 'Suite'});380 await db.insert('tests', {id: test1Id, name: 'test1', parent: 1});381 await db.insert('repositories', {id: webkitId, name: 'WebKit'});382 await db.insert('platforms', {id: platformId, name: 'some platform'});383 await db.insert('build_triggerables', {id: 1234, name: 'test-triggerable'});384 await db.insert('triggerable_repository_groups', {id: 2345, name: 'webkit-only', triggerable: triggerableId});385 await db.insert('triggerable_repositories', {repository: webkitId, group: 2345});386 await db.insert('triggerable_configurations', {test: test1Id, platform: platformId, triggerable: triggerableId});387 await addBuilderForReport(reportWithRevision[0]);388 await TestServer.remoteAPI().postJSON('/api/report/', reportWithRevision);389 await TestServer.remoteAPI().postJSON('/api/report/', anotherReportWithRevision);390 await Manifest.fetch();391 let test1 = Test.findById(test1Id);392 let somePlatform = Platform.findById(platformId);393 const configRow = await db.selectFirstRow('test_configurations', {metric: test1.metrics()[0].id(), platform: somePlatform.id()});394 const testRuns = await db.selectRows('test_runs', {config: configRow['id']});395 assert.equal(testRuns.length, 2);396 const oneRevisionSet = {[webkitId]: {revision: '191622'}};397 const anotherRevisionSet = {[webkitId]: {revision: '191623'}};398 const content = await PrivilegedAPI.sendRequest('create-analysis-task', {name: 'confirm', repetitionCount: 1,399 testGroupName: 'Confirm', revisionSets: [oneRevisionSet, anotherRevisionSet],400 startRun: testRuns[0]['id'], endRun: testRuns[1]['id']});401 const task = await AnalysisTask.fetchById(content['taskId']);402 assert.equal(task.name(), 'confirm');403 assert(!task.hasResults());404 assert(task.hasPendingRequests());405 assert.deepEqual(task.bugs(), []);406 assert.deepEqual(task.causes(), []);407 assert.deepEqual(task.fixes(), []);408 assert.equal(task.changeType(), null);409 assert.equal(task.platform().label(), 'some platform');410 assert.equal(task.metric().test().label(), 'test1');411 const testGroups = await TestGroup.fetchForTask(task.id());412 assert.equal(testGroups.length, 1);413 const testGroup = testGroups[0];414 assert.equal(testGroup.name(), 'Confirm');415 const buildRequests = testGroup.buildRequests();416 assert.equal(buildRequests.length, 2);417 assert.equal(buildRequests[0].triggerable().id(), triggerableId);418 assert.equal(buildRequests[0].triggerable().id(), triggerableId);419 assert.equal(buildRequests[0].testGroup(), testGroup);420 assert.equal(buildRequests[1].testGroup(), testGroup);421 assert.equal(buildRequests[0].platform(), task.platform());422 assert.equal(buildRequests[1].platform(), task.platform());423 assert.equal(buildRequests[0].analysisTaskId(), task.id());424 assert.equal(buildRequests[1].analysisTaskId(), task.id());425 assert.equal(buildRequests[0].test(), test1);426 assert.equal(buildRequests[1].test(), test1);427 assert.ok(!buildRequests[0].isBuild());428 assert.ok(!buildRequests[1].isBuild());429 assert.ok(buildRequests[0].isTest());430 assert.ok(buildRequests[1].isTest());431 const firstCommitSet = buildRequests[0].commitSet();432 const secondCommitSet = buildRequests[1].commitSet();433 const webkitRepository = Repository.findById(webkitId);434 assert.equal(firstCommitSet.commitForRepository(webkitRepository).revision(), '191622');435 assert.equal(secondCommitSet.commitForRepository(webkitRepository).revision(), '191623');436 });437});438describe('/privileged-api/create-analysis-task with node privileged api', function () {439 prepareServerTest(this, 'node');440 beforeEach(() => {441 PrivilegedAPI.configure('test', 'password');442 });443 it('should return "SlaveNotFound" when incorrect slave user and password combination is provided and no analysis task, test group or build request should be created', async () => {444 PrivilegedAPI.configure('test', 'wrongpassword');445 const db = TestServer.database();446 await addBuilderForReport(reportWithRevision[0]);447 await TestServer.remoteAPI().postJSON('/api/report/', reportWithRevision);448 await TestServer.remoteAPI().postJSON('/api/report/', anotherReportWithRevision);449 await Manifest.fetch();450 const test1 = Test.findByPath(['Suite', 'test1']);451 const somePlatform = Platform.findByName('some platform');452 const configRow = await db.selectFirstRow('test_configurations', {metric: test1.metrics()[0].id(), platform: somePlatform.id()});453 const testRuns = await db.selectRows('test_runs', {config: configRow['id']});454 assert.equal(testRuns.length, 2);455 const webkitRepositoryRow = await db.selectFirstRow('repositories', {name: 'WebKit'});456 const webkitId = webkitRepositoryRow.id;457 const oneRevisionSet = {[webkitId]: {revision: '191622'}};458 const anotherRevisionSet = {[webkitId]: {revision: '191623'}};459 let raiseException = false;460 try {461 await PrivilegedAPI.sendRequest('create-analysis-task', {name: 'confirm', repetitionCount: 1,462 revisionSets: [oneRevisionSet, anotherRevisionSet],463 startRun: testRuns[0]['id'], endRun: testRuns[1]['id']});464 } catch (error) {465 assert.equal(error, 'SlaveNotFound');466 raiseException = true;467 }468 assert.ok(raiseException);469 const allAnalysisTasks = await db.selectRows('analysis_tasks');470 assert.ok(!allAnalysisTasks.length);471 const allTestGroups = await db.selectRows('analysis_test_groups');472 assert.ok(!allTestGroups.length);473 const allBuildRequests = await db.selectRows('build_requests');474 assert.ok(!allBuildRequests.length);475 });476 it('should create an analysis task with test group when commit set list and a positive repetition count is specified', async () => {477 const webkitId = 1;478 const platformId = 1;479 const test1Id = 2;480 const triggerableId = 1234;481 const db = TestServer.database();482 await db.insert('tests', {id: 1, name: 'Suite'});483 await db.insert('tests', {id: test1Id, name: 'test1', parent: 1});484 await db.insert('repositories', {id: webkitId, name: 'WebKit'});485 await db.insert('platforms', {id: platformId, name: 'some platform'});486 await db.insert('build_triggerables', {id: 1234, name: 'test-triggerable'});487 await db.insert('triggerable_repository_groups', {id: 2345, name: 'webkit-only', triggerable: triggerableId});488 await db.insert('triggerable_repositories', {repository: webkitId, group: 2345});489 await db.insert('triggerable_configurations', {test: test1Id, platform: platformId, triggerable: triggerableId});490 await addBuilderForReport(reportWithRevision[0]);491 await TestServer.remoteAPI().postJSON('/api/report/', reportWithRevision);492 await TestServer.remoteAPI().postJSON('/api/report/', anotherReportWithRevision);493 await Manifest.fetch();494 let test1 = Test.findById(test1Id);495 let somePlatform = Platform.findById(platformId);496 const configRow = await db.selectFirstRow('test_configurations', {metric: test1.metrics()[0].id(), platform: somePlatform.id()});497 const testRuns = await db.selectRows('test_runs', {config: configRow['id']});498 assert.equal(testRuns.length, 2);499 const oneRevisionSet = {[webkitId]: {revision: '191622'}};500 const anotherRevisionSet = {[webkitId]: {revision: '191623'}};501 const content = await PrivilegedAPI.sendRequest('create-analysis-task', {name: 'confirm', repetitionCount: 1,502 testGroupName: 'Confirm', revisionSets: [oneRevisionSet, anotherRevisionSet],503 startRun: testRuns[0]['id'], endRun: testRuns[1]['id']});504 const task = await AnalysisTask.fetchById(content['taskId']);505 assert.equal(task.name(), 'confirm');506 assert(!task.hasResults());507 assert(task.hasPendingRequests());508 assert.deepEqual(task.bugs(), []);509 assert.deepEqual(task.causes(), []);510 assert.deepEqual(task.fixes(), []);511 assert.equal(task.changeType(), null);512 assert.equal(task.platform().label(), 'some platform');513 assert.equal(task.metric().test().label(), 'test1');514 const testGroups = await TestGroup.fetchForTask(task.id());515 assert.equal(testGroups.length, 1);516 const testGroup = testGroups[0];517 assert.equal(testGroup.name(), 'Confirm');518 const buildRequests = testGroup.buildRequests();519 assert.equal(buildRequests.length, 2);520 assert.equal(buildRequests[0].triggerable().id(), triggerableId);521 assert.equal(buildRequests[0].triggerable().id(), triggerableId);522 assert.equal(buildRequests[0].testGroup(), testGroup);523 assert.equal(buildRequests[1].testGroup(), testGroup);524 assert.equal(buildRequests[0].platform(), task.platform());525 assert.equal(buildRequests[1].platform(), task.platform());526 assert.equal(buildRequests[0].analysisTaskId(), task.id());527 assert.equal(buildRequests[1].analysisTaskId(), task.id());528 assert.equal(buildRequests[0].test(), test1);529 assert.equal(buildRequests[1].test(), test1);530 assert.ok(!buildRequests[0].isBuild());531 assert.ok(!buildRequests[1].isBuild());532 assert.ok(buildRequests[0].isTest());533 assert.ok(buildRequests[1].isTest());534 const firstCommitSet = buildRequests[0].commitSet();535 const secondCommitSet = buildRequests[1].commitSet();536 const webkitRepository = Repository.findById(webkitId);537 assert.equal(firstCommitSet.commitForRepository(webkitRepository).revision(), '191622');538 assert.equal(secondCommitSet.commitForRepository(webkitRepository).revision(), '191623');539 });...

Full Screen

Full Screen

preview.js

Source:preview.js Github

copy

Full Screen

1injectDark()2loadPreview()3function endRun() {4 $('.page').addClass('hidden')5 $('#done').removeClass('hidden')6}7async function obtainAuth() {8 return new Promise(async (resolve, reject) => {9 const result = await fetch("https://accounts.spotify.com/api/token", {10 method: "POST",11 headers: {12 "Content-Type": "application/x-www-form-urlencoded",13 Authorization: "Basic YjJiMGU0MWQwYTNlNDQ2NGIxMmViYTY2NmExZGUzNmQ6Y2MwMWM3OTExYjRjNDE2ODliOTcxMDM0ZmY5NzM1ODc=",14 },15 body: `grant_type=client_credentials`,16 });17 18 const data = await result.json();19 window.spotifyCode = data.access_token20 resolve(true)21 })22}23async function loadPreview() {24 const urlParams = new URLSearchParams(window.location.search);25 const type = urlParams.get('type');26 const id = urlParams.get('id')27 try {28 switch (type) {29 case 'album':30 await obtainAuth()31 loadAlbum(id)32 break;33 case 'track':34 await obtainAuth()35 loadTrack(id)36 break;37 case 'artist':38 await obtainAuth()39 loadArtist(id)40 break;41 case 'playlist':42 await obtainAuth()43 loadPlaylist(id)44 break;45 default:46 endRun()47 break;48 } 49 } catch (error) {50 endRun()51 }52 $('.page').addClass('hidden')53 $('#contentView').removeClass('hidden')54}55async function loadAlbum(id) {56 data = await goFetch('albums/' + id)57 a = document.createElement('div')58 a.setAttribute('class', 'album')59 try {60 a.innerHTML = `61 <center>62 <img src="${data.images[0].url}"></img>63 <h1>${data.name}</h1>64 <h4>${artistToString(data.artists)}</h4>65 <p>${data.release_date}, ${data.total_tracks} tracks.</p>66 <br><br>67 <a href="eons://b=0190i2uwsoildjuakha=${id}" target="_blank" class="btn-contained-primary animated zoomIn slower">open eonsound</a>68 <a href="https://r0hin.github.io/eonsound/" target="_blank" class="btn-contained-primary animated zoomIn slower">Download</a>69 </center>70 ` 71 } catch (error) {72 endRun()73 }74 $('#contentView').get(0).appendChild(a)75 window.setTimeout(() => {76 initButtonsContained()77 }, 200)78}79async function loadTrack(id) {80 data = await goFetch('tracks/' + id)81 a = document.createElement('div')82 a.setAttribute('class', 'track')83 try {84 a.innerHTML = `85 <center>86 <img src="${data.album.images[0].url}"></img>87 <h1>${data.name}</h1>88 <h4>${artistToString(data.artists)}</h4>89 <br><br>90 <a href="eons://b=092ei0192jiwosdncsa=${id}" target="_blank" class="btn-contained-primary animated zoomIn slower">open eonsound</a>91 <a href="https://r0hin.github.io/eonsound/" target="_blank" class="btn-contained-primary animated zoomIn slower">Download</a>92 </center>93 `94 }95 catch(error) {96 endRun()97 }98 $('#contentView').get(0).appendChild(a)99 window.setTimeout(() => {100 initButtonsContained()101 }, 200)102}103async function loadArtist(id) {104 data = await goFetch('artists/' + id)105 a = document.createElement('div')106 a.setAttribute('class', 'artist')107 try {108 a.innerHTML = `109 <center>110 <img src="${data.images[0].url}"></img>111 <h1>${data.name}</h1>112 <br><br>113 <a href="eons://b=0s29ieu08jidsoja2sa=${id}" target="_blank" class="btn-contained-primary animated zoomIn slower">open eonsound</a>114 <a href="https://r0hin.github.io/eonsound/" target="_blank" class="btn-contained-primary animated zoomIn slower">Download</a>115 </center>116 ` 117 } catch (error) {118 endRun()119 }120 $('#contentView').get(0).appendChild(a)121 window.setTimeout(() => {122 initButtonsContained()123 }, 200)124}125async function loadPlaylist(id) {126 data = await goFetch('playlists/' + id)127 a = document.createElement('div')128 a.setAttribute('class', 'playlist')129 try {130 a.innerHTML = `131 <center>132 <img src="${data.images[0].url}"></img>133 <h1>${data.name}</h1>134 <br><br>135 <a href="eons://b=0912897812edhxkjbaa=${id}" target="_blank" class="btn-contained-primary animated zoomIn slower">open eonsound</a>136 <a href="https://r0hin.github.io/eonsound/" target="_blank" class="btn-contained-primary animated zoomIn slower">Download</a>137 </center>138 ` 139 } catch (error) {140 endRun()141 }142 $('#contentView').get(0).appendChild(a)143 window.setTimeout(() => {144 initButtonsContained()145 }, 200)146}147async function loadUserPlaylist(id) {148 // Maybe in a future update...

Full Screen

Full Screen

TestSynchronizrDiff.js

Source:TestSynchronizrDiff.js Github

copy

Full Screen

1class TestSynchronizrDiff extends UnitTest {2 constructor(root, text) {3 super(root, text);4 }5 // Reimplementation of receiver's bytecode parser6 getResult(arr, bytecode) {7 var t = this;8 var rtn = [];9 var ptr = 0;10 var endLastRun = 0;11 while (ptr < bytecode.length) {12 var op = bytecode[ptr++];13 let startRun, endRun;14 switch (op) {15 case 255: // Short Run16 startRun = endLastRun + bytecode[ptr++];17 endRun = startRun + bytecode[ptr++];18 endLastRun = endRun;19 for (let x = startRun; x <= endRun; x++)20 rtn.push(t.byteArrToStr(arr[x]));21 break;22 case 254: // Negative Short Run23 startRun = endLastRun - bytecode[ptr++];24 endRun = startRun + bytecode[ptr++];25 endLastRun = endRun;26 for (let x = startRun; x <= endRun; x++)27 rtn.push(t.byteArrToStr(arr[x]));28 break;29 case 253: // Long Run30 startRun = bytecode[ptr++] * 256 + bytecode[ptr++];31 endRun = bytecode[ptr++] * 256 + bytecode[ptr++];32 endLastRun = endRun;33 for (let x = startRun; x <= endRun; x++)34 rtn.push(t.byteArrToStr(arr[x]));35 break;36 case 252: // Singular Short Run [1 element long]37 startRun = endLastRun + bytecode[ptr++];38 endLastRun = startRun;39 rtn.push(t.byteArrToStr(arr[startRun]));40 break;41 default: // Just a normal string literal42 let len = op * 256 + bytecode[ptr++];43 var str = "";44 for (let x = 0; x < len; x++) {45 str += String.fromCharCode(bytecode[ptr++]);46 }47 rtn.push(str);48 break;49 }50 }51 return rtn;52 }53 byteArrToStr(byteArr){54 return SynchronizrUtils.byteArrToStr(byteArr);55 }56 strArrToByteArrArr(strArr){57 var rtn = [];58 for(var x = 0; x < strArr.length; x++){59 var itm = strArr[x];60 var rti = new Uint8Array(itm.length);61 for(var y = 0; y < itm.length; y++){62 rti[y] = itm.charCodeAt(y);63 }64 rtn.push(rti);65 }66 return rtn;67 }68 // byteArrArrToStrArr(byteArr){69 // var rtn = [];70 // for(var x = 0; x < byteArr.length; x++){71 // var itm = byteArr[x];72 // var rti = "";73 // for(var y = 0; x < itm.length; y++){74 // rti += String.fromCharCode(itm[y]);75 // }76 // }77 // }78 test() {79 try {80 var t = this;81 // Detailed test setup82 var str1 = "The sly quick brown fox jumped over the obese lazy dog after chewing on a juicy bone";83 // var str1 = "The quick brown fox Foo".split(" ");84 // var str1 = "1 2 3 4 5 6 7 Fizz Buzz Zip Zzzip ".split(" "); // Old85 str1 = t.strArrToByteArrArr(str1.split(" "));86 var str1Orig = [...str1];87 var str2 = "The orange fluffy kitten jumped the lazy dog and ran off with his juicy bone of beef";88 // var str2 = "Jumped over the lazy dog Foo".split(" ");89 // var str2 = "3 2 1 5 4 Fizz Zzzip Zip".split(" "); // New90 var str2Orig = str2;91 str2 = t.strArrToByteArrArr(str2.split(" "));92 var d = SynDiff.genDiffInfo(str1, str2);93 var result = t.getResult(str1Orig, d).join(" ");94 console.log(d);95 console.log(str1Orig);96 console.log(result);97 t.assertEquals(result, str2Orig);98 // Other tests99 str1 = t.strArrToByteArrArr("The brown quick fox jumped".split(" "));100 str1Orig = [...str1];101 str2 = t.strArrToByteArrArr("The quick brown fox jumped".split(" "));102 var foo2 = SynDiff.genDiffInfo(str1, str2);103 var str3 = t.getResult(str1Orig, foo2).join(" ");104 t.assertEquals("The quick brown fox jumped", str3);105 } catch (e) {106 console.error(e);107 return e;108 }109 return undefined;110 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import test from 'ava';2test('test', t => {3 t.endRun();4});5import test from 'ava';6test('test', t => {7 t.endRun();8});9import test from 'ava';10test('test', t => {11 t.endRun();12});13import test from 'ava';14test('test', t => {15 t.endRun();16});17import test from 'ava';18test('test', t => {19 t.endRun();20});21import test from 'ava';22test('test', t => {23 t.endRun();24});25import test from 'ava';26test('test', t => {27 t.endRun();28});29import test from 'ava';30test('test', t => {31 t.endRun();32});33import test from 'ava';34test('test', t => {35 t.endRun();36});37import test from 'ava';38test('test', t => {39 t.endRun();40});41import test from 'ava';42test('test', t => {43 t.endRun();44});45import test from 'ava';46test('test', t => {47 t.endRun();48});49import test from 'ava';50test('test', t => {51 t.endRun();52});53import test from 'ava';54test('test', t => {55 t.endRun();56});57import test from 'ava';58test('test', t => {59 t.endRun();60});61import test from 'ava';62test('test', t => {63 t.endRun();64});

Full Screen

Using AI Code Generation

copy

Full Screen

1var avatar = document.querySelector('a-entity[avatar]');2avatar.components.avatar.endRun();3var avatar = document.querySelector('a-entity[avatar]');4avatar.components.avatar.endRun();5var avatar = document.querySelector('a-entity[avatar]');6avatar.components.avatar.endRun();7var avatar = document.querySelector('a-entity[avatar]');8avatar.components.avatar.endRun();9var avatar = document.querySelector('a-entity[avatar]');10avatar.components.avatar.endRun();11var avatar = document.querySelector('a-entity[avatar]');12avatar.components.avatar.endRun();13var avatar = document.querySelector('a-entity[avatar]');14avatar.components.avatar.endRun();15var avatar = document.querySelector('a-entity[avatar]');16avatar.components.avatar.endRun();17var avatar = document.querySelector('a-entity[avatar]');18avatar.components.avatar.endRun();19var avatar = document.querySelector('a-entity[avatar]');20avatar.components.avatar.endRun();21var avatar = document.querySelector('a-entity[avatar]');22avatar.components.avatar.endRun();23var avatar = document.querySelector('a-entity[avatar]');24avatar.components.avatar.endRun();25var avatar = document.querySelector('a-entity[avatar]');26avatar.components.avatar.endRun();27var avatar = document.querySelector('a-entity[avatar]');28avatar.components.avatar.endRun();29var avatar = document.querySelector('a-entity[avatar]');

Full Screen

Using AI Code Generation

copy

Full Screen

1var availableRuns = require('./availableRuns');2var runs = availableRuns();3console.log(runs.endRun(10));4console.log(runs.endRun(20));5console.log(runs.endRun(30));6console.log(runs.endRun(40));7console.log(runs.endRun(50));8console.log(runs.endRun(60));9console.log(runs.endRun(70));10console.log(runs.endRun(80));11console.log(runs.endRun(90));12console.log(runs.endRun(100));13How to use the console.log() in Node.js - August 17, 202014How to use the console.log() in Node.js15How to use the process.exit() in Node.js16How to use the process.cwd() in Node.js17How to use the process.chdir() in Node.js18How to use the process.nextTick() in Node.js19How to use the process.kill() in Node.js20How to use the process.hrtime() in Node.js21How to use the process.memoryUsage() in Node.js22How to use the process.uptime() in Node.js

Full Screen

Using AI Code Generation

copy

Full Screen

1var avatar = require('avatar');2var avatar = new avatar();3avatar.endRun();4var avatar = function() {5 this.endRun = function() {6 console.log('avatar end run');7 }8}9module.exports = avatar;10var avatar = require('avatar');11var avatar = new avatar();12avatar.endRun();13var avatar = function() {14 this.endRun = function() {15 console.log('avatar end run');16 }17}18module.exports = avatar;19var avatar = require('avatar');20var avatar = new avatar();21avatar.endRun();22var avatar = function() {23 this.endRun = function() {24 console.log('avatar end run');25 }26}27module.exports = avatar;28var avatar = require('avatar');29var avatar = new avatar();30avatar.endRun();31var avatar = function() {32 this.endRun = function() {33 console.log('avatar end run');34 }35}36module.exports = avatar;37var avatar = require('avatar');38var avatar = new avatar();39avatar.endRun();40var avatar = function() {41 this.endRun = function() {42 console.log('avatar end run');43 }44}45module.exports = avatar;46var avatar = require('avatar');47var avatar = new avatar();48avatar.endRun();

Full Screen

Using AI Code Generation

copy

Full Screen

1test('test', t => {2 t.endRun();3});4### `t.log([message])`5const test = require('ava');6test('my passing test', t => {7 t.pass();8 t.log('hello');9});10### `t.plan(count)`11const test = require('ava');12test('my passing test', t => {13 t.plan(1);14 return Promise.resolve(3).then(n => {15 t.is(n, 3);16 });17});18### `t.snapshot([title], [snapshotData])`19const test = require('ava');20test('my passing test', t => {21 t.snapshot({foo: 'bar'});22});23### `t.snapshot.match([title], [snapshotData], [match])`24const test = require('ava');25test('my passing test', t => {26 t.snapshot.match({foo: 'bar'}, (t, a, b) => t.is(a.foo, b.foo));27});28### `t.throws(function|promise, [error, [message]])`29const test = require('ava');30test('my passing test', t => {31 const err = t.throws(() => {32 throw new TypeError('Wrong value');33 }, TypeError);34 t.is(err.message, 'Wrong value');35});36### `t.notThrows(function|promise, [

Full Screen

Using AI Code Generation

copy

Full Screen

1var run = availableRuns.find(function(run){2 return run.runId === runId;3});4if(run){5 run.endRun();6}7function endRun(){8 this.endTime = new Date();9 this.status = 'completed';10 this.duration = this.endTime - this.startTime;11 console.log('Run ended');12}13var run = availableRuns.find(function(run){14 return run.runId === runId;15});

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