github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/ui/tests/acceptance/task-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 task; 11 let files, taskDirectory, directory, nestedDirectory; 12 13 module('Acceptance | task fs', function (hooks) { 14 setupApplicationTest(hooks); 15 setupMirage(hooks); 16 17 hooks.beforeEach(async function () { 18 server.create('agent'); 19 server.create('node', 'forceIPv4'); 20 const job = server.create('job', { createAllocations: false }); 21 22 allocation = server.create('allocation', { 23 jobId: job.id, 24 clientStatus: 'running', 25 }); 26 task = server.schema.taskStates.where({ allocationId: allocation.id }) 27 .models[0]; 28 task.name = 'task-name'; 29 task.save(); 30 31 this.task = task; 32 this.allocation = allocation; 33 34 // Reset files 35 files = []; 36 37 taskDirectory = server.create('allocFile', { 38 isDir: true, 39 name: task.name, 40 }); 41 files.push(taskDirectory); 42 43 // Nested files 44 directory = server.create('allocFile', { 45 isDir: true, 46 name: 'directory', 47 parent: taskDirectory, 48 }); 49 files.push(directory); 50 51 nestedDirectory = server.create('allocFile', { 52 isDir: true, 53 name: 'another', 54 parent: directory, 55 }); 56 files.push(nestedDirectory); 57 58 files.push( 59 server.create('allocFile', 'file', { 60 name: 'something.txt', 61 fileType: 'txt', 62 parent: nestedDirectory, 63 }) 64 ); 65 66 files.push( 67 server.create('allocFile', { 68 isDir: true, 69 name: 'empty-directory', 70 parent: taskDirectory, 71 }) 72 ); 73 files.push( 74 server.create('allocFile', 'file', { 75 fileType: 'txt', 76 parent: taskDirectory, 77 }) 78 ); 79 files.push( 80 server.create('allocFile', 'file', { 81 fileType: 'txt', 82 parent: taskDirectory, 83 }) 84 ); 85 86 this.files = files; 87 this.directory = directory; 88 this.nestedDirectory = nestedDirectory; 89 }); 90 91 browseFilesystem({ 92 visitSegments: ({ allocation, task }) => ({ 93 id: allocation.id, 94 name: task.name, 95 }), 96 getExpectedPathBase: ({ allocation, task }) => 97 `/allocations/${allocation.id}/${task.name}/fs/`, 98 getTitleComponent: ({ task }) => `Task ${task.name} filesystem`, 99 getBreadcrumbComponent: ({ task }) => task.name, 100 getFilesystemRoot: ({ task }) => task.name, 101 pageObjectVisitFunctionName: 'visitTask', 102 pageObjectVisitPathFunctionName: 'visitTaskPath', 103 }); 104 });