Skip to content

Commit

Permalink
Merge branch 'feat/vadc_sprint23' into feat/currentTeamProjectValidation
Browse files Browse the repository at this point in the history
  • Loading branch information
jarvisraymond-uchicago authored Nov 21, 2023
2 parents e2d946a + d770619 commit 2c005ca
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
11 changes: 11 additions & 0 deletions src/Analysis/GWASResults/Utils/gwasWorkflowApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ const getDataFromUrl = async (
return response.json();
};

export const fetchGwasWorkflows = async () => {
const currentTeamProject = localStorage.getItem('teamProject');
const workflowsEndpoint = `${gwasWorkflowPath}workflows?team_projects=${currentTeamProject}`;
const response = await fetch(workflowsEndpoint, { headers });
if (!response.ok) {
const message = `An error has occured: ${response.status}`;
throw new Error(message);
}
return response.json();
};

export const fetchPresignedUrlForWorkflowArtifact = async (
workflowName,
workflowUid,
Expand Down
10 changes: 1 addition & 9 deletions src/Analysis/GWASResults/Views/Home/Home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,12 @@ import React from 'react';
import { Spin } from 'antd';
import { useQuery } from 'react-query';
import HomeTable from './HomeTable/HomeTable';
import { gwasWorkflowPath } from '../../../../localconf';
import LoadingErrorMessage from '../../../SharedUtils/LoadingErrorMessage/LoadingErrorMessage';
import ManageColumns from './ManageColumns/ManageColumns';
import { fetchGwasWorkflows } from '../../Utils/gwasWorkflowApi';

const Home = () => {
const refetchInterval = 5000;

async function fetchGwasWorkflows() {
const currentTeamProject = localStorage.getItem('teamProject');
const workflowsEndpoint = `${gwasWorkflowPath}workflows?team_projects=${currentTeamProject}`;
const getWorkflows = await fetch(workflowsEndpoint);
return getWorkflows.json();
}

const { data, status } = useQuery('workflows', fetchGwasWorkflows, {
refetchInterval,
});
Expand Down
9 changes: 8 additions & 1 deletion src/Analysis/GWASResults/Views/Home/Home.stories.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,14 @@ export const MockedError = MockTemplate.bind({});
MockedError.parameters = {
msw: {
handlers: [
rest.post('', (req, res, ctx) => res(ctx.delay(800), ctx.status(403))),
rest.get(
'http://:argowrapperpath/ga4gh/wes/v2/workflows',
(req, res, ctx) => {
const { argowrapperpath } = req.params;
console.log(argowrapperpath);
return res(ctx.delay(1000), ctx.status(500), ctx.json({"test":123}));
}
),
],
},
};
1 change: 1 addition & 0 deletions src/Analysis/GWASResults/Views/Home/Home.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ describe('Home component', () => {

it('should render the HomeTable component with data when test data is loaded', async () => {
jest.spyOn(window, 'fetch').mockResolvedValueOnce({
ok: true,
json: jest.fn().mockResolvedValueOnce(TableData),
});
render(testJSX());
Expand Down

0 comments on commit 2c005ca

Please sign in to comment.