github.com/hspak/nomad@v0.7.2-0.20180309000617-bc4ae22a39a5/ui/tests/integration/placement-failure-test.js (about)

     1  import { find, findAll } from 'ember-native-dom-helpers';
     2  import { test, moduleForComponent } from 'ember-qunit';
     3  import { assign } from '@ember/polyfills';
     4  import hbs from 'htmlbars-inline-precompile';
     5  import cleanWhitespace from '../utils/clean-whitespace';
     6  
     7  moduleForComponent('placement-failure', 'Integration | Component | placement failures', {
     8    integration: true,
     9  });
    10  
    11  const commonTemplate = hbs`
    12      {{placement-failure taskGroup=taskGroup}}
    13  `;
    14  
    15  test('should render the placement failure (basic render)', function(assert) {
    16    const name = 'Placement Failure';
    17    const failures = 11;
    18    this.set(
    19      'taskGroup',
    20      createFixture(
    21        {
    22          coalescedFailures: failures - 1,
    23        },
    24        name
    25      )
    26    );
    27  
    28    this.render(commonTemplate);
    29  
    30    assert.equal(
    31      cleanWhitespace(find('[data-test-placement-failure-task-group]').firstChild.wholeText),
    32      name,
    33      'Title is rendered with the name of the placement failure'
    34    );
    35    assert.equal(
    36      parseInt(find('[data-test-placement-failure-coalesced-failures]').textContent),
    37      failures,
    38      'Title is rendered correctly with a count of unplaced'
    39    );
    40    assert.equal(
    41      findAll('[data-test-placement-failure-no-evaluated-nodes]').length,
    42      1,
    43      'No evaluated nodes message shown'
    44    );
    45    assert.equal(
    46      findAll('[data-test-placement-failure-no-nodes-available]').length,
    47      1,
    48      'No nodes in datacenter message shown'
    49    );
    50    assert.equal(
    51      findAll('[data-test-placement-failure-class-filtered]').length,
    52      1,
    53      'Class filtered message shown'
    54    );
    55    assert.equal(
    56      findAll('[data-test-placement-failure-constraint-filtered]').length,
    57      1,
    58      'Constraint filtered message shown'
    59    );
    60    assert.equal(
    61      findAll('[data-test-placement-failure-nodes-exhausted]').length,
    62      1,
    63      'Node exhausted message shown'
    64    );
    65    assert.equal(
    66      findAll('[data-test-placement-failure-class-exhausted]').length,
    67      1,
    68      'Class exhausted message shown'
    69    );
    70    assert.equal(
    71      findAll('[data-test-placement-failure-dimension-exhausted]').length,
    72      1,
    73      'Dimension exhausted message shown'
    74    );
    75    assert.equal(
    76      findAll('[data-test-placement-failure-quota-exhausted]').length,
    77      1,
    78      'Quota exhausted message shown'
    79    );
    80    assert.equal(findAll('[data-test-placement-failure-scores]').length, 1, 'Scores message shown');
    81  });
    82  
    83  test('should render correctly when a node is not evaluated', function(assert) {
    84    this.set(
    85      'taskGroup',
    86      createFixture({
    87        nodesEvaluated: 1,
    88        nodesExhausted: 0,
    89      })
    90    );
    91  
    92    this.render(commonTemplate);
    93  
    94    assert.equal(
    95      findAll('[data-test-placement-failure-no-evaluated-nodes]').length,
    96      0,
    97      'No evaluated nodes message shown'
    98    );
    99    assert.equal(
   100      findAll('[data-test-placement-failure-nodes-exhausted]').length,
   101      0,
   102      'Nodes exhausted message NOT shown when there are no nodes exausted'
   103    );
   104  });
   105  
   106  function createFixture(obj = {}, name = 'Placement Failure') {
   107    return {
   108      name: name,
   109      placementFailures: assign(
   110        {
   111          coalescedFailures: 10,
   112          nodesEvaluated: 0,
   113          nodesAvailable: {
   114            datacenter: 0,
   115          },
   116          classFiltered: {
   117            filtered: 1,
   118          },
   119          constraintFiltered: {
   120            'prop = val': 1,
   121          },
   122          nodesExhausted: 3,
   123          classExhausted: {
   124            class: 3,
   125          },
   126          dimensionExhausted: {
   127            iops: 3,
   128          },
   129          quotaExhausted: {
   130            quota: 'dimension',
   131          },
   132          scores: {
   133            name: 3,
   134          },
   135        },
   136        obj
   137      ),
   138    };
   139  }