diff --git a/client/galaxy/scripts/components/Citations.vue b/client/galaxy/scripts/components/Citations.vue index 75906671f88..e138738d76e 100644 --- a/client/galaxy/scripts/components/Citations.vue +++ b/client/galaxy/scripts/components/Citations.vue @@ -1,33 +1,52 @@ diff --git a/client/galaxy/scripts/components/ToolsView/ToolsView.test.js b/client/galaxy/scripts/components/ToolsView/ToolsView.test.js new file mode 100644 index 00000000000..f12b524ca8a --- /dev/null +++ b/client/galaxy/scripts/components/ToolsView/ToolsView.test.js @@ -0,0 +1,82 @@ +/* global expect */ +import ToolsView from "./ToolsView"; +import { shallowMount, mount, createLocalVue } from "@vue/test-utils"; +import _l from "utils/localization"; +import Vue from "vue"; + +// test response +import testToolsListResponse from "./testData/toolsList"; +import testCitation from "./testData/citation"; +import MockAdapter from "axios-mock-adapter"; +import axios from "axios"; + +describe("ToolsView/ToolsView.vue", () => { + const localVue = createLocalVue(); + localVue.filter("localize", value => _l(value)); + let wrapper, emitted, axiosMock; + + beforeEach(async () => { + axiosMock = new MockAdapter(axios); + wrapper = mount(ToolsView); + emitted = wrapper.emitted(); + axiosMock.onGet("/api/tools?tool_help=True").reply(200, testToolsListResponse); + axiosMock.onGet(new RegExp(`./*/citations`)).reply(200, testCitation); + await Vue.nextTick(); + await Vue.nextTick(); + }); + + afterEach(() => { + axiosMock.restore(); + }); + + it("should render infinite scroll div", async () => { + expect(wrapper.html()).contain('
'); + }); + + it("should return defined number of tools", async () => { + assert(wrapper.vm.getToolsNumber() === 84, "Tools Get Response is not parsed correctly!"); + }); + + it("should render only specific number of tools, equal to current buffer", async () => { + let buttons = wrapper.findAll('[type="button"]').filter(button => button.text() === "Info"); + // one 'info' button per tool + assert(wrapper.vm.buffer.length === buttons.length, "Number of 'info' buttons do not equal the buffer size!"); + }); + + it("should open modal on button click", async () => { + // findAll() returns WrapperArray, thus regular array.find() won't work + let infoButton = wrapper + .findAll('[type="button"]') + .filter(button => button.text() === "Info") + .at(0); + const modalId = "modal--" + infoButton.attributes().index; + const modal = wrapper.find("#" + modalId); + assert(modal.isVisible() === false, "modal is visible before the click!"); + + infoButton.trigger("click"); + await Vue.nextTick(); + + assert(modal.isVisible(), "'Info' button didn't open a modal!"); + }); + + it("citation should open on click", async () => { + await Vue.nextTick(); + await Vue.nextTick(); + await Vue.nextTick(); + + let infoButton = wrapper + .findAll('[type="button"]') + .filter(button => button.text() === "Citations") + .at(0); + const citation = wrapper.find("#" + infoButton.attributes("aria-controls")); + + assert(citation.isVisible() === false, "citation is visible before being triggered!"); + assert(infoButton.attributes("aria-expanded") === "false", "citation is expanded before being triggered!"); + + infoButton.trigger("click"); + await Vue.nextTick(); + + assert(infoButton.attributes("aria-expanded") === "true", "citation field did not expand!"); + assert(citation.isVisible(), "citation is not visible, after being triggered!"); + }); +}); diff --git a/client/galaxy/scripts/components/ToolsView/ToolsView.vue b/client/galaxy/scripts/components/ToolsView/ToolsView.vue new file mode 100644 index 00000000000..879d5a932d7 --- /dev/null +++ b/client/galaxy/scripts/components/ToolsView/ToolsView.vue @@ -0,0 +1,209 @@ + + + diff --git a/client/galaxy/scripts/components/ToolsView/testData/citation.json b/client/galaxy/scripts/components/ToolsView/testData/citation.json new file mode 100644 index 00000000000..57b0e8214e0 --- /dev/null +++ b/client/galaxy/scripts/components/ToolsView/testData/citation.json @@ -0,0 +1 @@ +[{"content": " @article{Blankenberg_2011, title={Making whole genome multiple alignments usable for biologists}, volume={27}, ISSN={1367-4803}, url={http://dx.doi.org/10.1093/bioinformatics/btr398}, DOI={10.1093/bioinformatics/btr398}, number={17}, journal={Bioinformatics}, publisher={Oxford University Press (OUP)}, author={Blankenberg, Daniel and Taylor, James and Nekrutenko, Anton}, year={2011}, month={Jul}, pages={2426\u00e2\u0080\u00932428}}\n", "format": "bibtex"}] \ No newline at end of file diff --git a/client/galaxy/scripts/components/ToolsView/testData/toolsList.json b/client/galaxy/scripts/components/ToolsView/testData/toolsList.json new file mode 100644 index 00000000000..8f644230acd --- /dev/null +++ b/client/galaxy/scripts/components/ToolsView/testData/toolsList.json @@ -0,0 +1,1810 @@ +[ + { + "elems": [ + { + "panel_section_name": "Get Data", + "xrefs": [], + "description": "from your computer", + "is_workflow_compatible": false, + "labels": [], + "help": "

Auto-detect<\/strong><\/p>\n

The system will attempt to detect Axt, Fasta, Fastqsolexa, Gff, Gff3, Html, Lav, Maf, Tabular, Wiggle, Bed and Interval (Bed with headers) formats. If your file is not detected properly as one of the known formats, it most likely means that it has some format problems (e.g., different number of columns on different rows). You can still coerce the system to set your data to the format you think it should be. You can also upload compressed files, which will automatically be decompressed.<\/p>\n


\n

Ab1<\/strong><\/p>\n

A binary sequence file in 'ab1' format with a '.ab1' file extension. You must manually select this 'File Format' when uploading the file.<\/p>\n


\n

Axt<\/strong><\/p>\n

blastz pairwise alignment format. Each alignment block in an axt file contains three lines: a summary line and 2 sequence lines. Blocks are separated from one another by blank lines. The summary line contains chromosomal position and size information about the alignment. It consists of 9 required fields.<\/p>\n


\n

Bam<\/strong><\/p>\n

A binary file compressed in the BGZF format with a '.bam' file extension.<\/p>\n


\n

Bed<\/strong><\/p>\n