github.com/hernad/nomad@v1.6.112/ui/tests/acceptance/allocation-fs-test.js (about)

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