Skip to content

Commit 9d5ee7c

Browse files
fix tests
1 parent 676115e commit 9d5ee7c

File tree

1 file changed

+27
-57
lines changed

1 file changed

+27
-57
lines changed

test/api_test.js

Lines changed: 27 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ describe('TestingBot API Tests', function() {
5555

5656
describe('Test Management', function() {
5757
it('should list tests with default pagination', function(done) {
58-
this.api.getTests(function(err, response) {
58+
this.api.getTests(undefined, undefined, function(err, response) {
5959
assert.strictEqual(err, null, 'Should not have an error');
6060
assert.ok(response, 'Response should exist');
6161
assert.ok(Array.isArray(response.data), 'Response data should be an array');
@@ -65,12 +65,12 @@ describe('TestingBot API Tests', function() {
6565
});
6666

6767
it('should list tests with custom pagination', function(done) {
68-
this.api.getTests(function(err, response) {
68+
this.api.getTests(0, 5, function(err, response) {
6969
assert.strictEqual(err, null, 'Should not have an error');
7070
assert.ok(response, 'Response should exist');
7171
assert.ok(response.meta, 'Meta information should exist');
7272
done();
73-
}, 0, 5);
73+
});
7474
});
7575

7676
it('should error when no test is found', function(done) {
@@ -82,7 +82,7 @@ describe('TestingBot API Tests', function() {
8282
});
8383

8484
it('should find a specific test', function(done) {
85-
this.api.getTests((err, response) => {
85+
this.api.getTests(undefined, undefined, (err, response) => {
8686
assert.ok(response && response.data && response.data.length > 0, 'Should have test data');
8787
const singleTest = response.data[0];
8888
this.api.getTestDetails(singleTest.id, (err, response) => {
@@ -95,7 +95,7 @@ describe('TestingBot API Tests', function() {
9595
});
9696

9797
it('should update a test with legacy data format', function(done) {
98-
this.api.getTests((err, response) => {
98+
this.api.getTests(undefined, undefined, (err, response) => {
9999
assert.ok(response && response.data && response.data.length > 0, 'Should have test data');
100100
const singleTest = response.data[0];
101101
const statusMessage = 'test_' + Date.now();
@@ -112,7 +112,7 @@ describe('TestingBot API Tests', function() {
112112
});
113113

114114
it('should update a test with object data format', function(done) {
115-
this.api.getTests((err, response) => {
115+
this.api.getTests(undefined, undefined, (err, response) => {
116116
assert.ok(response && response.data && response.data.length > 0, 'Should have test data');
117117
const singleTest = response.data[0];
118118
const statusMessage = 'test2_' + Date.now();
@@ -129,7 +129,7 @@ describe('TestingBot API Tests', function() {
129129
});
130130

131131
it('should stop a test', function(done) {
132-
this.api.getTests((err, response) => {
132+
this.api.getTests(undefined, undefined, (err, response) => {
133133
if (!response || !response.data || response.data.length === 0) {
134134
return done();
135135
}
@@ -147,7 +147,7 @@ describe('TestingBot API Tests', function() {
147147
});
148148

149149
it('should delete a test', function(done) {
150-
this.api.getTests((err, response) => {
150+
this.api.getTests(undefined, undefined, (err, response) => {
151151
assert.ok(response && response.data && response.data.length > 0, 'Should have test data');
152152
const singleTest = response.data[0];
153153
this.api.deleteTest(singleTest.id, (err, response) => {
@@ -200,7 +200,7 @@ describe('TestingBot API Tests', function() {
200200

201201
describe('Browser Management', function() {
202202
it('should list all browsers', function(done) {
203-
this.api.getBrowsers(function(err, response) {
203+
this.api.getBrowsers(undefined, function(err, response) {
204204
assert.strictEqual(err, null, 'Should not have an error');
205205
assert.ok(response, 'Response should exist');
206206
assert.ok(Array.isArray(response), 'Response should be an array');
@@ -209,11 +209,11 @@ describe('TestingBot API Tests', function() {
209209
});
210210

211211
it('should list browsers by type', function(done) {
212-
this.api.getBrowsers(function(err, response) {
212+
this.api.getBrowsers('webdriver', function(err, response) {
213213
assert.strictEqual(err, null, 'Should not have an error');
214214
assert.ok(response, 'Response should exist');
215215
done();
216-
}, 'webdriver');
216+
});
217217
});
218218
});
219219

@@ -240,7 +240,7 @@ describe('TestingBot API Tests', function() {
240240
});
241241

242242
it('should list storage files', function(done) {
243-
this.api.getStorageFiles(function(err, response) {
243+
this.api.getStorageFiles(undefined, undefined, function(err, response) {
244244
assert.strictEqual(err, null, 'Should not have an error');
245245
assert.ok(response, 'Response should exist');
246246
assert.ok(Array.isArray(response.data) || Array.isArray(response), 'Response should contain an array');
@@ -249,15 +249,15 @@ describe('TestingBot API Tests', function() {
249249
});
250250

251251
it('should list storage files with pagination', function(done) {
252-
this.api.getStorageFiles(function(err, response) {
252+
this.api.getStorageFiles(0, 5, function(err, response) {
253253
assert.strictEqual(err, null, 'Should not have an error');
254254
assert.ok(response, 'Response should exist');
255255
done();
256-
}, 0, 5);
256+
});
257257
});
258258

259259
it('should get a specific storage file', function(done) {
260-
this.api.getStorageFiles((err, response) => {
260+
this.api.getStorageFiles(undefined, undefined, (err, response) => {
261261
const files = response.data || response;
262262
if (files && files.length > 0) {
263263
let appUrl = files[0].app_url || files[0].url;
@@ -294,16 +294,16 @@ describe('TestingBot API Tests', function() {
294294

295295
describe('Screenshot Service', function() {
296296
it('should take a screenshot', function(done) {
297-
this.api.takeScreenshot(function(err, response) {
297+
this.api.takeScreenshot('https://testingbot.com', [{ "browserName" : "chrome", "version" : 134, "os" : "WIN10"}], '1280x1024', 0, undefined, undefined, function(err, response) {
298298
assert.strictEqual(err, null, 'Should not have an error taking screenshot');
299299
assert.ok(response, 'Response should exist');
300300
assert.ok(response.screenshot_id || response.id, 'Screenshot ID should be returned');
301301
done();
302-
}, 'https://testingbot.com', [{ "browserName" : "chrome", "version" : 134, "os" : "WIN10"}], 0, '1280x1024');
302+
});
303303
});
304304

305305
it('should retrieve screenshot details', function(done) {
306-
this.api.takeScreenshot((err, response) => {
306+
this.api.takeScreenshot('https://testingbot.com', [{ "browserName" : "chrome", "version" : 134, "os" : "WIN10"}], '1280x1024', undefined, undefined, undefined, (err, response) => {
307307
if (response && (response.screenshot_id || response.id)) {
308308
const screenshotId = response.screenshot_id || response.id;
309309
setTimeout(() => {
@@ -316,11 +316,11 @@ describe('TestingBot API Tests', function() {
316316
} else {
317317
done();
318318
}
319-
}, 'https://testingbot.com', [{ "browserName" : "chrome", "version" : 134, "os" : "WIN10"}]);
319+
});
320320
});
321321

322322
it('should list screenshots', function(done) {
323-
this.api.getScreenshotList(function(err, response) {
323+
this.api.getScreenshotList(undefined, undefined, function(err, response) {
324324
assert.strictEqual(err, null, 'Should not have an error');
325325
assert.ok(response, 'Response should exist');
326326
assert.ok(Array.isArray(response.data) || Array.isArray(response), 'Response should contain an array');
@@ -329,11 +329,11 @@ describe('TestingBot API Tests', function() {
329329
});
330330

331331
it('should list screenshots with pagination', function(done) {
332-
this.api.getScreenshotList(function(err, response) {
332+
this.api.getScreenshotList(0, 5, function(err, response) {
333333
assert.strictEqual(err, null, 'Should not have an error');
334334
assert.ok(response, 'Response should exist');
335335
done();
336-
}, 0, 5);
336+
});
337337
});
338338
});
339339

@@ -467,23 +467,23 @@ describe('TestingBot API Tests', function() {
467467

468468
describe('Build Management', function() {
469469
it('should list builds', function(done) {
470-
this.api.getBuilds(function(err, response) {
470+
this.api.getBuilds(undefined, undefined, function(err, response) {
471471
assert.strictEqual(err, null, 'Should not have an error');
472472
assert.ok(response, 'Response should exist');
473473
done();
474474
});
475475
});
476476

477477
it('should list builds with pagination', function(done) {
478-
this.api.getBuilds(function(err, response) {
478+
this.api.getBuilds(0, 5, function(err, response) {
479479
assert.strictEqual(err, null, 'Should not have an error');
480480
assert.ok(response, 'Response should exist');
481481
done();
482-
}, 0, 5);
482+
});
483483
});
484484

485485
it('should get tests for a build', function(done) {
486-
this.api.getBuilds((err, response) => {
486+
this.api.getBuilds(undefined, undefined, (err, response) => {
487487
const builds = (response && response.data) || response || [];
488488
if (builds.length > 0) {
489489
const buildId = builds[0].id || builds[0].build_id;
@@ -499,7 +499,7 @@ describe('TestingBot API Tests', function() {
499499
});
500500

501501
it('should delete a build', function(done) {
502-
this.api.getBuilds((err, response) => {
502+
this.api.getBuilds(undefined, undefined, (err, response) => {
503503
const builds = (response && response.data) || response || [];
504504
if (builds.length > 0) {
505505
const buildId = builds[0].id || builds[0].build_id;
@@ -640,23 +640,6 @@ describe('TestingBot API Tests', function() {
640640
});
641641
});
642642

643-
it('should create a session with additional options', function(done) {
644-
const options = {
645-
capabilities: {
646-
browserName: 'chrome',
647-
browserVersion: '140',
648-
platform: 'WIN11'
649-
}
650-
};
651-
this.api.createSession(options, function(err, response) {
652-
if (err && err.message && err.message.includes('Unauthorized')) {
653-
return done();
654-
}
655-
assert.ok(response || err, 'Should have response or error');
656-
done();
657-
});
658-
});
659-
660643
it('should handle session creation errors gracefully', function(done) {
661644
const api = new TbApi({ api_key: 'invalid_key', api_secret: 'invalid_secret' });
662645
api.createSession({}, function(err, response) {
@@ -665,19 +648,6 @@ describe('TestingBot API Tests', function() {
665648
done();
666649
});
667650
});
668-
669-
it('should merge default capabilities with custom ones', function(done) {
670-
const partialCapabilities = {
671-
browserName: 'edge'
672-
};
673-
this.api.createSession({ capabilities: partialCapabilities }, function(err, response) {
674-
if (err && err.message && err.message.includes('Unauthorized')) {
675-
return done();
676-
}
677-
assert.ok(response || err, 'Should have response or error');
678-
done();
679-
});
680-
});
681651
});
682652

683653
describe('Edge Cases and Error Handling', function() {

0 commit comments

Comments
 (0)