From 9cca3084bc6afe2bdf87c370a17182a0b352610d Mon Sep 17 00:00:00 2001 From: guerler Date: Sun, 17 Apr 2022 20:53:31 -0400 Subject: [PATCH 1/7] Add content item test --- .../Collection/CollectionDescription.vue | 9 +-- .../History/Content/ContentItem.test.js | 59 +++++++++++++++++++ .../History/Content/ContentItem.vue | 6 +- 3 files changed, 66 insertions(+), 8 deletions(-) create mode 100644 client/src/components/History/Content/ContentItem.test.js diff --git a/client/src/components/History/Content/Collection/CollectionDescription.vue b/client/src/components/History/Content/Collection/CollectionDescription.vue index 0315e42a3cb..b1cfcc3e732 100644 --- a/client/src/components/History/Content/Collection/CollectionDescription.vue +++ b/client/src/components/History/Content/Collection/CollectionDescription.vue @@ -9,7 +9,8 @@ diff --git a/client/src/components/History/Content/ContentItem.test.js b/client/src/components/History/Content/ContentItem.test.js new file mode 100644 index 00000000000..bf280e703c5 --- /dev/null +++ b/client/src/components/History/Content/ContentItem.test.js @@ -0,0 +1,59 @@ +import { mount } from "@vue/test-utils"; +import { getLocalVue } from "jest/helpers"; +import ContentItem from "./ContentItem"; + +const localVue = getLocalVue(); + +describe("ContentItem", () => { + let wrapper; + + beforeEach(() => { + wrapper = mount(ContentItem, { + propsData: { + expandDataset: false, + item: { + id: "item_id", + some_data: "some_data", + tags: ["tag1", "tag2", "tag3"], + }, + id: 1, + isDataset: true, + isHistoryItem: false, + name: "name", + selected: false, + selectable: false, + }, + localVue, + }); + }); + + it("check basics", async () => { + expect(wrapper.attributes("data-hid")).toBe("1"); + expect(wrapper.find(".content-title").text()).toBe("name"); + const tags = wrapper.find(".nametags").findAll(".badge"); + // verify tags + expect(tags.length).toBe(3); + for (let i = 0; i < 3; i++) { + expect(tags.at(i).text()).toBe(`tag${i + 1}`); + } + // expansion button + const $el = wrapper.find(".cursor-pointer"); + $el.trigger("click"); + expect(wrapper.emitted()["update:expand-dataset"]).toBeDefined(); + // select and unselect + const noSelector = wrapper.find(".selector > svg"); + expect(noSelector.exists()).toBe(false); + await wrapper.setProps({ selectable: true }); + expect(wrapper.classes()).toEqual(expect.arrayContaining(["alert-success"])); + const selector = wrapper.find(".selector > svg"); + expect(selector.attributes("data-icon")).toBe("square"); + selector.trigger("click"); + await localVue.nextTick(); + expect(wrapper.emitted()["update:selected"][0][0]).toBe(true); + await wrapper.setProps({ selected: true }); + selector.trigger("click"); + await localVue.nextTick(); + expect(wrapper.emitted()["update:selected"][1][0]).toBe(false); + expect(wrapper.classes()).toEqual(expect.arrayContaining(["alert-info"])); + }); +}); diff --git a/client/src/components/History/Content/ContentItem.vue b/client/src/components/History/Content/ContentItem.vue index f553e24194b..04ef162cb32 100644 --- a/client/src/components/History/Content/ContentItem.vue +++ b/client/src/components/History/Content/ContentItem.vue @@ -29,7 +29,11 @@ {{ id }} : {{ name }} - +
From 369e7cd16323202c758d54f39c2a8e006105179c Mon Sep 17 00:00:00 2001 From: guerler Date: Sun, 17 Apr 2022 21:20:48 -0400 Subject: [PATCH 2/7] Add collection description item test --- .../Collection/CollectionDescription.test.js | 33 +++++++++++++++++++ .../History/Content/ContentItem.vue | 3 +- 2 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 client/src/components/History/Content/Collection/CollectionDescription.test.js diff --git a/client/src/components/History/Content/Collection/CollectionDescription.test.js b/client/src/components/History/Content/Collection/CollectionDescription.test.js new file mode 100644 index 00000000000..50c9f7729b8 --- /dev/null +++ b/client/src/components/History/Content/Collection/CollectionDescription.test.js @@ -0,0 +1,33 @@ +import { mount } from "@vue/test-utils"; +import { getLocalVue } from "jest/helpers"; +import CollectionDescription from "./CollectionDescription"; + +const localVue = getLocalVue(); + +describe("CollectionDescription", () => { + let wrapper; + + beforeEach(() => { + wrapper = mount(CollectionDescription, { + propsData: { + collectionType: "list", + elementCount: 10, + }, + localVue, + }); + }); + + it("check basics", async () => { + const details = wrapper.findAll("span"); + expect(details.at(0).text()).toBe("a list"); + expect(details.at(1).text()).toBe("with 10 items"); + await wrapper.setProps({ elementCount: 1 }); + expect(details.at(1).text()).toBe("with 1 item"); + await wrapper.setProps({ collectionType: "paired" }); + expect(details.at(0).text()).toBe("a dataset pair"); + await wrapper.setProps({ collectionType: "list:paired" }); + expect(details.at(0).text()).toBe("a list of pairs"); + await wrapper.setProps({ collectionType: "other" }); + expect(details.at(0).text()).toBe("a nested list"); + }); +}); diff --git a/client/src/components/History/Content/ContentItem.vue b/client/src/components/History/Content/ContentItem.vue index 04ef162cb32..52ef4928ffe 100644 --- a/client/src/components/History/Content/ContentItem.vue +++ b/client/src/components/History/Content/ContentItem.vue @@ -32,8 +32,7 @@ + :element-count="item.element_count" />
From 87de0da246db52329f85158b07ef45808d3dc54e Mon Sep 17 00:00:00 2001 From: guerler Date: Mon, 18 Apr 2022 05:40:12 -0400 Subject: [PATCH 3/7] Use consistent modal component naming --- .../History/CurrentHistory/HistoryNavigation.vue | 16 ++++++++-------- ...istorySelectorModal.vue => SelectorModal.vue} | 0 2 files changed, 8 insertions(+), 8 deletions(-) rename client/src/components/History/Modals/{HistorySelectorModal.vue => SelectorModal.vue} (100%) diff --git a/client/src/components/History/CurrentHistory/HistoryNavigation.vue b/client/src/components/History/CurrentHistory/HistoryNavigation.vue index c2742ffe6eb..b85d801dc4e 100644 --- a/client/src/components/History/CurrentHistory/HistoryNavigation.vue +++ b/client/src/components/History/CurrentHistory/HistoryNavigation.vue @@ -17,7 +17,7 @@ - - + import { legacyNavigationMixin } from "components/plugins/legacyNavigation"; import { switchToLegacyHistoryPanel } from "components/History/adapters/betaToggle"; -import CopyHistoryModal from "components/History/Modals/CopyModal"; -import HistorySelectorModal from "components/History/Modals/HistorySelectorModal"; +import CopyModal from "components/History/Modals/CopyModal"; +import SelectorModal from "components/History/Modals/SelectorModal"; export default { mixins: [legacyNavigationMixin], components: { - CopyHistoryModal, - HistorySelectorModal, + CopyModal, + SelectorModal, }, props: { histories: { type: Array, required: true }, diff --git a/client/src/components/History/Modals/HistorySelectorModal.vue b/client/src/components/History/Modals/SelectorModal.vue similarity index 100% rename from client/src/components/History/Modals/HistorySelectorModal.vue rename to client/src/components/History/Modals/SelectorModal.vue From 610c08fbe6aef2afebcde326fe002e9dbf56c187 Mon Sep 17 00:00:00 2001 From: guerler Date: Mon, 18 Apr 2022 05:41:23 -0400 Subject: [PATCH 4/7] Remove unused history help details modal --- .../History/Content/ContentItem.test.js | 1 + .../History/CurrentHistory/HistoryPanel.vue | 3 -- .../History/Modals/ToolHelpModal.vue | 49 ------------------- 3 files changed, 1 insertion(+), 52 deletions(-) delete mode 100644 client/src/components/History/Modals/ToolHelpModal.vue diff --git a/client/src/components/History/Content/ContentItem.test.js b/client/src/components/History/Content/ContentItem.test.js index bf280e703c5..d82ecb04e04 100644 --- a/client/src/components/History/Content/ContentItem.test.js +++ b/client/src/components/History/Content/ContentItem.test.js @@ -55,5 +55,6 @@ describe("ContentItem", () => { await localVue.nextTick(); expect(wrapper.emitted()["update:selected"][1][0]).toBe(false); expect(wrapper.classes()).toEqual(expect.arrayContaining(["alert-info"])); + expect(selector.attributes("data-icon")).toBe("check-square"); }); }); diff --git a/client/src/components/History/CurrentHistory/HistoryPanel.vue b/client/src/components/History/CurrentHistory/HistoryPanel.vue index 981466ed0f0..57c364ebae2 100644 --- a/client/src/components/History/CurrentHistory/HistoryPanel.vue +++ b/client/src/components/History/CurrentHistory/HistoryPanel.vue @@ -95,7 +95,6 @@ - @@ -111,7 +110,6 @@ import { deleteContent, updateContentFields } from "components/History/model/que import ExpandedItems from "components/History/Content/ExpandedItems"; import SelectedItems from "components/History/Content/SelectedItems"; import Listing from "components/History/Layout/Listing"; -import ToolHelpModal from "components/History/Modals/ToolHelpModal"; import HistoryOperations from "./HistoryOperations/Index"; import HistoryDetails from "./HistoryDetails"; import HistoryEmpty from "./HistoryEmpty"; @@ -135,7 +133,6 @@ export default { LoadingSpan, Listing, SelectedItems, - ToolHelpModal, }, props: { history: { type: Object, required: true }, diff --git a/client/src/components/History/Modals/ToolHelpModal.vue b/client/src/components/History/Modals/ToolHelpModal.vue deleted file mode 100644 index 43f5bd0b008..00000000000 --- a/client/src/components/History/Modals/ToolHelpModal.vue +++ /dev/null @@ -1,49 +0,0 @@ - - - From a48e3977f581745a93469efdf347df265a69490a Mon Sep 17 00:00:00 2001 From: guerler Date: Mon, 18 Apr 2022 11:13:20 -0400 Subject: [PATCH 5/7] Remove final use_legacy_history helper from selenium upload tests --- lib/galaxy_test/selenium/test_uploads.py | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/galaxy_test/selenium/test_uploads.py b/lib/galaxy_test/selenium/test_uploads.py index 16dc1a554a5..b94de653115 100644 --- a/lib/galaxy_test/selenium/test_uploads.py +++ b/lib/galaxy_test/selenium/test_uploads.py @@ -104,7 +104,6 @@ class UploadsTestCase(SeleniumTestCase, UsesHistoryItemAssertions): @selenium_test def test_upload_paired_list(self): - self.use_legacy_history() self.upload_paired_list( [self.get_filename("1.tabular"), self.get_filename("2.tabular")], name="Test Paired List" ) From 4e04393b701cec86469e3e381b033a762e628cbc Mon Sep 17 00:00:00 2001 From: guerler Date: Mon, 18 Apr 2022 12:21:23 -0400 Subject: [PATCH 6/7] Adjust tool tour generator plugin, remove legacy history dependence --- .../History/adapters/HistoryPanelProxy.js | 4 +- .../store/historyStore/historyItemsStore.js | 2 +- .../webhooks/demo/tour_generator/script.js | 4 +- .../demo/tour_generator/tour_generator.js | 77 +++++++------------ .../selenium/test_tool_describing_tours.py | 5 -- 5 files changed, 34 insertions(+), 58 deletions(-) diff --git a/client/src/components/History/adapters/HistoryPanelProxy.js b/client/src/components/History/adapters/HistoryPanelProxy.js index e90a37e8619..cb0bf6d4295 100644 --- a/client/src/components/History/adapters/HistoryPanelProxy.js +++ b/client/src/components/History/adapters/HistoryPanelProxy.js @@ -23,8 +23,8 @@ export class HistoryPanelProxy { this.models = models; this.unwatch = null; }, - each(callback) { - const historyItems = store.getters.getHistoryItems({ historyId: model.id, filterText: "" }); + each(callback, filterText = "") { + const historyItems = store.getters.getHistoryItems({ historyId: model.id, filterText: filterText }); historyItems.forEach((model) => { callback(new Backbone.Model(model)); }); diff --git a/client/src/store/historyStore/historyItemsStore.js b/client/src/store/historyStore/historyItemsStore.js index 945c961a98c..8a0976a3ee1 100644 --- a/client/src/store/historyStore/historyItemsStore.js +++ b/client/src/store/historyStore/historyItemsStore.js @@ -48,7 +48,7 @@ const getQueryString = (filterText) => { }; const actions = { - fetchHistoryItems: async ({ commit, dispatch }, { historyId, filterText, offset }) => { + fetchHistoryItems: async ({ commit }, { historyId, filterText, offset }) => { const queryString = getQueryString(filterText); const params = `v=dev&order=hid&offset=${offset}&limit=${limit}`; const url = `api/histories/${historyId}/contents?${params}&${queryString}`; diff --git a/config/plugins/webhooks/demo/tour_generator/script.js b/config/plugins/webhooks/demo/tour_generator/script.js index 81a57948472..372b52c7334 100644 --- a/config/plugins/webhooks/demo/tour_generator/script.js +++ b/config/plugins/webhooks/demo/tour_generator/script.js @@ -335,7 +335,7 @@ var r=arguments[3];Object.defineProperty(exports,"__esModule",{value:!0}),export },{"./index-default.js":"HxwB","./index.js":"lIGW"}],"kFNo":[function(require,module,exports) { var global = arguments[3]; var define; -var t,e=arguments[3];!function(i){var n="object"==typeof self&&self.self===self&&self||"object"==typeof e&&e.global===e&&e;if("function"==typeof t&&t.amd)t(["underscore","jquery","exports"],function(t,e,s){n.Backbone=i(n,s,t,e)});else if("undefined"!=typeof exports){var s,r=require("underscore");try{s=require("jquery")}catch(o){}i(n,exports,r,s)}else n.Backbone=i(n,{},n._,n.jQuery||n.Zepto||n.ender||n.$)}(function(t,e,i,n){var s=t.Backbone,r=Array.prototype.slice;e.VERSION="1.4.0",e.$=n,e.noConflict=function(){return t.Backbone=s,this},e.emulateHTTP=!1,e.emulateJSON=!1;var o,a=e.Events={},h=/\s+/,u=function(t,e,n,s,r){var o,a=0;if(n&&"object"==typeof n){void 0!==s&&"context"in r&&void 0===r.context&&(r.context=s);for(o=i.keys(n);athis.length&&(s=this.length),s<0&&(s+=this.length+1);var r,o,a=[],h=[],u=[],c=[],l={},d=e.add,f=e.merge,p=e.remove,g=!1,v=this.comparator&&null==s&&!1!==e.sort,m=i.isString(this.comparator)?this.comparator:null;for(o=0;o7),this._useHashChange=this._wantsHashChange&&this._hasHashChange,this._wantsPushState=!!this.options.pushState,this._hasPushState=!(!this.history||!this.history.pushState),this._usePushState=this._wantsPushState&&this._hasPushState,this.fragment=this.getFragment(),this.root=("/"+this.root+"/").replace(F,"/"),this._wantsHashChange&&this._wantsPushState){if(!this._hasPushState&&!this.atRoot()){var e=this.root.slice(0,-1)||"/";return this.location.replace(e+"#"+this.getPath()),!0}this._hasPushState&&this.atRoot()&&this.navigate(this.getHash(),{replace:!0})}if(!this._hasHashChange&&this._wantsHashChange&&!this._usePushState){this.iframe=document.createElement("iframe"),this.iframe.src="javascript:0",this.iframe.style.display="none",this.iframe.tabIndex=-1;var n=document.body,s=n.insertBefore(this.iframe,n.firstChild).contentWindow;s.document.open(),s.document.close(),s.location.hash="#"+this.fragment}var r=window.addEventListener||function(t,e){return attachEvent("on"+t,e)};if(this._usePushState?r("popstate",this.checkUrl,!1):this._useHashChange&&!this.iframe?r("hashchange",this.checkUrl,!1):this._wantsHashChange&&(this._checkUrlInterval=setInterval(this.checkUrl,this.interval)),!this.options.silent)return this.loadUrl()},stop:function(){var t=window.removeEventListener||function(t,e){return detachEvent("on"+t,e)};this._usePushState?t("popstate",this.checkUrl,!1):this._useHashChange&&!this.iframe&&t("hashchange",this.checkUrl,!1),this.iframe&&(document.body.removeChild(this.iframe),this.iframe=null),this._checkUrlInterval&&clearInterval(this._checkUrlInterval),z.started=!1},route:function(t,e){this.handlers.unshift({route:t,callback:e})},checkUrl:function(t){var e=this.getFragment();if(e===this.fragment&&this.iframe&&(e=this.getHash(this.iframe.contentWindow)),e===this.fragment)return!1;this.iframe&&this.navigate(e),this.loadUrl()},loadUrl:function(t){return!!this.matchRoot()&&(t=this.fragment=this.getFragment(t),i.some(this.handlers,function(e){if(e.route.test(t))return e.callback(t),!0}))},navigate:function(t,e){if(!z.started)return!1;e&&!0!==e||(e={trigger:!!e}),t=this.getFragment(t||"");var i=this.root;""!==t&&"?"!==t.charAt(0)||(i=i.slice(0,-1)||"/");var n=i+t;t=t.replace(B,"");var s=this.decodeFragment(t);if(this.fragment!==s){if(this.fragment=s,this._usePushState)this.history[e.replace?"replaceState":"pushState"]({},document.title,n);else{if(!this._wantsHashChange)return this.location.assign(n);if(this._updateHash(this.location,t,e.replace),this.iframe&&t!==this.getHash(this.iframe.contentWindow)){var r=this.iframe.contentWindow;e.replace||(r.document.open(),r.document.close()),this._updateHash(r.location,t,e.replace)}}return e.trigger?this.loadUrl(t):void 0}},_updateHash:function(t,e,i){if(i){var n=t.href.replace(/(javascript:|#).*$/,"");t.replace(n+"#"+e)}else t.hash="#"+e}}),e.history=new z;m.extend=_.extend=M.extend=T.extend=z.extend=function(t,e){var n,s=this;return n=t&&i.has(t,"constructor")?t.constructor:function(){return s.apply(this,arguments)},i.extend(n,s,e),n.prototype=i.create(s.prototype,t),n.prototype.constructor=n,n.__super__=s.prototype,n};var J=function(){throw new Error('A "url" property or function must be specified')},L=function(t,e){var i=e.error;e.error=function(n){i&&i.call(e.context,t,n,e),t.trigger("error",t,n,e)}};return e}); +var t,e=arguments[3];!function(i){var n="object"==typeof self&&self.self===self&&self||"object"==typeof e&&e.global===e&&e;if("function"==typeof t&&t.amd)t(["underscore","jquery","exports"],function(t,e,s){n.Backbone=i(n,s,t,e)});else if("undefined"!=typeof exports){var s,r=require("underscore");try{s=require("jquery")}catch(o){}i(n,exports,r,s)}else n.Backbone=i(n,{},n._,n.jQuery||n.Zepto||n.ender||n.$)}(function(t,e,i,n){var s=t.Backbone,r=Array.prototype.slice;e.VERSION="1.4.1",e.$=n,e.noConflict=function(){return t.Backbone=s,this},e.emulateHTTP=!1,e.emulateJSON=!1;var o,h=e.Events={},a=/\s+/,u=function(t,e,n,s,r){var o,h=0;if(n&&"object"==typeof n){void 0!==s&&"context"in r&&void 0===r.context&&(r.context=s);for(o=i.keys(n);hthis.length&&(s=this.length),s<0&&(s+=this.length+1);var r,o,h=[],a=[],u=[],c=[],l={},d=e.add,f=e.merge,p=e.remove,g=!1,v=this.comparator&&null==s&&!1!==e.sort,m=i.isString(this.comparator)?this.comparator:null;for(o=0;o7),this._useHashChange=this._wantsHashChange&&this._hasHashChange,this._wantsPushState=!!this.options.pushState,this._hasPushState=!(!this.history||!this.history.pushState),this._usePushState=this._wantsPushState&&this._hasPushState,this.fragment=this.getFragment(),this.root=("/"+this.root+"/").replace(F,"/"),this._wantsHashChange&&this._wantsPushState){if(!this._hasPushState&&!this.atRoot()){var e=this.root.slice(0,-1)||"/";return this.location.replace(e+"#"+this.getPath()),!0}this._hasPushState&&this.atRoot()&&this.navigate(this.getHash(),{replace:!0})}if(!this._hasHashChange&&this._wantsHashChange&&!this._usePushState){this.iframe=document.createElement("iframe"),this.iframe.src="javascript:0",this.iframe.style.display="none",this.iframe.tabIndex=-1;var n=document.body,s=n.insertBefore(this.iframe,n.firstChild).contentWindow;s.document.open(),s.document.close(),s.location.hash="#"+this.fragment}var r=window.addEventListener||function(t,e){return attachEvent("on"+t,e)};if(this._usePushState?r("popstate",this.checkUrl,!1):this._useHashChange&&!this.iframe?r("hashchange",this.checkUrl,!1):this._wantsHashChange&&(this._checkUrlInterval=setInterval(this.checkUrl,this.interval)),!this.options.silent)return this.loadUrl()},stop:function(){var t=window.removeEventListener||function(t,e){return detachEvent("on"+t,e)};this._usePushState?t("popstate",this.checkUrl,!1):this._useHashChange&&!this.iframe&&t("hashchange",this.checkUrl,!1),this.iframe&&(document.body.removeChild(this.iframe),this.iframe=null),this._checkUrlInterval&&clearInterval(this._checkUrlInterval),z.started=!1},route:function(t,e){this.handlers.unshift({route:t,callback:e})},checkUrl:function(t){var e=this.getFragment();if(e===this.fragment&&this.iframe&&(e=this.getHash(this.iframe.contentWindow)),e===this.fragment)return!1;this.iframe&&this.navigate(e),this.loadUrl()},loadUrl:function(t){return!!this.matchRoot()&&(t=this.fragment=this.getFragment(t),i.some(this.handlers,function(e){if(e.route.test(t))return e.callback(t),!0}))},navigate:function(t,e){if(!z.started)return!1;e&&!0!==e||(e={trigger:!!e}),t=this.getFragment(t||"");var i=this.root;""!==t&&"?"!==t.charAt(0)||(i=i.slice(0,-1)||"/");var n=i+t;t=t.replace(B,"");var s=this.decodeFragment(t);if(this.fragment!==s){if(this.fragment=s,this._usePushState)this.history[e.replace?"replaceState":"pushState"]({},document.title,n);else{if(!this._wantsHashChange)return this.location.assign(n);if(this._updateHash(this.location,t,e.replace),this.iframe&&t!==this.getHash(this.iframe.contentWindow)){var r=this.iframe.contentWindow;e.replace||(r.document.open(),r.document.close()),this._updateHash(r.location,t,e.replace)}}return e.trigger?this.loadUrl(t):void 0}},_updateHash:function(t,e,i){if(i){var n=t.href.replace(/(javascript:|#).*$/,"");t.replace(n+"#"+e)}else t.hash="#"+e}}),e.history=new z;m.extend=_.extend=M.extend=A.extend=z.extend=function(t,e){var n,s=this;return n=t&&i.has(t,"constructor")?t.constructor:function(){return s.apply(this,arguments)},i.extend(n,s,e),n.prototype=i.create(s.prototype,t),n.prototype.constructor=n,n.__super__=s.prototype,n};var J=function(){throw new Error('A "url" property or function must be specified')},L=function(t,e){var i=e.error;e.error=function(n){i&&i.call(e.context,t,n,e),t.trigger("error",t,n,e)}};return e}); },{"underscore":"XWoq","jquery":"HlZQ"}],"wXLC":[function(require,module,exports) { -"use strict";var e=n(require("toastr")),t=n(require("backbone")),r=n(require("underscore"));function o(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(o=function(e){return e?r:t})(e)}function n(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=o(t);if(r&&r.has(e))return r.get(e);var n={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if("default"!==i&&Object.prototype.hasOwnProperty.call(e,i)){var u=a?Object.getOwnPropertyDescriptor(e,i):null;u&&(u.get||u.set)?Object.defineProperty(n,i,u):n[i]=e[i]}return n.default=e,r&&r.set(e,n),n}window.TourGenerator=t.View.extend({initialize:function(t){var o=this;o.toolId=t.toolId,o.toolVersion=t.toolVersion;var n=window.bundleEntries.getGalaxyInstance();$("#execute").attr("tour_id","execute"),e.info("Tour generation might take some time."),$.getJSON("".concat(n.root,"api/webhooks/tour_generator/data/"),{tool_id:o.toolId,tool_version:o.toolVersion},function(t){t.success?t.data.useDatasets?(n.currHistoryPanel.refreshContents(),setTimeout(function(){var a=[],i=0;r.each(t.data.hids,function(e){var t=n.currHistoryPanel.collection.where({hid:e})[0];t&&a.push(t)}),a.length===t.data.hids.length?r.each(a,function(e){"ok"===e.get("state")?i++:e.on("change:state",function(e){"ok"===e.get("state")&&i++,i===a.length&&o._generateTour(t.data.tour)})}):(e.warning("Cannot generate a tour."),console.error("Some of the test datasets cannot be found in the history."))},1500)):o._generateTour(t.data.tour):(e.warning("Cannot generate a tour."),console.error("Tour Generator: "+t.error))})},_generateTour:function(e){var t=window.bundleEntries.getGalaxyInstance().giveTourWithData(e);$("#execute").on("mousedown",function(){t&&t.end()})}}); +"use strict";var e=o(require("toastr")),t=o(require("backbone")),n=o(require("underscore"));function r(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return(r=function(e){return e?n:t})(e)}function o(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var n=r(t);if(n&&n.has(e))return n.get(e);var o={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if("default"!==i&&Object.prototype.hasOwnProperty.call(e,i)){var u=a?Object.getOwnPropertyDescriptor(e,i):null;u&&(u.get||u.set)?Object.defineProperty(o,i,u):o[i]=e[i]}return o.default=e,n&&n.set(e,o),o}window.TourGenerator=t.View.extend({initialize:function(t){var n=this,r=window.bundleEntries.getGalaxyInstance(),o=t.toolId,a=t.toolVersion;$("#execute").attr("tour_id","execute"),e.info("Tour generation might take some time."),$.getJSON("".concat(r.root,"api/webhooks/tour_generator/data/"),{tool_id:o,tool_version:a},function(t){t.success?t.data.useDatasets?n._getData(t):n._generateTour(t.data.tour):(e.warning("Cannot generate a tour."),console.error("Tour Generator: "+t.error))})},_getData:function(t){var r=this,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:20,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1e3,i=[];n.each(t.data.hids,function(e){Galaxy.currHistoryPanel.collection.each(function(e){i.push(e)},"hid=".concat(e," state=ok"))}),i.length===t.data.hids.length?this._generateTour(t.data.tour):o>0?setTimeout(function(){r._getData(t,o-1)},a):(e.warning("Cannot generate a tour."),console.error("Some of the test datasets cannot be found in the history."))},_generateTour:function(e){var t=window.bundleEntries.getGalaxyInstance().giveTourWithData(e);$("#execute").on("mousedown",function(){t&&t.end()})}}); },{"toastr":"cfPU","backbone":"kFNo","underscore":"XWoq"}]},{},["wXLC"], null) \ No newline at end of file diff --git a/config/plugins/webhooks/demo/tour_generator/tour_generator.js b/config/plugins/webhooks/demo/tour_generator/tour_generator.js index cdad7a54821..d2d0f811f32 100644 --- a/config/plugins/webhooks/demo/tour_generator/tour_generator.js +++ b/config/plugins/webhooks/demo/tour_generator/tour_generator.js @@ -6,59 +6,23 @@ import * as _ from "underscore"; window.TourGenerator = Backbone.View.extend({ initialize: function (options) { - var me = this; - me.toolId = options.toolId; - me.toolVersion = options.toolVersion; - const Galaxy = window.bundleEntries.getGalaxyInstance(); - + const toolId = options.toolId; + const toolVersion = options.toolVersion; // Add attribute 'tour_id' to the execution button $("#execute").attr("tour_id", "execute"); - Toastr.info("Tour generation might take some time."); $.getJSON( - `${Galaxy.root}api/webhooks/tour_generator/data/`, - { - tool_id: me.toolId, - tool_version: me.toolVersion, + `${Galaxy.root}api/webhooks/tour_generator/data/`, { + tool_id: toolId, + tool_version: toolVersion, }, - function (obj) { + (obj) => { if (obj.success) { if (obj.data.useDatasets) { - Galaxy.currHistoryPanel.refreshContents(); // Refresh history panel - - // Add a delay because of the history panel refreshing - setTimeout(function () { - var datasets = [], - numUploadedDatasets = 0; - - _.each(obj.data.hids, function (hid) { - var dataset = Galaxy.currHistoryPanel.collection.where({ - hid: hid, - })[0]; - if (dataset) datasets.push(dataset); - }); - - if (datasets.length === obj.data.hids.length) { - _.each(datasets, function (dataset) { - if (dataset.get("state") === "ok") { - numUploadedDatasets++; - } else { - dataset.on("change:state", function (model) { - if (model.get("state") === "ok") numUploadedDatasets++; - // Make sure that all test datasets have been successfully uploaded - if (numUploadedDatasets === datasets.length) - me._generateTour(obj.data.tour); - }); - } - }); - } else { - Toastr.warning("Cannot generate a tour."); - console.error("Some of the test datasets cannot be found in the history."); - } - }, 1500); + this._getData(obj); } else { - me._generateTour(obj.data.tour); + this._generateTour(obj.data.tour); } } else { Toastr.warning("Cannot generate a tour."); @@ -67,12 +31,29 @@ window.TourGenerator = Backbone.View.extend({ } ); }, - + _getData: function(obj, attempts = 20, delay = 1000) { + let datasets = []; + _.each(obj.data.hids, (hid) => { + Galaxy.currHistoryPanel.collection.each((dataset) => { + datasets.push(dataset); + }, `hid=${hid} state=ok`); + }); + if (datasets.length === obj.data.hids.length) { + this._generateTour(obj.data.tour); + } else if (attempts > 0) { + setTimeout(() => { + this._getData(obj, attempts - 1); + }, delay); + } else { + Toastr.warning("Cannot generate a tour."); + console.error("Some of the test datasets cannot be found in the history."); + } + }, _generateTour: function (data) { - var Galaxy = window.bundleEntries.getGalaxyInstance(); - var tour = Galaxy.giveTourWithData(data); + const Galaxy = window.bundleEntries.getGalaxyInstance(); + const tour = Galaxy.giveTourWithData(data); // Force ending the tour when pressing the Execute button - $("#execute").on("mousedown", function () { + $("#execute").on("mousedown", () => { if (tour) { tour.end(); } diff --git a/lib/galaxy_test/selenium/test_tool_describing_tours.py b/lib/galaxy_test/selenium/test_tool_describing_tours.py index b6e33bcd51b..7fdee274cdd 100644 --- a/lib/galaxy_test/selenium/test_tool_describing_tours.py +++ b/lib/galaxy_test/selenium/test_tool_describing_tours.py @@ -34,11 +34,8 @@ class ToolDescribingToursTestCase(SeleniumTestCase): def test_generate_tour_with_data(self): """Ensure a tour with data populates history.""" self._ensure_tdt_available() - self.use_legacy_history() self.tool_open("md5sum") - self.tool_form_generate_tour() - self.history_panel_wait_for_hid_ok(1) popover_component = self.components.tour.popover._ @@ -49,7 +46,6 @@ class ToolDescribingToursTestCase(SeleniumTestCase): self.screenshot("tool_describing_tour_0_start") popover_component.next.wait_for_and_click() - self.sleep_for(self.wait_types.UX_RENDER) text = popover_component.content.wait_for_visible().text @@ -57,7 +53,6 @@ class ToolDescribingToursTestCase(SeleniumTestCase): self.screenshot("tool_describing_tour_1_select") popover_component.next.wait_for_and_click() - self.sleep_for(self.wait_types.UX_RENDER) title = popover_component.title.wait_for_visible().text From b4d11a042a568fb93b1b752b108c43ee89617d48 Mon Sep 17 00:00:00 2001 From: guerler Date: Mon, 18 Apr 2022 17:22:22 -0400 Subject: [PATCH 7/7] Remove use_legacy_history helper from sharing tests, thx @jmchilton --- lib/galaxy_test/selenium/test_history_sharing.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lib/galaxy_test/selenium/test_history_sharing.py b/lib/galaxy_test/selenium/test_history_sharing.py index 0803222b457..9116612316c 100644 --- a/lib/galaxy_test/selenium/test_history_sharing.py +++ b/lib/galaxy_test/selenium/test_history_sharing.py @@ -10,7 +10,6 @@ VALID_LOGIN_RETRIES = 3 class HistorySharingTestCase(SeleniumTestCase): @selenium_test def test_sharing_valid(self): - self.use_legacy_history() user1_email, user2_email, history_id = self.setup_two_users_with_one_shared_history() self.submit_login(user2_email, retries=VALID_LOGIN_RETRIES) response = self.api_get(f"histories/{history_id}", raw=True) @@ -18,7 +17,6 @@ class HistorySharingTestCase(SeleniumTestCase): @selenium_test def test_sharing_valid_by_id(self): - self.use_legacy_history() user1_email, user2_email, history_id = self.setup_two_users_with_one_shared_history(share_by_id=True) self.submit_login(user2_email, retries=VALID_LOGIN_RETRIES) response = self.api_get(f"histories/{history_id}", raw=True) @@ -26,7 +24,6 @@ class HistorySharingTestCase(SeleniumTestCase): @selenium_test def test_unsharing(self): - self.use_legacy_history() user1_email, user2_email, history_id = self.setup_two_users_with_one_shared_history() self.submit_login(user1_email, retries=VALID_LOGIN_RETRIES) self.home() @@ -62,7 +59,6 @@ class HistorySharingTestCase(SeleniumTestCase): @selenium_test def test_sharing_with_invalid_user(self): - self.use_legacy_history() user1_email = self._get_random_email() self.register(user1_email) self.share_history_with_user(user_email="invalid_user@test.com") @@ -70,7 +66,6 @@ class HistorySharingTestCase(SeleniumTestCase): @selenium_test def test_sharing_with_self(self): - self.use_legacy_history() user1_email = self._get_random_email() self.register(user1_email) self.share_history_with_user(user_email=user1_email)