Skip to content

Commit

Permalink
Merge pull request #2726 from alisman/urlWrapper
Browse files Browse the repository at this point in the history
Url wrapper
  • Loading branch information
alisman authored Dec 6, 2019
2 parents 31a57ae + 72f52d2 commit eceb5f8
Show file tree
Hide file tree
Showing 44 changed files with 1,775 additions and 1,219 deletions.
9 changes: 5 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ run_e2e_and_save_artifacts: &run_e2e_and_save_artifacts
(curl --insecure https://localhost:3000 || curl http://localhost:3000) > /dev/null && \
sleep 1s && \
cd end-to-end-test && \
echo "CBIOPORTAL_URL=$CBIOPORTAL_URL"
yarn run e2e
when: always
environment:
Expand Down Expand Up @@ -199,14 +200,14 @@ jobs:
./setup_environment.sh && ./setup_environment.sh >> $BASH_ENV
- run:
name: Generate checksum of data that populates the test database
command: |
command: |
$TEST_HOME/local/runtime-config/db_content_fingerprint.sh > /tmp/db_data_md5key
- restore_cache:
keys:
- v4-e2e-database-files-{{ checksum "/tmp/db_data_md5key" }}
- run:
name: Create MySQL data directory when no cache found
command: |
command: |
mkdir -p $DB_DATA_DIR
- run:
name: Setup docker images and containers
Expand All @@ -220,7 +221,7 @@ jobs:
fi
- run:
name: Change owner of MySQL database files (needed by cache)
command: |
command: |
sudo chmod -R 777 $DB_DATA_DIR && \
sudo chown -R circleci:circleci $DB_DATA_DIR
- save_cache:
Expand All @@ -229,7 +230,7 @@ jobs:
key: v4-e2e-database-files-{{ checksum "/tmp/db_data_md5key" }}
- run:
name: Run end-2-end tests with studies in local database
command: |
command: |
cd $PORTAL_SOURCE_DIR && $TEST_HOME/local/runtime-config/run_container_screenshot_test.sh
- run:
name: "Make sure all screenshots are tracked (otherwise the test will always be successful)"
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 9 additions & 2 deletions end-to-end-test/remote/specs/core/oncoprint.spec.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

71 changes: 29 additions & 42 deletions src/appShell/App/Container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@ export default class Container extends React.Component<IContainerProps, {}> {
c => React.cloneElement(c as React.ReactElement<any>, childProps));
}

@computed get isSessionLoaded(){

return !this.routingStore.needsRemoteSessionLookup || this.routingStore.remoteSessionData.isComplete;

}

render() {
if (!isWebdriver() && !ServerConfigHelpers.sessionServiceIsEnabled()) {
return (
Expand All @@ -61,44 +55,37 @@ export default class Container extends React.Component<IContainerProps, {}> {
}

return (
<If condition={this.isSessionLoaded}>
<div>
<Helmet>
<meta charSet="utf-8" />
<title>{AppConfig.serverConfig.skin_title}</title>
<meta name="description" content={AppConfig.serverConfig.skin_description} />
</Helmet>

<div className="pageTopContainer">
<UserMessager />
<div className="contentWidth">
<PortalHeader appStore={this.appStore}/>
</div>
<div>
<Helmet>
<meta charSet="utf-8" />
<title>{AppConfig.serverConfig.skin_title}</title>
<meta name="description" content={AppConfig.serverConfig.skin_description} />
</Helmet>

<div className="pageTopContainer">
<UserMessager />
<div className="contentWidth">
<PortalHeader appStore={this.appStore}/>
</div>
<If condition={this.appStore.isErrorCondition}>
<Then>
<div className="contentWrapper">
<ErrorScreen
title={formatErrorTitle(this.appStore.undismissedSiteErrors) || "Oops. There was an error retrieving data."}
body={<a href={buildCBioPortalPageUrl("/")}>Return to homepage</a>}
errorLog={formatErrorLog(this.appStore.undismissedSiteErrors)}
errorMessages={formatErrorMessages(this.appStore.undismissedSiteErrors)}
/>
</div>
</Then>
<Else>
<div className="contentWrapper">
{(this.isSessionLoaded) && this.props.children}
</div>
</Else>
</If>


</div>
<Else>
<LoadingIndicator isLoading={!this.isSessionLoaded} center={true} size={"big"}/>
</Else>
</If>
<If condition={this.appStore.isErrorCondition}>
<Then>
<div className="contentWrapper">
<ErrorScreen
title={formatErrorTitle(this.appStore.undismissedSiteErrors) || "Oops. There was an error retrieving data."}
body={<a href={buildCBioPortalPageUrl("/")}>Return to homepage</a>}
errorLog={formatErrorLog(this.appStore.undismissedSiteErrors)}
errorMessages={formatErrorMessages(this.appStore.undismissedSiteErrors)}
/>
</div>
</Then>
<Else>
<div className="contentWrapper">
{this.props.children}
</div>
</Else>
</If>
</div>
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/config/serverConfigDefaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ const ServerConfigDefaults: Partial<IServerConfig> = {

enable_darwin: false,

session_url_length_threshold: '1990',
session_url_length_threshold: '1500',

study_view: {
tableAttrs: ['SAMPLE_CANCER_TYPE', 'SAMPLE_CANCER_TYPE_DETAILED'],
Expand Down Expand Up @@ -156,7 +156,7 @@ const ServerConfigDefaults: Partial<IServerConfig> = {
'http://grch37.ensembl.org/homo_sapiens/Transcript/Summary?t=<%= transcriptId %>',

query_product_limit: 1000000,

skin_show_gsva: false,
};

Expand Down
1 change: 1 addition & 0 deletions src/pages/groupComparison/GroupComparisonPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export default class GroupComparisonPage extends React.Component<IGroupCompariso
componentWillUnmount() {
this.queryReaction && this.queryReaction();
this.store && this.store.destroy();
this.urlWrapper.destroy();
}

readonly tabs = MakeMobxView({
Expand Down
10 changes: 5 additions & 5 deletions src/pages/groupComparison/GroupComparisonStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export default class GroupComparisonStore {
}

@action public updateOverlapStrategy(strategy:OverlapStrategy) {
this.urlWrapper.updateQuery({ overlapStrategy: strategy });
this.urlWrapper.updateURL({ overlapStrategy: strategy });
}

@computed get overlapStrategy() {
Expand All @@ -120,7 +120,7 @@ export default class GroupComparisonStore {

@autobind
@action public setUsePatientLevelEnrichments(e:boolean) {
this.urlWrapper.updateQuery({ patientEnrichments: e.toString()});
this.urlWrapper.updateURL({ patientEnrichments: e.toString()});
}

@computed get groupOrder() {
Expand All @@ -141,11 +141,11 @@ export default class GroupComparisonStore {
const poppedUid = groupOrder.splice(oldIndex, 1)[0];
groupOrder.splice(newIndex, 0, poppedUid);

this.urlWrapper.updateQuery({ groupOrder: JSON.stringify(groupOrder) });
this.urlWrapper.updateURL({ groupOrder: JSON.stringify(groupOrder) });
}

@action private updateUnselectedGroups(names:string[]) {
this.urlWrapper.updateQuery({ unselectedGroups: JSON.stringify(names) });
this.urlWrapper.updateURL({ unselectedGroups: JSON.stringify(names) });
}

@computed get unselectedGroups() {
Expand Down Expand Up @@ -210,7 +210,7 @@ export default class GroupComparisonStore {
@action
private async saveAndGoToSession(newSession:Session) {
const {id} = await comparisonClient.addComparisonSession(newSession);
this.urlWrapper.updateQuery({ sessionId: id});
this.urlWrapper.updateURL({ sessionId: id});
}

readonly _session = remoteData<Session>({
Expand Down
4 changes: 2 additions & 2 deletions src/pages/groupComparison/GroupComparisonURLWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ export default class GroupComparisonURLWrapper extends URLWrapper<GroupCompariso

@autobind
public setTabId(tabId:GroupComparisonTab, replace?:boolean) {
this.routing.updateRoute({}, `comparison/${tabId}`, false, replace);
this.updateURL({}, `comparison/${tabId}`, false, replace);
}
}
}
4 changes: 1 addition & 3 deletions src/pages/groupComparison/Survival.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from 'react';
import SurvivalChart from "../resultsView/survival/SurvivalChart";
import 'react-rangeslider/lib/index.css';
import LoadingIndicator from "shared/components/loadingIndicator/LoadingIndicator";
import {observer} from "mobx-react";
import GroupComparisonStore, {OverlapStrategy} from './GroupComparisonStore';
Expand All @@ -11,9 +12,6 @@ import {blendColors} from "./OverlapUtils";
import OverlapExclusionIndicator from "./OverlapExclusionIndicator";
import {getPatientIdentifiers} from "../studyView/StudyViewUtils";
import DefaultTooltip from 'public-lib/components/defaultTooltip/DefaultTooltip';
import classnames from 'classnames';
import styles from "./styles.module.scss";
import { ClinicalData, ClinicalAttribute } from 'shared/api/generated/CBioPortalAPI';
import _ from 'lodash';
import SurvivalDescriptionTable from 'pages/resultsView/survival/SurvivalDescriptionTable';
import {
Expand Down
22 changes: 3 additions & 19 deletions src/pages/home/HomePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import getBrowserWindow from "../../public-lib/lib/getBrowserWindow";
// tslint:disable-next-line:no-import-side-effect
import "./homePage.scss";
import autobind from "autobind-decorator";
import {ResultsViewTab} from "pages/resultsView/ResultsViewPageHelpers";
import ResultsViewURLWrapper from "pages/resultsView/ResultsViewURLWrapper";
import {createQueryStore} from "shared/lib/createQueryStore";

(Chart as any).plugins.register({
beforeDraw: function (chartInstance: any) {
Expand All @@ -29,25 +32,6 @@ export interface IResultsViewPageProps {
routing: any;
}

export function createQueryStore(currentQuery?:any) {

const win:any = window;

const queryStore = new QueryStore(currentQuery);

queryStore.singlePageAppSubmitRoutine = function(query:CancerStudyQueryUrlParams) {

// normalize this
query.cancer_study_list = query.cancer_study_list || query.cancer_study_id;
delete query.cancer_study_id;

win.routingStore.updateRoute(query, "results", true);

};

return queryStore;

}

@inject('routing')
@observer
Expand Down
37 changes: 16 additions & 21 deletions src/pages/patientView/PatientViewPage.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,32 @@ import PatientViewPage from './PatientViewPage';
import React from 'react';
import {assert} from 'chai';
import sinon from 'sinon';
import PatientViewUrlWrapper from './PatientViewUrlWrapper';
import ExtendedRouterStore from 'shared/lib/ExtendedRouterStore';

const componentUnderTest: PatientViewPage = (PatientViewPage as any).wrappedComponent;


describe('PatientViewPage', () => {

describe('handleSampleClick', () => {

const handleSampleClick = (componentUnderTest as any).prototype.handleSampleClick;

let updateRouteStub: sinon.SinonStub,
urlWrapper: PatientViewUrlWrapper,
preventDefaultStub: sinon.SinonStub,
mock: any,
ev: Partial<React.MouseEvent<HTMLAnchorElement>>;
let updateURLStub:sinon.SinonStub,
preventDefaultStub: sinon.SinonStub,
mock: any,
ev: Partial<React.MouseEvent<HTMLAnchorElement>>;



beforeEach(() => {
updateRouteStub = sinon.stub();
urlWrapper = new PatientViewUrlWrapper(new ExtendedRouterStore());
urlWrapper.updateQuery = updateRouteStub;

updateURLStub = sinon.stub();

preventDefaultStub = sinon.stub();

mock = {
props: {
routing: {
updateRoute: updateRouteStub
}
},
urlWrapper: urlWrapper,
urlWrapper: {
updateURL:updateURLStub
}
};

ev = {
Expand All @@ -43,29 +38,29 @@ describe('PatientViewPage', () => {

it('calls update route when no modifier keys are pressed', () => {
handleSampleClick.call(mock, 1, ev);
assert.isTrue(updateRouteStub.calledOnce);
assert.isTrue(updateURLStub.calledOnce);
assert.isTrue(preventDefaultStub.called);
});

it('does not call updateRoute or preventDefault if altKey is true', () => {
ev.altKey = true;
handleSampleClick.call(mock, 1, ev);
assert.isFalse(updateRouteStub.called);
assert.isFalse(updateURLStub.called);
assert.isFalse(preventDefaultStub.called);
});


it('does not call updateRoute or preventDefault if metaKey is true', () => {
ev.metaKey = true;
handleSampleClick.call(mock, 1, ev);
assert.isFalse(updateRouteStub.called);
assert.isFalse(updateURLStub.called);
assert.isFalse(preventDefaultStub.called);
});

it('does not call updateRoute or preventDefault if shiftKey is true', () => {
ev.shiftKey = true;
handleSampleClick.call(mock, 1, ev);
assert.isFalse(updateRouteStub.called);
assert.isFalse(updateURLStub.called);
assert.isFalse(preventDefaultStub.called);
});

Expand Down
Loading

0 comments on commit eceb5f8

Please sign in to comment.