var HelixWebServicesClient = require('../helix_web_services_client'); require('../polyfill'); describe('HelixWebServicesClient', function() { describe('logIn', function() { it('can log in and out with real creds', function(done) { var client = new HelixWebServicesClient({ url: 'http://localhost:9000', user: 'jdoe' }); client.logIn('johndoe1A!') .done(function() { expect(client.session_token).toBeDefined(); client.logOut() .done(done) .fail(function() { done.fail("logout failed") }); }) .fail(done.fail); }); it('will fail if you provide incorrect creds', function(done) { var client = new HelixWebServicesClient({ url: 'http://localhost:9000', user: 'jdoe' }); client.logIn('invalid') .done(done.fail) .fail(function(jqXHR) { expect(jqXHR.status).toBe(401); done(); }); }); }); // TODO we very likely want to actually create a test project describe('syncProjects', function() { var randomStr = require('crypto').randomBytes(8).toString('hex'); var testProjectName = 'Test Project ' + randomStr; var testProjectId = 'test_project_' + randomStr; it('can create a sync project', function(done) { var client = new HelixWebServicesClient({ url: 'http://localhost:9000', user: 'jdoe' }); client.logIn('johndoe1A!') .fail(done.fail) .done(function() { client.createSyncProject({ name: testProjectName }) .fail(function() { console.log('create project failed', arguments); done.fail('create project failed'); }) .done(function() { client.logOut().fail(done.fail).done(done); }); }); }); it('can find our project in all projects on the server', function(done) { var client = new HelixWebServicesClient({ url: 'http://localhost:9000', user: 'jdoe' }); client.logIn('johndoe1A!') .fail(done.fail) .done(function() { client.syncProjects() .fail(done.fail) .done(function(projects) { var project; for (var ii = 0; ii < projects.length; ii++) { if (projects[ii].id == testProjectId) project = projects[ii]; } expect(project).toBeDefined(); client.logOut().fail(done.fail).done(done); }); }); }); }); describe('listFiles', function() { it('should list depots if no path is specified', function(done) { var client = new HelixWebServicesClient({ url: 'http://localhost:9000', user: 'jdoe' }); client.logIn('johndoe1A!') .fail(done.fail) .done(function() { client.listFiles() .fail(done.fail) .done(function(items) { var depot = items.find(function(x) { return x.name == 'depot'; }); expect(depot).toBeDefined(); client.logOut().fail(done.fail).done(done); }); }); }); it('can list directories in the "depot" depot', function(done) { var client = new HelixWebServicesClient({ url: 'http://localhost:9000', user: 'jdoe' }); client.logIn('johndoe1A!') .fail(done.fail) .done(function() { client.listFiles('depot') .fail(done.fail) .done(function(items) { var dev = items.find(function(x) { return x.name == 'dev'; }); expect(dev).toBeDefined(); client.logOut().fail(done.fail).done(done); }); }); }); it('can list files in the "//depot/dev/Experimental" directory', function(done) { var client = new HelixWebServicesClient({ url: 'http://localhost:9000', user: 'jdoe' }); client.logIn('johndoe1A!') .fail(done.fail) .done(function() { client.listFiles('//depot/dev/Experimental') .fail(done.fail) .done(function(items) { var dev = items.find(function(x) { return x.name == 'README'; }); expect(dev).toBeDefined(); client.logOut().fail(done.fail).done(done); }); }); }); }); });
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 15688 | Doug Scheirer |
Populate -o //guest/perforce_software/helix-web-services/... //guest/doug_scheirer/helix-web-services/.... |
||
//guest/perforce_software/helix-web-services/main/source/helix_web_services_client_js/spec/helix_web_services_client_spec.js | |||||
#1 | 15622 | tjuricek |
Move source code to 'source/' subdirectory of branch. build/ will remain where it is. |
||
//guest/perforce_software/helix-web-services/main/helix_web_services_client_js/spec/helix_web_services_client_spec.js | |||||
#3 | 14108 | tjuricek |
Added models for handling Perforce server depot listing and traversal. This is not complete, however, the models are a start to making it easy to generate a tree control. (Most tree controls in the wild assume you know the tree structure from the start, which is not true in our case.) The tricky bit is making it easy to build the tree out given that you're visiting only one directory at a time. |
||
#2 | 13998 | tjuricek |
Add a basic ability for the JS SDK to create and list projects. Cleaned up some node madness on SDK initialization. |
||
#1 | 13976 | tjuricek |
Client SDK for JavaScript that logs in. This is currently tested via node using jasmine against a test environment, which requires some funky initialization. So this isn't a particularly useful client yet, but we'll need to add more error handling, etc, to smooth things out. |