From 4aa7152525b1dabf42a79e23e8c6073c6bb3ff99 Mon Sep 17 00:00:00 2001 From: Louise Davies Date: Fri, 30 Aug 2024 14:12:37 +0100 Subject: [PATCH] Add back in modTime & createTime fields --- packages/datagateway-common/src/app.types.tsx | 6 ++++-- .../datafilePreview/detailsPane.component.test.tsx | 12 ++++++++---- .../src/views/datafilePreview/testData.ts | 6 ++++-- .../src/views/table/datafileTable.component.test.tsx | 12 ++++++++---- .../table/dls/dlsDatafilesTable.component.test.tsx | 8 +++++--- .../table/isis/isisDatafilesTable.component.test.tsx | 8 +++++--- packages/datagateway-download/src/testData.ts | 4 ++-- 7 files changed, 36 insertions(+), 20 deletions(-) diff --git a/packages/datagateway-common/src/app.types.tsx b/packages/datagateway-common/src/app.types.tsx index 3239d5353..2f1cbf391 100644 --- a/packages/datagateway-common/src/app.types.tsx +++ b/packages/datagateway-common/src/app.types.tsx @@ -64,8 +64,10 @@ export interface Dataset { export interface Datafile { id: number; name: string; - datafileModTime: string; - datafileCreateTime: string; + modTime: string; + createTime: string; + datafileModTime?: string; + datafileCreateTime?: string; fileSize?: number; location?: string; description?: string; diff --git a/packages/datagateway-dataview/src/views/datafilePreview/detailsPane.component.test.tsx b/packages/datagateway-dataview/src/views/datafilePreview/detailsPane.component.test.tsx index 763c8086c..5116c780e 100644 --- a/packages/datagateway-dataview/src/views/datafilePreview/detailsPane.component.test.tsx +++ b/packages/datagateway-dataview/src/views/datafilePreview/detailsPane.component.test.tsx @@ -96,14 +96,16 @@ describe('DetailsPane', () => { expect( await screen.findByText('datafiles.details.mod_time') ).toBeInTheDocument(); - expect(screen.getByText(mockDatafile.datafileModTime)).toBeInTheDocument(); + expect( + screen.getByText(mockDatafile.datafileModTime) + ).toBeInTheDocument(); }); it('with an unknown message if the last modified time is unknown', async () => { renderComponent({ datafile: { ...mockDatafile, - datafileModTime: '', + datafileModTime: undefined, }, }); @@ -121,14 +123,16 @@ describe('DetailsPane', () => { expect( await screen.findByText('datafiles.details.create_time') ).toBeInTheDocument(); - expect(screen.getByText(mockDatafile.datafileCreateTime)).toBeInTheDocument(); + expect( + screen.getByText(mockDatafile.datafileCreateTime) + ).toBeInTheDocument(); }); it('with an unknown message if the creation date is unknown', async () => { renderComponent({ datafile: { ...mockDatafile, - datafileCreateTime: '', + datafileCreateTime: undefined, }, }); diff --git a/packages/datagateway-dataview/src/views/datafilePreview/testData.ts b/packages/datagateway-dataview/src/views/datafilePreview/testData.ts index f92c8e134..bae29d298 100644 --- a/packages/datagateway-dataview/src/views/datafilePreview/testData.ts +++ b/packages/datagateway-dataview/src/views/datafilePreview/testData.ts @@ -3,13 +3,15 @@ import type { Datafile } from 'datagateway-common'; const mockDatafile = { - datafileCreateTime: '2020-01-01', + createTime: '2020-01-01', + datafileCreateTime: '2019-01-01', dataset: undefined, description: 'test description', fileSize: 100, id: 123, location: 'test location', - datafileModTime: '2020-01-02', + modTime: '2020-01-02', + datafileModTime: '2019-01-02', name: 'Datafile.txt', parameters: [], } satisfies Datafile; diff --git a/packages/datagateway-dataview/src/views/table/datafileTable.component.test.tsx b/packages/datagateway-dataview/src/views/table/datafileTable.component.test.tsx index e9a71df7c..35dfaee96 100644 --- a/packages/datagateway-dataview/src/views/table/datafileTable.component.test.tsx +++ b/packages/datagateway-dataview/src/views/table/datafileTable.component.test.tsx @@ -63,8 +63,10 @@ describe('Datafile table component', () => { name: 'Test 1', location: '/test1', fileSize: 1, - datafileModTime: '2019-07-23', - datafileCreateTime: '2019-07-23', + modTime: '2019-07-23', + createTime: '2019-07-23', + datafileModTime: '2019-01-02', + datafileCreateTime: '2019-01-01', }, ]; history = createMemoryHistory(); @@ -200,7 +202,7 @@ describe('Datafile table component', () => { findCellInRow(row, { columnIndex: await findColumnIndexByName('datafiles.modified_time'), }) - ).getByText('2019-07-23') + ).getByText('2019-01-02') ).toBeInTheDocument(); }); @@ -243,7 +245,9 @@ describe('Datafile table component', () => { expect(history.length).toBe(2); expect(history.location.search).toBe( - `?filters=${encodeURIComponent('{"datafileModTime":{"endDate":"2019-08-06"}}')}` + `?filters=${encodeURIComponent( + '{"datafileModTime":{"endDate":"2019-08-06"}}' + )}` ); // await user.clear(filterInput); diff --git a/packages/datagateway-dataview/src/views/table/dls/dlsDatafilesTable.component.test.tsx b/packages/datagateway-dataview/src/views/table/dls/dlsDatafilesTable.component.test.tsx index df6f781da..b4501d05c 100644 --- a/packages/datagateway-dataview/src/views/table/dls/dlsDatafilesTable.component.test.tsx +++ b/packages/datagateway-dataview/src/views/table/dls/dlsDatafilesTable.component.test.tsx @@ -78,8 +78,10 @@ describe('DLS datafiles table component', () => { name: 'Test 1', location: '/test1', fileSize: 1, - datafileModTime: '2019-07-23', - datafileCreateTime: '2019-07-23', + modTime: '2019-07-23', + createTime: '2019-07-23', + datafileModTime: '2019-01-02', + datafileCreateTime: '2019-01-01', }, ]; history = createMemoryHistory(); @@ -165,7 +167,7 @@ describe('DLS datafiles table component', () => { findCellInRow(row, { columnIndex: await findColumnIndexByName('datafiles.create_time'), }) - ).getByText('2019-07-23') + ).getByText('2019-01-01') ).toBeInTheDocument(); }); diff --git a/packages/datagateway-dataview/src/views/table/isis/isisDatafilesTable.component.test.tsx b/packages/datagateway-dataview/src/views/table/isis/isisDatafilesTable.component.test.tsx index 144941130..5b89cd726 100644 --- a/packages/datagateway-dataview/src/views/table/isis/isisDatafilesTable.component.test.tsx +++ b/packages/datagateway-dataview/src/views/table/isis/isisDatafilesTable.component.test.tsx @@ -61,8 +61,10 @@ describe('ISIS datafiles table component', () => { name: 'Test 1', location: '/test1', fileSize: 1, - datafileModTime: '2019-07-23', - datafileCreateTime: '2019-07-23', + modTime: '2019-07-23', + createTime: '2019-07-23', + datafileModTime: '2019-01-02', + datafileCreateTime: '2019-01-01', }, ]; cartItems = []; @@ -201,7 +203,7 @@ describe('ISIS datafiles table component', () => { findCellInRow(row, { columnIndex: await findColumnIndexByName('datafiles.modified_time'), }) - ).getByText('2019-07-23') + ).getByText('2019-01-02') ).toBeInTheDocument(); }); diff --git a/packages/datagateway-download/src/testData.ts b/packages/datagateway-download/src/testData.ts index fd4dc6b10..5e229ddb1 100644 --- a/packages/datagateway-download/src/testData.ts +++ b/packages/datagateway-download/src/testData.ts @@ -323,8 +323,8 @@ export const mockDatafiles: Datafile[] = [ { id: 70, name: 'datafile weekend', - datafileModTime: '2018-03-10T08:19:55Z', - datafileCreateTime: '2018-03-10T08:19:55Z', + modTime: '2018-03-10T08:19:55Z', + createTime: '2018-03-10T08:19:55Z', dataset: mockDatasets[0], }, ];