Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/app/AlignmentCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ interface CardModelExtra {
value: string;
onChange: ( value: string ) => void;
notAvailable: boolean;
hoverInfo: string;
hoverInfo?: string;
error: unknown;
}

Expand Down
6 changes: 3 additions & 3 deletions src/app/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type InputRun = PartitionFileCardProps['run'] & {
inputIsAlignment: boolean;
alignments: ( AlignmentCardProps['alignment'] & { path: string } )[];
inputIsTree: boolean;
astralTree: AstralTreeCardProps['astralTree'];
astralTree: AstralTreeCardProps['astralTree'] | null | undefined;
canLoadAlignment: boolean;
haveAlignments: boolean;
canLoadPartitionFile: boolean;
Expand All @@ -60,7 +60,7 @@ function droppedPath( file: File ): string {
}

const Input = ( { run }: InputProps ): React.JSX.Element => {
// run.hasAstralTree is the condition on which to show an astral tree card
// run.astralTree (hasAstralTree) is the condition on which to show an astral tree card
// For some reason when changed in the mobx store a rerender is not triggered with this boolean with the conditional below alone
// With this if the component rerenders as should be
if ( run.hasAstralTree ) {
Expand Down Expand Up @@ -143,7 +143,7 @@ const Input = ( { run }: InputProps ): React.JSX.Element => {
/>
) )
: null}
{run.inputIsTree && run.hasAstralTree
{run.inputIsTree && run.astralTree
? (
<AstralTreeCard astralTree={run.astralTree} />
)
Expand Down
6 changes: 3 additions & 3 deletions src/app/components/ErrorDialog.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ it( 'the reload action reloads the window', () => {
} );

const button = Array.from( document.body.querySelectorAll( 'button' ) )
.find( ( item ) => item.textContent === 'Ignore and reload' );
.find( ( item ) => item.textContent === 'Ignore and reload' )!;
act( () => {
button.click();
} );
Expand Down Expand Up @@ -55,7 +55,7 @@ function renderDialog( error: Error ) {
div,
button( label: string ) {
return Array.from( document.body.querySelectorAll<HTMLElement>( 'button, a' ) )
.find( ( item ) => item.textContent === label );
.find( ( item ) => item.textContent === label )!;
},
};
}
Expand Down Expand Up @@ -94,7 +94,7 @@ Locale: en-US`;
const url = new URL( openExternal.mock.calls[0][0] );
expect( `${url.origin}${url.pathname}` ).toBe( 'https://github.com/AntonelliLab/raxmlGUI/issues/new' );
expect( url.searchParams.get( 'title' ) ).toBe( 'Error: boom' );
const body = url.searchParams.get( 'body' );
const body = url.searchParams.get( 'body' )!;
expect( body.startsWith( 'Autogenerated report:' ) ).toBe( true );
expect( body ).toContain( 'boom' );
expect( body ).toContain( 'raxml -s primates.fasta' );
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/OptionCheck.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export interface OptionCheckOptionLike {
value: boolean;
setValue: ( value: boolean ) => void;
notAvailable: boolean;
hoverInfo: string;
hoverInfo?: string;
}

export interface OptionCheckProps {
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/OptionSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface OptionSelectChoice {
export interface OptionSelectOptionLike<Value extends string | number | readonly string[]> {
notAvailable?: boolean;
title: string;
hoverInfo: string;
hoverInfo?: string;
options: readonly OptionSelectChoice[];
value: Value;
setValue: ( value: Value ) => void;
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/OptionTextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export interface OptionTextFieldOptionLike {
value: string | number | boolean;
setValue: ( value: string ) => void;
notAvailable: boolean;
hoverInfo: string;
hoverInfo?: string;
haveError: boolean;
disabled?: boolean;
placeholder?: string;
Expand Down
10 changes: 5 additions & 5 deletions src/app/droppedFile.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ function mountInput( run: object ) {
}

function button( div: HTMLElement, text: string ) {
return Array.from( div.querySelectorAll( 'button' ) ).find( ( node ) => node.textContent.trim() === text );
return Array.from( div.querySelectorAll( 'button' ) ).find( ( node ) => node.textContent.trim() === text )!;
}

async function drop( target: Element, name: string ) {
const input = target.closest( '[role="presentation"]' ).querySelector( 'input[type="file"]' );
const input = target.closest( '[role="presentation"]' )!.querySelector( 'input[type="file"]' )!;
const file = new File( ['x'], name );
Object.defineProperty( input, 'files', {
configurable: true,
Expand All @@ -79,7 +79,7 @@ it( 'each drop target keeps the dropped file path', async () => {
'cats.fasta': '/tmp/drop-6',
'dogs.fasta': '/tmp/drop-7',
'genes.part': '/tmp/drop-8',
}[file.name];
}[file.name]!;
},
} );

Expand Down Expand Up @@ -109,7 +109,7 @@ it( 'each drop target keeps the dropped file path', async () => {
} );
const secondView = mountInput( second );
await drop(
secondView.div.querySelector( 'button[title="Concatenate new alignments and create partition"]' ),
secondView.div.querySelector( 'button[title="Concatenate new alignments and create partition"]' )!,
'cats.fasta',
);
expect( second.addAlignments ).toHaveBeenCalledWith( [{ path: '/tmp/drop-6' }] );
Expand All @@ -122,7 +122,7 @@ it( 'each drop target keeps the dropped file path', async () => {
} );
const thirdView = mountInput( third );
await drop(
thirdView.div.querySelector( 'button[title="Concatenate new alignments and automatically generate a partition"]' ),
thirdView.div.querySelector( 'button[title="Concatenate new alignments and automatically generate a partition"]' )!,
'dogs.fasta',
);
await drop( button( thirdView.div, 'Load partition' ), 'genes.part' );
Expand Down
2 changes: 1 addition & 1 deletion src/app/store/AlignmentOptions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function useOtherBinary( run: Run ) {
runInAction( () => {
run.binary.value = run.binary.options.find(
( o ) => !o.value.includes( 'raxml-ng' ),
).value;
)!.value;
} );
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/store/Part.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function makeAlignment(
if ( !ng ) {
run.binary.value = run.binary.options
.map( ( o ) => o.value )
.find( ( v ) => /raxml/i.test( v ) && !v.includes( 'raxml-ng' ) );
.find( ( v ) => /raxml/i.test( v ) && !v.includes( 'raxml-ng' ) )!;
}
// 'dna' is the dead case of #269; the store still maps it to DNA.
alignment.dataType = dataType as DataType;
Expand Down
12 changes: 7 additions & 5 deletions src/app/store/Run.computeds.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import type AstralTree from './AstralTree';
import Run from './Run';
import { analysisOptions, binaries } from './RunOptions';

const modeltestName = binaries.find( ( b ) => b.type === 'modeltest' ).name;
type RunParent = ConstructorParameters<typeof Run>[0];

const modeltestName = binaries.find( ( b ) => b.type === 'modeltest' )!.name;

let checkOutput: Mock<RendererBridge['checkOutput']>;
let stops: ( () => void )[] = [];
Expand All @@ -22,7 +24,7 @@ beforeEach( () => {
checkOutput = vi.fn<RendererBridge['checkOutput']>( async ( { outputName } ) => ( {
ok: true,
outputNameUnused: outputName,
resultFilenames: [],
resultFilenames: [] as string[],
} as CheckOutputResult ) );
installBridge( { checkOutput, getVersion: () => Promise.resolve( '2.0.0' ) } );
} );
Expand All @@ -49,7 +51,7 @@ const nucleotide = ( over: Record<string, unknown> = {} ): Alignment => ( {
} as unknown as Alignment );

function makeRun( { alignments = [nucleotide()], binary = 'raxmlHPC', outputDir = '/out' } = {} ) {
const run = new Run( null, 1 );
const run = new Run( {} as RunParent, 1 );
runInAction( () => {
run.binary.value = binary;
run.outputDir = outputDir;
Expand All @@ -62,7 +64,7 @@ function makeRun( { alignments = [nucleotide()], binary = 'raxmlHPC', outputDir

// outputNameAvailable only settles inside a reaction, so reads that touch it go through here.
function read<T>( fn: () => T ): T {
let value: T;
let value!: T;
autorun( () => {
value = fn();
} )();
Expand Down Expand Up @@ -219,7 +221,7 @@ describe( 'Run alignment computeds', () => {
describe( 'Run state computeds', () => {
it( 'missing asks for a tree only for an analysis that needs one', () => {
const run = makeRun( { binary: 'raxmlHPC' } );
const needsTree = analysisOptions.find( ( o ) => o.params.includes( 'tree' ) );
const needsTree = analysisOptions.find( ( o ) => o.params.includes( 'tree' ) )!;
run.analysis.setValue( 'FT' );
expect( run.missing ).toBe( '' );
run.analysis.setValue( needsTree.value );
Expand Down
14 changes: 8 additions & 6 deletions src/app/store/RunSimpleOptions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import type Alignment from './Alignment';
import Run from './Run';
import { binaries, MAX_NUM_CPUS } from './RunOptions';

const threaded = binaries.find( ( b ) => /PTHREADS/.test( b.name ) );
const plain = binaries.find( ( b ) => b.type === 'raxml' && !/PTHREADS|-ng/.test( b.name ) );
type RunParent = ConstructorParameters<typeof Run>[0];

const threaded = binaries.find( ( b ) => /PTHREADS/.test( b.name ) )!;
const plain = binaries.find( ( b ) => b.type === 'raxml' && !/PTHREADS|-ng/.test( b.name ) )!;

// Run.analysis is a computed that builds a new option on each evaluation, so an
// unobserved run forgets a set analysis value. A kept-alive reaction models the page.
Expand All @@ -15,7 +17,7 @@ afterEach( () => stops.splice( 0 ).forEach( ( stop ) => stop() ) );

// The initial binary is raxml-ng on some hosts; most tests start from classic RAxML.
const newRun = () => {
const run = new Run( null, 1 );
const run = new Run( {} as RunParent, 1 );
stops.push( autorun( () => run.analysis ) );
runInAction( () => {
run.binary.value = plain.name;
Expand All @@ -42,16 +44,16 @@ const addAlignment = ( run: Run, dataType: string ) => runInAction( () => {

describe( 'Binary', () => {
it( 'defaults to the initial binary and offers every binary', () => {
const run = new Run( null, 1 );
expect( run.binary.value ).toBe( binaries.find( ( b ) => b.initial ).name );
const run = new Run( {} as RunParent, 1 );
expect( run.binary.value ).toBe( binaries.find( ( b ) => b.initial )!.name );
expect( run.binary.options.map( ( o ) => o.value ) ).toEqual(
binaries.map( ( b ) => b.name ),
);
} );

it( 'derives version and type from the chosen binary and updates reactions', () => {
const run = newRun();
const modeltest = binaries.find( ( b ) => b.type === 'modeltest' );
const modeltest = binaries.find( ( b ) => b.type === 'modeltest' )!;
const { seen, stop } = track( () => [run.binary.version, run.binary.type] );
set( run.binary, modeltest.name );
stop();
Expand Down
20 changes: 10 additions & 10 deletions src/app/store/alignmentStore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ describe( 'Alignment observable fields update the page store', () => {
runInAction( () => {
run.binary.value = run.binary.options.find(
( { value } ) => !value.includes( 'raxml-ng' ),
).value;
)!.value;
} );
expect( run.usesRaxmlNg ).toBe( false );
const { seen, stop } = track( () => [
Expand All @@ -144,14 +144,14 @@ describe( 'Alignment observable fields update the page store', () => {
it( 'aaMatrixName updates partitionType and modelExtra, and onChangeAAMatrixName sets it', () => {
const { run, alignment } = setup();
set( run.binary, {
value: run.binary.options.find( ( { value } ) => !value.includes( 'raxml-ng' ) ).value,
value: run.binary.options.find( ( { value } ) => !value.includes( 'raxml-ng' ) )!.value,
} );
set( alignment, { dataType: 'protein' } );
const { seen, stop } = track( () => [
alignment.partitionType,
alignment.modelExtra?.value,
] );
alignment.modelExtra.onChange( 'WAG' );
alignment.modelExtra!.onChange( 'WAG' );
expect( alignment.aaMatrixName ).toBe( 'WAG' );
expect( seen[seen.length - 1] ).toEqual( ['WAG', 'WAG'] );
stop();
Expand All @@ -160,8 +160,8 @@ describe( 'Alignment observable fields update the page store', () => {
it( 'modelExtra is null for protein with raxml-ng', () => {
const { run, alignment } = setup();
set( alignment, { dataType: 'protein' } );
const ng = run.binary.options.find( ( { value } ) => value.includes( 'raxml-ng' ) );
const old = run.binary.options.find( ( { value } ) => !value.includes( 'raxml-ng' ) );
const ng = run.binary.options.find( ( { value } ) => value.includes( 'raxml-ng' ) )!;
const old = run.binary.options.find( ( { value } ) => !value.includes( 'raxml-ng' ) )!;
set( run.binary, { value: old.value } );
const { seen, stop } = track( () => alignment.modelExtra?.value );
set( run.binary, { value: ng.value } );
Expand All @@ -187,8 +187,8 @@ describe( 'Alignment observable fields update the page store', () => {
it( 'dataType, length and aaMatrixName update partitionFileContent', () => {
const { run, alignment } = setup();
set( alignment, { dataType: 'nucleotide', length: 10 } );
const ng = run.binary.options.find( ( { value } ) => value.includes( 'raxml-ng' ) );
const old = run.binary.options.find( ( { value } ) => !value.includes( 'raxml-ng' ) );
const ng = run.binary.options.find( ( { value } ) => value.includes( 'raxml-ng' ) )!;
const old = run.binary.options.find( ( { value } ) => !value.includes( 'raxml-ng' ) )!;
set( run.binary, { value: old.value } );
const { seen, stop } = track( () => alignment.partitionFileContent );
set( alignment, { length: 12 } );
Expand Down Expand Up @@ -239,7 +239,7 @@ describe( 'Alignment observable fields update the page store', () => {

it( 'hasInvariantSites updates ascertainment bias availability', () => {
const { run, alignment } = setup();
const ng = run.binary.options.find( ( { value } ) => value.includes( 'raxml-ng' ) );
const ng = run.binary.options.find( ( { value } ) => value.includes( 'raxml-ng' ) )!;
set( run.binary, { value: ng.value } );
const { seen, stop } = track( () => alignment.ngAscertainmentBias.notAvailable );
set( alignment, { hasInvariantSites: true } );
Expand Down Expand Up @@ -518,10 +518,10 @@ describe( 'Alignment model selection', () => {
it( 'dispose stops listening and cancels a running model selection', () => {
const { alignment } = setup();
set( alignment, { modeltestLoading: true } );
const before = listeners[runEvents.onModelSelectionSuccess].length;
const before = listeners[runEvents.onModelSelectionSuccess]!.length;
alignment.dispose();
expect( bridge.cancelModelSelection ).toHaveBeenCalledWith( alignment.id );
expect( listeners[runEvents.onModelSelectionSuccess].length ).toBe( before - 1 );
expect( listeners[runEvents.onModelSelectionSuccess]!.length ).toBe( before - 1 );
} );

it( 'remove disposes and removes the alignment from the run', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/app/store/astral.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function bridge( extra: Partial<RendererBridge> = {} ) {
stops.push( 'success' );
};
},
checkOutput: async () => ( { ok: true, resultFilenames: [] } as CheckOutputResult ),
checkOutput: async () => ( { ok: true, resultFilenames: [] as string[] } as CheckOutputResult ),
parseAlignment: () => new Promise( () => {} ),
...extra,
} );
Expand Down
6 changes: 3 additions & 3 deletions src/app/store/loadAstralTree.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ it( 'the ASTRAL file picker adds the chosen file', async () => {
await run.loadAstralTree();

expect( selectAstralFile ).toHaveBeenCalledWith( 7 );
expect( run.astralTree.path ).toBe( '/data/trees.tre' );
expect( run.astralTree!.path ).toBe( '/data/trees.tre' );
} );

it( 'cancel leaves the ASTRAL file unchanged', async () => {
Expand All @@ -30,7 +30,7 @@ it( 'cancel leaves the ASTRAL file unchanged', async () => {
await run.loadAstralTree();

expect( selectAstralFile ).toHaveBeenCalledWith( 7 );
expect( run.astralTree.path ).toBe( '/data/already.tre' );
expect( run.astralTree!.path ).toBe( '/data/already.tre' );
} );

it( 'a dialog failure fails the ASTRAL file choice', async () => {
Expand All @@ -43,5 +43,5 @@ it( 'a dialog failure fails the ASTRAL file choice', async () => {
} );

await expect( run.loadAstralTree() ).rejects.toThrow( 'dialog failed' );
expect( run.astralTree.path ).toBe( '/data/already.tre' );
expect( run.astralTree!.path ).toBe( '/data/already.tre' );
} );
2 changes: 1 addition & 1 deletion src/app/store/parseAlignment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,5 @@ it( 'a failed parse removes the alignment', async () => {
await pending.catch( () => {} );

expect( run.alignments ).toEqual( [] );
expect( run.error.message ).toBe( 'unrecognized format' );
expect( run.error!.message ).toBe( 'unrecognized format' );
} );
10 changes: 5 additions & 5 deletions src/app/store/runInputActions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const stayParsed = async (): Promise<AlignmentParseResult> => ( {
const checkOutput = vi.fn<RendererBridge['checkOutput']>( async ( { outputName } ) => ( {
ok: true,
outputNameUnused: outputName,
resultFilenames: [],
resultFilenames: [] as string[],
} as CheckOutputResult ) );

const flush = () => new Promise( ( resolve ) => setTimeout( resolve, 0 ) );
Expand Down Expand Up @@ -209,9 +209,9 @@ describe( 'ASTRAL tree', () => {
run.addAstralFiles( { path: '/data/second.tre' } );
dispose();

expect( run.astralTree.path ).toBe( '/data/trees.tre' );
expect( run.outputName ).toBe( run.astralTree.name );
expect( run.outputDir ).toBe( run.astralTree.dir );
expect( run.astralTree!.path ).toBe( '/data/trees.tre' );
expect( run.outputName ).toBe( run.astralTree!.name );
expect( run.outputDir ).toBe( run.astralTree!.dir );
expect( seen ).toEqual( [ false, true ] );
} );

Expand All @@ -229,7 +229,7 @@ describe( 'ASTRAL tree', () => {

describe( 'partition file', () => {
it( 'loadPartitionFile shows the path and content after the read resolves', async () => {
let finishRead: ( content: string ) => void;
let finishRead!: ( content: string ) => void;
const readFile = vi.fn<RendererBridge['readFile']>(
() => new Promise<string>( ( resolve ) => { finishRead = resolve; } ),
);
Expand Down
4 changes: 2 additions & 2 deletions src/app/store/runLifecycle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ describe( 'start', () => {
bridge.checkOutput = vi.fn( async () => ( {
ok: false,
outputNameUnused: 'primates_2',
resultFilenames: [],
resultFilenames: [] as string[],
} as CheckOutputResult ) );
const name = track( () => run.outputName );
const safe = track( () => run.outputNameSafe );
Expand Down Expand Up @@ -273,7 +273,7 @@ describe( 'cancel', () => {

it( 'stops a start that is still writing files from starting the run', async () => {
const { run } = makeRun();
let release: () => void;
let release!: () => void;
bridge.writeFile = vi.fn(
() => new Promise<void>( ( resolve ) => {
release = resolve;
Expand Down
Loading
Loading