open-nomad/ui/tests/acceptance/task-fs-test.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

105 lines
2.6 KiB
JavaScript
Raw Normal View History

/* eslint-disable ember-a11y-testing/a11y-audit-called */ // Covered in behaviours/fs
import { module } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
import browseFilesystem from './behaviors/fs';
let allocation;
let task;
let files, taskDirectory, directory, nestedDirectory;
2021-12-28 14:45:20 +00:00
module('Acceptance | task fs', function (hooks) {
setupApplicationTest(hooks);
setupMirage(hooks);
2021-12-28 14:45:20 +00:00
hooks.beforeEach(async function () {
server.create('agent');
server.create('node', 'forceIPv4');
const job = server.create('job', { createAllocations: false });
2021-12-28 16:08:12 +00:00
allocation = server.create('allocation', {
jobId: job.id,
clientStatus: 'running',
});
task = server.schema.taskStates.where({ allocationId: allocation.id })
.models[0];
task.name = 'task-name';
task.save();
this.task = task;
this.allocation = allocation;
// Reset files
files = [];
2021-12-28 16:08:12 +00:00
taskDirectory = server.create('allocFile', {
isDir: true,
name: task.name,
});
files.push(taskDirectory);
// Nested files
directory = server.create('allocFile', {
isDir: true,
name: 'directory',
parent: taskDirectory,
});
files.push(directory);
nestedDirectory = server.create('allocFile', {
isDir: true,
name: 'another',
parent: directory,
});
files.push(nestedDirectory);
files.push(
server.create('allocFile', 'file', {
name: 'something.txt',
fileType: 'txt',
parent: nestedDirectory,
})
);
files.push(
2021-12-28 16:08:12 +00:00
server.create('allocFile', {
isDir: true,
name: 'empty-directory',
parent: taskDirectory,
})
);
files.push(
server.create('allocFile', 'file', {
fileType: 'txt',
parent: taskDirectory,
})
);
files.push(
server.create('allocFile', 'file', {
fileType: 'txt',
parent: taskDirectory,
})
);
this.files = files;
this.directory = directory;
this.nestedDirectory = nestedDirectory;
});
browseFilesystem({
2021-12-28 16:08:12 +00:00
visitSegments: ({ allocation, task }) => ({
id: allocation.id,
name: task.name,
}),
getExpectedPathBase: ({ allocation, task }) =>
`/allocations/${allocation.id}/${task.name}/fs/`,
getTitleComponent: ({ task }) => `Task ${task.name} filesystem`,
getBreadcrumbComponent: ({ task }) => task.name,
getFilesystemRoot: ({ task }) => task.name,
pageObjectVisitFunctionName: 'visitTask',
pageObjectVisitPathFunctionName: 'visitTaskPath',
});
});