-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(website): don't display the segment name if there is only one se…
…gment in the sequence viewer #803
- Loading branch information
1 parent
288a07b
commit c6f475f
Showing
3 changed files
with
261 additions
and
54 deletions.
There are no files selected for viewing
99 changes: 99 additions & 0 deletions
99
website/src/components/SequenceDetailsPage/SequenceContainer.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; | ||
import { render, screen, waitFor } from '@testing-library/react'; | ||
import React from 'react'; | ||
import { act } from 'react-dom/test-utils'; | ||
import { beforeEach, describe, expect, test, vi } from 'vitest'; | ||
|
||
import { SequencesContainer } from './SequencesContainer.tsx'; | ||
import { mockRequest, testConfig, testOrganism } from '../../../vitest.setup.ts'; | ||
|
||
vi.mock('../../config', () => ({ | ||
getLapisUrl: vi.fn().mockReturnValue('http://lapis.dummy'), | ||
})); | ||
|
||
const queryClient = new QueryClient(); | ||
const accessionVersion = 'accession'; | ||
|
||
function renderSequenceViewer({ | ||
nucleotideSegmentNames, | ||
genes, | ||
}: Pick<React.ComponentProps<typeof SequencesContainer>, 'nucleotideSegmentNames' | 'genes'>) { | ||
render( | ||
<QueryClientProvider client={queryClient}> | ||
<SequencesContainer | ||
organism={testOrganism} | ||
accessionVersion={accessionVersion} | ||
clientConfig={testConfig.public} | ||
genes={genes} | ||
nucleotideSegmentNames={nucleotideSegmentNames} | ||
/> | ||
</QueryClientProvider>, | ||
); | ||
} | ||
|
||
const multiSegmentName = 'main2'; | ||
|
||
const singleSegmentSequence = 'SingleSegmentSequence'; | ||
const multiSegmentSequence = 'MultiSegmentSequence'; | ||
const unalignedSingleSegmentSequence = 'UnalignedSingleSegmentSequence'; | ||
const unalignedMultiSegmentSequence = 'UnalignedMultiSegmentSequence'; | ||
|
||
describe('SequencesContainer', () => { | ||
beforeEach(() => { | ||
mockRequest.lapis.alignedNucleotideSequences(200, `>some\n${singleSegmentSequence}`); | ||
mockRequest.lapis.alignedNucleotideSequencesMultiSegment( | ||
200, | ||
`>some\n${multiSegmentSequence}`, | ||
multiSegmentName, | ||
); | ||
mockRequest.lapis.unalignedNucleotideSequences(200, `>some\n${unalignedSingleSegmentSequence}`); | ||
mockRequest.lapis.unalignedNucleotideSequencesMultiSegment(200, '', 'main'); | ||
mockRequest.lapis.unalignedNucleotideSequencesMultiSegment( | ||
200, | ||
`>some\n${unalignedMultiSegmentSequence}`, | ||
multiSegmentName, | ||
); | ||
}); | ||
|
||
test('should render single segmented sequence', async () => { | ||
renderSequenceViewer({ | ||
nucleotideSegmentNames: ['main'], | ||
genes: [], | ||
}); | ||
|
||
click('Load sequences'); | ||
|
||
click('Aligned'); | ||
await waitFor(() => { | ||
expect(screen.getByText(singleSegmentSequence)).toBeVisible(); | ||
}); | ||
|
||
click('Sequence'); | ||
await waitFor(() => { | ||
expect(screen.getByText("LAPIS v2 doesn't support unaligned nucleotide sequences yet")).toBeVisible(); | ||
}); | ||
}); | ||
|
||
test('should render multi segmented sequence', async () => { | ||
renderSequenceViewer({ | ||
nucleotideSegmentNames: ['main', multiSegmentName], | ||
genes: [], | ||
}); | ||
|
||
click('Load sequences'); | ||
|
||
click(`${multiSegmentName} (aligned)`); | ||
await waitFor(() => { | ||
expect(screen.getByText(multiSegmentSequence)).toBeVisible(); | ||
}); | ||
|
||
click(`${multiSegmentName} (unaligned)`); | ||
await waitFor(() => { | ||
expect(screen.getByText("LAPIS v2 doesn't support unaligned nucleotide sequences yet")).toBeVisible(); | ||
}); | ||
}); | ||
|
||
function click(name: string) { | ||
act(() => screen.getByRole('button', { name }).click()); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters