Skip to content

Commit

Permalink
chore: refactoring tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gromdimon committed Dec 11, 2023
1 parent aa186c3 commit d2e8611
Show file tree
Hide file tree
Showing 38 changed files with 382 additions and 563 deletions.
2 changes: 1 addition & 1 deletion frontend/src/api/__tests__/acmgseqvar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'
import createFetchMock from 'vitest-fetch-mock'

import { AcmgSeqVarClient } from '@/api/acmgseqvar'
import { type AcmgRatingBackend } from '@/stores/variantAcmgRating'
import { type AcmgRatingBackend } from '@/stores/seqVarAcmgRating'

const fetchMocker = createFetchMock(vi)

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/api/acmgseqvar.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { API_V1_BASE_PREFIX } from '@/api/common'
import { type AcmgRatingBackend } from '@/stores/variantAcmgRating'
import { type AcmgRatingBackend } from '@/stores/seqVarAcmgRating'

/**
* Access to the seqvar part of the API.
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/assets/__tests__/BRCA1VariantInfo.json
Git LFS file not shown
4 changes: 2 additions & 2 deletions frontend/src/components/Profile/SeqVarsACMGCard.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<script setup lang="ts">
import { onMounted } from 'vue'
import { useVariantAcmgRatingStore } from '@/stores/variantAcmgRating'
import { useSeqVarAcmgRatingStore } from '@/stores/seqVarAcmgRating'
const acmgRatingStore = useVariantAcmgRatingStore()
const acmgRatingStore = useSeqVarAcmgRatingStore()
const getPresentCriterias = (criterias: any) =>
criterias.filter((criteria: any) => criteria.presence === 'Present')
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/SeqvarDetails/ClinsigCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
} from '@/lib/acmgSeqVar'
import { type Seqvar } from '@/lib/genomicVars'
import { StoreState } from '@/stores/misc'
import { useVariantAcmgRatingStore } from '@/stores/variantAcmgRating'
import { useSeqVarAcmgRatingStore } from '@/stores/seqVarAcmgRating'
/** Data type used for component's props. */
interface Props {
Expand All @@ -36,7 +36,7 @@ const emit = defineEmits<{
}>()
/** Store to use for ACMG ratings of sequence variants. */
const acmgRatingStore = useVariantAcmgRatingStore()
const acmgRatingStore = useSeqVarAcmgRatingStore()
/** Component state: error message to display, if any. */
const errorMessage = ref<string>('')
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/StrucvarDetails/ClinsigCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import CnLoss from '@/components/StrucvarDetails/ClinsigCard/CnLoss.vue'
import SummarySheet from '@/components/StrucvarDetails/ClinsigCard/SummarySheet.vue'
import type { Strucvar } from '@/lib/genomicVars'
import { StoreState } from '@/stores/misc'
import { useSvAcmgRatingStore } from '@/stores/svAcmgRating'
import { useStrucVarAcmgRatingStore } from '@/stores/strucVarAcmgRating'
/** Data type used for component's props. */
interface Props {
Expand All @@ -37,7 +37,7 @@ const emit = defineEmits<{
}>()
/** Store to use for ACMG ratings of structural variants. */
const acmgRatingStore = useSvAcmgRatingStore()
const acmgRatingStore = useStrucVarAcmgRatingStore()
/** Component state: whether display of conflicting sections is enabled. */
const showConflictingSections = ref<boolean>(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
Presence,
StateSourceCNV
} from '@/components/StrucvarDetails/ClinsigCard.c'
import { useSvAcmgRatingStore } from '@/stores/svAcmgRating'
import { useStrucVarAcmgRatingStore } from '@/stores/strucVarAcmgRating'
const emit = defineEmits<{
(e: 'switchCriteria', criteria: AcmgCriteriaCNVGain, presence: Presence): void
Expand All @@ -22,7 +22,7 @@ const props = withDefaults(
}
)
const acmgRatingStore = useSvAcmgRatingStore()
const acmgRatingStore = useStrucVarAcmgRatingStore()
</script>

<template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
Presence,
StateSourceCNV
} from '@/components/StrucvarDetails/ClinsigCard.c'
import { useSvAcmgRatingStore } from '@/stores/svAcmgRating'
import { useStrucVarAcmgRatingStore } from '@/stores/strucVarAcmgRating'
const emit = defineEmits<{
(e: 'switchCriteria', criteria: AcmgCriteriaCNVLoss, presence: Presence): void
Expand All @@ -22,7 +22,7 @@ const props = withDefaults(
}
)
const acmgRatingStore = useSvAcmgRatingStore()
const acmgRatingStore = useStrucVarAcmgRatingStore()
</script>

<template>
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/StrucvarDetails/ClinvarCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from '@/components/SeqvarDetails/ClinvarCard.c'
import { type Strucvar } from '@/lib/genomicVars'
import { roundIt } from '@/lib/utils'
import { useSvInfoStore } from '@/stores/svInfo'
import { useStrucVarInfoStore } from '@/stores/strucVarInfo'
/** Type for this component's props. */
interface Props {
Expand All @@ -18,7 +18,7 @@ interface Props {
const props = defineProps<Props>()
const svInfoStore = useSvInfoStore()
const svInfoStore = useStrucVarInfoStore()
const vcvUrl = (vcv: string): string => {
const stripped = vcv.replace(/^VCV0+/, '')
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/StrucvarDetails/GeneListCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { onMounted } from 'vue'
import GeneListEntry from '@/components/StrucvarDetails/GeneListCard/GeneListEntry.vue'
import { type Strucvar } from '@/lib/genomicVars'
import { StoreState } from '@/stores/misc'
import { type Consequence } from '@/stores/svInfo'
import { type Consequence } from '@/stores/strucVarInfo'
/** `GeneInfo` is a type alias for easier future interface definition. */
type GeneInfo = any
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { describe, expect, it, vi } from 'vitest'
import SeqVarACMGCard from '@/components/Profile/SeqVarsACMGCard.vue'
import { setupMountedComponents } from '@/lib/test-utils'
import { StoreState } from '@/stores/misc'
import { useVariantAcmgRatingStore } from '@/stores/variantAcmgRating'
import { useSeqVarAcmgRatingStore } from '@/stores/seqVarAcmgRating'

// Example ACMG Rating data
const exampleAcmgRating = {
Expand All @@ -23,7 +23,7 @@ const exampleAcmgRating = {
describe.concurrent('SeqVarACMGCard', async () => {
it('renders the SeqVarACMGCard information with ACMG ratings.', async () => {
const pinia = createTestingPinia({ createSpy: vi.fn })
const acmgRatingStore = useVariantAcmgRatingStore(pinia)
const acmgRatingStore = useSeqVarAcmgRatingStore(pinia)
const mockListAcmgRatings = vi.fn().mockImplementation(() => {
acmgRatingStore.acmgRatings = [exampleAcmgRating]
})
Expand All @@ -32,7 +32,7 @@ describe.concurrent('SeqVarACMGCard', async () => {
{ component: SeqVarACMGCard, template: false },
{
initialStoreState: {
variantAcmgRating: {
seqVarAcmgRating: {
storeState: StoreState.Active,
acmgRatings: []
}
Expand All @@ -46,7 +46,7 @@ describe.concurrent('SeqVarACMGCard', async () => {

it('renders the SeqVarACMGCard information with no ACMG ratings.', async () => {
const pinia = createTestingPinia({ createSpy: vi.fn })
const acmgRatingStore = useVariantAcmgRatingStore(pinia)
const acmgRatingStore = useSeqVarAcmgRatingStore(pinia)
const mockListAcmgRatings = vi.fn().mockImplementation(() => {
acmgRatingStore.acmgRatings = []
})
Expand All @@ -55,7 +55,7 @@ describe.concurrent('SeqVarACMGCard', async () => {
{ component: SeqVarACMGCard, template: false },
{
initialStoreState: {
variantAcmgRating: {
seqVarAcmgRating: {
storeState: StoreState.Active,
acmgRatings: []
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { describe, expect, it } from 'vitest'

import BeaconNetwork from '@/components/SeqvarDetails/BeaconNetworkCard.vue'
import type { Seqvar } from '@/lib/genomicVars'
import { setupMountedComponents } from '@/lib/test-utils'

const smallVariantInfo = {
release: 'grch37',
chromosome: 'chr17',
start: '43044295',
end: '43044295',
reference: 'G',
alternative: 'A',
hgnc_id: 'HGNC:1100'
const seqvarInfo: Seqvar = {
genomeBuild: 'grch37',
chrom: '17',
pos: 43044295,
del: 'G',
ins: 'A',
userRepr: 'grch37-17-43044295-G-A'
}

describe.concurrent('BeaconNetwork', async () => {
Expand All @@ -19,7 +19,7 @@ describe.concurrent('BeaconNetwork', async () => {
{ component: BeaconNetwork, template: false },
{
props: {
smallVariant: smallVariantInfo
seqvar: seqvarInfo
}
}
)
Expand All @@ -33,7 +33,7 @@ describe.concurrent('BeaconNetwork', async () => {
{ component: BeaconNetwork, template: false },
{
props: {
smallVariant: smallVariantInfo
seqvar: seqvarInfo
}
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { AcmgCriteria, MultiSourceAcmgCriteriaState, Presence, StateSource } fro
import type { Seqvar } from '@/lib/genomicVars'
import { deepCopy, setupMountedComponents } from '@/lib/test-utils'
import { StoreState } from '@/stores/misc'
import { useVariantAcmgRatingStore } from '@/stores/variantAcmgRating'
import { useSeqVarAcmgRatingStore } from '@/stores/seqVarAcmgRating'

const seqvarInfo: Seqvar = {
genomeBuild: 'grch37',
Expand All @@ -21,7 +21,7 @@ const seqvarInfo: Seqvar = {

const makeWrapper = () => {
const pinia = createTestingPinia({ createSpy: vi.fn })
const store = useVariantAcmgRatingStore(pinia)
const store = useSeqVarAcmgRatingStore(pinia)

const mockRetrieveAcmgRating = vi.fn().mockImplementation(async () => {
store.storeState = StoreState.Active
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import ClinVar from '@/components/SeqvarDetails/ClinvarCard.vue'
import { setupMountedComponents } from '@/lib/test-utils'

describe.concurrent('ClinVar', async () => {
it.skip('renders the ClinVar info', async () => {
it('renders the ClinVar info', async () => {
const { wrapper } = await setupMountedComponents(
{ component: ClinVar, template: false },
{
Expand All @@ -14,14 +14,15 @@ describe.concurrent('ClinVar', async () => {
}
}
)
expect(wrapper.text()).toContain('ClinVar')
expect(wrapper.text()).toContain('VCV000055407')
const stars = wrapper.findAll('.mdi-star')
expect(stars.length).toBe(18)
expect(stars.length).toBe(15)
const starsOutline = wrapper.findAll('.mdi-star-outline')
expect(starsOutline.length).toBe(27)
expect(starsOutline.length).toBe(30)
})

it.skip('renders the ClinVar info with stars', async () => {
it('renders the ClinVar info with stars', async () => {
const clinVarInfoStars = structuredClone(clinVarInfo)
clinVarInfoStars.referenceAssertions[0].reviewStatus =
'REVIEW_STATUS_NO_ASSERTION_CRITERIA_PROVIDED'
Expand All @@ -35,9 +36,9 @@ describe.concurrent('ClinVar', async () => {
)
expect(wrapper.text()).toContain('VCV000055407')
const stars = wrapper.findAll('.mdi-star')
expect(stars.length).toBe(12)
expect(stars.length).toBe(9)
const starsOutline = wrapper.findAll('.mdi-star-outline')
expect(starsOutline.length).toBe(33)
expect(starsOutline.length).toBe(36)
})

it('renders the ClinVar info (not found)', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const seqvarInfo: Seqvar = {
userRepr: 'grch37-17-43044295-G-A'
}

const variantInfo = {
const seqVarInfo = {
helixmtdb: {
num_total: 1,
num_het: 1,
Expand All @@ -38,7 +38,7 @@ describe.concurrent('FreqsMitochondrial', async () => {
{
props: {
seqVar: seqvarInfo,
varAnnos: variantInfo
varAnnos: seqVarInfo
}
}
)
Expand All @@ -49,7 +49,7 @@ describe.concurrent('FreqsMitochondrial', async () => {
})

it('renders the FreqsMitochondrial info with no helixmtdb', async () => {
const variantInfoNoHelixmtdb: any = structuredClone(variantInfo)
const variantInfoNoHelixmtdb: any = structuredClone(seqVarInfo)
variantInfoNoHelixmtdb.helixmtdb = {}
const { wrapper } = await setupMountedComponents(
{ component: FreqsMitochondrial, template: false },
Expand All @@ -67,7 +67,7 @@ describe.concurrent('FreqsMitochondrial', async () => {
})

it('renders the FreqsMitochondrial info with no gnomad-mtdna', async () => {
const variantInfoNoGnomad: any = structuredClone(variantInfo)
const variantInfoNoGnomad: any = structuredClone(seqVarInfo)
variantInfoNoGnomad['gnomad-mtdna'] = {}
const { wrapper } = await setupMountedComponents(
{ component: FreqsMitochondrial, template: false },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,29 @@ import * as BRCA1VariantInfo from '@/assets/__tests__/BRCA1VariantInfo.json'
import VariantTools from '@/components/SeqvarDetails/VariantScoresCard.vue'
import { setupMountedComponents } from '@/lib/test-utils'

const smallVariantInfo = {
release: 'grch37',
chromosome: 'chr17',
start: '43044295',
end: '43044295',
reference: 'G',
alternative: 'A',
hgnc_id: 'HGNC:1100'
}

describe.concurrent('VariantTools', async () => {
it('renders the Variant Tools info', async () => {
const { wrapper } = await setupMountedComponents(
{ component: VariantTools, template: false },
{
props: {
smallVar: smallVariantInfo,
varAnnos: BRCA1VariantInfo['result']
}
}
)
expect(wrapper.text()).toContain('Scoring Method')
expect(wrapper.text()).toContain('BayesDel')
})

it('renders the Variant Tools info with empty variance information', async () => {
const { wrapper } = await setupMountedComponents(
{ component: VariantTools, template: false },
{
props: {
varAnnos: undefined
}
}
)
expect(wrapper.text()).toContain('No UCSC conservation data available.')
})
})
Loading

0 comments on commit d2e8611

Please sign in to comment.