<commit_before>/**
 * E2E tests for /templates.
 */
var helper = require('../../protractor-help');

'use strict';

describe('templates test', function () {

  var templates;

  it('should log in', function () {
    helper.loginAsAdmin();
  });
  
  it('should show no templates', function () {
    templates = element.all(by.repeater('item in list'));
    expect(templates.count()).toEqual(0);
  });

  it('should create a template', function () {
    // First create provider
    browser.get('/providers/create');
    element(by.name('name')).sendKeys('Testprovider');
    element(by.css('#inputProviderDescription')).sendKeys('Test description');
    element(by.cssContainingText('option', 'google')).click();
    var formfields = element.all(by.repeater('(name,fieldData) in config.fields'));
    formfields.first().element(by.css('input')).sendKeys('Test resource');
    formfields.get(5).element(by.css('input')).sendKeys('Test username');
    formfields.get(1).element(by.css('input')).sendKeys('Test email');
    formfields.get(3).element(by.css('input')).sendKeys('Test project id');
    formfields.get(4).element(by.css('input')).sendKeys('Test keyname');
    element(by.partialButtonText('Create')).click();
    browser.waitForAngular();

    browser.get('/templates/create');
    
    expect(
      browser.getLocationAbsUrl()
    ).toMatch(/\/templates\/create\/tab\/0$/);

    element(by.css('#inputTemplateName')).sendKeys('foo');
    element(by.css('#inputTemplateDescription')).sendKeys('bar');
    element(by.cssContainingText('fieldset.active button.btn.btn-sm.btn-default', 'Next')).click();

    expect(
      browser.getLocationAbsUrl()
    ).toMatch(/\/templates\/create\/tab\/1$/);

    element(by.cssContainingText('fieldset.active button.btn.btn-sm.btn-default', 'Next')).click();

    expect(
      browser.getLocationAbsUrl()
    ).toMatch(/\/templates\/create\/tab\/2$/);

    element(by.css('#inputTemplateDefaultProvider option:nth-child(2)')).click();
    element(by.cssContainingText('fieldset.active button.btn.btn-sm.btn-default', 'Next')).click();

    expect(
      browser.getLocationAbsUrl()
    ).toMatch(/\/templates\/create\/tab\/3$/);

    element(by.cssContainingText('button.action-btn:not(.ng-hide)', 'Create')).click();

    expect(
      browser.getLocationAbsUrl()
    ).toMatch(/\/templates$/);

    // Delete provider created for test
    browser.get('/providers');
    providersList = element.all(by.repeater('item in list'));
    providersList.first().element(by.cssContainingText('.btn', 'Delete')).click();
    element(by.css('.modal-dialog .modal-footer .btn-primary')).click();
  });

  it('should verify a template', function () {
    browser.get('/templates');
    templates = element.all(by.repeater('item in list'));
    expect(templates.count()).toEqual(1);

    browser.get('/templates/edit/foo');

    expect(element(by.css('#inputTemplateName')).getAttribute('value')).toBe('foo');
    expect(element(by.css('#inputTemplateDescription')).getAttribute('value')).toBe('bar');
  });

  it('should delete a template', function () {
    browser.get('/templates');
    templates = element.all(by.repeater('item in list'));
    templates.first().element(by.cssContainingText('.btn', 'Delete')).click();
    element(by.css('.modal-dialog .modal-footer .btn-primary')).click();
    templates = element.all(by.repeater('item in list'));
    expect(templates.count()).toEqual(0);
  });


  it('should logout', function () {
    helper.logout();
  });

});

<commit_msg>Updates basic tests for template spec to make CRUD operations more self-sustained<commit_after>/**
 * E2E tests for /templates.
 */
var helper = require('../../protractor-help');

'use strict';

describe('templates test', function () {

  var templates,
      template,
      provider;

  it('should log in', function () {
    helper.loginAsAdmin();
  });

  it('should show no templates', function () {
    templates = element.all(by.repeater('item in list'));
    expect(templates.count()).toEqual(0);
  });

  it('should create a template', function () {
    var providerNames;
    provider = Date.now() + '-provider';
    // First create provider
    browser.get('/providers/create');
    element(by.name('name')).sendKeys(provider);
    element(by.css('#inputProviderDescription')).sendKeys('Test description');
    element(by.cssContainingText('option', 'google')).click();
    var formfields = element.all(by.repeater('(name,fieldData) in config.fields'));
    formfields.first().element(by.css('input')).sendKeys('Test resource');
    formfields.get(5).element(by.css('input')).sendKeys('Test username');
    formfields.get(1).element(by.css('input')).sendKeys('Test email');
    formfields.get(3).element(by.css('input')).sendKeys('Test project id');
    formfields.get(4).element(by.css('input')).sendKeys('Test keyname');
    element(by.partialButtonText('Create')).click();
    browser.waitForAngular();

    browser.get('/templates/create');

    expect(
      browser.getLocationAbsUrl()
    ).toMatch(/\/templates\/create\/tab\/0$/);

    template = Date.now() + '-template';
    element(by.css('#inputTemplateName')).sendKeys(template);
    element(by.css('#inputTemplateDescription')).sendKeys('bar');
    element(by.cssContainingText('fieldset.active button.btn.btn-sm.btn-default', 'Next')).click();

    expect(
      browser.getLocationAbsUrl()
    ).toMatch(/\/templates\/create\/tab\/1$/);

    element(by.cssContainingText('fieldset.active button.btn.btn-sm.btn-default', 'Next')).click();

    expect(
      browser.getLocationAbsUrl()
    ).toMatch(/\/templates\/create\/tab\/2$/);

    element(by.css('#inputTemplateDefaultProvider option:nth-child(2)')).click();
    element(by.cssContainingText('fieldset.active button.btn.btn-sm.btn-default', 'Next')).click();

    expect(
      browser.getLocationAbsUrl()
    ).toMatch(/\/templates\/create\/tab\/3$/);

    element(by.cssContainingText('button.action-btn:not(.ng-hide)', 'Create')).click();

    expect(
      browser.getLocationAbsUrl()
    ).toMatch(/\/templates$/);

    // Delete provider created for test
    browser.get('/providers');
    providerNames = element.all(by.repeater('item in list').column('item.name'));
    helper.deleteAssetFromList(providerNames, provider)
  });

  it('should verify a template', function () {
    browser.get('/templates');
    var templateNames = element.all(by.repeater('item in list').column('item.name'));
    helper.editAssetFromList(templateNames, template);

    expect(element(by.css('#inputTemplateName')).getAttribute('value')).toBe(template);
    expect(element(by.css('#inputTemplateDescription')).getAttribute('value')).toBe('bar');
  });

  it('should delete a template', function () {
    browser.get('/templates');
    var templateNames = element.all(by.repeater('item in list').column('item.name'));
    var templateCount = templateNames.count();
    helper.deleteAssetFromList(templateNames, template);

    expect(templateCount.then(function(i) {
      return i - 1;
    })).toBe(
      templateNames.count()
    ); //Lame..
  });


  it('should logout', function () {
    helper.logout();
  });

});
{'fraction_non_alphanumeric': 0.19653824678950307, 'fraction_numerical': 0.0034896705750977106, 'mean_word_length': 4.121515368120086, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5316061', 'n_tokens_mistral': 2161, 'n_tokens_neox': 2159, 'n_words': 314}