github.com/zhizhiboom/nomad@v0.8.5-0.20180907175415-f28fd3a1a056/ui/tests/acceptance/job-evaluations-test.js (about)

     1  import { test } from 'qunit';
     2  import moduleForAcceptance from 'nomad-ui/tests/helpers/module-for-acceptance';
     3  import Evaluations from 'nomad-ui/tests/pages/jobs/job/evaluations';
     4  
     5  let job;
     6  let evaluations;
     7  
     8  moduleForAcceptance('Acceptance | job evaluations', {
     9    beforeEach() {
    10      job = server.create('job', { noFailedPlacements: true, createAllocations: false });
    11      evaluations = server.db.evaluations.where({ jobId: job.id });
    12  
    13      Evaluations.visit({ id: job.id });
    14    },
    15  });
    16  
    17  test('lists all evaluations for the job', function(assert) {
    18    assert.equal(Evaluations.evaluations.length, evaluations.length, 'All evaluations are listed');
    19  
    20    const sortedEvaluations = evaluations.sortBy('modifyIndex').reverse();
    21  
    22    Evaluations.evaluations.forEach((evaluation, index) => {
    23      const shortId = sortedEvaluations[index].id.split('-')[0];
    24      assert.equal(evaluation.id, shortId, `Evaluation ${index} is ${shortId}`);
    25    });
    26  });
    27  
    28  test('evaluations table is sortable', function(assert) {
    29    Evaluations.sortBy('priority');
    30  
    31    andThen(() => {
    32      assert.equal(
    33        currentURL(),
    34        `/jobs/${job.id}/evaluations?sort=priority`,
    35        'the URL persists the sort parameter'
    36      );
    37      const sortedEvaluations = evaluations.sortBy('priority').reverse();
    38      Evaluations.evaluations.forEach((evaluation, index) => {
    39        const shortId = sortedEvaluations[index].id.split('-')[0];
    40        assert.equal(
    41          evaluation.id,
    42          shortId,
    43          `Evaluation ${index} is ${shortId} with priority ${sortedEvaluations[index].priority}`
    44        );
    45      });
    46    });
    47  });