From ed55a7b09a4401dc39fbfaf56886c9af52d8eeee Mon Sep 17 00:00:00 2001 From: Michael Lange Date: Wed, 7 Aug 2019 17:35:43 -0700 Subject: [PATCH] Test that the client is contacted correctly, and the server is used as a fallback --- ui/tests/acceptance/task-fs-test.js | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/ui/tests/acceptance/task-fs-test.js b/ui/tests/acceptance/task-fs-test.js index 6d41f191f..4c3481d92 100644 --- a/ui/tests/acceptance/task-fs-test.js +++ b/ui/tests/acceptance/task-fs-test.js @@ -59,8 +59,8 @@ module('Acceptance | task fs', function(hooks) { ); files.push(server.create('allocFile', { isDir: true, name: 'empty-directory' })); - files.push(server.create('allocFile', 'file')); - files.push(server.create('allocFile', 'file')); + files.push(server.create('allocFile', 'file', { fileType: 'txt' })); + files.push(server.create('allocFile', 'file', { fileType: 'txt' })); }); test('visiting /allocations/:allocation_id/:task_name/fs', async function(assert) { @@ -296,6 +296,13 @@ module('Acceptance | task fs', function(hooks) { }); test('viewing a file', async function(assert) { + const node = server.db.nodes.find(allocation.nodeId); + + server.logging = true; + server.get(`http://${node.httpAddr}/v1/client/fs/readat/:allocation_id`, function() { + return new Response(500); + }); + await FS.visitPath({ id: allocation.id, name: task.name, path: '/' }); const sortedFiles = fileSort('name', filesForPath(this.server.schema.allocFiles, '').models); @@ -307,6 +314,22 @@ module('Acceptance | task fs', function(hooks) { assert.equal(FS.breadcrumbsText, `${task.name} ${fileRecord.name}`); assert.ok(FS.fileViewer.isPresent); + + const requests = this.server.pretender.handledRequests; + const secondAttempt = requests.pop(); + const firstAttempt = requests.pop(); + + assert.equal( + firstAttempt.url.split('?')[0], + `//${node.httpAddr}/v1/client/fs/readat/${allocation.id}`, + 'Client is hit first' + ); + assert.equal(firstAttempt.status, 500, 'Client request fails'); + assert.equal( + secondAttempt.url.split('?')[0], + `/v1/client/fs/readat/${allocation.id}`, + 'Server is hit second' + ); }); test('viewing an empty directory', async function(assert) {