github.com/aminovpavel/nomad@v0.11.8/ui/tests/acceptance/allocation-fs-test.js (about) 1 import { module, test } from 'qunit'; 2 import { setupApplicationTest } from 'ember-qunit'; 3 4 import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; 5 import Response from 'ember-cli-mirage/response'; 6 7 import browseFilesystem from './behaviors/fs'; 8 9 import FS from 'nomad-ui/tests/pages/allocations/fs'; 10 11 let allocation; 12 let files; 13 14 module('Acceptance | allocation fs', function(hooks) { 15 setupApplicationTest(hooks); 16 setupMirage(hooks); 17 18 hooks.beforeEach(async function() { 19 server.create('agent'); 20 server.create('node', 'forceIPv4'); 21 const job = server.create('job', { createAllocations: false }); 22 23 allocation = server.create('allocation', { jobId: job.id, clientStatus: 'running' }); 24 25 this.allocation = allocation; 26 27 // Reset files 28 files = []; 29 30 // Nested files 31 files.push(server.create('allocFile', { isDir: true, name: 'directory' })); 32 files.push(server.create('allocFile', { isDir: true, name: 'another', parent: files[0] })); 33 files.push( 34 server.create('allocFile', 'file', { 35 name: 'something.txt', 36 fileType: 'txt', 37 parent: files[1], 38 }) 39 ); 40 41 files.push(server.create('allocFile', { isDir: true, name: 'empty-directory' })); 42 files.push(server.create('allocFile', 'file', { fileType: 'txt' })); 43 files.push(server.create('allocFile', 'file', { fileType: 'txt' })); 44 45 this.files = files; 46 this.directory = files[0]; 47 this.nestedDirectory = files[1]; 48 }); 49 50 test('when the allocation is not running, an empty state is shown', async function(assert) { 51 // The API 500s on stat when not running 52 this.server.get('/client/fs/stat/:allocation_id', () => { 53 return new Response(500, {}, 'no such file or directory'); 54 }); 55 56 allocation.update({ 57 clientStatus: 'complete', 58 }); 59 60 await FS.visitAllocation({ id: allocation.id }); 61 assert.ok(FS.hasEmptyState, 'Non-running allocation has no files'); 62 assert.ok( 63 FS.emptyState.headline.includes('Allocation is not Running'), 64 'Empty state explains the condition' 65 ); 66 }); 67 68 browseFilesystem({ 69 visitSegments: ({ allocation }) => ({ id: allocation.id }), 70 getExpectedPathBase: ({ allocation }) => `/allocations/${allocation.id}/fs/`, 71 getTitleComponent: ({ allocation }) => `Allocation ${allocation.id.split('-')[0]} filesystem`, 72 getBreadcrumbComponent: ({ allocation }) => allocation.id.split('-')[0], 73 getFilesystemRoot: () => '', 74 pageObjectVisitFunctionName: 'visitAllocation', 75 pageObjectVisitPathFunctionName: 'visitAllocationPath', 76 }); 77 });