Skip to content

Commit

Permalink
add end to end tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bprize15 committed Jun 20, 2024
1 parent 531eb0b commit 28b4dec
Show file tree
Hide file tree
Showing 11 changed files with 337 additions and 172 deletions.
4 changes: 3 additions & 1 deletion src/main/webapp/app/components/sidebar/OncoKBSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const OncoKBSidebar = ({ showOncoKBSidebar, defaultOpen = false, ...props }: IOn
onClick={() => {
props.toggleOncoKBSidebar(true);
}}
data-testid="open-sidebar-button"
/>
</div>
</div>
Expand Down Expand Up @@ -155,12 +156,13 @@ const OncoKBSidebarExpanded = observer(
toggleOncoKBSidebar(false);
setOncoKBSidebarWidth(ONCOKB_SIDEBAR_MIN_WIDTH);
}}
data-testid="close-sidebar-button"
/>
</div>
<div style={{ marginTop: '2rem', display: 'flex', width: '100%' }}>{children}</div>
</div>
);
}
},
);

const mapStoreToProps = ({ layoutStore }: IRootStore) => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ function SomaticGermlineToggleButton({ hugoSymbol, firebaseDb, createGene }: ISo
style={{ width: BUTTON_WIDTH }}
disabled={isSomatic}
onClick={handleToggle}
data-testid="somatic-button"
>
{isSomatic && <FaCheckCircle className="me-2" style={{ marginBottom: '.1rem' }} />}
<span>Somatic</span>
Expand All @@ -59,6 +60,7 @@ function SomaticGermlineToggleButton({ hugoSymbol, firebaseDb, createGene }: ISo
style={{ width: BUTTON_WIDTH }}
disabled={!isSomatic}
onClick={handleToggle}
data-testid="germline-button"
>
{!isSomatic && <FaCheckCircle className="me-2" style={{ marginBottom: '.1rem' }} />}
<span>Germline</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function MutationName({ mutationPath, firebaseDb }: IMutationNameProps) {
return () => unsubscribe?.();
}, [mutationPath]);

return <span>{mutationName}</span>;
return <span data-testid="mutation-breadcrumbs-name">{mutationName}</span>;
}

const mapStoreToProps = ({ firebaseAppStore }: IRootStore) => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function MutationsSection({
<>
{!_.isNil(openMutationCollapsibleIndex) && (
// though a greater minHeight would reduce blinking more, need to choose a minHeight that looks good on the smallest possible mutation
<div style={{ transition: 'height 0.5s, opacity 0.5s', minHeight: 400 }} className={'mb-2'}>
<div style={{ transition: 'height 0.5s, opacity 0.5s', minHeight: 400 }} className={'mb-2'} data-testid="single-mutation-view">
<MutationCollapsible
open
mutationPath={`${mutationsPath}/${openMutationCollapsibleIndex}`}
Expand All @@ -99,6 +99,7 @@ function MutationsSection({
visibility: !_.isNil(openMutationCollapsibleIndex) ? 'hidden' : 'inherit',
maxHeight: !_.isNil(openMutationCollapsibleIndex) ? '0px' : null,
}}
data-testid="mutation-list"
>
<FirebaseList<Mutation>
path={mutationsPath}
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/app/shared/form/AutoParseRefField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const AutoParseRefField: React.FunctionComponent<IAutoParseRefField> = pr
<span>References:</span>
{content.map(c => {
let ref = (
<span className="ms-2" key={c.content}>
<span className="ms-2" key={c.content} data-testid={c.content}>
<a target="_blank" rel="noopener noreferrer" href={c.link} className="reference-link">
{`${c.prefix}${c.content}`}
</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const PubMedArticleTooltipContent: React.FunctionComponent<IPubMedArticleTooltip
const date = new Date(pubMedDto.date);
return (
<div>
<h5>{pubMedDto.title}</h5>
<h5 data-testid={`${props.pmid}-pub-med-title`}>{pubMedDto.title}</h5>
<p>
{pubMedDto.authors}, {pubMedDto.additionalInfo.journal.isoAbbreviation}, on {formatDate(date, true)}
</p>
Expand Down
5 changes: 5 additions & 0 deletions src/test/javascript/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const BASE_URL = process.env.DOCKER ? 'https://app:9000' : 'http://localhost:9000';
export const DATABASE_EMULATOR_URL = process.env.DOCKER ? 'http://firebase/?ns=mock-data' : 'http://localhost/?ns=mock-data';

export const PUB_MED_ARTICLE_TITLE = 'The RAF proteins take centre stage.';
export const PUB_MED_PMID = '15520807';
234 changes: 234 additions & 0 deletions src/test/javascript/setup-mocks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,234 @@
import { browser } from '@wdio/globals';
import { DATABASE_EMULATOR_URL, PUB_MED_PMID, PUB_MED_ARTICLE_TITLE } from './constants';

export default async function setUpMocks() {
const firebaseConfig = JSON.stringify({
firebase: {
enabled: true,
connectToFirebaseEmulators: true,
databaseURL: DATABASE_EMULATOR_URL,
apiKey: 'AIzaSyCUd3bf-TEg5T78w_-RKT6uV_pf3VTVvo8',
projectId: 'oncokb-curation-test-54b6c',
},
});
const indexMock = await browser.mock(`**`, {
headers: { 'content-type': 'text/html; charset=utf-8' },
statusCode: 200,
});
indexMock.respond(req => {
if (typeof req.body === 'string') {
req.body = req.body.replace(/(window\.serverConfig\.frontend\s*=\s*.*)({.*})(;)/, `$1${firebaseConfig}$3`);
}
return req.body;
});
const authMock = await browser.mock('**/api/account');
authMock.respond(
{
authorities: ['ROLE_CURATOR', 'ROLE_USER'],
},
{
statusCode: 200,
fetchResponse: false,
},
);
const firebaseTokenMock = await browser.mock('**/api/account/firebase-token');
firebaseTokenMock.respond(
'eyJhbGciOiJSUzI1NiJ9.eyJhdWQiOiJodHRwczovL2lkZW50aXR5dG9vbGtpdC5nb29nbGVhcGlzLmNvbS9nb29nbGUuaWRlbnRpdHkuaWRlbnRpdHl0b29sa2l0LnYxLklkZW50aXR5VG9vbGtpdCIsImNsYWltcyI6eyJmaXJlYmFzZUF1dGhvcml6ZWRVc2VyIjp0cnVlfSwiZXhwIjoxNzE1MTk2MDAxLCJpYXQiOjE3MTUxOTI0MDEsImlzcyI6ImZpcmViYXNlLWFkbWluc2RrLXVrNjRhQGRldi1vbmNva2ItY3VyYXRpb24tdjIuaWFtLmdzZXJ2aWNlYWNjb3VudC5jb20iLCJzdWIiOiJmaXJlYmFzZS1hZG1pbnNkay11azY0YUBkZXYtb25jb2tiLWN1cmF0aW9uLXYyLmlhbS5nc2VydmljZWFjY291bnQuY29tIiwidWlkIjoiYnByaXplMTVAZ21haWwuY29tIn0.XCZVZG4RgwZ3XoO_uKERJFRsHNAn9pVXT12NkHTN4LgWIlfZPzKAszHinWGK9XQqbxWWxryDCE8YtJ-BNvIFNU-J5cFUgUzbYCYhoNWQy4g4M90Zwf1U478F2LjL6kYbSTxcCpfUBGI3RT-cea9GhOx8PjE_T78JZYeI-1xCHPOm78ABfaDEnfcb7l8mFVyCUqbXRhRtZa6Sl-K1TnFtuXgZQLK24Yp9iXTBbFKvndc7J6ymS2OTL7aRQGROMMSyWMNs8rdThW2e5eHz4tl9ICH0gWvzRXCwH7sXgGXw5o0XoCH4hFUlhxhkT2yjThY1b10GTS_BWB3PF2bi3a-JXA',
{
statusCode: 200,
fetchResponse: false,
},
);
const drugsMock = await browser.mock('**/api/drugs*');
drugsMock.respond(
[
{
id: 1,
uuid: '2e8ce490-86c2-45a4-a6e4-db5e5314981c',
name: 'Prednisolone',
nciThesaurus: {
id: 158405,
version: '23.11d',
code: 'C769',
preferredName: 'Prednisolone',
displayName: 'Prednisolone',
synonyms: null,
},
fdaDrugs: [],
flags: [],
associations: [],
},
{
id: 15,
uuid: '939cd40b-b515-499d-b099-fd29027c0d17',
name: 'Dabrafenib',
nciThesaurus: {
id: 163898,
version: '23.11d',
code: 'C82386',
preferredName: 'Dabrafenib',
displayName: 'Dabrafenib',
synonyms: null,
},
fdaDrugs: [],
flags: [],
associations: [],
},
],
{
statusCode: 200,
fetchResponse: false,
},
);
const genesMock = await browser.mock('**/api/genes/search*');
genesMock.respond([{ hugoSymbol: 'BRAF' }, { hugoSymbol: 'ROS1' }, { hugoSymbol: 'TP53' }], {
statusCode: 200,
fetchResponse: false,
});
const annotateAlterationsMock = await browser.mock('**/api/annotate-alterations');
annotateAlterationsMock.respond(
[
{
entity: {
id: null,
type: 'PROTEIN_CHANGE',
name: 'V600E',
alteration: 'V600E',
proteinChange: 'V600E',
start: 600,
end: 600,
refResidues: 'V',
variantResidues: 'E',
flags: [],
genes: [
{
id: 41135,
entrezGeneId: 673,
hugoSymbol: 'BRAF',
hgncId: '1097',
},
],
transcripts: [],
consequence: {
id: 16,
term: 'MISSENSE_VARIANT',
name: 'Missense Variant',
isGenerallyTruncating: false,
description:
'A sequence variant, that changes one or more bases, resulting in a different amino acid sequence but where the length is preserved',
},
associations: [],
},
message: '',
type: 'OK',
queryId: 'V600E',
annotation: {
hotspot: {
associatedHotspots: [
{
type: 'HOTSPOT_V1',
alteration: 'V600',
},
{
type: 'THREE_D',
alteration: 'V600',
},
{
type: 'HOTSPOT_V1',
alteration: 'V600',
},
{
type: 'THREE_D',
alteration: 'V600',
},
],
hotspot: true,
},
exons: [
{
range: {
start: 581,
end: 620,
},
exon: 15,
},
],
},
warning: false,
ok: true,
error: false,
},
],
{
statusCode: 200,
fetchResponse: false,
},
);

const pubMedArticleMock = await browser.mock('**/api/articles/pubmed/*');
pubMedArticleMock.respond(
{
id: 451,
type: 'PUBMED',
pmid: PUB_MED_PMID,
title: PUB_MED_ARTICLE_TITLE,
content:
'Since their discovery over 20 years ago, the RAF proteins have been intensely studied. For most of that time, the focus of the field has been the C-RAF isoform and its role as an effector of the RAS proteins. However, a report that implicates B-RAF in human cancer has highlighted the importance of all members of this protein kinase family and recent studies have uncovered intriguing new data relating to their complex regulation and biological functions.',
link: null,
authors: 'Wellbrock et al.',
date: '2004-12-15T00:00:00Z',
additionalInfo: {
abstractTexts: [
{
label: null,
nlmCategory: null,
value:
'Since their discovery over 20 years ago, the RAF proteins have been intensely studied. For most of that time, the focus of the field has been the C-RAF isoform and its role as an effector of the RAS proteins. However, a report that implicates B-RAF in human cancer has highlighted the importance of all members of this protein kinase family and recent studies have uncovered intriguing new data relating to their complex regulation and biological functions.',
},
],
journal: {
issn: '1471-0072',
volume: '5',
issue: '11',
pages: '875-85',
title: 'Nature reviews. Molecular cell biology',
isoAbbreviation: 'Nat Rev Mol Cell Biol',
},
completedDate: '2004-12-15T00:00:00Z',
revisedDate: '2022-04-08T00:00:00Z',
dataBanks: [],
},
flags: [],
synonyms: [
{
id: 434469,
type: 'ARTICLE',
source: 'pubmed',
code: null,
name: PUB_MED_PMID,
note: null,
},
{
id: 434470,
type: 'ARTICLE',
source: 'doi',
code: null,
name: '10.1038/nrm1498',
note: null,
},
{
id: 434471,
type: 'ARTICLE',
source: 'pii',
code: null,
name: 'nrm1498',
note: null,
},
],
},
{
statusCode: 200,
fetchResponse: false,
},
);
}
Loading

0 comments on commit 28b4dec

Please sign in to comment.