github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/ui/tests/acceptance/allocation-fs-test.js (about)

     1  /* eslint-disable ember-a11y-testing/a11y-audit-called */ // Covered in behaviours/fs
     2  import { module } from 'qunit';
     3  import { setupApplicationTest } from 'ember-qunit';
     4  
     5  import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
     6  
     7  import browseFilesystem from './behaviors/fs';
     8  
     9  let allocation;
    10  let files;
    11  
    12  module('Acceptance | allocation fs', function (hooks) {
    13    setupApplicationTest(hooks);
    14    setupMirage(hooks);
    15  
    16    hooks.beforeEach(async function () {
    17      server.create('agent');
    18      server.create('node', 'forceIPv4');
    19      const job = server.create('job', { createAllocations: false });
    20  
    21      allocation = server.create('allocation', {
    22        jobId: job.id,
    23        clientStatus: 'running',
    24      });
    25  
    26      this.allocation = allocation;
    27  
    28      // Reset files
    29      files = [];
    30  
    31      // Nested files
    32      files.push(server.create('allocFile', { isDir: true, name: 'directory' }));
    33      files.push(
    34        server.create('allocFile', {
    35          isDir: true,
    36          name: 'another',
    37          parent: files[0],
    38        })
    39      );
    40      files.push(
    41        server.create('allocFile', 'file', {
    42          name: 'something.txt',
    43          fileType: 'txt',
    44          parent: files[1],
    45        })
    46      );
    47  
    48      files.push(
    49        server.create('allocFile', { isDir: true, name: 'empty-directory' })
    50      );
    51      files.push(server.create('allocFile', 'file', { fileType: 'txt' }));
    52      files.push(server.create('allocFile', 'file', { fileType: 'txt' }));
    53  
    54      this.files = files;
    55      this.directory = files[0];
    56      this.nestedDirectory = files[1];
    57    });
    58  
    59    browseFilesystem({
    60      visitSegments: ({ allocation }) => ({ id: allocation.id }),
    61      getExpectedPathBase: ({ allocation }) =>
    62        `/allocations/${allocation.id}/fs/`,
    63      getTitleComponent: ({ allocation }) =>
    64        `Allocation ${allocation.id.split('-')[0]} filesystem`,
    65      getBreadcrumbComponent: ({ allocation }) => allocation.id.split('-')[0],
    66      getFilesystemRoot: () => '',
    67      pageObjectVisitFunctionName: 'visitAllocation',
    68      pageObjectVisitPathFunctionName: 'visitAllocationPath',
    69    });
    70  });