Fix tests for history revision

This commit is contained in:
guerler
2022-02-10 11:58:39 -05:00
parent 178492bb38
commit bed31a9f8f
13 changed files with 33 additions and 40 deletions
@@ -10,6 +10,7 @@ either through the props, and make updates through the events -->
class="dataset history-content"
:id="typeId"
:class="{ expanded, collapsed, selected }"
:data-hid="dataset.hid"
:data-state="dataset.state"
@keydown.arrow-left.self.stop="$emit('update:expanded', false)"
@keydown.arrow-right.self.stop="$emit('update:expanded', true)"
@@ -6,6 +6,7 @@
class="dataset dataset-collection collapsed"
:class="{ selected }"
:id="typedId"
:data-hid="dsc.hid"
:data-state="dsc.state"
@keydown.arrow-right.self.stop="$emit('viewCollection')"
@keydown.space.self.stop.prevent="$emit('update:selected', !selected)">
@@ -44,7 +44,7 @@ export default {
this.$emit("update:expand", val);
},
async loadDetails() {
await getContentDetails(this.item);
const loadedDataset = await getContentDetails(this.item);
this.localItem = loadedDataset;
},
},
@@ -4,6 +4,7 @@
<b-button-group>
<IconButton
title="Select Items"
class="show-history-content-selectors-btn"
icon="check-square"
:disabled="!hasMatches"
:pressed="showSelection"
@@ -280,11 +281,12 @@ export default {
},
async buildNewCollection(collectionTypeCode) {
const modalResult = await buildCollectionModal(collectionTypeCode, this.history.id, this.contentSelection);
const newCollection = await createDatasetCollection(this.history, modalResult);
await createDatasetCollection(this.history, modalResult);
// have to hide the source items if that was requested
if (modalResult.hide_source_items) {
this.$emit("resetSelection");
this.$emit("hide-selection", this.contentSelection);
this.$emit("reset-selection");
}
},
},
@@ -1,7 +1,7 @@
<!-- When a dataset collection is being viewed, this panel shows the contents of that collection -->
<template>
<UrlDataProvider v-if="dsc" :url="getUrl(selectedCollection)" :auto-refresh="false" v-slot="{ result: payload }">
<UrlDataProvider v-if="dsc" :url="getUrl(selectedCollection)" v-slot="{ result: payload }">
<ExpandedItems
:scope-key="selectedCollection.id"
:get-item-key="(item) => item.element_index"
@@ -54,7 +54,7 @@ import { updateContentFields } from "../model/queries";
import ExpandedItems from "../ExpandedItems";
import Layout from "../Layout";
import TopNav from "./TopNav";
import CollectionOperations from "./CollectionOperations.vue";
import CollectionOperations from "./CollectionOperations";
import Details from "./Details";
import { CollectionContentItem } from "../ContentItem";
import HistoryListing from "components/History/HistoryListing";
+1 -1
View File
@@ -1,5 +1,5 @@
<template>
<UrlDataProvider :url="dataUrl" :auto-refresh="true" v-slot="{ loading, result: payload }">
<UrlDataProvider :url="dataUrl" auto-refresh v-slot="{ loading, result: payload }">
<ExpandedItems
:scope-key="history.id"
:get-item-key="(item) => item.type_id"
-4
View File
@@ -4,7 +4,3 @@ export { default as CurrentHistoryPanel } from "./CurrentHistoryPanel";
// Adapter: backbone view that mounts HistoryPanel
export { default as HistoryPanelProxy } from "./adapters/HistoryPanelProxy";
// rxjs debugging panel
// import { initSpy } from "utils/observable/rxjsDebugging";
// initSpy();
@@ -1,3 +1,6 @@
import axios from "axios";
import { getAppRoot } from "onload/loadConfig";
import { rethrowSimple } from "utils/simple-error";
import { SingleQueryProvider } from "components/providers/SingleQueryProvider";
async function getDatasetCollection({ id }) {
@@ -9,10 +9,8 @@ import { LastQueue } from "utils/promise-queue";
* whose properties are the attributes assigned to the provider component
* @return {VueComponentOptions} Vue component options definition
*/
const throttlePeriod = 100;
export const SingleQueryProvider = (lookup) => {
const promiseCache = new Map();
const queue = new LastQueue(throttlePeriod);
return {
props: {
useCache: {
@@ -25,7 +23,7 @@ export const SingleQueryProvider = (lookup) => {
},
autoTime: {
type: Number,
default: throttlePeriod,
default: 500,
},
},
data() {
@@ -34,6 +32,9 @@ export const SingleQueryProvider = (lookup) => {
error: null,
};
},
created() {
this.queue = new LastQueue(this.autoTime);
},
computed: {
loading() {
return this.result === null;
@@ -72,7 +73,7 @@ export const SingleQueryProvider = (lookup) => {
promiseCache.set(this.cacheKey, lookupPromise);
}
} else {
lookupPromise = queue.enqueue(lookup, this.$attrs);
lookupPromise = this.queue.enqueue(lookup, this.$attrs);
}
lookupPromise.then(
(result) => {
+2 -2
View File
@@ -11,7 +11,7 @@ export class LastQueue {
this.pendingPromise = false;
}
async enqueue(action, ...args) {
async enqueue(action, args) {
return new Promise((resolve, reject) => {
this.nextPromise = { action, args, resolve, reject };
this.dequeue();
@@ -24,7 +24,7 @@ export class LastQueue {
this.nextPromise = null;
this.pendingPromise = true;
try {
const payload = await item.action(...item.args);
const payload = await item.action(item.args);
item.resolve(payload);
} catch (e) {
item.reject(e);
@@ -185,19 +185,11 @@ class CollectionBuildersTestCase(SeleniumTestCase):
depending on how fast the upload goes compared to the history polling updates, it might just
skip to the end for a really fast upload
"""
if self.is_beta_history():
for hid in hids:
timeout = self.wait_length(self.wait_types.JOB_COMPLETION)
row_selector = self.content_item_by_attributes(hid=hid, state="ok")
row = self.wait_for_present(row_selector, timeout=timeout)
row.send_keys(" ")
else:
for hid in hids:
self.history_panel_wait_for_hid_ok(hid)
self.history_panel_multi_operations_show()
for hid in hids:
self.history_panel_muli_operation_select_hid(hid)
for hid in hids:
self.history_panel_wait_for_hid_ok(hid)
self.history_panel_multi_operations_show()
for hid in hids:
self.history_panel_muli_operation_select_hid(hid)
def _show_hidden_content(self):
"""Switches the beta hidden filter toggle on"""
@@ -58,12 +58,11 @@ class CollectionEditTestCase(SeleniumTestCase):
depending on how fast the upload goes compared to the history polling updates, it might just
skip to the end for a really fast upload
"""
for hid in hids:
timeout = self.wait_length(self.wait_types.JOB_COMPLETION)
row_selector = self.content_item_by_attributes(hid=hid, state="ok")
row = self.wait_for_present(row_selector, timeout=timeout)
row.send_keys(" ")
self.history_panel_wait_for_hid_ok(hid)
self.history_panel_multi_operations_show()
for hid in hids:
self.history_panel_muli_operation_select_hid(hid)
def _collection_dropdown(self, option_description):
return self.use_bootstrap_dropdown(option=option_description, menu="selected content menu")
@@ -36,11 +36,8 @@ class HistoryPanelCollectionsTestCase(SeleniumTestCase):
)
ok_hid = ok_response["implicit_collections"][0]["hid"]
if not self.is_beta_history():
# sleep really shouldn't be needed :(
time.sleep(1)
self.home()
# sleep really shouldn't be needed :(
self.home()
self.history_panel_wait_for_hid_state(input_hid, "ok")
self.history_panel_wait_for_hid_state(failed_hid, "error")
@@ -222,12 +219,13 @@ class HistoryPanelCollectionsTestCase(SeleniumTestCase):
if self.is_beta_history():
self.sleep_for(WAIT_TYPES.HISTORY_POLL)
dataset_elements = self.content_item_by_attributes().all()
dataset_elements = collection_view.list_items_beta.all()
else:
dataset_elements = collection_view.list_items.all()
assert len(dataset_elements) == 2, dataset_elements
titles = [de.find_element_by_css_selector(".title .name").text for de in dataset_elements]
titles.sort()
assert titles == ["forward", "reverse"]
self.screenshot("history_panel_collection_view_paired")