From 1b00d49d347568460cf755e51307a16bc722b783 Mon Sep 17 00:00:00 2001 From: Yuan Gong Date: Tue, 5 Nov 2019 18:06:41 +0800 Subject: [PATCH 1/2] Failure test case for the bug reported --- frontend/src/pages/PipelineDetails.test.tsx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/frontend/src/pages/PipelineDetails.test.tsx b/frontend/src/pages/PipelineDetails.test.tsx index 858f5af1574..1a9a16a197b 100644 --- a/frontend/src/pages/PipelineDetails.test.tsx +++ b/frontend/src/pages/PipelineDetails.test.tsx @@ -416,6 +416,20 @@ describe('PipelineDetails', () => { ); }); + it('clicking new run button when viewing half-loaded page navigates to the new run page with run ID', async () => { + tree = shallow(); + // Intentionally don't wait until all network requests finish. + const instance = tree.instance() as PipelineDetails; + const newRunFromPipelineBtn = instance.getInitialToolbarState().actions[ + ButtonKeys.NEW_RUN_FROM_PIPELINE + ]; + newRunFromPipelineBtn.action(); + expect(historyPushSpy).toHaveBeenCalledTimes(1); + expect(historyPushSpy).toHaveBeenLastCalledWith( + RoutePage.NEW_RUN + `?${QUERY_PARAMS.pipelineId}=${testPipeline.id}`, + ); + }); + it('clicking new experiment button navigates to new experiment page', async () => { tree = shallow(); await getTemplateSpy; From b106d290ccce42143d049234292ae559e56ded7f Mon Sep 17 00:00:00 2001 From: Yuan Gong Date: Tue, 5 Nov 2019 18:07:23 +0800 Subject: [PATCH 2/2] Populate pipeline id from params if data not yet ready. --- frontend/src/pages/PipelineDetails.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/frontend/src/pages/PipelineDetails.tsx b/frontend/src/pages/PipelineDetails.tsx index 62bdc4d75c5..0a8d4f20ce9 100644 --- a/frontend/src/pages/PipelineDetails.tsx +++ b/frontend/src/pages/PipelineDetails.tsx @@ -118,7 +118,14 @@ class PipelineDetails extends Page<{}, PipelineDetailsState> { public getInitialToolbarState(): ToolbarProps { const buttons = new Buttons(this.props, this.refresh.bind(this)); const fromRunId = new URLParser(this.props).get(QUERY_PARAMS.fromRunId); - buttons.newRunFromPipeline(() => (this.state.pipeline ? this.state.pipeline.id! : '')); + buttons.newRunFromPipeline(() => { + const pipelineIdFromParams = this.props.match.params[RouteParams.pipelineId]; + return this.state.pipeline + ? this.state.pipeline.id! + : pipelineIdFromParams + ? pipelineIdFromParams + : ''; + }); if (fromRunId) { return {