From 0e3878c48b301759d26e5e49abbea6f584834a6e Mon Sep 17 00:00:00 2001 From: ramfox Date: Thu, 16 Jan 2020 14:03:15 -0500 Subject: [PATCH] fix(setWorkingDataset): don't clear workingDataset when setWorkingDataset is called Also adds an e2e test to confirm behavior --- RELEASE_PROCESS.md | 3 +- app/actions/selections.ts | 3 -- app/components/Body.tsx | 56 +++++++++-------------- app/components/DatasetList.tsx | 2 +- app/containers/BodyContainer.tsx | 3 +- app/containers/CommitDetailsContainer.tsx | 11 ++--- app/reducers/selections.ts | 2 + app/reducers/workingDataset.ts | 7 +-- test/e2e/e2e.spec.ts | 30 +++++++++++- 9 files changed, 61 insertions(+), 56 deletions(-) diff --git a/RELEASE_PROCESS.md b/RELEASE_PROCESS.md index ad674063..10724fa5 100644 --- a/RELEASE_PROCESS.md +++ b/RELEASE_PROCESS.md @@ -23,4 +23,5 @@ This will only work if you are internal to Qri and have the correct keys - app-builder is modifying the contents of the zip, which is messing up the notarization. The -o flag indicates an output file that app-builder can futz with without ruining the integrity of the original app - take the updated file into from size, sha512 and blockMapSize - update the `/release/latest-mac.yml` with that info - - replace `FILENAME.zip` to the release page \ No newline at end of file + - replace `FILENAME.zip` to the release page +12) **remember to change website link give details of where here** \ No newline at end of file diff --git a/app/actions/selections.ts b/app/actions/selections.ts index ba0ac55d..8c1388dd 100644 --- a/app/actions/selections.ts +++ b/app/actions/selections.ts @@ -15,9 +15,6 @@ export const setActiveTab = (activeTab: string) => { } export const setSelectedListItem = (type: string, selectedListItem: string) => { - if (type === 'commit') { - console.log('setting to', selectedListItem) - } return { type: SELECTIONS_SET_SELECTED_LISTITEM, payload: { diff --git a/app/components/Body.tsx b/app/components/Body.tsx index 28ea8c61..e29a5fbb 100644 --- a/app/components/Body.tsx +++ b/app/components/Body.tsx @@ -3,8 +3,8 @@ import * as React from 'react' import BodyTable from './BodyTable' import BodyJson from './BodyJson' import { ApiAction } from '../store/api' +import { Structure } from '../models/dataset' -import Spinner from './chrome/Spinner' import { PageInfo, WorkingDataset } from '../models/store' import { Action } from 'redux' import { DetailsType, Details, StatsDetails } from '../models/details' @@ -15,6 +15,7 @@ export interface BodyProps { name: string path: string value: any[] + structure: Structure pageInfo: PageInfo history: boolean format: string @@ -35,13 +36,12 @@ export interface Header { type: string } -const extractColumnHeaders = (workingDataset: WorkingDataset): undefined | object => { - const structure = workingDataset.components.structure.value +const extractColumnHeaders = (structure: any, value: any): undefined | object => { const schema = structure.schema if (!schema) { // iterate over first row of body - const firstRow = workingDataset.components.body.value && workingDataset.components.body.value[0] + const firstRow = value && value[0] if (!firstRow) return undefined // need to take a slice from index 1 because we have mutated the @@ -63,22 +63,19 @@ const Body: React.FunctionComponent = (props) => { const { value, pageInfo, - workingDataset, history, fetchBody, format, fetchCommitBody, details, setDetailsBar, - stats + stats, + structure } = props const onFetch = history ? fetchCommitBody : fetchBody - const headers = extractColumnHeaders(workingDataset) - - // if there's no value or format, don't show anything yet - const showSpinner = !(value && format) + const headers = extractColumnHeaders(structure, value) const makeStatsDetails = (stats: {[key: string]: any}, title: string, index: number): StatsDetails => { return { @@ -110,31 +107,20 @@ const Body: React.FunctionComponent = (props) => { return (
- <> - { showSpinner && -
- -
- } - { !showSpinner && - <> - {shouldDisplayTable(value, format) - ? - : - } - - } - + {shouldDisplayTable(value, format) + ? + : + }
) } diff --git a/app/components/DatasetList.tsx b/app/components/DatasetList.tsx index fb29a967..9057093d 100644 --- a/app/components/DatasetList.tsx +++ b/app/components/DatasetList.tsx @@ -193,7 +193,7 @@ class DatasetList extends React.Component { return (
{ var format = '' if (history) { - format = workingDataset.components.structure.value.format + format = dataset.components.structure.value.format } else { format = state.workingDataset.status && state.workingDataset.status.body && state.workingDataset.status.body.filepath ? path.extname(state.workingDataset.status.body.filepath).slice(1) @@ -36,7 +36,6 @@ const mapStateToProps = (state: Store) => { format, history, details, - workingDataset, stats } } diff --git a/app/containers/CommitDetailsContainer.tsx b/app/containers/CommitDetailsContainer.tsx index e9e4a865..d3f47cdb 100644 --- a/app/containers/CommitDetailsContainer.tsx +++ b/app/containers/CommitDetailsContainer.tsx @@ -6,7 +6,7 @@ import { setSelectedListItem } from '../actions/selections' import { fetchCommitDetail } from '../actions/api' const mapStateToProps = (state: Store) => { - const { workingDataset, selections, commitDetails } = state + const { selections, commitDetails } = state const { peername, @@ -15,18 +15,15 @@ const mapStateToProps = (state: Store) => { commitComponent: selectedComponent } = selections - // find the currently selected commit - const selectedCommit = workingDataset.history.value - .find(d => d.path === selectedCommitPath) - return { peername, name, selectedCommitPath: selectedCommitPath, - commit: selectedCommit, + commit: commitDetails.components.commit.value, selectedComponent, commitDetails, - structure: commitDetails.components.structure.value + structure: commitDetails.components.structure.value, + isLoading: commitDetails.isLoading } } diff --git a/app/reducers/selections.ts b/app/reducers/selections.ts index decbb64d..807fa02a 100644 --- a/app/reducers/selections.ts +++ b/app/reducers/selections.ts @@ -93,6 +93,8 @@ export default (state = initialState, action: AnyAction) => { case SELECTIONS_SET_WORKING_DATASET: const { peername, name } = action.payload + if (peername === state.peername && name === state.name) return state + localStore().setItem('peername', peername) localStore().setItem('name', name) localStore().setItem('commit', '') diff --git a/app/reducers/workingDataset.ts b/app/reducers/workingDataset.ts index 553d33be..b3c272a8 100644 --- a/app/reducers/workingDataset.ts +++ b/app/reducers/workingDataset.ts @@ -7,8 +7,7 @@ import { ipcRenderer } from 'electron' import bodyValue from '../utils/bodyValue' import { - REMOVE_SUCC, - SELECTIONS_SET_WORKING_DATASET + REMOVE_SUCC } from './selections' const initialState: WorkingDataset = { @@ -18,7 +17,6 @@ const initialState: WorkingDataset = { name: '', status: {}, isLoading: false, - isCommiting: false, fsiPath: '', published: true, hasHistory: true, @@ -271,9 +269,6 @@ const workingDatasetsReducer: Reducer = (state = initialState, action: AnyAction stats: [] } - case SELECTIONS_SET_WORKING_DATASET: - return initialState - case RENAME_SUCC: return { ...state, diff --git a/test/e2e/e2e.spec.ts b/test/e2e/e2e.spec.ts index 29bdbd0a..2faa5fc4 100644 --- a/test/e2e/e2e.spec.ts +++ b/test/e2e/e2e.spec.ts @@ -23,7 +23,7 @@ describe('Qri End to End tests', function spec () { const password = '1234567890!!' beforeAll(async () => { - jest.setTimeout(30000) + jest.setTimeout(60000) // spin up a new mock backend with a mock registry server attached backend = new TestBackendProcess() @@ -206,6 +206,31 @@ describe('Qri End to End tests', function spec () { await checkStatus('structure', 'added') }) + it ('navigate to collection and back to dataset', async () => { + const { + atLocation, + click, + expectTextToBe, + onHistoryTab + } = utils + + await click('#history-tab') + await onHistoryTab() + + await click('#collection') + // ensure we have redirected to the collection page + await atLocation('#/collection') + // click the dataset + const ref = `#${username}-${datasetName}` + await click(ref) + // ensure we have redirected to the dataset page + await atLocation('#/dataset') + // ensure we are still at the history tab + await onHistoryTab() + // ensure we have a commit title + await expectTextToBe('#commit-title', 'created dataset') + }) + // checkout it('checkout a dataset', async () => { const { @@ -219,6 +244,9 @@ describe('Qri End to End tests', function spec () { // at dataset await click('#dataset') + // at status + await click('#status-tab') + await onStatusTab() // body is disabled await exists(['#body-status.disabled']) // click #checkout to open checkout modal