Fix view not taking into account download status
The variant analysis view would allow expanding the results when the repo task was completed. However, it did not take into account whether the results were actually downloaded. This will that by usign the download status when the repo task was succeeded and sending the repo states to the view on load.
This commit is contained in:
@@ -129,6 +129,10 @@ export class VariantAnalysisManager extends DisposableObject implements VariantA
|
||||
return this.variantAnalyses.get(variantAnalysisId);
|
||||
}
|
||||
|
||||
public async getRepoStates(variantAnalysisId: number): Promise<VariantAnalysisScannedRepositoryState[]> {
|
||||
return Object.values(this.repoStates.get(variantAnalysisId) ?? {});
|
||||
}
|
||||
|
||||
public get variantAnalysesSize(): number {
|
||||
return this.variantAnalyses.size;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { VariantAnalysis } from './shared/variant-analysis';
|
||||
import { VariantAnalysis, VariantAnalysisScannedRepositoryState } from './shared/variant-analysis';
|
||||
|
||||
export interface VariantAnalysisViewInterface {
|
||||
variantAnalysisId: number;
|
||||
@@ -10,4 +10,5 @@ export interface VariantAnalysisViewManager<T extends VariantAnalysisViewInterfa
|
||||
unregisterView(view: T): void;
|
||||
|
||||
getVariantAnalysis(variantAnalysisId: number): Promise<VariantAnalysis | undefined>;
|
||||
getRepoStates(variantAnalysisId: number): Promise<VariantAnalysisScannedRepositoryState[]>;
|
||||
}
|
||||
|
||||
@@ -117,6 +117,16 @@ export class VariantAnalysisView extends AbstractWebview<ToVariantAnalysisMessag
|
||||
t: 'setVariantAnalysis',
|
||||
variantAnalysis,
|
||||
});
|
||||
|
||||
const repoStates = await this.manager.getRepoStates(this.variantAnalysisId);
|
||||
if (repoStates.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
await this.postMessage({
|
||||
t: 'setRepoStates',
|
||||
repoStates,
|
||||
});
|
||||
}
|
||||
|
||||
private async openQueryFile(): Promise<void> {
|
||||
|
||||
@@ -111,7 +111,7 @@ export const RepoRow = ({
|
||||
}
|
||||
}, [resultsLoaded, resultsLoading]);
|
||||
|
||||
const disabled = !status || !isCompletedAnalysisRepoStatus(status);
|
||||
const disabled = !status || !isCompletedAnalysisRepoStatus(status) || (status === VariantAnalysisRepoStatus.Succeeded && downloadStatus !== VariantAnalysisScannedRepositoryDownloadStatus.Succeeded);
|
||||
const expandableContentLoaded = status && (status !== VariantAnalysisRepoStatus.Succeeded || resultsLoaded);
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import * as React from 'react';
|
||||
import { render as reactRender, screen } from '@testing-library/react';
|
||||
import { VariantAnalysisRepoStatus } from '../../../remote-queries/shared/variant-analysis';
|
||||
import {
|
||||
VariantAnalysisRepoStatus,
|
||||
VariantAnalysisScannedRepositoryDownloadStatus
|
||||
} from '../../../remote-queries/shared/variant-analysis';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { RepoRow, RepoRowProps } from '../RepoRow';
|
||||
|
||||
@@ -48,7 +51,7 @@ describe(RepoRow.name, () => {
|
||||
})).toBeDisabled();
|
||||
});
|
||||
|
||||
it('renders the succeeded state', () => {
|
||||
it('renders the succeeded state without download status', () => {
|
||||
render({
|
||||
status: VariantAnalysisRepoStatus.Succeeded,
|
||||
resultCount: 178,
|
||||
@@ -58,6 +61,42 @@ describe(RepoRow.name, () => {
|
||||
name: 'Success',
|
||||
})).toBeInTheDocument();
|
||||
expect(screen.getByText('178')).toBeInTheDocument();
|
||||
expect(screen.getByRole<HTMLButtonElement>('button', {
|
||||
expanded: false
|
||||
})).toBeDisabled();
|
||||
});
|
||||
|
||||
it('renders the succeeded state with pending download status', () => {
|
||||
render({
|
||||
status: VariantAnalysisRepoStatus.Succeeded,
|
||||
resultCount: 178,
|
||||
downloadStatus: VariantAnalysisScannedRepositoryDownloadStatus.Pending,
|
||||
});
|
||||
|
||||
expect(screen.getByRole<HTMLButtonElement>('button', {
|
||||
expanded: false
|
||||
})).toBeDisabled();
|
||||
});
|
||||
|
||||
it('renders the succeeded state with in progress download status', () => {
|
||||
render({
|
||||
status: VariantAnalysisRepoStatus.Succeeded,
|
||||
resultCount: 178,
|
||||
downloadStatus: VariantAnalysisScannedRepositoryDownloadStatus.InProgress,
|
||||
});
|
||||
|
||||
expect(screen.getByRole<HTMLButtonElement>('button', {
|
||||
expanded: false
|
||||
})).toBeDisabled();
|
||||
});
|
||||
|
||||
it('renders the succeeded state with succeeded download status', () => {
|
||||
render({
|
||||
status: VariantAnalysisRepoStatus.Succeeded,
|
||||
resultCount: 178,
|
||||
downloadStatus: VariantAnalysisScannedRepositoryDownloadStatus.Succeeded,
|
||||
});
|
||||
|
||||
expect(screen.getByRole<HTMLButtonElement>('button', {
|
||||
expanded: false
|
||||
})).toBeEnabled();
|
||||
@@ -167,6 +206,7 @@ describe(RepoRow.name, () => {
|
||||
it('can expand the repo item when succeeded and loaded', async () => {
|
||||
render({
|
||||
status: VariantAnalysisRepoStatus.Succeeded,
|
||||
downloadStatus: VariantAnalysisScannedRepositoryDownloadStatus.Succeeded,
|
||||
interpretedResults: [],
|
||||
});
|
||||
|
||||
@@ -182,6 +222,7 @@ describe(RepoRow.name, () => {
|
||||
it('can expand the repo item when succeeded and not loaded', async () => {
|
||||
const { rerender } = render({
|
||||
status: VariantAnalysisRepoStatus.Succeeded,
|
||||
downloadStatus: VariantAnalysisScannedRepositoryDownloadStatus.Succeeded,
|
||||
});
|
||||
|
||||
await userEvent.click(screen.getByRole('button', {
|
||||
|
||||
@@ -4,6 +4,7 @@ import userEvent from '@testing-library/user-event';
|
||||
import {
|
||||
VariantAnalysisQueryLanguage,
|
||||
VariantAnalysisRepoStatus,
|
||||
VariantAnalysisScannedRepositoryDownloadStatus,
|
||||
VariantAnalysisStatus
|
||||
} from '../../../remote-queries/shared/variant-analysis';
|
||||
import { VariantAnalysisAnalyzedRepos, VariantAnalysisAnalyzedReposProps } from '../VariantAnalysisAnalyzedRepos';
|
||||
@@ -80,6 +81,12 @@ describe(VariantAnalysisAnalyzedRepos.name, () => {
|
||||
|
||||
it('renders the interpreted result for a succeeded repo', async () => {
|
||||
render({
|
||||
repositoryStates: [
|
||||
{
|
||||
repositoryId: 2,
|
||||
downloadStatus: VariantAnalysisScannedRepositoryDownloadStatus.Succeeded,
|
||||
}
|
||||
],
|
||||
repositoryResults: [
|
||||
{
|
||||
variantAnalysisId: 1,
|
||||
|
||||
Reference in New Issue
Block a user