Skip to content

Commit

Permalink
Merge pull request #18126 from guerler/workflow_run_warnings
Browse files Browse the repository at this point in the history
Revises handling of warnings in the workflow run form
  • Loading branch information
dannon authored May 14, 2024
2 parents f2b163b + 1b9ff32 commit f6de20c
Show file tree
Hide file tree
Showing 7 changed files with 218 additions and 196 deletions.
3 changes: 2 additions & 1 deletion client/src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,10 @@ export interface User extends QuotaUsageResponse {
}

export interface AnonymousUser {
id?: string;
isAnonymous: true;
username?: string;
is_admin?: false;
username?: string;
}

export type GenericUser = User | AnonymousUser;
Expand Down
4 changes: 3 additions & 1 deletion client/src/components/LoadingSpan.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<template>
<span>
<span :class="spinnerClasses" title="loading"></span>
<span v-if="!spinnerOnly" class="loading-message">{{ message }}.<span class="blinking">..</span></span>
<span v-if="!spinnerOnly" class="loading-message" data-description="loading message">
{{ message }}.<span class="blinking">..</span>
</span>
</span>
</template>
<script>
Expand Down
56 changes: 29 additions & 27 deletions client/src/components/Workflow/Run/WorkflowRun.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createTestingPinia } from "@pinia/testing";
import { createLocalVue, shallowMount } from "@vue/test-utils";
import { createLocalVue, mount } from "@vue/test-utils";
import flushPromises from "flush-promises";
import { PiniaVuePlugin } from "pinia";
import { watchForChange } from "tests/jest/helpers";

import { getRunData } from "./services";
import sampleRunData1 from "./testdata/run1.json";
Expand Down Expand Up @@ -35,37 +35,36 @@ describe("WorkflowRun.vue", () => {
const propsData = { workflowId: run1WorkflowId };
localVue = createLocalVue();
localVue.use(PiniaVuePlugin);
wrapper = shallowMount(WorkflowRun, {
wrapper = mount(WorkflowRun, {
propsData: propsData,
localVue,
pinia: createTestingPinia(),
});
});

it("loads run data from API and parses it into a WorkflowRunModel object", async () => {
// waits for vue to render wrapper
await localVue.nextTick();

expect(wrapper.vm.loading).toBe(true);
expect(wrapper.vm.error).toBeNull();
expect(wrapper.vm.model).toBeNull();
const loadingTag = "[data-description='loading message']";
expect(wrapper.find(loadingTag).exists()).toBeTruthy();
expect(wrapper.vm.workflowError).toBe("");
expect(wrapper.vm.workflowModel).toBeNull();

await watchForChange({ vm: wrapper.vm, propName: "loading" });
await flushPromises();
await wrapper.vm.$nextTick();

expect(wrapper.vm.error).toBeNull();
expect(wrapper.vm.loading).toBe(false);
expect(wrapper.find(loadingTag).exists()).toBeFalsy();
expect(wrapper.vm.simpleForm).toBe(false);
const model = wrapper.vm.model;
expect(model).not.toBeNull();
expect(model.workflowId).toBe(run1WorkflowId);
expect(model.name).toBe("Cool Test Workflow");
expect(model.historyId).toBe("8f7a155755f10e73");
expect(model.hasUpgradeMessages).toBe(false);
expect(model.hasStepVersionChanges).toBe(false);
expect(model.wpInputs.wf_param.label).toBe("wf_param");

const workflowModel = wrapper.vm.workflowModel;
expect(workflowModel).not.toBeNull();
expect(workflowModel.workflowId).toBe(run1WorkflowId);
expect(workflowModel.name).toBe("Cool Test Workflow");
expect(workflowModel.historyId).toBe("8f7a155755f10e73");
expect(workflowModel.hasUpgradeMessages).toBe(false);
expect(workflowModel.hasStepVersionChanges).toBe(false);
expect(workflowModel.wpInputs.wf_param.label).toBe("wf_param");
// all steps are expanded since data and parameter steps are expanded by default,
// the same is true for tools with unconnected data inputs.
model.steps.forEach((step) => {
workflowModel.steps.forEach((step) => {
expect(step.expanded).toBe(true);
});
});
Expand All @@ -75,17 +74,20 @@ describe("WorkflowRun.vue", () => {
await localVue.nextTick();

expect(wrapper.vm.loading).toBe(true);
expect(wrapper.vm.error).toBeNull();
expect(wrapper.vm.model).toBeNull();
expect(wrapper.vm.workflowError).toBe("");
expect(wrapper.vm.workflowModel).toBeNull();

await watchForChange({ vm: wrapper.vm, propName: "loading" });
await flushPromises();
await wrapper.vm.$nextTick();

expect(wrapper.vm.error).toBeNull();
expect(wrapper.vm.workflowError).toBe("");
expect(wrapper.vm.loading).toBe(false);
expect(wrapper.find("b-alert-stub").exists()).toBe(false);
expect(wrapper.find(".alert-danger").exists()).toBe(false);
wrapper.vm.handleSubmissionError("Some exception here");

await localVue.nextTick();

expect(wrapper.vm.submissionError).toBe("Some exception here");
expect(wrapper.find("b-alert-stub").attributes("variant")).toEqual("danger");
expect(wrapper.find(".alert-danger").exists()).toBe(true);
});
});
Loading

0 comments on commit f6de20c

Please sign in to comment.