Skip to content

Commit

Permalink
Merge branch 'develop' into gfi-1664
Browse files Browse the repository at this point in the history
  • Loading branch information
louise-davies authored Sep 19, 2024
2 parents a424309 + 7ec33f3 commit 4e34c0c
Show file tree
Hide file tree
Showing 27 changed files with 427 additions and 387 deletions.
2 changes: 1 addition & 1 deletion packages/datagateway-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"@emotion/styled": "11.11.0",
"@mui/x-date-pickers": "6.11.2",
"@types/lodash.debounce": "4.0.6",
"axios": "1.6.1",
"axios": "1.7.4",
"connected-react-router": "6.9.1",
"date-fns": "2.30.0",
"hex-to-rgba": "2.0.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import TextColumnFilter, {
usePrincipalExperimenterFilter,
useTextFilter,
DEBOUNCE_DELAY,
} from './textColumnFilter.component';
import { act } from 'react-dom/test-utils';
import { usePushFilter, usePushFilters } from '../../api';
Expand All @@ -12,7 +13,6 @@ import userEvent from '@testing-library/user-event';

jest.mock('../../api');
jest.useFakeTimers('modern');
const DEBOUNCE_DELAY = 250;

describe('Text filter component', () => {
let user: UserEvent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,12 @@ const TextColumnFilter = (props: {
propValue ? propValue : ''
);
const [type, setType] = React.useState(propType ? propType : 'include');

// Debounce the updating of the column filter by 250 milliseconds.
// Debounce the updating of the column filter by 500 milliseconds.
const updateValue = React.useMemo(
() =>
debounce((value: string) => {
onChange(value === '' ? null : { value: value, type: type });
}, 250),
}, DEBOUNCE_DELAY),
[onChange, type]
);

Expand Down Expand Up @@ -129,6 +128,8 @@ const TextColumnFilter = (props: {
);
};

export const DEBOUNCE_DELAY = 500;

export default TextColumnFilter;

export const useTextFilter = (
Expand Down
25 changes: 12 additions & 13 deletions packages/datagateway-dataview/cypress/e2e/card/dls/datasets.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ describe('DLS - Datasets Cards', () => {
cy.get('#datagateway-dataview').should('be.visible');

//Default sort
cy.contains('[role="button"]', 'desc').should('exist');
cy.get('.MuiTableSortLabel-iconDirectionDesc').should('be.visible');
cy.contains('[role="button"]', 'asc').should('exist');
cy.get('.MuiTableSortLabel-iconDirectionAsc').should('be.visible');
});

it('should be able to click a dataset to see its datafiles', () => {
cy.get('[data-testid="card"]')
.first()
.contains('DATASET 61')
.contains('DATASET 1')
.click({ force: true });
cy.location('pathname').should(
'eq',
'/browse/proposal/INVESTIGATION%201/investigation/1/dataset/61/datafile'
'/browse/proposal/INVESTIGATION%201/investigation/1/dataset/1/datafile'
);
});

Expand All @@ -38,29 +38,28 @@ describe('DLS - Datasets Cards', () => {
cy.get('[data-testid="card"]')
.first()
.get('[aria-label="card-more-information"]')
.contains('DATASET 61');
.contains('DATASET 1');
cy.get('[data-testid="card"]')
.first()
.get('[aria-label="card-more-information"]')
.contains('1.73 GB', { timeout: 10000 });
.contains('1.39 GB', { timeout: 10000 });

cy.get('#dataset-type-tab').click({ force: true });
cy.get('[data-testid="card"]')
.first()
.get('[aria-label="card-more-information"]')
.contains('DATASETTYPE 3');
.contains('DATASETTYPE 2');
});

it('should be able to sort by one field or multiple', () => {
//Revert the default sort
cy.contains('[role="button"]', 'Create Time').as('timeSortButton').click();
// Revert the default sort
cy.contains('[role="button"]', 'Name').as('nameSortButton').click();
cy.get('@nameSortButton').click();

cy.wait('@getDatasetsOrder', { timeout: 10000 });

// ascending
cy.contains('[role="button"]', 'Name').as('nameSortButton').click();
cy.wait('@getDatasetsOrder', {
timeout: 10000,
});
cy.contains('[role="button"]', 'asc').should('exist');
cy.contains('[role="button"]', 'desc').should('not.exist');
cy.get('[data-testid="card"]').first().contains('DATASET 1');
Expand All @@ -81,7 +80,7 @@ describe('DLS - Datasets Cards', () => {
cy.get('[data-testid="card"]').first().contains('DATASET 1');

// multiple fields (shift click)
cy.get('@timeSortButton').click();
cy.contains('[role="button"]', 'Create Time').as('timeSortButton').click();
cy.wait('@getDatasetsOrder', {
timeout: 10000,
});
Expand Down
26 changes: 13 additions & 13 deletions packages/datagateway-dataview/cypress/e2e/card/isis/datasets.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,27 @@ describe('ISIS - Datasets Cards', () => {
cy.get('#datagateway-dataview').should('be.visible');

//Default sort
cy.contains('[role="button"]', 'desc').should('exist');
cy.get('.MuiTableSortLabel-iconDirectionDesc').should('be.visible');
cy.contains('[role="button"]', 'asc').should('exist');
cy.get('.MuiTableSortLabel-iconDirectionAsc').should('be.visible');
});

it('should be able to click a dataset to see its datafiles', () => {
cy.get('[data-testid="card"]')
.first()
.contains('DATASET 79')
.contains('DATASET 19')
.click({ force: true });
cy.location('pathname').should(
'eq',
'/browse/instrument/1/facilityCycle/19/investigation/19/dataset/79'
'/browse/instrument/1/facilityCycle/19/investigation/19/dataset/19'
);
});

it('should be able to expand "More Information"', () => {
//Revert the default sort
cy.contains('[role="button"]', 'Create Time').click();
cy.wait('@getDatasetsOrder', { timeout: 10000 });
// Revert the default sort
cy.contains('[role="button"]', 'Name').as('nameSortButton').click();
cy.get('@nameSortButton').click();

cy.get('[data-testid="card"]').first().contains('DATASET 19');
cy.get('[data-testid="card"]')
.first()
.contains('More Information')
Expand All @@ -56,15 +57,14 @@ describe('ISIS - Datasets Cards', () => {
});

it('should be able to sort by one field or multiple', () => {
//Revert the default sort
cy.contains('[role="button"]', 'Create Time').as('timeSortButton').click();
// Revert the default sort
cy.contains('[role="button"]', 'Name').as('nameSortButton').click();
cy.get('@nameSortButton').click();
cy.wait('@getDatasetsOrder', { timeout: 10000 });

// ascending
cy.contains('[role="button"]', 'Name').as('nameSortButton').click();
cy.wait('@getDatasetsOrder', {
timeout: 10000,
});

cy.contains('[role="button"]', 'asc').should('exist');
cy.contains('[role="button"]', 'desc').should('not.exist');
cy.get('[data-testid="card"]').first().contains('DATASET 19');
Expand All @@ -85,7 +85,7 @@ describe('ISIS - Datasets Cards', () => {
cy.get('[data-testid="card"]').first().contains('DATASET 19');

// multiple fields (shift click)
cy.get('@timeSortButton').click();
cy.contains('[role="button"]', 'Create Time').as('timeSortButton').click();
cy.wait('@getDatasetsOrder', {
timeout: 10000,
});
Expand Down
8 changes: 4 additions & 4 deletions packages/datagateway-dataview/cypress/e2e/cartSelection.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,16 +311,16 @@ describe('Add/remove from cart functionality', () => {
.and('eq', 'true');

cy.get('[aria-label="select row 0"]').should('be.checked');
cy.get('[aria-label="select row 1"]').should('not.be.checked');
cy.get('[aria-label="select row 2"]').should('not.be.checked');

cy.get('[aria-label="grid"]').scrollTo('bottom', {
ensureScrollable: false,
});
cy.get('[aria-label="grid"]').scrollTo('bottom', {
ensureScrollable: false,
});
cy.get('[aria-label="select row 13"]').should('not.be.checked');
cy.get('[aria-label="select row 14"]').should('be.checked');
cy.get('[aria-label="select row 12"]').should('not.be.checked');
cy.get('[aria-label="select row 13"]').should('be.checked');
});

it('by shift clicking', () => {
Expand Down Expand Up @@ -467,7 +467,7 @@ describe('Add/remove from cart functionality', () => {
cy.get('[aria-label="grid"]').scrollTo('bottom', {
ensureScrollable: false,
});
cy.get('[aria-label="select row 13"]').should('be.checked');
cy.get('[aria-label="select row 13"]').should('not.be.checked');
cy.get('[aria-label="select row 14"]').should('be.checked');
});

Expand Down
21 changes: 10 additions & 11 deletions packages/datagateway-dataview/cypress/e2e/table/dls/datafiles.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ describe('DLS - Datafiles Table', () => {
cy.get('#datagateway-dataview').should('be.visible');

//Default sort
cy.get('[aria-sort="descending"]').should('exist');
cy.get('.MuiTableSortLabel-iconDirectionDesc').should('be.visible');
cy.get('[aria-sort="ascending"]').should('exist');
cy.get('.MuiTableSortLabel-iconDirectionAsc').should('be.visible');
});

it('should not load incorrect URL', () => {
Expand All @@ -38,8 +38,9 @@ describe('DLS - Datafiles Table', () => {
});

it('should be able to sort by all sort directions on single and multiple columns', () => {
//Revert the default sort
cy.contains('[role="button"]', 'Create Time').as('timeSortButton').click();
// Revert the default sort
cy.contains('[role="button"]', 'Name').as('nameSortButton').click();
cy.get('@nameSortButton').click();
cy.wait('@datafilesOrder', { timeout: 10000 });

// ascending order
Expand Down Expand Up @@ -81,11 +82,9 @@ describe('DLS - Datafiles Table', () => {
);

// multiple columns (shift click)
cy.get('@timeSortButton').click();
cy.contains('[role="button"]', 'Create Time').click();
cy.wait('@datafilesOrder', { timeout: 10000 });
cy.contains('[role="button"]', 'Name')
.as('nameSortButton')
.click({ shiftKey: true });
cy.get('@nameSortButton').click({ shiftKey: true });
cy.wait('@datafilesOrder', { timeout: 10000 });
cy.get('@nameSortButton').click({ shiftKey: true });
cy.wait('@datafilesOrder', { timeout: 10000 });
Expand Down Expand Up @@ -141,12 +140,12 @@ describe('DLS - Datafiles Table', () => {

cy.get('#details-panel').should('be.visible');
cy.get('[aria-label="Hide details"]').should('exist');
cy.get('#details-panel').contains('Datafile 1607').should('be.visible');
cy.get('#details-panel').contains('Datafile 1131').should('be.visible');

cy.get('[aria-label="Show details"]').first().click();

cy.get('#details-panel').contains('Datafile 1726').should('be.visible');
cy.get('#details-panel').contains('Datafile 1607').should('not.exist');
cy.get('#details-panel').contains('Datafile 1012').should('be.visible');
cy.get('#details-panel').contains('Datafile 1131').should('not.exist');
cy.get('[aria-label="Hide details"]').should('have.length', 1);

cy.get('[aria-label="Hide details"]').first().click();
Expand Down
31 changes: 17 additions & 14 deletions packages/datagateway-dataview/cypress/e2e/table/dls/datasets.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ describe('DLS - Datasets Table', () => {
cy.get('#datagateway-dataview').should('be.visible');

//Default sort
cy.get('[aria-sort="descending"]').should('exist');
cy.get('.MuiTableSortLabel-iconDirectionDesc').should('be.visible');
cy.get('[aria-sort="ascending"]').should('exist');
cy.get('.MuiTableSortLabel-iconDirectionAsc').should('be.visible');
});

it('should not load incorrect URL', () => {
Expand All @@ -37,7 +37,7 @@ describe('DLS - Datasets Table', () => {

cy.location('pathname').should(
'eq',
'/browse/proposal/INVESTIGATION%201/investigation/1/dataset/61/datafile'
'/browse/proposal/INVESTIGATION%201/investigation/1/dataset/1/datafile'
);
});

Expand All @@ -49,11 +49,12 @@ describe('DLS - Datasets Table', () => {
});

it('should be able to sort by all sort directions on single and multiple columns', () => {
//Revert the default sort
cy.contains('[role="button"]', 'Create Time').as('timeSortButton').click();
// Revert the default sort
cy.contains('[role="button"]', 'Name').as('nameSortButton').click();
cy.get('@nameSortButton').click();

// ascending order
cy.contains('[role="button"]', 'Name').as('nameSortButton').click();
cy.get('@nameSortButton').click();
cy.wait('@datasets', { timeout: 10000 });

cy.get('[aria-sort="ascending"]').should('exist');
Expand Down Expand Up @@ -84,7 +85,8 @@ describe('DLS - Datasets Table', () => {
cy.get('[aria-rowindex="1"] [aria-colindex="3"]').contains('DATASET 1');

// multiple columns (shift click)
cy.get('@timeSortButton').click();
cy.contains('[role="button"]', 'Create Time').as('timeSortButton').click();
// ascending order
cy.wait('@datasets', { timeout: 10000 });
cy.get('@nameSortButton').click({ shiftKey: true });
cy.wait('@datasets', { timeout: 10000 });
Expand All @@ -102,8 +104,9 @@ describe('DLS - Datasets Table', () => {
});

it('should change icons when sorting on a column', () => {
// clear the default sort
cy.contains('[role="button"]', 'Create Time').click();
// clear default sort
cy.contains('[role="button"]', 'Name').click();
cy.contains('[role="button"]', 'Name').click();

cy.get('[data-testid="SortIcon"]').should('have.length', 5);

Expand Down Expand Up @@ -145,21 +148,21 @@ describe('DLS - Datasets Table', () => {

cy.get('#details-panel').should('be.visible');
cy.get('[aria-label="Hide details"]').should('exist');
cy.get('#details-panel').contains('DATASET 1').should('be.visible');
cy.get('#details-panel').contains('DATASET 61').should('be.visible');

cy.get('[aria-label="Show details"]').first().click();

cy.get('#details-panel').contains('DATASET 61').should('be.visible');
cy.get('#details-panel').contains('DATASET 1').should('not.exist');
cy.get('#details-panel').contains('DATASET 1').should('be.visible');
cy.get('#details-panel').contains('DATASET 61').should('not.exist');
cy.get('[aria-label="Hide details"]').should('have.length', 1);

cy.get('#details-panel')
.contains('Home down your nice amount successful')
.contains('Suggest shake effort many last prepare small')
.should('be.visible');

cy.get('[aria-controls="dataset-type-panel"]').click();
cy.get('#dataset-type-panel').should('not.have.attr', 'hidden');
cy.get('#details-panel').contains('DATASETTYPE 3');
cy.get('#details-panel').contains('DATASETTYPE 2');

cy.get('[aria-label="Hide details"]').first().click();

Expand Down
Loading

0 comments on commit 4e34c0c

Please sign in to comment.