Skip to content

Commit

Permalink
4342 // Cypress tests for workspaces and dashboards
Browse files Browse the repository at this point in the history
Signed-off-by: Dinika Saxena <dinikasaxenas@gmail.com>
  • Loading branch information
Dinika committed Oct 19, 2023
1 parent 59c6ec6 commit 37918c0
Showing 1 changed file with 212 additions and 28 deletions.
240 changes: 212 additions & 28 deletions cypress/e2e/PublicStudios.cy.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,5 @@
import * as _ from 'lodash';

const PUBLIC_STUDIOS = [
{
id: 'thalamus',
title: 'public | thalamus',
url:
'https://bbp.epfl.ch/nexus/web/studios/public/thalamus/studios/e9ceee28-b2c2-4c4d-bff9-d16f43c3eb0f?workspaceId=https%3A%2F%2Fbbp.epfl.ch%2Fneurosciencegraph%2Fdata%2F52e9c443-534b-4b2f-bd6a-ad340ae10d00&dashboardId=https%3A%2F%2Fbbp.epfl.ch%2Fneurosciencegraph%2Fdata%2Fcaea33ce-2333-40af-a9cb-3149077f1ec9',
expectedColumns: 7,
expectedRows: 157,
},
{
id: 'topological-sampling',
title: 'public | topological-sampling',
url:
'https://bbp.epfl.ch/nexus/web/studios/public/topological-sampling/studios/https%3A%2F%2Fbbp.epfl.ch%2Fneurosciencegraph%2Fdata%2Fa7cc7e9f-53c5-4940-929c-95f4c4f57728?workspaceId=https%3A%2F%2Fbbp.epfl.ch%2Fneurosciencegraph%2Fdata%2F165e54c5-e8f6-4d85-ac94-53bc3dfe5cd4&dashboardId=https%3A%2F%2Fbbp.epfl.ch%2Fneurosciencegraph%2Fdata%2Ff7f58b8a-fe14-4956-9c20-44a60729893a',
expectedColumns: 8,
expectedRows: 15,
},
];

describe('Public Studios', () => {
const RowsPerPage = 50;

Expand All @@ -27,8 +8,10 @@ describe('Public Studios', () => {

const RowSelector = 'tr.data-table-row';
const PaginationButtonsSelector = 'li.ant-pagination-item';
const WorkspaceItemsSelector =
'.workspace-list-container li.ant-menu-submenu-horizontal:not(.ant-menu-submenu-disabled)';

it('can visit public studios', () => {
it('visiting public studios loads default dashboard', () => {
PUBLIC_STUDIOS.forEach(publicStudio => {
cy.intercept('POST', sparqlEndpoint(publicStudio.id)).as(
'studioQueryResult'
Expand All @@ -46,29 +29,102 @@ describe('Public Studios', () => {
cy.findByRole('heading', { name: new RegExp(publicStudio.title, 'i') });
cy.get('table').scrollIntoView(); // Scrolling the table into view triggers the request to fetch rows for the table.

cy.wait('@studioQueryResult', { timeout: 15000 }).then(interception => {
cy.wait('@studioQueryResult', { timeout: 30000 }).then(interception => {
expect(interception.response.statusCode).to.equal(200);
expect(interception.response.body.head.vars.length).to.be.equal(
publicStudio.expectedColumns
publicStudio.defaultDashboardColumnsCount
);

expect(interception.response.body.results.bindings.length).to.be.equal(
publicStudio.expectedRows
publicStudio.defaultDashboardRowsCount
);

cy.wrap(assertColumns(interception.response.body.head.vars));
cy.wrap(assertRows(publicStudio.expectedRows));
cy.wrap(assertColumns(interception.response.body.head.vars, true));
cy.wrap(assertRowCount(publicStudio.defaultDashboardRowsCount));
});
});
});

it('shows correct tabs for all workspaces', () => {
PUBLIC_STUDIOS.forEach(studio => {
cy.visit(studio.url, {
onBeforeLoad: window => dismissConsentToTrackingModal(window),
});
cy.get('table').scrollIntoView(); // Scrolling the table into view triggers the request to fetch rows for the table.

cy.get(WorkspaceItemsSelector).should(
'have.length',
studio.workspaces.length
);

studio.workspaces.forEach(workspace => {
cy.findByRole('menuitem', { name: new RegExp(workspace.name, 'i') });
});
});
});

it('loads data for each dashboard in workspace', () => {
PUBLIC_STUDIOS.forEach(studio => {
cy.visit(studio.url, {
onBeforeLoad: window => dismissConsentToTrackingModal(window),
});
cy.get('table').scrollIntoView(); // Scrolling the table into view triggers the request to fetch rows for the table.

studio.workspaces.forEach(workspace => {
workspace.dashboards.forEach((dashboard, index) => {
if (index !== 0) {
// First dashboard is already tested in the first `it` as it is the default dashboard
cy.findByRole('menuitem', {
name: new RegExp(workspace.name, 'i'),
}).click();

cy.intercept('POST', sparqlEndpoint(studio.id)).as(
`dashboardSparqlRequest-${dashboard.name}`
);

cy.findByRole('menuitem', {
name: dashboard.name,
}).click();

cy.wait(`@dashboardSparqlRequest-${dashboard.name}`, {
timeout: 30000,
}).then(interception => {
cy.wrap(
assertColumns(
interception.response.body.head.vars,
dashboard.sortable
)
);
cy.wrap(
assertRowCount(
interception.response.body.results.bindings.length
)
);
});
}
});
});
});
});

const assertColumns = async (columnsData: string[]) => {
const dismissConsentToTrackingModal = window => {
window.localStorage.setItem(
'consentToTracking',
JSON.stringify({ consentToTracking: true, hasSetPreferences: true })
);
};

const assertColumns = async (columnsData: string[], sortable: boolean) => {
columnsData.forEach(column => {
if (column !== 'self') cy.findByLabelText(_.startCase(column));
if (column !== 'self')
// cy.findByRole('cell', { name: _.startCase(column) });
cy.findByText(_.startCase(column), {
selector: sortable ? 'th .ant-table-column-title' : 'th',
});
});
};

const assertRows = async (expectedTotalRows: number) => {
const assertRowCount = async (expectedTotalRows: number) => {
const totalPaginationButtons = Math.ceil(expectedTotalRows / RowsPerPage);

cy.findByText(new RegExp(`${expectedTotalRows} Results`));
Expand All @@ -85,3 +141,131 @@ describe('Public Studios', () => {
}
};
});

export const PUBLIC_STUDIOS = [
{
id: 'thalamus',
title: 'public | thalamus',
url:
'https://bbp.epfl.ch/nexus/web/studios/public/thalamus/studios/e9ceee28-b2c2-4c4d-bff9-d16f43c3eb0f?workspaceId=https%3A%2F%2Fbbp.epfl.ch%2Fneurosciencegraph%2Fdata%2F52e9c443-534b-4b2f-bd6a-ad340ae10d00&dashboardId=https%3A%2F%2Fbbp.epfl.ch%2Fneurosciencegraph%2Fdata%2Fcaea33ce-2333-40af-a9cb-3149077f1ec9',
defaultDashboardColumnsCount: 7,
defaultDashboardRowsCount: 157,
workspaces: [
{
name: 'Experimental data',
dashboards: [
{
name: '1-Neuron morphology',
sortable: true,
},
{
name: '2-Neuron electrophysiology',
sortable: true,
},
{
name: '3-Layer anatomy',
sortable: true,
},
{
name: '4-Neuron density',
sortable: true,
},
{
name: '5-Bouton density',
sortable: true,
},
],
},
{
name: 'Digital reconstructions',
dashboards: [
{
name: '1-Single cell model',
sortable: true,
},
{
name: '2-Neuron morphology',
sortable: true,
},
{
name: '3-Neuron electrophysiology',
sortable: true,
},
{
name: '4-Factsheet',
sortable: true,
},
{
name: '5-Microcircuit reconstruction',
sortable: true,
},
],
},
{
name: 'Network simulations',
dashboards: [
{
name:
'Video 1-Evoked sensory activity, in vivo-like condition (related to Figure 4)',
sortable: false,
},
{
name:
'Video 2-Sensory adaptation, control vs. cortical input, in vivo-like condition (related to Figure 5)',
sortable: false,
},
{
name:
'Video 3-Transition from wakefulness-like states to simulated cortical UP and DOWN activity, with spindle-like oscillations appearing during the UP state (related to Figure 6)',
sortable: false,
},
{
name:
'Video 4-Spindle-like oscillations, in vitro-like condition (related to Figure 7)',
sortable: false,
},
{
name:
'Video 5-Spindle-like oscillations, control vs. gap-junctions removed (related to Figure 7)',
sortable: false,
},
],
},
],
},
{
id: 'topological-sampling',
title: 'public | topological-sampling',
url:
'https://bbp.epfl.ch/nexus/web/studios/public/topological-sampling/studios/https%3A%2F%2Fbbp.epfl.ch%2Fneurosciencegraph%2Fdata%2Fa7cc7e9f-53c5-4940-929c-95f4c4f57728?workspaceId=https%3A%2F%2Fbbp.epfl.ch%2Fneurosciencegraph%2Fdata%2F165e54c5-e8f6-4d85-ac94-53bc3dfe5cd4&dashboardId=https%3A%2F%2Fbbp.epfl.ch%2Fneurosciencegraph%2Fdata%2Ff7f58b8a-fe14-4956-9c20-44a60729893a',
defaultDashboardColumnsCount: 8,
defaultDashboardRowsCount: 15,
workspaces: [
{
name: 'Data dashboards',
dashboards: [
{
name: 'All data',
sortable: true,
},
{
name: 'Analysis results',
sortable: true,
},
{
name: 'Configurations',
sortable: true,
},
{
name: 'Input data',
sortable: true,
},
{
name: 'Notebooks',
sortable: true,
},
],
},
],
},
];

0 comments on commit 37918c0

Please sign in to comment.