<commit_before> var request = require('request');
var neo4j = require('node-neo4j');
 require('../testserver.js').startserver();
 describe('Localr API', function() {
     describe('test local connection', function() {
         it('make connection to server', function(done) {
             var url = 'http://localhost:8080/users/test';
             // getting the parameters
             var params = {
                 uri: url,
                 headers: {
                     authorization: getBasic('testuser', 'test')
                 }
             };
             request.get(params, function(error, response, body) {
                 expect(response.statusCode).toBe(200);
                 expect(body).toBe('"works"');
                 console.log(body)
                 if(error) {
                     expect(error.code).not.toBe('ECONNREFUSED');
                 }
                 done();
             })
             console.log("connection works")
         })
     })
     describe('Users', function() {
         describe('create the user', function() {
             it("be able to create a user", function(done) {
                 var url = 'http://localhost:8080/users';
                 // getting the parameters
                 var params = {
                     uri: url,
                     headers: {
                         authorization: getBasic('testuser', 'test')
                     }
                 };
                 request.post(params, function(error, response, body) {
                     expect(response.statusCode).toBe(201);
                     body = JSON.parse(body);
                     expect(body.Username).toBe('testuser');
                     expect(body.url).toBe('api.adam-holt.co.uk/users/testuser');
                     if(error) {
                         expect(error.code).not.toBe('ECONNREFUSED');
                     }
                     done();
                 })
             })
             it("be not able to create duplicate user", function(done) {
                 var url = 'http://localhost:8080/users';
                 // getting the parameters
                 var params = {
                     uri: url,
                     headers: {
                         authorization: getBasic('testuser', 'test')
                     }
                 };
                 request.post(params, function(error, response, body) {
                     expect(response.statusCode).toBe(409);
                     if(error) {
                         expect(error.code).not.toBe('ECONNREFUSED');
                     }
                     done();
                 })
             })
         })
     })
     describe('checkin', function() {
         it("be able to checkin", function(done) {
             var url = 'http://localhost:8080/users/checkin?username=testuser&points=10';
             var doc = {
                 username: "testuser",
                 points: 10
             };
             // getting the parameters
             var params = {
                 uri: url,
                 headers: {
                     authorization: getBasic('testuser', 'test')
                 },
                 body: JSON.stringify(doc)
             };
             request.put(params, function(error, response, body) {
                 expect(response.statusCode).toBe(200);
                 expect(response.body).toBe("{'Points added':'10'}")
                 if(error) {
                     expect(error.code).not.toBe('ECONNREFUSED');
                 }
                 done();
             })
         })
         it("check points have been added", function(done) {
             var url = 'http://localhost:8080/users/testuser';
             // getting the parameters
             var params = {
                 uri: url,
                 headers: {
                     authorization: getBasic('testuser', 'test')
                 }
             };
             request.get(params, function(error, response, body) {
                 expect(response.statusCode).toBe(200);
                 body = JSON.parse(body);
                 expect(body.points).toBe(10);
                 if(error) {
                     expect(error.code).not.toBe('ECONNREFUSED');
                 }
                 done();
             })
         })
         it("be able to see where you've checked in", function() {})
     })
     describe("groups", function() {
         it("be able to create a group", function(done) {
             var db = new neo4j('http://localhost:7474');
             var url = 'http://localhost:8080/groups'
             var doc = {
                 username: "testuser",
                 groupname: "testgroup",
                 description: "This is a Test Group",
                 competition: "freshers"
             };
             // getting the parameters
             var params = {
                 uri: url,
                 headers: {
                     authorization: getBasic('testuser', 'test'),
                     "content-type": "application/json"
                 },
                 body: JSON.stringify(doc)
             };
             request.post(params, function(error, response, body) {
                 expect(response.statusCode).toBe(201);
                 if(error) {
                     expect(error.code).not.toBe('ECONNREFUSED');
                 }
                 db.cypherQuery(" MATCH (n:Group) WHERE n.name ='testgroup' RETURN n", function(err, Results) {
                    if(err) throw err;
                     expect(Results.data[0].name).toBe('testgroup');
                       db.cypherQuery(" MATCH n-[r]->m RETURN n,r,m", function(err, Results) {
                    if(err) throw err;
                     console.log("getting relationships")
                     console.log(Results)
                    done();
                })
                })

             })
         })
         it("be able to join a group", function(done) {
             var url = 'http://localhost:8080/users/groups/testgroup';
             // getting the parameters
             var params = {
                 uri: url,
                 headers: {
                     authorization: getBasic('testuser', 'test')
                 },
             };
             request.put(params, function(error, response, body) {
                 expect(response.statusCode).toBe(200);
                 if(error) {
                     expect(error.code).not.toBe('ECONNREFUSED');
                 }
                 done();
             })
         })
         it("be able to delete a group", function(done) {
             var url = 'http://localhost:8080/users/groups';
             var doc = {
                 username: "testuser",
                 groupname: "testgroup",
                 description: "testgroup",
                 competition: "freshers"
             };
             // getting the parameters
             var params = {
                 uri: url,
                 headers: {
                     authorization: getBasic('testuser', 'test')
                 },
                 body: JSON.stringify(doc)
             };
             request.del(params, function(error, response, body) {
                 expect(response.statusCode).toBe(200);
                 if(error) {
                     expect(error.code).not.toBe('ECONNREFUSED');
                 }
                 done();
             })
         })
     });
     describe('businesses', function() {
         it('able to create new business', function(done) {
             var url = 'http://localhost:8080/business';
             // getting the parameters
             var params = {
                 uri: url,
                 headers: {
                     authorization: getBasic('testBusinesses', 'test')
                 },
             };
             request.put(params, function(error, response, body) {
                 expect(response.statusCode).toBe(201);
                 if(error) {
                     expect(error.code).not.toBe('ECONNREFUSED');
                 }
                 done();
             })
         })
     })
     describe('Offers', function() {
         it("Be able to add an offer", function(done) {
             var url = 'http://localhost:8080/business/offers';
             var doc = {
                 businessname: 'testbusiness',
                 description: 'description',
                 title: 'test offer',
                 cost: 50
             }
             // getting the parameters
             var params = {
                 uri: url,
                 headers: {
                     authorization: getBasic('testuser', 'test')
                 },
                 body: JSON.stringify(doc)
             };
             request.post(params, function(error, response, body) {
                 expect(response.statusCode).toBe(200);
                 if(error) {
                     expect(error.code).not.toBe('ECONNREFUSED');
                 }
                 done();
             })
         })
         it("Be able to get the latest offers", function(done) {
             var url = 'http://localhost:8080/business/offers/all';
             // getting the parameters
             var params = {
                 uri: url,
                 headers: {
                     authorization: getBasic('testuser', 'test')
                 },
             };
             request.get(params, function(error, response, body) {
                 expect(response.statusCode).toBe(200);
                 if(error) {
                     expect(error.code).not.toBe('ECONNREFUSED');
                 }
                 done();
             })
         })
         it("be able to get a businesses offers", function(done) {
             var url = 'http://localhost:8080/business/offers/testbusiness';
             // getting the parameters
             var params = {
                 uri: url,
                 headers: {
                     authorization: getBasic('testuser', 'test')
                 },
             };
             request.get(params, function(error, response, body) {
                 expect(response.statusCode).toBe(200);
                 if(error) {
                     expect(error.code).not.toBe('ECONNREFUSED');
                 }
                 done();
             })
         })
     })
     it("be able to check what offers youve redeemed", function() {})
     describe('delete all', function() {
         it("be able to delete the user", function(done) {
             var url = 'http://localhost:8080/users';
             // getting the parameters
             var params = {
                 uri: url,
                 headers: {
                     authorization: getBasic('testuser', 'test')
                 },
             };
             request.del(params, function(error, response, body) {
                 expect(response.statusCode).toBe(200);
                 expect(body).toBe('"Deleted User!"')
                 if(error) {
                     expect(error.code).not.toBe('ECONNREFUSED');
                 }
                 done();
             })
         })
         it('be able to delete the business', function(done) {
             var url = 'http://localhost:8080/business';
             // getting the parameters
             var params = {
                 uri: url,
                 headers: {
                     authorization: getBasic('testBusiness', 'test')
                 },
             };
             request.del(params, function(error, response, body) {
                 expect(response.statusCode).toBe(200);
                 expect(body).toBe('"Deleted Business!"')
                 if(error) {
                     expect(error.code).not.toBe('ECONNREFUSED');
                 }
                 done();
             })
         })
         it('delete offers', function(done) {
             var url = 'http://localhost:8080/business/offers';
             // getting the parameters
             var params = {
                 uri: url,
                 headers: {
                     authorization: getBasic('testuser', 'test')
                 },
             };
             request.del(params, function(error, response, body) {
                 expect(response.statusCode).toBe(200);
                 if(error) {
                     expect(error.code).not.toBe('ECONNREFUSED');
                 }
                 done();
             })
         })
         it('delete group', function(done) {
             var url = 'http://localhost:8080/business';
             // getting the parameters
             var params = {
                 uri: url,
                 headers: {
                     authorization: getBasic('testuser', 'test')
                 },
             };
             request.del(params, function(error, response, body) {
                 expect(response.statusCode).toBe(200);
                 if(error) {
                     expect(error.code).not.toBe('ECONNREFUSED');
                 }
                 done();
             })
         })
     });
 })
 getBasic = function(username, password) {
     return "Basic " + new Buffer(username + ":" + password).toString('base64')
 };<commit_msg>adding the competition node<commit_after> var request = require('request');
 var neo4j = require('node-neo4j');
 require('../testserver.js').startserver();
 describe('Localr API', function() {
     describe('test local connection', function() {
         it('make connection to server', function(done) {
             var url = 'http://localhost:8080/users/test';
             // getting the parameters
             var params = {
                 uri: url,
                 headers: {
                     authorization: getBasic('testuser', 'test')
                 }
             };
             request.get(params, function(error, response, body) {
                 expect(response.statusCode).toBe(200);
                 expect(body).toBe('"works"');
                 console.log(body)
                 if(error) {
                     expect(error.code).not.toBe('ECONNREFUSED');
                 }
                 done();
             })
             console.log("connection works")
         })
     })
     describe('Users', function() {
         describe('create the user', function() {
             it("be able to create a user", function(done) {
                 var url = 'http://localhost:8080/users';
                 // getting the parameters
                 var params = {
                     uri: url,
                     headers: {
                         authorization: getBasic('testuser', 'test')
                     }
                 };
                 request.post(params, function(error, response, body) {
                     expect(response.statusCode).toBe(201);
                     body = JSON.parse(body);
                     expect(body.Username).toBe('testuser');
                     expect(body.url).toBe('api.adam-holt.co.uk/users/testuser');
                     if(error) {
                         expect(error.code).not.toBe('ECONNREFUSED');
                     }
                     done();
                 })
             })
             it("be not able to create duplicate user", function(done) {
                 var url = 'http://localhost:8080/users';
                 // getting the parameters
                 var params = {
                     uri: url,
                     headers: {
                         authorization: getBasic('testuser', 'test')
                     }
                 };
                 request.post(params, function(error, response, body) {
                     expect(response.statusCode).toBe(409);
                     if(error) {
                         expect(error.code).not.toBe('ECONNREFUSED');
                     }
                     done();
                 })
             })
         })
     })
     describe('checkin', function() {
         it("be able to checkin", function(done) {
             var url = 'http://localhost:8080/users/checkin?username=testuser&points=10';
             var doc = {
                 username: "testuser",
                 points: 10
             };
             // getting the parameters
             var params = {
                 uri: url,
                 headers: {
                     authorization: getBasic('testuser', 'test')
                 },
                 body: JSON.stringify(doc)
             };
             request.put(params, function(error, response, body) {
                 expect(response.statusCode).toBe(200);
                 expect(response.body).toBe("{'Points added':'10'}")
                 if(error) {
                     expect(error.code).not.toBe('ECONNREFUSED');
                 }
                 done();
             })
         })
         it("check points have been added", function(done) {
             var url = 'http://localhost:8080/users/testuser';
             // getting the parameters
             var params = {
                 uri: url,
                 headers: {
                     authorization: getBasic('testuser', 'test')
                 }
             };
             request.get(params, function(error, response, body) {
                 expect(response.statusCode).toBe(200);
                 body = JSON.parse(body);
                 expect(body.points).toBe(10);
                 if(error) {
                     expect(error.code).not.toBe('ECONNREFUSED');
                 }
                 done();
             })
         })
         it("be able to see where you've checked in", function() {})
     })
     describe("groups", function() {
         it("be able to create a group", function(done) {
             var db = new neo4j('http://localhost:7474');
             var url = 'http://localhost:8080/groups'
             var doc = {
                 username: "testuser",
                 groupname: "testgroup",
                 description: "This is a Test Group",
                 competition: "freshers"
             };
             // getting the parameters
             var params = {
                 uri: url,
                 headers: {
                     authorization: getBasic('testuser', 'test'),
                     "content-type": "application/json"
                 },
                 body: JSON.stringify(doc)
             };
             // create the competition node
             db.insertNode({
                 name: "freshers",
                 description: description
             }, ['competition'], function(err, node) {
                 if(err) throw err;
                 request.post(params, function(error, response, body) {
                 expect(response.statusCode).toBe(201);
                 if(error) {
                     expect(error.code).not.toBe('ECONNREFUSED');
                 }
                 db.cypherQuery(" MATCH (n:Group) WHERE n.name ='testgroup' RETURN n", function(err, Results) {
                     if(err) throw err;
                     expect(Results.data[0].name).toBe('testgroup');
                     db.cypherQuery(" MATCH n-[r]->m RETURN n,r,m", function(err, Results) {
                         if(err) throw err;
                         console.log("getting relationships")
                         console.log(Results)
                         done();
                     })
                 })
             })
             });

         })
         it("be able to join a group", function(done) {
             var url = 'http://localhost:8080/users/groups/testgroup';
             // getting the parameters
             var params = {
                 uri: url,
                 headers: {
                     authorization: getBasic('testuser', 'test')
                 },
             };
             request.put(params, function(error, response, body) {
                 expect(response.statusCode).toBe(200);
                 if(error) {
                     expect(error.code).not.toBe('ECONNREFUSED');
                 }
                 done();
             })
         })
         it("be able to delete a group", function(done) {
             var url = 'http://localhost:8080/users/groups';
             var doc = {
                 username: "testuser",
                 groupname: "testgroup",
                 description: "testgroup",
                 competition: "freshers"
             };
             // getting the parameters
             var params = {
                 uri: url,
                 headers: {
                     authorization: getBasic('testuser', 'test')
                 },
                 body: JSON.stringify(doc)
             };
             request.del(params, function(error, response, body) {
                 expect(response.statusCode).toBe(200);
                 if(error) {
                     expect(error.code).not.toBe('ECONNREFUSED');
                 }
                 done();
             })
         })
     });
     describe('businesses', function() {
         it('able to create new business', function(done) {
             var url = 'http://localhost:8080/business';
             // getting the parameters
             var params = {
                 uri: url,
                 headers: {
                     authorization: getBasic('testBusinesses', 'test')
                 },
             };
             request.put(params, function(error, response, body) {
                 expect(response.statusCode).toBe(201);
                 if(error) {
                     expect(error.code).not.toBe('ECONNREFUSED');
                 }
                 done();
             })
         })
     })
     describe('Offers', function() {
         it("Be able to add an offer", function(done) {
             var url = 'http://localhost:8080/business/offers';
             var doc = {
                 businessname: 'testbusiness',
                 description: 'description',
                 title: 'test offer',
                 cost: 50
             }
             // getting the parameters
             var params = {
                 uri: url,
                 headers: {
                     authorization: getBasic('testuser', 'test')
                 },
                 body: JSON.stringify(doc)
             };
             request.post(params, function(error, response, body) {
                 expect(response.statusCode).toBe(200);
                 if(error) {
                     expect(error.code).not.toBe('ECONNREFUSED');
                 }
                 done();
             })
         })
         it("Be able to get the latest offers", function(done) {
             var url = 'http://localhost:8080/business/offers/all';
             // getting the parameters
             var params = {
                 uri: url,
                 headers: {
                     authorization: getBasic('testuser', 'test')
                 },
             };
             request.get(params, function(error, response, body) {
                 expect(response.statusCode).toBe(200);
                 if(error) {
                     expect(error.code).not.toBe('ECONNREFUSED');
                 }
                 done();
             })
         })
         it("be able to get a businesses offers", function(done) {
             var url = 'http://localhost:8080/business/offers/testbusiness';
             // getting the parameters
             var params = {
                 uri: url,
                 headers: {
                     authorization: getBasic('testuser', 'test')
                 },
             };
             request.get(params, function(error, response, body) {
                 expect(response.statusCode).toBe(200);
                 if(error) {
                     expect(error.code).not.toBe('ECONNREFUSED');
                 }
                 done();
             })
         })
     })
     it("be able to check what offers youve redeemed", function() {})
     describe('delete all', function() {
         it("be able to delete the user", function(done) {
             var url = 'http://localhost:8080/users';
             // getting the parameters
             var params = {
                 uri: url,
                 headers: {
                     authorization: getBasic('testuser', 'test')
                 },
             };
             request.del(params, function(error, response, body) {
                 expect(response.statusCode).toBe(200);
                 expect(body).toBe('"Deleted User!"')
                 if(error) {
                     expect(error.code).not.toBe('ECONNREFUSED');
                 }
                 done();
             })
         })
         it('be able to delete the business', function(done) {
             var url = 'http://localhost:8080/business';
             // getting the parameters
             var params = {
                 uri: url,
                 headers: {
                     authorization: getBasic('testBusiness', 'test')
                 },
             };
             request.del(params, function(error, response, body) {
                 expect(response.statusCode).toBe(200);
                 expect(body).toBe('"Deleted Business!"')
                 if(error) {
                     expect(error.code).not.toBe('ECONNREFUSED');
                 }
                 done();
             })
         })
         it('delete offers', function(done) {
             var url = 'http://localhost:8080/business/offers';
             // getting the parameters
             var params = {
                 uri: url,
                 headers: {
                     authorization: getBasic('testuser', 'test')
                 },
             };
             request.del(params, function(error, response, body) {
                 expect(response.statusCode).toBe(200);
                 if(error) {
                     expect(error.code).not.toBe('ECONNREFUSED');
                 }
                 done();
             })
         })
         it('delete group', function(done) {
             var url = 'http://localhost:8080/business';
             // getting the parameters
             var params = {
                 uri: url,
                 headers: {
                     authorization: getBasic('testuser', 'test')
                 },
             };
             request.del(params, function(error, response, body) {
                 expect(response.statusCode).toBe(200);
                 if(error) {
                     expect(error.code).not.toBe('ECONNREFUSED');
                 }
                 done();
             })
         })
     });
 })
 getBasic = function(username, password) {
     return "Basic " + new Buffer(username + ":" + password).toString('base64')
 };<|endoftext|>


<commit_before>//= require_tree ./templates

var App = Ember.Application.create({
  rootElement: '#builds-application'
});

App.Router.map(function() {
  this.route('release');
  this.route('beta');
  this.route('canary');
  this.route('tagged');
});

App.Router.reopen({
  notifyGoogleAnalytics: function() {
    var url = this.get('url');

    // Add a slash if neccesary
    if (!/^\//.test(url)){ url = '/' + url; }

    _gaq.push(['_trackPageview', '/builds' + url]);
  }.on('didTransition')
});

App.CopyClipboardComponent = Ember.Component.extend({
  tagName: 'span',
  hasFlash: ZeroClipboard.detectFlashSupport(),

  didInsertElement: function () {
    var clip = new ZeroClipboard(this.$('button'), {
      // This would normally be a relative path
      moviePath: "/images/ZeroClipboard.swf",

      trustedDomains: ["*"],
      allowScriptAccess: "always"
    });

    clip.on('mousedown', function(client, e) {
      Em.run.later(this, function() {
        $(this).removeClass('loading');
        $(this).removeAttr('disabled');
      }, 1000);
      Em.run.next(this, function() {
        $(this).addClass('loading');
        $(this).attr('disabled', 'disabled');
      });
    });

    this.$('input').on('click', function() {
      $(this).select();
    });
  }
});

App.S3Bucket = Ember.Object.extend({
  files: [],
  isLoading: false,

  // Setup these as default values.
  // They can be overridden on create.
  queryUseSSL: true,
  objectUseSSL: false,
  delimiter: '/',
  bucket: 'builds.emberjs.com',
  endpoint: 's3.amazonaws.com',

  delimiterParameter: function(){
    var delimiter = this.getWithDefault('delimiter','').toString();
    return (delimiter) ? 'delimiter=' + delimiter : '';
  }.property('delimiter'),

  markerParameter: function(){
    return 'marker=' + this.getWithDefault('marker','').toString();
  }.property('marker'),

  maxKeysParameter: function(){
    return 'max-keys=' + this.getWithDefault('maxKeys','').toString();
  }.property('maxKeys'),

  prefixParameter: function(){
    return 'prefix=' + this.getWithDefault('prefix','').toString();
  }.property('prefix'),

  queryProtocol: function() {
    return this.get('queryUseSSL') ? 'https://' : 'http://';
  }.property('queryUseSSL'),

  queryBaseUrl: function(){
    return this.get('queryProtocol') + this.get('endpoint') + '/' + this.get('bucket')
  }.property('queryProtocol', 'endpoint', 'bucket'),

  objectProtocol: function() {
    return this.get('objectUseSSL') ? 'https://' : 'http://';
  }.property('objectUseSSL'),

  objectBaseUrl: function(){
    return this.get('objectProtocol') + this.get('bucket');
  }.property('objectProtocol', 'bucket'),

  queryParams: function(){
    return this.get('delimiterParameter')  + '&' +
      this.get('markerParameter')     + '&' +
      this.get('maxKeysParameter')    + '&' +
      this.get('prefixParameter');
  }.property('delimiterParameter','markerParameter','maxKeysParameter','prefixParameter'),

  queryUrl: function(){
    return this.get('queryBaseUrl') + '?' + this.get('queryParams');
  }.property('queryBaseUrl','queryParams'),

  filesPresent: function(){
    return this.get('files').length;
  }.property('files.@each'),

  filterFiles: function(filter, ignoreFiles){
    var files = this.get('files');
    var ignoreFiles = Ember.A(ignoreFiles);

    return files.filter(function(e) {
      var name = e.get('name');
      var ignored = ignoreFiles.any(function(f) { return name.indexOf(f) >= 0; });
      var selected = filter.any(function(f) { return name.match(f); });

      return !ignored && selected;
    });
  },

  load: function(){
    var self = this,
    baseUrl = this.get('objectBaseUrl');

    this.set('isLoading', true);
    Ember.$.get(this.get('queryUrl'), function(data){
      self.set('isLoading', false);
      self.set('response', data);

      var contents = data.getElementsByTagName('Contents'),
      length   = contents.length,
      files    = [];

      for(var i = 0; i < length; i++) {
        var size = contents[i].getElementsByTagName('Size')[0].firstChild.data,
        name = contents[i].getElementsByTagName('Key')[0].firstChild.data,
        lastModified = new Date(contents[i].getElementsByTagName('LastModified')[0].firstChild.data);

        files.push(
          App.S3File.create({
          name: name,
          size: size,
          lastModified: lastModified,
          relativePath: name,
          baseUrl: baseUrl
        })
        );
      }

      self.set('files', files.sort(function(a,b){
        return b.lastModified - a.lastModified;
      }));
    });
  }.observes('queryUrl').on('init')
});

App.S3File = Ember.Object.extend({
  scriptTag: function(){
    var escapedURL = Ember.Handlebars.Utils.escapeExpression(this.get('url'));

    return new Ember.Handlebars.SafeString('<script src="' + escapedURL + '"></script>').toString();
  }.property('url'),

  url: function(){
    return this.get('baseUrl') + '/' + this.get('relativePath');
  }.property('baseUrl', 'relativePath')
});

App.Project = Ember.Object.extend();

App.Project.reopenClass({
  FIXTURES:
    [ {
      projectName: 'Ember',
      baseFileName: 'ember',
      projectFilter: [ /ember\./, /ember-template-compiler/ ],
      projectRepo: 'emberjs/ember.js',
      channel: "tagged"
    }, {
      projectName: 'Ember Data',
      baseFileName: 'ember-data',
      projectFilter: [ /ember-data\./ ],
      projectRepo: 'emberjs/data',
      channel: "tagged"
    }, {
      projectName: "Ember",
      baseFileName: 'ember',
      projectFilter: [ /ember\./, /ember-template-compiler/ ],
      projectRepo: 'emberjs/ember.js',
      initialVersion: "1.13.2",
      initialReleaseDate: "2015-06-17",
      lastRelease: "1.13.2",
      futureVersion: "1.13.3",
      channel: "release",
      date: "2015-06-17",
      changelogPath: "CHANGELOG.md",
      enableTestURL: true,
      debugFileName: ".debug.js"
    }, {
      projectName: "Ember",
      baseFileName: 'ember',
      projectFilter: [ /ember\./, /ember-template-compiler/ ],
      projectRepo: 'emberjs/ember.js',
      lastRelease: "2.0.0-beta.1",
      futureVersion: "2.0.0-beta.2",
      finalVersion: '2.0.0',
      channel: "beta",
      cycleEstimatedFinishDate: '2015-07-24',
      date: "2015-06-12",
      nextDate: "2015-06-19",
      changelogPath: "CHANGELOG.md",
      enableTestURL: true,
      debugFileName: ".debug.js",
      ignoreFiles: ['ember.js']
    }, {
      projectName: "Ember Data",
      baseFileName: 'ember-data',
      projectFilter: [ /ember-data\./ ],
      projectRepo: 'emberjs/data',
      lastRelease: "1.13.2",
      futureVersion: "2.0.0",
      channel: "release",
      date: "2015-06-18",
      changelogPath: "CHANGELOG.md",
      debugFileName: ".js"
    }, {
      projectName: "Ember",
      baseFileName: 'ember',
      projectFilter: [ /ember\./, /ember-template-compiler/ ],
      projectRepo: 'emberjs/ember.js',
      channel: "canary",
      enableTestURL: true,
      debugFileName: ".debug.js",
      ignoreFiles: ['ember.js']
    }, {
      projectName: "Ember Data",
      baseFileName: 'ember-data',
      projectFilter: [ /ember-data\./ ],
      projectRepo: 'emberjs/data',
      channel: "canary",
      debugFileName: ".js"
    }],

  all: function(channel){
    var projects;

    if (channel)
      projects = this.FIXTURES.filterBy('channel', channel);
    else
      projects = this.FIXTURES;

    return projects.map(function(obj) {
      return App.Project.create(obj);
    });
  },

  find: function(channel, name) {
    var allProjects = this.all(channel);

    if (!name)
      return allProjects;
    else
      return allProjects.filterBy('projectName', name);
  }
});

App.BuildCategoryMixin = Ember.Mixin.create({
  renderTemplate: function() {
    this.render('build-list');
  }
});

App.ApplicationController = Ember.Controller.extend({
  isIndexActive: function(){
    return this.isActiveChannel('index');
  }.property('currentRouteName'),

  isTaggedActive: function(){
    return this.isActiveChannel('tagged');
  }.property('currentRouteName'),

  isChannelsActive: function(){
    var self = this;
    return !['index','tagged'].some(function(name){ return name === self.get('currentRouteName'); })
  }.property('currentRouteName'),

  isReleaseActive: function(){
    return this.isActiveChannel('release');
  }.property('currentRouteName'),

  isBetaActive: function(){
    return this.isActiveChannel('beta');
  }.property('currentRouteName'),

  isCanaryActive: function(){
    return this.isActiveChannel('canary');
  }.property('currentRouteName'),

  isActiveChannel: function(channel){
    return this.get('currentRouteName').indexOf(channel) !== -1;
  }
});

App.ProjectsMixin = Ember.Mixin.create({
  projects: function(){
    var projects = App.Project.find(this.get('channel')),
        bucket   = this.get('model'),
        self = this;

    projects.forEach(function(project){
      if (project.channel === 'beta'){
        project.isEmberBeta = project.projectName === 'Ember';

        [1,2,3,4,5].forEach(function(increment){
          var versionParts = project.lastRelease.split('.');
          var currentBetaNumber = parseInt(versionParts[versionParts.length - 1], 10);
          project['beta' + increment + 'Completed'] = increment <= currentBetaNumber;
          project['isBeta' + increment] = increment === currentBetaNumber;
        });

        var release = App.Project.find('release', project.projectName)[0];

        // no releases exist for ember-data (yet)
        if (release) {
          project.lastStableVersion = release.initialVersion;
          project.lastStableDate = release.initialReleaseDate;
        }
      }

      project.files = bucket.filterFiles(project.projectFilter, project.ignoreFiles);
      project.description = self.description(project);
      project.lastReleaseDebugUrl = self.lastReleaseUrl(project.baseFileName, project.channel, project.lastRelease, project.debugFileName);
      project.lastReleaseProdUrl  = self.lastReleaseUrl(project.baseFileName, project.channel, project.lastRelease, '.prod.js');
      project.lastReleaseMinUrl   = self.lastReleaseUrl(project.baseFileName, project.channel, project.lastRelease, '.min.js');

      if (project.enableTestURL) {
        project.lastReleaseTestUrl  = self.lastReleaseUrl(project.baseFileName, project.channel, project.lastRelease, '-tests-index.html');
      }

      if (project.channel === 'canary') {
        project.lastRelease = 'latest';
      } else if (project.changelog !== 'false') {
        project.lastReleaseChangelogUrl   = 'https://github.com/' + project.projectRepo + '/blob/v' + project.lastRelease + '/' + project.changelogPath;
      }
    });

    return projects;
  }.property('channel', 'model'),

  description: function(project){
    var lastRelease = project.lastRelease,
        futureVersion = project.futureVersion,
        value;

    if (this.get('channel') === 'tagged') {
      value = '';
    } else if (lastRelease) {
      value = 'The builds listed below are incremental improvements made since ' + lastRelease + ' and may become ' + futureVersion + '.'
    } else if (futureVersion) {
      value = 'The builds listed below are not based on a tagged release. Upon the next release cycle they will become ' + futureVersion + '.';
    } else {
      value = 'The builds listed below are based on the most recent development.';
    }

    return new Ember.Handlebars.SafeString(value);
  },

  lastReleaseUrl: function(project, channel, lastRelease, extension){
    if (channel === 'canary')
      return 'http://builds.emberjs.com/canary/' + project + extension;
    else
      return 'http://builds.emberjs.com/tags/v' + lastRelease + '/' + project + extension;
  }

});

App.CanaryRoute = Ember.Route.extend(App.BuildCategoryMixin, {
  model: function() {
    return App.S3Bucket.create({title: 'Canary Builds', prefix: 'canary/' });
  }
});

App.CanaryController = Ember.Controller.extend(App.ProjectsMixin, {
  templateName: 'buildList',
  channel: 'canary'
});

App.BetaRoute = Ember.Route.extend(App.BuildCategoryMixin, {
  model: function() {
    return App.S3Bucket.create({title: 'Beta Builds', prefix: 'beta/'});
  }
});

App.BetaController = Ember.Controller.extend(App.ProjectsMixin, {
  templateName: 'buildList',
  channel: 'beta'
});

App.ReleaseRoute = Ember.Route.extend(App.BuildCategoryMixin, {
  model: function() {
    return App.S3Bucket.create({title: 'Release Builds', prefix: 'release/'});
  }
});

App.ReleaseController = Ember.Controller.extend(App.ProjectsMixin, {
  templateName: 'buildList',
  channel: 'release'
});

App.TaggedRoute = Ember.Route.extend(App.BuildCategoryMixin, {
  model: function() {
    var bucket = App.S3Bucket.create({
      title: 'Tagged Release Builds',
      prefix: 'tags/',
      delimiter: '',
    });
    return bucket;
  }
});

App.TaggedController = Ember.Controller.extend(App.ProjectsMixin, {
  channel: 'tagged'
});
/*
 * Handlebars Helpers
 */
Ember.Handlebars.helper('format-date-time', function(date, format, options) {
  if (!options) {
    options = format;
    format = null;
  }

  if (format){
    return moment(date).format(format);
  } else {
    return moment(date).fromNow();
  }
});
<commit_msg>Reset initial release date of ember 1.13.<commit_after>//= require_tree ./templates

var App = Ember.Application.create({
  rootElement: '#builds-application'
});

App.Router.map(function() {
  this.route('release');
  this.route('beta');
  this.route('canary');
  this.route('tagged');
});

App.Router.reopen({
  notifyGoogleAnalytics: function() {
    var url = this.get('url');

    // Add a slash if neccesary
    if (!/^\//.test(url)){ url = '/' + url; }

    _gaq.push(['_trackPageview', '/builds' + url]);
  }.on('didTransition')
});

App.CopyClipboardComponent = Ember.Component.extend({
  tagName: 'span',
  hasFlash: ZeroClipboard.detectFlashSupport(),

  didInsertElement: function () {
    var clip = new ZeroClipboard(this.$('button'), {
      // This would normally be a relative path
      moviePath: "/images/ZeroClipboard.swf",

      trustedDomains: ["*"],
      allowScriptAccess: "always"
    });

    clip.on('mousedown', function(client, e) {
      Em.run.later(this, function() {
        $(this).removeClass('loading');
        $(this).removeAttr('disabled');
      }, 1000);
      Em.run.next(this, function() {
        $(this).addClass('loading');
        $(this).attr('disabled', 'disabled');
      });
    });

    this.$('input').on('click', function() {
      $(this).select();
    });
  }
});

App.S3Bucket = Ember.Object.extend({
  files: [],
  isLoading: false,

  // Setup these as default values.
  // They can be overridden on create.
  queryUseSSL: true,
  objectUseSSL: false,
  delimiter: '/',
  bucket: 'builds.emberjs.com',
  endpoint: 's3.amazonaws.com',

  delimiterParameter: function(){
    var delimiter = this.getWithDefault('delimiter','').toString();
    return (delimiter) ? 'delimiter=' + delimiter : '';
  }.property('delimiter'),

  markerParameter: function(){
    return 'marker=' + this.getWithDefault('marker','').toString();
  }.property('marker'),

  maxKeysParameter: function(){
    return 'max-keys=' + this.getWithDefault('maxKeys','').toString();
  }.property('maxKeys'),

  prefixParameter: function(){
    return 'prefix=' + this.getWithDefault('prefix','').toString();
  }.property('prefix'),

  queryProtocol: function() {
    return this.get('queryUseSSL') ? 'https://' : 'http://';
  }.property('queryUseSSL'),

  queryBaseUrl: function(){
    return this.get('queryProtocol') + this.get('endpoint') + '/' + this.get('bucket')
  }.property('queryProtocol', 'endpoint', 'bucket'),

  objectProtocol: function() {
    return this.get('objectUseSSL') ? 'https://' : 'http://';
  }.property('objectUseSSL'),

  objectBaseUrl: function(){
    return this.get('objectProtocol') + this.get('bucket');
  }.property('objectProtocol', 'bucket'),

  queryParams: function(){
    return this.get('delimiterParameter')  + '&' +
      this.get('markerParameter')     + '&' +
      this.get('maxKeysParameter')    + '&' +
      this.get('prefixParameter');
  }.property('delimiterParameter','markerParameter','maxKeysParameter','prefixParameter'),

  queryUrl: function(){
    return this.get('queryBaseUrl') + '?' + this.get('queryParams');
  }.property('queryBaseUrl','queryParams'),

  filesPresent: function(){
    return this.get('files').length;
  }.property('files.@each'),

  filterFiles: function(filter, ignoreFiles){
    var files = this.get('files');
    var ignoreFiles = Ember.A(ignoreFiles);

    return files.filter(function(e) {
      var name = e.get('name');
      var ignored = ignoreFiles.any(function(f) { return name.indexOf(f) >= 0; });
      var selected = filter.any(function(f) { return name.match(f); });

      return !ignored && selected;
    });
  },

  load: function(){
    var self = this,
    baseUrl = this.get('objectBaseUrl');

    this.set('isLoading', true);
    Ember.$.get(this.get('queryUrl'), function(data){
      self.set('isLoading', false);
      self.set('response', data);

      var contents = data.getElementsByTagName('Contents'),
      length   = contents.length,
      files    = [];

      for(var i = 0; i < length; i++) {
        var size = contents[i].getElementsByTagName('Size')[0].firstChild.data,
        name = contents[i].getElementsByTagName('Key')[0].firstChild.data,
        lastModified = new Date(contents[i].getElementsByTagName('LastModified')[0].firstChild.data);

        files.push(
          App.S3File.create({
          name: name,
          size: size,
          lastModified: lastModified,
          relativePath: name,
          baseUrl: baseUrl
        })
        );
      }

      self.set('files', files.sort(function(a,b){
        return b.lastModified - a.lastModified;
      }));
    });
  }.observes('queryUrl').on('init')
});

App.S3File = Ember.Object.extend({
  scriptTag: function(){
    var escapedURL = Ember.Handlebars.Utils.escapeExpression(this.get('url'));

    return new Ember.Handlebars.SafeString('<script src="' + escapedURL + '"></script>').toString();
  }.property('url'),

  url: function(){
    return this.get('baseUrl') + '/' + this.get('relativePath');
  }.property('baseUrl', 'relativePath')
});

App.Project = Ember.Object.extend();

App.Project.reopenClass({
  FIXTURES:
    [ {
      projectName: 'Ember',
      baseFileName: 'ember',
      projectFilter: [ /ember\./, /ember-template-compiler/ ],
      projectRepo: 'emberjs/ember.js',
      channel: "tagged"
    }, {
      projectName: 'Ember Data',
      baseFileName: 'ember-data',
      projectFilter: [ /ember-data\./ ],
      projectRepo: 'emberjs/data',
      channel: "tagged"
    }, {
      projectName: "Ember",
      baseFileName: 'ember',
      projectFilter: [ /ember\./, /ember-template-compiler/ ],
      projectRepo: 'emberjs/ember.js',
      initialVersion: "1.13.0",
      initialReleaseDate: "2015-06-12",
      lastRelease: "1.13.2",
      futureVersion: "1.13.3",
      channel: "release",
      date: "2015-06-17",
      changelogPath: "CHANGELOG.md",
      enableTestURL: true,
      debugFileName: ".debug.js"
    }, {
      projectName: "Ember",
      baseFileName: 'ember',
      projectFilter: [ /ember\./, /ember-template-compiler/ ],
      projectRepo: 'emberjs/ember.js',
      lastRelease: "2.0.0-beta.1",
      futureVersion: "2.0.0-beta.2",
      finalVersion: '2.0.0',
      channel: "beta",
      cycleEstimatedFinishDate: '2015-07-24',
      date: "2015-06-12",
      nextDate: "2015-06-19",
      changelogPath: "CHANGELOG.md",
      enableTestURL: true,
      debugFileName: ".debug.js",
      ignoreFiles: ['ember.js']
    }, {
      projectName: "Ember Data",
      baseFileName: 'ember-data',
      projectFilter: [ /ember-data\./ ],
      projectRepo: 'emberjs/data',
      lastRelease: "1.13.2",
      futureVersion: "2.0.0",
      channel: "release",
      date: "2015-06-18",
      changelogPath: "CHANGELOG.md",
      debugFileName: ".js"
    }, {
      projectName: "Ember",
      baseFileName: 'ember',
      projectFilter: [ /ember\./, /ember-template-compiler/ ],
      projectRepo: 'emberjs/ember.js',
      channel: "canary",
      enableTestURL: true,
      debugFileName: ".debug.js",
      ignoreFiles: ['ember.js']
    }, {
      projectName: "Ember Data",
      baseFileName: 'ember-data',
      projectFilter: [ /ember-data\./ ],
      projectRepo: 'emberjs/data',
      channel: "canary",
      debugFileName: ".js"
    }],

  all: function(channel){
    var projects;

    if (channel)
      projects = this.FIXTURES.filterBy('channel', channel);
    else
      projects = this.FIXTURES;

    return projects.map(function(obj) {
      return App.Project.create(obj);
    });
  },

  find: function(channel, name) {
    var allProjects = this.all(channel);

    if (!name)
      return allProjects;
    else
      return allProjects.filterBy('projectName', name);
  }
});

App.BuildCategoryMixin = Ember.Mixin.create({
  renderTemplate: function() {
    this.render('build-list');
  }
});

App.ApplicationController = Ember.Controller.extend({
  isIndexActive: function(){
    return this.isActiveChannel('index');
  }.property('currentRouteName'),

  isTaggedActive: function(){
    return this.isActiveChannel('tagged');
  }.property('currentRouteName'),

  isChannelsActive: function(){
    var self = this;
    return !['index','tagged'].some(function(name){ return name === self.get('currentRouteName'); })
  }.property('currentRouteName'),

  isReleaseActive: function(){
    return this.isActiveChannel('release');
  }.property('currentRouteName'),

  isBetaActive: function(){
    return this.isActiveChannel('beta');
  }.property('currentRouteName'),

  isCanaryActive: function(){
    return this.isActiveChannel('canary');
  }.property('currentRouteName'),

  isActiveChannel: function(channel){
    return this.get('currentRouteName').indexOf(channel) !== -1;
  }
});

App.ProjectsMixin = Ember.Mixin.create({
  projects: function(){
    var projects = App.Project.find(this.get('channel')),
        bucket   = this.get('model'),
        self = this;

    projects.forEach(function(project){
      if (project.channel === 'beta'){
        project.isEmberBeta = project.projectName === 'Ember';

        [1,2,3,4,5].forEach(function(increment){
          var versionParts = project.lastRelease.split('.');
          var currentBetaNumber = parseInt(versionParts[versionParts.length - 1], 10);
          project['beta' + increment + 'Completed'] = increment <= currentBetaNumber;
          project['isBeta' + increment] = increment === currentBetaNumber;
        });

        var release = App.Project.find('release', project.projectName)[0];

        // no releases exist for ember-data (yet)
        if (release) {
          project.lastStableVersion = release.initialVersion;
          project.lastStableDate = release.initialReleaseDate;
        }
      }

      project.files = bucket.filterFiles(project.projectFilter, project.ignoreFiles);
      project.description = self.description(project);
      project.lastReleaseDebugUrl = self.lastReleaseUrl(project.baseFileName, project.channel, project.lastRelease, project.debugFileName);
      project.lastReleaseProdUrl  = self.lastReleaseUrl(project.baseFileName, project.channel, project.lastRelease, '.prod.js');
      project.lastReleaseMinUrl   = self.lastReleaseUrl(project.baseFileName, project.channel, project.lastRelease, '.min.js');

      if (project.enableTestURL) {
        project.lastReleaseTestUrl  = self.lastReleaseUrl(project.baseFileName, project.channel, project.lastRelease, '-tests-index.html');
      }

      if (project.channel === 'canary') {
        project.lastRelease = 'latest';
      } else if (project.changelog !== 'false') {
        project.lastReleaseChangelogUrl   = 'https://github.com/' + project.projectRepo + '/blob/v' + project.lastRelease + '/' + project.changelogPath;
      }
    });

    return projects;
  }.property('channel', 'model'),

  description: function(project){
    var lastRelease = project.lastRelease,
        futureVersion = project.futureVersion,
        value;

    if (this.get('channel') === 'tagged') {
      value = '';
    } else if (lastRelease) {
      value = 'The builds listed below are incremental improvements made since ' + lastRelease + ' and may become ' + futureVersion + '.'
    } else if (futureVersion) {
      value = 'The builds listed below are not based on a tagged release. Upon the next release cycle they will become ' + futureVersion + '.';
    } else {
      value = 'The builds listed below are based on the most recent development.';
    }

    return new Ember.Handlebars.SafeString(value);
  },

  lastReleaseUrl: function(project, channel, lastRelease, extension){
    if (channel === 'canary')
      return 'http://builds.emberjs.com/canary/' + project + extension;
    else
      return 'http://builds.emberjs.com/tags/v' + lastRelease + '/' + project + extension;
  }

});

App.CanaryRoute = Ember.Route.extend(App.BuildCategoryMixin, {
  model: function() {
    return App.S3Bucket.create({title: 'Canary Builds', prefix: 'canary/' });
  }
});

App.CanaryController = Ember.Controller.extend(App.ProjectsMixin, {
  templateName: 'buildList',
  channel: 'canary'
});

App.BetaRoute = Ember.Route.extend(App.BuildCategoryMixin, {
  model: function() {
    return App.S3Bucket.create({title: 'Beta Builds', prefix: 'beta/'});
  }
});

App.BetaController = Ember.Controller.extend(App.ProjectsMixin, {
  templateName: 'buildList',
  channel: 'beta'
});

App.ReleaseRoute = Ember.Route.extend(App.BuildCategoryMixin, {
  model: function() {
    return App.S3Bucket.create({title: 'Release Builds', prefix: 'release/'});
  }
});

App.ReleaseController = Ember.Controller.extend(App.ProjectsMixin, {
  templateName: 'buildList',
  channel: 'release'
});

App.TaggedRoute = Ember.Route.extend(App.BuildCategoryMixin, {
  model: function() {
    var bucket = App.S3Bucket.create({
      title: 'Tagged Release Builds',
      prefix: 'tags/',
      delimiter: '',
    });
    return bucket;
  }
});

App.TaggedController = Ember.Controller.extend(App.ProjectsMixin, {
  channel: 'tagged'
});
/*
 * Handlebars Helpers
 */
Ember.Handlebars.helper('format-date-time', function(date, format, options) {
  if (!options) {
    options = format;
    format = null;
  }

  if (format){
    return moment(date).format(format);
  } else {
    return moment(date).fromNow();
  }
});
<|endoftext|>


<commit_before>var describe = require('../lib/spec_my_node.js').describe
var assert = require("assert");
var inspect = require('sys').inspect;
console.log("running");
//console.log(inspect(spec.describe));

describe("Passing Tests").it("Should pass",function(){
  assert.equal(1,1);
});

describe("Test 2").it("Should fail",function(){
  assert.equal(1,2);
});

var value = 0;
describe("Before Test").beforeEach (function (){
  value = 2;
}).it ("Should run before to pass", function () {
  assert.equal(value,2);
});
/*
spec.describe("Multiple tests in context").
  it("First in context", function () {
    assert.equal(2,2);
  }).
  it("Second in context", function () {
    assert.equal(2,2);
  });*/

<commit_msg>added multiple tests per context<commit_after>var describe = require('../lib/spec_my_node.js').describe
var assert = require("assert");
var inspect = require('sys').inspect;
console.log("running");
//console.log(inspect(spec.describe));

describe("Passing Tests").it("Should pass",function(){
  assert.equal(1,1);
});

describe("Test 2").it("Should fail",function(){
  assert.equal(1,2);
});

var value = 0;
describe("Before Test").beforeEach (function (){
  value = 2;
}).it ("Should run before to pass", function () {
  assert.equal(value,2);
});

describe("Multiple tests in context").
  it("First in context", function () {
    assert.equal(2,2);
  }).
  it("Second in context", function () {
    assert.equal(2,2);
  });

<|endoftext|>


<commit_before>/* eslint-disable newline-per-chained-call */

var nav = require('./helpers/utils').nav,
    globalSearch = require('./helpers/search'),
    authoring = require('./helpers/authoring'),
    content = require('./helpers/pages').content,
    monitoring = require('./helpers/monitoring'),
    scrollToView = require('./helpers/utils').scrollToView;

describe('search', () => {
    beforeEach(() => {
        nav('/search').then(globalSearch.setListView());
    });

    it('can search by search field', () => {
        expect(globalSearch.getItems().count()).toBe(14);
        globalSearch.searchInput.click();
        globalSearch.searchInput.clear();
        globalSearch.searchInput.sendKeys('item3');
        var focused = browser.driver.switchTo().activeElement().getAttribute('id');

        expect(globalSearch.searchInput.getAttribute('id')).toEqual(focused);
        element(by.id('search-button')).click();
        expect(globalSearch.getItems().count()).toBe(3);
        globalSearch.openFilterPanel();
        globalSearch.clickClearFilters();

        // can navigate/filter subject field and search by selected subject term
        expect(globalSearch.getItems().count()).toBe(14);
        globalSearch.toggleSearchTabs('parameters');
        globalSearch.toggleSubjectMetadata(); // opens subject drop-down
        browser.sleep(100);
        browser.actions().sendKeys('archa').perform();
        expect(globalSearch.getSubjectFilteredTerm(0)).toBe('archaeology');
        browser.actions().sendKeys(protractor.Key.DOWN).perform();
        browser.actions().sendKeys(protractor.Key.ENTER).perform(); // selects subject term
        browser.sleep(200);
        globalSearch.goButton.click();
        // expect selected term in filter pane
        expect(globalSearch.getSelectedSubjectsInFilter().count()).toBe(1);
        // expect selected term in tag list, at top of search list
        expect(globalSearch.getSelectedTags().count()).toBe(1);
        // expect some search result returned
        expect(globalSearch.getItems().count()).toBeGreaterThan(0);
        globalSearch.clickClearFilters();

        // can search by priority field
        expect(globalSearch.getItems().count()).toBe(14);
        globalSearch.toggleSearchTabs('filters');
        expect(globalSearch.getPriorityElements().count()).toBe(3);
        var priority = globalSearch.getPriorityElementByIndex(0);

        priority.click();
        expect(globalSearch.getItems().count()).toBe(1);
        globalSearch.clickClearFilters();

        // can search by byline field
        expect(globalSearch.getItems().count()).toBe(14);
        globalSearch.openParameters();
        var bylineTextbox = element(by.id('search-byline'));

        bylineTextbox.clear();
        bylineTextbox.sendKeys('Billy The Fish');
        globalSearch.goButton.click();
        expect(globalSearch.getItems().count()).toBe(1);
        globalSearch.clickClearFilters();

        // can search by slugline
        expect(globalSearch.getItems().count()).toBe(14);
        globalSearch.openParameters();
        bylineTextbox = element(by.id('search-slugline'));
        bylineTextbox.clear();
        bylineTextbox.sendKeys('one/two');
        globalSearch.goButton.click();
        expect(globalSearch.getItems().count()).toBe(1);
        globalSearch.clickClearFilters();

        // can search by slugline with parenthesis and clear by tag
        expect(globalSearch.getItems().count()).toBe(14);
        globalSearch.openParameters();
        bylineTextbox = element(by.id('search-slugline'));
        bylineTextbox.clear();
        bylineTextbox.sendKeys('(one/two)');
        globalSearch.goButton.click();
        expect(globalSearch.getItems().count()).toBe(1);
        expect(element.all(by.repeater('parameter in tags.selectedParameters')).count()).toBe(1);
        element(by.css('.tag-label__remove')).click();
        expect(globalSearch.getItems().count()).toBe(14);

        // can search by original creator
        expect(globalSearch.getItems().count()).toBe(14);
        globalSearch.openParameters();
        globalSearch.selectCreator('search-creator', 'first name last name');
        globalSearch.goButton.click();
        expect(globalSearch.getItems().count()).toBe(10);
        globalSearch.clickClearFilters();

        // can search by ingest provider
        expect(globalSearch.getItems().count()).toBe(14);
        globalSearch.openParameters();
        globalSearch.selectProvider('search-ingest-provider', 'aap');
        globalSearch.goButton.click();
        expect(globalSearch.getItems().count()).toBe(1);
        globalSearch.clickClearFilters();

        // can search by genre field
        expect(globalSearch.getItems().count()).toBe(14);
        globalSearch.toggleSearchTabs('filters');
        expect(globalSearch.getGenreElements().count()).toBe(2);
        var genre = globalSearch.getGenreElementByIndex(0);

        genre.click();
        expect(globalSearch.getItems().count()).toBe(10);
        globalSearch.clickClearFilters();

        // initialize for search by from desk field and company
        monitoring.openMonitoring();
        monitoring.selectDesk('SPORTS DESK');
        authoring.createTextItem();
        authoring.writeTextToHeadline('From-Sports-To-Politics');
        authoring.writeText('This is Body');
        authoring.writeTextToAbstract('This is Abstract');
        authoring.save();
        authoring.sendTo('Politic Desk');
        authoring.confirmSendTo();
        monitoring.switchToDesk('POLITIC DESK');
        expect(monitoring.getTextItem(1, 0)).toBe('From-Sports-To-Politics');

        // search by from desk field
        globalSearch.openGlobalSearch();
        globalSearch.setListView();
        expect(globalSearch.getItems().count()).toBe(15);
        globalSearch.openFilterPanel();
        globalSearch.openParameters();
        globalSearch.selectDesk('from-desk', 'Sports Desk');
        globalSearch.goButton.click();
        expect(globalSearch.getItems().count()).toBe(1);
        expect(globalSearch.getHeadlineElement(0).getText()).toBe('From-Sports-To-Politics');
        globalSearch.selectDesk('to-desk', 'Politic Desk');
        globalSearch.goButton.click();
        expect(globalSearch.getItems().count()).toBe(1);
        expect(globalSearch.getHeadlineElement(0).getText()).toBe('From-Sports-To-Politics');
        globalSearch.selectDesk('from-desk', '');
        globalSearch.goButton.click();
        expect(globalSearch.getItems().count()).toBe(1);
        expect(globalSearch.getHeadlineElement(0).getText()).toBe('From-Sports-To-Politics');
        globalSearch.selectDesk('to-desk', '');
        globalSearch.goButton.click();
        expect(globalSearch.getItems().count()).toBe(15);

        // can dynamically update items in related tab when item duplicated
        expect(globalSearch.getItems().count()).toBe(15);
        globalSearch.actionOnSubmenuItem('Duplicate', 'Duplicate in place', 0, true);
        globalSearch.itemClick(0);
        monitoring.tabAction('related');
        expect(globalSearch.getRelatedItems().count()).toBe(1);
        globalSearch.actionOnSubmenuItem('Duplicate', 'Duplicate in place', 0, true);
        globalSearch.itemClick(0);
        monitoring.tabAction('related');
        expect(globalSearch.getRelatedItems().count()).toBe(2);
        element(by.css('.close-preview')).click();

        // can search with different repos
        globalSearch.openParameters();
        globalSearch.ingestRepo.click();
        browser.sleep(200);
        expect(globalSearch.getItems().count()).toBe(16);
        globalSearch.archiveRepo.click();
        browser.sleep(200);
        expect(globalSearch.getItems().count()).toBe(3);
        globalSearch.archivedRepo.click();
        browser.sleep(200);
        expect(globalSearch.getItems().count()).toBe(0);

        // can do a boolean search in the raw panel
        globalSearch.clickClearFilters();
        globalSearch.archiveRepo.click();
        globalSearch.archivedRepo.click();
        globalSearch.openRawSearchTab();
        var rawTextbox = element(by.id('raw-query'));

        rawTextbox.clear();
        rawTextbox.sendKeys('type:text AND (item1 OR item4)');
        globalSearch.goButton.click();
        expect(globalSearch.getItems().count()).toBe(2);
        // toggle filter panel to reset it
        globalSearch.openFilterPanel();

        // search spiked content
        globalSearch.openGlobalSearch();
        globalSearch.setListView();
        expect(globalSearch.getItems().count()).toBe(17);
        content.actionOnItem('Spike Item', 2, null, true);
        content.actionOnItem('Spike Item', 1, null, true);
        content.actionOnItem('Spike Item', 0, null, true);
        browser.sleep(200);
        expect(globalSearch.getItems().count()).toBe(14);
        globalSearch.openFilterPanel();
        globalSearch.openParameters();
        globalSearch.selectDesk('spike-options', 'Include spiked content');
        globalSearch.goButton.click();
        expect(globalSearch.getItems().count()).toBe(17);
        expect(globalSearch.getSelectedTags().count()).toBe(1);
        globalSearch.selectDesk('spike-options', 'Spiked only content');
        globalSearch.goButton.click();
        expect(globalSearch.getItems().count()).toBe(3);
        expect(globalSearch.getSelectedTags().count()).toBe(1);
    });

    it('can action on items', () => {
        // DOWN arrow key selects an item and opens preview pane
        expect(globalSearch.getItems().count()).toBe(14);
        var previewPane = element(by.id('item-preview'));

        expect(previewPane.isPresent()).toBe(false);
        globalSearch.itemClick(2);
        browser.actions().sendKeys(protractor.Key.DOWN).perform();
        expect(previewPane.isPresent()).toBe(true);
        // now proceed to perform keyboard operation on text editor
        globalSearch.actionOnItem('Edit', 2);
        expect(authoring.getBodyText()).toBe('item5 text');
        authoring.focusBodyHtmlElement();
        browser.actions().sendKeys(protractor.Key.ENTER).perform();
        browser.actions().sendKeys('additional text').perform();
        expect(previewPane.isPresent()).toBe(false); // ENTER key avoided for opening preview
        browser.actions().sendKeys(protractor.Key.DOWN).perform();
        expect(authoring.getBodyText()).toContain('additional text');
        expect(previewPane.isPresent()).toBe(false); // DOWN arrow key avoided for opening preview
        browser.actions().sendKeys(protractor.Key.UP).perform();
        expect(previewPane.isPresent()).toBe(false); // UP arrow key avoided for opening preview
        // it should not effect global keyboard shortcuts (e.g: 'ctrl+alt+d', 'ctrl+shift+*')
        // now test 'ctrl+shift+*' shortcut that triggers spell checker when not set to automatic
        expect(element(by.model('spellcheckMenu.isAuto')).getAttribute('checked')).toBeTruthy();
        authoring.toggleAutoSpellCheck();
        expect(element(by.model('spellcheckMenu.isAuto')).getAttribute('checked')).toBeFalsy();
        authoring.focusBodyHtmlElement();
        browser.actions().sendKeys(protractor.Key.ENTER).perform();
        browser.actions().sendKeys('Testhilite').perform();
        expect(authoring.getBodyText()).toContain('Testhilite');
        expect(authoring.getBodyInnerHtml()).not.toContain('sderror sdhilite');
        // trigger spell checker via keyboard operation
        browser.actions().sendKeys(protractor.Key.chord(protractor.Key.CONTROL, protractor.Key.SHIFT, 'y')).perform();
        expect(authoring.getBodyText()).toContain('Testhilite');
        expect(authoring.getBodyInnerHtml()).toContain('sderror sdhilite');
        authoring.save();
        authoring.close();
        // now test 'ctrl+0' shortcut that triggers story search dialog box
        browser.actions().sendKeys(protractor.Key.chord(protractor.Key.CONTROL, '0')).perform();
        browser.sleep(200);
        var storyNameEl = element(by.model('meta.unique_name'));

        expect(storyNameEl.isPresent()).toBe(true);
        storyNameEl.click();
        browser.actions().sendKeys('item1-in-archived').perform();
        browser.actions().sendKeys(protractor.Key.ENTER).perform();
        browser.sleep(200);
        expect(authoring.getHeaderSluglineText()).toBe('item1 slugline');
        authoring.close();

        // can avoid opening item\'s preview on an item action
        expect(globalSearch.getItems().count()).toBe(14);
        previewPane = element(by.id('item-preview'));
        expect(previewPane.isPresent()).toBe(false);
        globalSearch.actionOnItem('Edit', 2);
        expect(previewPane.isPresent()).toBe(false); // avoids opening preview
        authoring.close();

        // can avoid retaining item\'s preview on an item action
        expect(globalSearch.getItems().count()).toBe(14);
        globalSearch.itemClick(2);
        previewPane = element(by.id('item-preview'));
        expect(previewPane.isPresent()).toBe(true);
        globalSearch.actionOnItem('Edit', 3);
        expect(previewPane.isPresent()).toBe(false); // avoids retaining already opened preview
        authoring.close();

        // can display embargo item when set
        expect(globalSearch.getItems().count()).toBe(14);
        globalSearch.actionOnItem('Edit', 4);
        authoring.sendToButton.click();
        authoring.setEmbargo();
        authoring.save();
        authoring.close();
        expect(globalSearch.getItem(0).element(by.className('state_embargo')).isDisplayed()).toBe(true);
        expect(globalSearch.getItem(0).element(by.className('state_embargo')).getText()).toEqual('EMBARGO');

        // can search scheduled
        expect(globalSearch.getItems().count()).toBe(14);
        globalSearch.actionOnItem('Edit', 1);
        authoring.schedule(false);
        globalSearch.openFilterPanel();
        globalSearch.openParameters();
        globalSearch.toggleSearchTabs('filters');

        const scheduleFilter = element(by.css('#filter-schedule_settings\\.utc_publish_schedule .toggle-box__header'));

        scrollToView(scheduleFilter);
        scheduleFilter.click();

        element.all(by.buttonText('Last 24 Hours')).then(function(items) {
          expect(items.length).toBe(4);
          scrollToView(items[3])
          items[3].click();
        });

        expect(globalSearch.getItems().count()).toBe(1);
        expect(globalSearch.getItem(0).element(by.className('state-scheduled')).isDisplayed()).toBe(true);
        expect(globalSearch.getItem(0).element(by.className('state-scheduled')).getText()).toEqual('SCHEDULED');
        expect(element.all(by.repeater('key in keys')).count()).toBe(1);
        element(by.css('.tag-label__remove')).click();
        expect(globalSearch.getItems().count()).toBe(14);
    });

    it('can search by facet and exclude facet', () => {
        expect(globalSearch.getItems().count()).toBe(14);
        globalSearch.openFilterPanel();
        globalSearch.toggleSearchTabs('filters');
        browser.sleep(200);
        expect(globalSearch.getDeskElements().count()).toBe(2);
        globalSearch.excludeDeskFacet(0);
        expect(globalSearch.getDeskElements().count()).toBe(1);
        expect(globalSearch.getItems().count()).toBe(6);
        expect(globalSearch.getExcludedFacetTags().count()).toBe(1);
        globalSearch.deleteExcludedFacetTagByIndex(0);
        expect(globalSearch.getExcludedFacetTags().count()).toBe(0);
        expect(globalSearch.getDeskElements().count()).toBe(2);
        expect(globalSearch.getItems().count()).toBe(14);
    });
});
<commit_msg>minor changes<commit_after>/* eslint-disable newline-per-chained-call */

var nav = require('./helpers/utils').nav,
    globalSearch = require('./helpers/search'),
    authoring = require('./helpers/authoring'),
    content = require('./helpers/pages').content,
    monitoring = require('./helpers/monitoring'),
    scrollToView = require('./helpers/utils').scrollToView;

describe('search', () => {
    beforeEach(() => {
        nav('/search').then(globalSearch.setListView());
    });

    it('can search by search field', () => {
        expect(globalSearch.getItems().count()).toBe(14);
        globalSearch.searchInput.click();
        globalSearch.searchInput.clear();
        globalSearch.searchInput.sendKeys('item3');
        var focused = browser.driver.switchTo().activeElement().getAttribute('id');

        expect(globalSearch.searchInput.getAttribute('id')).toEqual(focused);
        element(by.id('search-button')).click();
        expect(globalSearch.getItems().count()).toBe(3);
        globalSearch.openFilterPanel();
        globalSearch.clickClearFilters();

        // can navigate/filter subject field and search by selected subject term
        expect(globalSearch.getItems().count()).toBe(14);
        globalSearch.toggleSearchTabs('parameters');
        globalSearch.toggleSubjectMetadata(); // opens subject drop-down
        browser.sleep(100);
        browser.actions().sendKeys('archa').perform();
        expect(globalSearch.getSubjectFilteredTerm(0)).toBe('archaeology');
        browser.actions().sendKeys(protractor.Key.DOWN).perform();
        browser.actions().sendKeys(protractor.Key.ENTER).perform(); // selects subject term
        browser.sleep(200);
        globalSearch.goButton.click();
        // expect selected term in filter pane
        expect(globalSearch.getSelectedSubjectsInFilter().count()).toBe(1);
        // expect selected term in tag list, at top of search list
        expect(globalSearch.getSelectedTags().count()).toBe(1);
        // expect some search result returned
        expect(globalSearch.getItems().count()).toBeGreaterThan(0);
        globalSearch.clickClearFilters();

        // can search by priority field
        expect(globalSearch.getItems().count()).toBe(14);
        globalSearch.toggleSearchTabs('filters');
        expect(globalSearch.getPriorityElements().count()).toBe(3);
        var priority = globalSearch.getPriorityElementByIndex(0);

        priority.click();
        expect(globalSearch.getItems().count()).toBe(1);
        globalSearch.clickClearFilters();

        // can search by byline field
        expect(globalSearch.getItems().count()).toBe(14);
        globalSearch.openParameters();
        var bylineTextbox = element(by.id('search-byline'));

        bylineTextbox.clear();
        bylineTextbox.sendKeys('Billy The Fish');
        globalSearch.goButton.click();
        expect(globalSearch.getItems().count()).toBe(1);
        globalSearch.clickClearFilters();

        // can search by slugline
        expect(globalSearch.getItems().count()).toBe(14);
        globalSearch.openParameters();
        bylineTextbox = element(by.id('search-slugline'));
        bylineTextbox.clear();
        bylineTextbox.sendKeys('one/two');
        globalSearch.goButton.click();
        expect(globalSearch.getItems().count()).toBe(1);
        globalSearch.clickClearFilters();

        // can search by slugline with parenthesis and clear by tag
        expect(globalSearch.getItems().count()).toBe(14);
        globalSearch.openParameters();
        bylineTextbox = element(by.id('search-slugline'));
        bylineTextbox.clear();
        bylineTextbox.sendKeys('(one/two)');
        globalSearch.goButton.click();
        expect(globalSearch.getItems().count()).toBe(1);
        expect(element.all(by.repeater('parameter in tags.selectedParameters')).count()).toBe(1);
        element(by.css('.tag-label__remove')).click();
        expect(globalSearch.getItems().count()).toBe(14);

        // can search by original creator
        expect(globalSearch.getItems().count()).toBe(14);
        globalSearch.openParameters();
        globalSearch.selectCreator('search-creator', 'first name last name');
        globalSearch.goButton.click();
        expect(globalSearch.getItems().count()).toBe(10);
        globalSearch.clickClearFilters();

        // can search by ingest provider
        expect(globalSearch.getItems().count()).toBe(14);
        globalSearch.openParameters();
        globalSearch.selectProvider('search-ingest-provider', 'aap');
        globalSearch.goButton.click();
        expect(globalSearch.getItems().count()).toBe(1);
        globalSearch.clickClearFilters();

        // can search by genre field
        expect(globalSearch.getItems().count()).toBe(14);
        globalSearch.toggleSearchTabs('filters');
        expect(globalSearch.getGenreElements().count()).toBe(2);
        var genre = globalSearch.getGenreElementByIndex(0);

        genre.click();
        expect(globalSearch.getItems().count()).toBe(10);
        globalSearch.clickClearFilters();

        // initialize for search by from desk field and company
        monitoring.openMonitoring();
        monitoring.selectDesk('SPORTS DESK');
        authoring.createTextItem();
        authoring.writeTextToHeadline('From-Sports-To-Politics');
        authoring.writeText('This is Body');
        authoring.writeTextToAbstract('This is Abstract');
        authoring.save();
        authoring.sendTo('Politic Desk');
        authoring.confirmSendTo();
        monitoring.switchToDesk('POLITIC DESK');
        expect(monitoring.getTextItem(1, 0)).toBe('From-Sports-To-Politics');

        // search by from desk field
        globalSearch.openGlobalSearch();
        globalSearch.setListView();
        expect(globalSearch.getItems().count()).toBe(15);
        globalSearch.openFilterPanel();
        globalSearch.openParameters();
        globalSearch.selectDesk('from-desk', 'Sports Desk');
        globalSearch.goButton.click();
        expect(globalSearch.getItems().count()).toBe(1);
        expect(globalSearch.getHeadlineElement(0).getText()).toBe('From-Sports-To-Politics');
        globalSearch.selectDesk('to-desk', 'Politic Desk');
        globalSearch.goButton.click();
        expect(globalSearch.getItems().count()).toBe(1);
        expect(globalSearch.getHeadlineElement(0).getText()).toBe('From-Sports-To-Politics');
        globalSearch.selectDesk('from-desk', '');
        globalSearch.goButton.click();
        expect(globalSearch.getItems().count()).toBe(1);
        expect(globalSearch.getHeadlineElement(0).getText()).toBe('From-Sports-To-Politics');
        globalSearch.selectDesk('to-desk', '');
        globalSearch.goButton.click();
        expect(globalSearch.getItems().count()).toBe(15);

        // can dynamically update items in related tab when item duplicated
        expect(globalSearch.getItems().count()).toBe(15);
        globalSearch.actionOnSubmenuItem('Duplicate', 'Duplicate in place', 0, true);
        globalSearch.itemClick(0);
        monitoring.tabAction('related');
        expect(globalSearch.getRelatedItems().count()).toBe(1);
        globalSearch.actionOnSubmenuItem('Duplicate', 'Duplicate in place', 0, true);
        globalSearch.itemClick(0);
        monitoring.tabAction('related');
        expect(globalSearch.getRelatedItems().count()).toBe(2);
        element(by.css('.close-preview')).click();

        // can search with different repos
        globalSearch.openParameters();
        globalSearch.ingestRepo.click();
        browser.sleep(200);
        expect(globalSearch.getItems().count()).toBe(16);
        globalSearch.archiveRepo.click();
        browser.sleep(200);
        expect(globalSearch.getItems().count()).toBe(3);
        globalSearch.archivedRepo.click();
        browser.sleep(200);
        expect(globalSearch.getItems().count()).toBe(0);

        // can do a boolean search in the raw panel
        globalSearch.clickClearFilters();
        globalSearch.archiveRepo.click();
        globalSearch.archivedRepo.click();
        globalSearch.openRawSearchTab();
        var rawTextbox = element(by.id('raw-query'));

        rawTextbox.clear();
        rawTextbox.sendKeys('type:text AND (item1 OR item4)');
        globalSearch.goButton.click();
        expect(globalSearch.getItems().count()).toBe(2);
        // toggle filter panel to reset it
        globalSearch.openFilterPanel();

        // search spiked content
        globalSearch.openGlobalSearch();
        globalSearch.setListView();
        expect(globalSearch.getItems().count()).toBe(17);
        content.actionOnItem('Spike Item', 2, null, true);
        content.actionOnItem('Spike Item', 1, null, true);
        content.actionOnItem('Spike Item', 0, null, true);
        browser.sleep(200);
        expect(globalSearch.getItems().count()).toBe(14);
        globalSearch.openFilterPanel();
        globalSearch.openParameters();
        globalSearch.selectDesk('spike-options', 'Include spiked content');
        globalSearch.goButton.click();
        expect(globalSearch.getItems().count()).toBe(17);
        expect(globalSearch.getSelectedTags().count()).toBe(1);
        globalSearch.selectDesk('spike-options', 'Spiked only content');
        globalSearch.goButton.click();
        expect(globalSearch.getItems().count()).toBe(3);
        expect(globalSearch.getSelectedTags().count()).toBe(1);
    });

    it('can action on items', () => {
        // DOWN arrow key selects an item and opens preview pane
        expect(globalSearch.getItems().count()).toBe(14);
        var previewPane = element(by.id('item-preview'));

        expect(previewPane.isPresent()).toBe(false);
        globalSearch.itemClick(2);
        browser.actions().sendKeys(protractor.Key.DOWN).perform();
        expect(previewPane.isPresent()).toBe(true);
        // now proceed to perform keyboard operation on text editor
        globalSearch.actionOnItem('Edit', 2);
        expect(authoring.getBodyText()).toBe('item5 text');
        authoring.focusBodyHtmlElement();
        browser.actions().sendKeys(protractor.Key.ENTER).perform();
        browser.actions().sendKeys('additional text').perform();
        expect(previewPane.isPresent()).toBe(false); // ENTER key avoided for opening preview
        browser.actions().sendKeys(protractor.Key.DOWN).perform();
        expect(authoring.getBodyText()).toContain('additional text');
        expect(previewPane.isPresent()).toBe(false); // DOWN arrow key avoided for opening preview
        browser.actions().sendKeys(protractor.Key.UP).perform();
        expect(previewPane.isPresent()).toBe(false); // UP arrow key avoided for opening preview
        // it should not effect global keyboard shortcuts (e.g: 'ctrl+alt+d', 'ctrl+shift+*')
        // now test 'ctrl+shift+*' shortcut that triggers spell checker when not set to automatic
        expect(element(by.model('spellcheckMenu.isAuto')).getAttribute('checked')).toBeTruthy();
        authoring.toggleAutoSpellCheck();
        expect(element(by.model('spellcheckMenu.isAuto')).getAttribute('checked')).toBeFalsy();
        authoring.focusBodyHtmlElement();
        browser.actions().sendKeys(protractor.Key.ENTER).perform();
        browser.actions().sendKeys('Testhilite').perform();
        expect(authoring.getBodyText()).toContain('Testhilite');
        expect(authoring.getBodyInnerHtml()).not.toContain('sderror sdhilite');
        // trigger spell checker via keyboard operation
        browser.actions().sendKeys(protractor.Key.chord(protractor.Key.CONTROL, protractor.Key.SHIFT, 'y')).perform();
        expect(authoring.getBodyText()).toContain('Testhilite');
        expect(authoring.getBodyInnerHtml()).toContain('sderror sdhilite');
        authoring.save();
        authoring.close();
        // now test 'ctrl+0' shortcut that triggers story search dialog box
        browser.actions().sendKeys(protractor.Key.chord(protractor.Key.CONTROL, '0')).perform();
        browser.sleep(200);
        var storyNameEl = element(by.model('meta.unique_name'));

        expect(storyNameEl.isPresent()).toBe(true);
        storyNameEl.click();
        browser.actions().sendKeys('item1-in-archived').perform();
        browser.actions().sendKeys(protractor.Key.ENTER).perform();
        browser.sleep(200);
        expect(authoring.getHeaderSluglineText()).toBe('item1 slugline');
        authoring.close();

        // can avoid opening item\'s preview on an item action
        expect(globalSearch.getItems().count()).toBe(14);
        previewPane = element(by.id('item-preview'));
        expect(previewPane.isPresent()).toBe(false);
        globalSearch.actionOnItem('Edit', 2);
        expect(previewPane.isPresent()).toBe(false); // avoids opening preview
        authoring.close();

        // can avoid retaining item\'s preview on an item action
        expect(globalSearch.getItems().count()).toBe(14);
        globalSearch.itemClick(2);
        previewPane = element(by.id('item-preview'));
        expect(previewPane.isPresent()).toBe(true);
        globalSearch.actionOnItem('Edit', 3);
        expect(previewPane.isPresent()).toBe(false); // avoids retaining already opened preview
        authoring.close();

        // can display embargo item when set
        expect(globalSearch.getItems().count()).toBe(14);
        globalSearch.actionOnItem('Edit', 4);
        authoring.sendToButton.click();
        authoring.setEmbargo();
        authoring.save();
        authoring.close();
        expect(globalSearch.getItem(0).element(by.className('state_embargo')).isDisplayed()).toBe(true);
        expect(globalSearch.getItem(0).element(by.className('state_embargo')).getText()).toEqual('EMBARGO');

        // can search scheduled
        expect(globalSearch.getItems().count()).toBe(14);
        globalSearch.actionOnItem('Edit', 1);
        authoring.schedule(false);
        globalSearch.openFilterPanel();
        globalSearch.openParameters();
        globalSearch.toggleSearchTabs('filters');

        const scheduleFilter = element(by.css('#filter-schedule_settings\\.utc_publish_schedule .toggle-box__header'));

        scrollToView(scheduleFilter);
        scheduleFilter.click();

        element.all(by.buttonText('Last 24 Hours')).then(function(items) {
            expect(items.length).toBe(4);
            scrollToView(items[3]);
            items[3].click();
        });

        expect(globalSearch.getItems().count()).toBe(1);
        expect(globalSearch.getItem(0).element(by.className('state-scheduled')).isDisplayed()).toBe(true);
        expect(globalSearch.getItem(0).element(by.className('state-scheduled')).getText()).toEqual('SCHEDULED');
        expect(element.all(by.repeater('key in keys')).count()).toBe(1);
        element(by.css('.tag-label__remove')).click();
        expect(globalSearch.getItems().count()).toBe(14);
    });

    it('can search by facet and exclude facet', () => {
        expect(globalSearch.getItems().count()).toBe(14);
        globalSearch.openFilterPanel();
        globalSearch.toggleSearchTabs('filters');
        browser.sleep(200);
        expect(globalSearch.getDeskElements().count()).toBe(2);
        globalSearch.excludeDeskFacet(0);
        expect(globalSearch.getDeskElements().count()).toBe(1);
        expect(globalSearch.getItems().count()).toBe(6);
        expect(globalSearch.getExcludedFacetTags().count()).toBe(1);
        globalSearch.deleteExcludedFacetTagByIndex(0);
        expect(globalSearch.getExcludedFacetTags().count()).toBe(0);
        expect(globalSearch.getDeskElements().count()).toBe(2);
        expect(globalSearch.getItems().count()).toBe(14);
    });
});
<|endoftext|>


<commit_before>// @flow
import {toLaxTitleCase} from 'titlecase'

export function trimStationName(stationName: string) {
  return stationName.replace(/<strong>@(.*)<\/strong>/, '$1')
}

export function trimItemLabel(label: string) {
  // remove extraneous whitespace and title-case the bonapp titles
  return toLaxTitleCase(label.replace(/\s+/g, ' '))
}
<commit_msg>Trim carleton menu icons (#779)<commit_after>// @flow
import {toLaxTitleCase} from 'titlecase'

export function trimStationName(stationName: string) {
  return stationName.replace(/<strong>@(.*)<\/strong>/, '$1')
}

function removeParenTags(str: string) {
  const parensRegex = / \([^)]*?\)$/
  while (str.match(parensRegex)) {
    str = str.replace(parensRegex, '')
  }
  return str
}

export function trimItemLabel(label: string) {
  // remove extraneous whitespace and title-case the bonapp titles
  const evenedWhitespace = label.replace(/\s+/g, ' ')
  const noParens = removeParenTags(evenedWhitespace)
  return toLaxTitleCase(noParens)
}
<|endoftext|>