2020-07-30 17:40:05 +00:00
|
|
|
/* eslint-disable ember-a11y-testing/a11y-audit-called */ // Covered in behaviours/fs
|
2020-10-26 05:17:41 +00:00
|
|
|
import { module } from 'qunit';
|
2019-06-20 22:20:15 +00:00
|
|
|
import { setupApplicationTest } from 'ember-qunit';
|
2019-07-02 21:42:38 +00:00
|
|
|
|
2019-06-20 22:20:15 +00:00
|
|
|
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
|
2019-07-02 21:42:38 +00:00
|
|
|
|
2020-06-01 13:15:59 +00:00
|
|
|
import browseFilesystem from './behaviors/fs';
|
2019-07-02 21:42:38 +00:00
|
|
|
|
2019-06-20 22:20:15 +00:00
|
|
|
let allocation;
|
|
|
|
let task;
|
2020-06-01 13:15:59 +00:00
|
|
|
let files, taskDirectory, directory, nestedDirectory;
|
2019-06-20 22:20:15 +00:00
|
|
|
|
2021-12-28 14:45:20 +00:00
|
|
|
module('Acceptance | task fs', function (hooks) {
|
2019-06-20 22:20:15 +00:00
|
|
|
setupApplicationTest(hooks);
|
|
|
|
setupMirage(hooks);
|
|
|
|
|
2021-12-28 14:45:20 +00:00
|
|
|
hooks.beforeEach(async function () {
|
2019-06-20 22:20:15 +00:00
|
|
|
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];
|
2019-07-02 21:42:38 +00:00
|
|
|
task.name = 'task-name';
|
|
|
|
task.save();
|
2019-07-26 05:44:29 +00:00
|
|
|
|
2020-06-01 13:15:59 +00:00
|
|
|
this.task = task;
|
|
|
|
this.allocation = allocation;
|
|
|
|
|
2019-07-26 05:44:29 +00:00
|
|
|
// Reset files
|
|
|
|
files = [];
|
|
|
|
|
2021-12-28 16:08:12 +00:00
|
|
|
taskDirectory = server.create('allocFile', {
|
|
|
|
isDir: true,
|
|
|
|
name: task.name,
|
|
|
|
});
|
2020-06-01 13:15:59 +00:00
|
|
|
files.push(taskDirectory);
|
|
|
|
|
2019-07-26 05:44:29 +00:00
|
|
|
// Nested files
|
2020-10-26 05:17:41 +00:00
|
|
|
directory = server.create('allocFile', {
|
|
|
|
isDir: true,
|
|
|
|
name: 'directory',
|
|
|
|
parent: taskDirectory,
|
|
|
|
});
|
2020-06-01 13:15:59 +00:00
|
|
|
files.push(directory);
|
|
|
|
|
2020-10-26 05:17:41 +00:00
|
|
|
nestedDirectory = server.create('allocFile', {
|
|
|
|
isDir: true,
|
|
|
|
name: 'another',
|
|
|
|
parent: directory,
|
|
|
|
});
|
2020-06-01 13:15:59 +00:00
|
|
|
files.push(nestedDirectory);
|
|
|
|
|
2019-07-26 05:44:29 +00:00
|
|
|
files.push(
|
|
|
|
server.create('allocFile', 'file', {
|
|
|
|
name: 'something.txt',
|
|
|
|
fileType: 'txt',
|
2020-06-01 13:15:59 +00:00
|
|
|
parent: nestedDirectory,
|
2019-07-26 05:44:29 +00:00
|
|
|
})
|
|
|
|
);
|
|
|
|
|
2020-10-26 05:17:41 +00:00
|
|
|
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,
|
|
|
|
})
|
2020-10-26 05:17:41 +00:00
|
|
|
);
|
2019-06-20 22:20:15 +00:00
|
|
|
|
2020-06-01 13:15:59 +00:00
|
|
|
this.files = files;
|
|
|
|
this.directory = directory;
|
|
|
|
this.nestedDirectory = nestedDirectory;
|
2019-06-20 22:20:15 +00:00
|
|
|
});
|
|
|
|
|
2020-06-01 13:15:59 +00:00
|
|
|
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/`,
|
2020-10-26 05:17:41 +00:00
|
|
|
getTitleComponent: ({ task }) => `Task ${task.name} filesystem`,
|
|
|
|
getBreadcrumbComponent: ({ task }) => task.name,
|
2020-06-01 13:15:59 +00:00
|
|
|
getFilesystemRoot: ({ task }) => task.name,
|
|
|
|
pageObjectVisitFunctionName: 'visitTask',
|
|
|
|
pageObjectVisitPathFunctionName: 'visitTaskPath',
|
2019-07-02 21:42:38 +00:00
|
|
|
});
|
2019-06-20 22:20:15 +00:00
|
|
|
});
|