Skip to content

Commit

Permalink
Merge pull request #17804 from itisAliRH/dataset-information-refactors
Browse files Browse the repository at this point in the history
Dataset information refactors
  • Loading branch information
dannon authored Apr 15, 2024
2 parents 5d6db06 + 9c9bf57 commit 7344b1d
Show file tree
Hide file tree
Showing 23 changed files with 1,123 additions and 891 deletions.
7 changes: 7 additions & 0 deletions client/src/api/datasets.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import axios from "axios";
import type { FetchArgType } from "openapi-typescript-fetch";

import { HDADetailed } from "@/api";
Expand Down Expand Up @@ -88,3 +89,9 @@ export function getCompositeDatasetLink(historyDatasetId: string, path: string)

export type DatasetExtraFiles = components["schemas"]["DatasetExtraFiles"];
export const fetchDatasetExtraFiles = fetcher.path("/api/datasets/{dataset_id}/extra_files").method("get").create();

export async function fetchDatasetAttributes(datasetId: string) {
const { data } = await axios.get(withPrefix(`/dataset/get_edit?dataset_id=${datasetId}`));

return data;
}
7 changes: 7 additions & 0 deletions client/src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,3 +235,10 @@ export function userOwnsHistory(user: User | AnonymousUser | null, history: AnyH
function hasOwner(history: AnyHistory): history is HistorySummaryExtended {
return "user_id" in history && history.user_id !== null;
}

export type DatasetHash = components["schemas"]["DatasetHash"];

export type DatasetTransform = {
action: "to_posix_lines" | "spaces_to_tabs" | "datatype_groom";
datatype_ext: "bam" | "qname_sorted.bam" | "qname_input_sorted.bam" | "isa-tab" | "isa-json";
};
9 changes: 8 additions & 1 deletion client/src/api/jobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,11 @@ export const fetchJobDestinationParams = fetcher.path("/api/jobs/{job_id}/destin

export const jobsFetcher = fetcher.path("/api/jobs").method("get").create();

export const jobsReportError = fetcher.path("/api/jobs/{job_id}/error").method("post").create();
export type ShowFullJobResponse = components["schemas"]["ShowFullJobResponse"];
export type JobDetails = components["schemas"]["ShowFullJobResponse"] | components["schemas"]["EncodedJobDetails"];
export const fetchJobDetails = fetcher.path("/api/jobs/{job_id}").method("get").create();

export type JobInputSummary = components["schemas"]["JobInputSummary"];
export const fetchJobCommonProblems = fetcher.path("/api/jobs/{job_id}/common_problems").method("get").create();

export const postJobErrorReport = fetcher.path("/api/jobs/{job_id}/error").method("post").create();
Original file line number Diff line number Diff line change
@@ -1,58 +1,68 @@
import { createTestingPinia } from "@pinia/testing";
import { getLocalVue } from "@tests/jest/helpers";
import { mount } from "@vue/test-utils";
import axios from "axios";
import MockAdapter from "axios-mock-adapter";
import flushPromises from "flush-promises";
import { getLocalVue } from "tests/jest/helpers";
import { setActivePinia } from "pinia";

import MockProvider from "../providers/MockProvider";
import DatasetAttributes from "./DatasetAttributes";
import DatasetAttributes from "./DatasetAttributes.vue";

const DATASET_ID = "dataset_id";

const localVue = getLocalVue();

async function buildWrapper(conversion_disable = false) {
const wrapper = mount(DatasetAttributes, {
async function mountDatasetAttributes(conversion_disable = false) {
const pinia = createTestingPinia();
setActivePinia(pinia);

const axiosMock = new MockAdapter(axios);
axiosMock.onPut(`/dataset/set_edit`).reply(200, { message: "success", status: "success" });
axiosMock.onGet(`/dataset/get_edit?dataset_id=${DATASET_ID}`).reply(200, {
attribute_inputs: [{ name: "attribute_text", type: "text" }],
conversion_inputs: [{ name: "conversion_text", type: "text" }],
conversion_disable: conversion_disable,
datatype_inputs: [{ name: "datatype_text", type: "text" }],
permission_inputs: [{ name: "permission_text", type: "text" }],
});

const wrapper = mount(DatasetAttributes as object, {
propsData: {
datasetId: "dataset_id",
datasetId: DATASET_ID,
},
localVue,
stubs: {
DatasetAttributesProvider: MockProvider({
result: {
attribute_inputs: [{ name: "attribute_text", type: "text" }],
conversion_inputs: [{ name: "conversion_text", type: "text" }],
conversion_disable: conversion_disable,
datatype_inputs: [{ name: "datatype_text", type: "text" }],
permission_inputs: [{ name: "permission_text", type: "text" }],
},
}),
FontAwesomeIcon: false,
FormElement: false,
},
pinia,
});

await flushPromises();

return wrapper;
}

describe("DatasetAttributes", () => {
it("check rendering", async () => {
const axiosMock = new MockAdapter(axios);
axiosMock.onPut(`/dataset/set_edit`).reply(200, { message: "success", status: "success" });
const wrapper = await buildWrapper();
const wrapper = await mountDatasetAttributes();

expect(wrapper.findAll("button").length).toBe(6);
expect(wrapper.findAll("#attribute_text").length).toBe(1);
expect(wrapper.findAll("#conversion_text").length).toBe(1);
expect(wrapper.findAll("#datatype_text").length).toBe(1);
expect(wrapper.findAll("#permission_text").length).toBe(1);
expect(wrapper.findAll(".tab-pane").length).toBe(3);
expect(wrapper.findAll(".ui-portlet-section").length).toBe(2);
const $button = wrapper.find("#dataset-attributes-default-save");
await $button.trigger("click");

const saveButton = wrapper.find("#dataset-attributes-default-save");

await saveButton.trigger("click");

await flushPromises();

expect(wrapper.find("[role=alert]").text()).toBe("success");
});

it("check rendering without conversion option", async () => {
const wrapper = await buildWrapper(true);
const wrapper = await mountDatasetAttributes(true);

expect(wrapper.findAll("button").length).toBe(5);
expect(wrapper.findAll("#attribute_text").length).toBe(1);
expect(wrapper.findAll("#conversion_text").length).toBe(0);
Expand Down
Loading

0 comments on commit 7344b1d

Please sign in to comment.