From 24b800ec4003f442663615ea7859686aacfebe58 Mon Sep 17 00:00:00 2001 From: guerler Date: Wed, 21 Sep 2022 20:25:17 -0400 Subject: [PATCH] Remove legacy qunit tests --- client/tests/qunit/tests/hda_base_tests.js | 32 -- .../tests/history_contents_model_tests.js | 47 --- client/tests/qunit/tests/job_dag_tests.js | 297 ------------------ 3 files changed, 376 deletions(-) delete mode 100644 client/tests/qunit/tests/hda_base_tests.js delete mode 100644 client/tests/qunit/tests/history_contents_model_tests.js delete mode 100644 client/tests/qunit/tests/job_dag_tests.js diff --git a/client/tests/qunit/tests/hda_base_tests.js b/client/tests/qunit/tests/hda_base_tests.js deleted file mode 100644 index cffe9a3aa40..00000000000 --- a/client/tests/qunit/tests/hda_base_tests.js +++ /dev/null @@ -1,32 +0,0 @@ -// This file isn't really testing anything useful yet, it is just testing -// (or demonstrating) qunit+backbone interactions. - -/* global QUnit */ -import testApp from "../test-app"; -import HDA_MODEL from "mvc/history/hda-model"; -import HDA_BASE from "mvc/history/hda-li"; - -QUnit.module("HDA base backbone view tests", { - beforeEach: function () { - testApp.create(); - }, - afterEach: function () { - testApp.destroy(); - }, -}); - -QUnit.test("Base HDA view default construction, initialize", function (assert) { - var hda = new HDA_MODEL.HistoryDatasetAssociation({ - id: "123", - }), - view = new HDA_BASE.HDAListItemView({ model: hda }); - - assert.strictEqual(view.model, hda); - - assert.equal(view.linkTarget, "_blank"); - assert.equal(view.selectable, false); - assert.equal(view.selected, false); - assert.equal(view.expanded, false); - assert.equal(view.draggable, false); - assert.equal(view.id(), "dataset-123"); -}); diff --git a/client/tests/qunit/tests/history_contents_model_tests.js b/client/tests/qunit/tests/history_contents_model_tests.js deleted file mode 100644 index a4da59b8c0e..00000000000 --- a/client/tests/qunit/tests/history_contents_model_tests.js +++ /dev/null @@ -1,47 +0,0 @@ -/* global QUnit */ -import $ from "jquery"; -import sinon from "sinon"; -import testApp from "../test-app"; -import HDA_MODEL from "mvc/history/hda-model"; - -QUnit.module("History Contents Model QUnit.Tests", { - beforeEach: function () { - testApp.create(); - }, - afterEach: function () { - testApp.destroy(); - }, -}); - -QUnit.test("HDA Constructions with Default Attributes", function (assert) { - var hda = new HDA_MODEL.HistoryDatasetAssociation({}); - assert.equal(hda.get("name"), "(unnamed dataset)"); - assert.equal(hda.get("state"), "new"); -}); - -QUnit.test("HDA Construction with Supplied Attributes", function (assert) { - var hda = new HDA_MODEL.HistoryDatasetAssociation({ - history_content_type: "dataset", - name: "my dataset", - state: "ok", - }); - assert.equal(hda.get("name"), "my dataset"); - assert.equal(hda.get("state"), "ok"); -}); - -QUnit.test("HDA Deletion", function (assert) { - var hda = new HDA_MODEL.HistoryDatasetAssociation({ - history_content_type: "dataset", - id: "hda1", - history_id: "h1", - deleted: false, - }); - assert.equal(hda.get("deleted"), false); - - sinon.stub($, "ajax").yieldsTo("success", { deleted: true }); - hda["delete"](); - // to get the url sinon used: - //console.debug( $.ajax.lastCall.args[0].url ) - assert.ok($.ajax.calledWithMatch({ url: "/api/histories/h1/contents/datasets/hda1" })); - assert.equal(hda.get("deleted"), true); -}); diff --git a/client/tests/qunit/tests/job_dag_tests.js b/client/tests/qunit/tests/job_dag_tests.js deleted file mode 100644 index 0502ea95297..00000000000 --- a/client/tests/qunit/tests/job_dag_tests.js +++ /dev/null @@ -1,297 +0,0 @@ -/* global QUnit */ -import _ from "underscore"; -import testApp from "../test-app"; -import testData from "../test-data/job-dag-1"; -import JobDAG from "mvc/history/job-dag"; - -QUnit.module("mvc/history/job-dag.js tests", { - beforeEach: function () { - testApp.create(); - }, - afterEach: function () { - testApp.destroy(); - }, -}); - -// ------------------------------------------------------------------------ -QUnit.test("Empty JobDAG construction", function (assert) { - var dag = new JobDAG(); - assert.ok(dag instanceof JobDAG); - - // default options - assert.deepEqual(dag.filters, []); - assert.deepEqual(dag.options, { - excludeSetMetadata: false, - }); - - // test (empty) instance vars - assert.deepEqual(dag._jobsData, []); - assert.deepEqual(dag._historyContentsMap, {}); - assert.deepEqual(dag._toolMap, {}); - assert.equal(dag.noInputJobs.length, 0); - assert.equal(dag.noOutputJobs.length, 0); - - // logging - assert.equal(typeof dag.debug, "function"); - assert.equal(typeof dag.info, "function"); - assert.equal(typeof dag.warn, "function"); - assert.equal(typeof dag.error, "function"); -}); - -QUnit.test("Empty JobDAG construction - changing options", function (assert) { - var dag; - dag = new JobDAG({ - excludeSetMetadata: true, - }); - - // excludeSetMetadata - assert.deepEqual(dag.options, { - excludeSetMetadata: true, - }); - assert.equal(dag.filters.length, 1); - assert.equal(typeof dag.filters[0], "function"); - - // filters - function testFilter(job, index, jobData) { - return true; - } - dag = new JobDAG({ - filters: [testFilter], - }); - assert.equal(dag.filters[0], testFilter); -}); - -QUnit.test("JobDAG construction with history and jobs", function (assert) { - assert.equal(testData.jobs1.length, 3); - assert.equal(testData.historyContents1.length, 3); - - var history = testData.historyContents1, - jobs = testData.jobs1, - dag; - dag = new JobDAG({ - historyContents: history, - tools: testData.tools, - jobs: jobs, - }); - - assert.deepEqual(dag._outputIdToJobMap, { - "8c959c9304a2bc4b": "8a81cf6f989c4467", - "132016f833b57406": "6505e875ddb66fd2", - "846fb0a2a64137c0": "77f74776fd03cbc5", - }); - assert.deepEqual(dag._jobsData, [ - { - job: _.findWhere(jobs, { id: "8a81cf6f989c4467" }), - inputs: {}, - outputs: { - "8c959c9304a2bc4b": { - src: "hda", - id: "8c959c9304a2bc4b", - name: "output0", - content: _.findWhere(history, { id: "8c959c9304a2bc4b" }), - }, - }, - tool: {}, - }, - { - job: _.findWhere(jobs, { id: "6505e875ddb66fd2" }), - inputs: { - "8c959c9304a2bc4b": { - src: "hda", - id: "8c959c9304a2bc4b", - name: "input", - content: _.findWhere(history, { id: "8c959c9304a2bc4b" }), - }, - }, - outputs: { - "132016f833b57406": { - src: "hda", - id: "132016f833b57406", - name: "out_file1", - content: _.findWhere(history, { id: "132016f833b57406" }), - }, - }, - tool: {}, - }, - { - job: _.findWhere(jobs, { id: "77f74776fd03cbc5" }), - inputs: { - "132016f833b57406": { - src: "hda", - id: "132016f833b57406", - name: "input", - content: _.findWhere(history, { id: "132016f833b57406" }), - }, - }, - outputs: { - "846fb0a2a64137c0": { - src: "hda", - id: "846fb0a2a64137c0", - name: "out_file1", - content: _.findWhere(history, { id: "846fb0a2a64137c0" }), - }, - }, - tool: {}, - }, - ]); - - var jobsDataMap = dag._jobsDataMap(); - assert.deepEqual(dag.toNodesAndLinks(), { - nodes: [ - { name: "8a81cf6f989c4467", data: jobsDataMap["8a81cf6f989c4467"] }, - { name: "6505e875ddb66fd2", data: jobsDataMap["6505e875ddb66fd2"] }, - { name: "77f74776fd03cbc5", data: jobsDataMap["77f74776fd03cbc5"] }, - ], - links: [ - { source: 0, target: 1, data: { dataset: "8c959c9304a2bc4b" } }, - { source: 1, target: 2, data: { dataset: "132016f833b57406" } }, - ], - }); - - assert.deepEqual(dag.toVerticesAndEdges(), { - vertices: [ - { name: "8a81cf6f989c4467", data: jobsDataMap["8a81cf6f989c4467"] }, - { name: "6505e875ddb66fd2", data: jobsDataMap["6505e875ddb66fd2"] }, - { name: "77f74776fd03cbc5", data: jobsDataMap["77f74776fd03cbc5"] }, - ], - edges: [ - { - source: "8a81cf6f989c4467", - target: "6505e875ddb66fd2", - data: { dataset: "8c959c9304a2bc4b" }, - }, - { - source: "6505e875ddb66fd2", - target: "77f74776fd03cbc5", - data: { dataset: "132016f833b57406" }, - }, - ], - }); - - // test cloning -}); - -QUnit.test("JobDAG removal of __SET_METADATA__ jobs", function (assert) { - assert.equal(testData.jobs2.length, 3); - assert.equal(testData.historyContents2.length, 2); - - var history = testData.historyContents2, - jobs = testData.jobs2, - dag; - dag = new JobDAG({ - historyContents: history, - tools: testData.tools, - jobs: jobs, - excludeSetMetadata: true, - }); - - var jobsDataMap = dag._jobsDataMap(); - assert.deepEqual(dag.toNodesAndLinks(), { - nodes: [ - { name: "bf60fd5f5f7f44bf", data: jobsDataMap["bf60fd5f5f7f44bf"] }, - { name: "90240358ebde1489", data: jobsDataMap["90240358ebde1489"] }, - ], - links: [{ source: 0, target: 1, data: { dataset: "eca0af6fb47bf90c" } }], - }); -}); - -//TODO: test filtering out errored jobs -QUnit.test("JobDAG construction with history and jobs", function (assert) { - assert.equal(testData.jobs3.length, 5); - assert.equal(testData.historyContents3.length, 5); - - var history = testData.historyContents3, - jobs = testData.jobs3, - dag; - dag = new JobDAG({ - historyContents: history, - tools: testData.tools, - jobs: jobs, - }); - - var jobsDataMap = dag._jobsDataMap(); - assert.deepEqual(dag.toVerticesAndEdges(), { - vertices: [ - { name: "8c959c9304a2bc4b", data: jobsDataMap["8c959c9304a2bc4b"] }, - { name: "132016f833b57406", data: jobsDataMap["132016f833b57406"] }, - { name: "846fb0a2a64137c0", data: jobsDataMap["846fb0a2a64137c0"] }, - { name: "eca0af6fb47bf90c", data: jobsDataMap["eca0af6fb47bf90c"] }, - { name: "6fc9fbb81c497f69", data: jobsDataMap["6fc9fbb81c497f69"] }, - ], - edges: [ - { - source: "8c959c9304a2bc4b", - target: "846fb0a2a64137c0", - data: { dataset: "6fb17d0cc6e8fae5" }, - }, - { - source: "132016f833b57406", - target: "eca0af6fb47bf90c", - data: { dataset: "5114a2a207b7caff" }, - }, - { - source: "eca0af6fb47bf90c", - target: "6fc9fbb81c497f69", - data: { dataset: "b8a0d6158b9961df" }, - }, - ], - }); - - var components = dag.weakComponents(); - assert.deepEqual(components, [ - { - vertices: [ - { name: "8c959c9304a2bc4b", data: jobsDataMap["8c959c9304a2bc4b"] }, - { name: "846fb0a2a64137c0", data: jobsDataMap["846fb0a2a64137c0"] }, - ], - edges: [{ source: "8c959c9304a2bc4b", target: "846fb0a2a64137c0" }], - }, - { - vertices: [ - { name: "132016f833b57406", data: jobsDataMap["132016f833b57406"] }, - { name: "eca0af6fb47bf90c", data: jobsDataMap["eca0af6fb47bf90c"] }, - { name: "6fc9fbb81c497f69", data: jobsDataMap["6fc9fbb81c497f69"] }, - ], - edges: [ - { source: "132016f833b57406", target: "eca0af6fb47bf90c" }, - { source: "eca0af6fb47bf90c", target: "6fc9fbb81c497f69" }, - ], - }, - ]); -}); - -//TODO: test filtering out errored jobs -QUnit.test("JobDAG construction with copied history contents", function (assert) { - assert.equal(testData.jobs4.length, 1); - assert.equal(testData.historyContents4.length, 3); - - var history = testData.historyContents4, - jobs = testData.jobs4, - dag; - dag = new JobDAG({ - historyContents: history, - tools: testData.tools, - jobs: jobs, - }); - - var jobsDataMap = dag._jobsDataMap(); - assert.deepEqual(dag.toVerticesAndEdges(), { - vertices: [ - { name: "92b83968e0b52980", data: jobsDataMap["92b83968e0b52980"] }, - { name: "copy-422eef6b1b545329", data: _.findWhere(history, { id: "422eef6b1b545329" }) }, - { name: "copy-c86c1b73aa7102dd", data: _.findWhere(history, { id: "c86c1b73aa7102dd" }) }, - ], - edges: [ - { - source: "copy-422eef6b1b545329", - target: "92b83968e0b52980", - data: { dataset: "422eef6b1b545329" }, - }, - { - source: "copy-c86c1b73aa7102dd", - target: "92b83968e0b52980", - data: { dataset: "c86c1b73aa7102dd" }, - }, - ], - }); -});