diff --git a/lib/public/views/Logs/ActiveColumns/index.js b/lib/public/views/Logs/ActiveColumns/index.js index d25f9db88c..863ef6dfe9 100644 --- a/lib/public/views/Logs/ActiveColumns/index.js +++ b/lib/public/views/Logs/ActiveColumns/index.js @@ -108,6 +108,11 @@ const activeColumns = (model) => ({ * @return {Object} A collection of columns with parameters for the Log table */ export const activeHomeOverviewColumns = (model) => ({ + id: { + name: 'Entry ID', + visible: false, + primary: true, + }, title: { name: 'Title', visible: true, diff --git a/test/public/home/overview.test.js b/test/public/home/overview.test.js index 5c19581c9c..d29e46d927 100644 --- a/test/public/home/overview.test.js +++ b/test/public/home/overview.test.js @@ -12,7 +12,11 @@ */ const chai = require('chai'); -const { defaultBefore, defaultAfter, getFirstRow } = require('../defaults'); +const { + defaultBefore, + defaultAfter, + getFirstRow, +} = require('../defaults'); const { expect } = chai; @@ -47,25 +51,51 @@ module.exports = () => { firstRowId = await getFirstRow(table, page); // We expect to find a table - expect(firstRowId).to.equal('rowundefined'); + expect(firstRowId).to.equal('row129'); }); - /* - * It('can navigate to a log detail page', async () => { - * const firstRow = await page.$('tr.clickable'); - * const firstRowId = await firstRow.evaluate((row) => row.id); - * parsedFirstRowId = parseInt(firstRowId.slice('row'.length, firstRowId.length), 10); - */ - - /* - * // We expect the entry page to have the same id as the id from the log overview - * await firstRow.evaluate((row) => row.click()); - * await page.waitForTimeout(500); - */ - - /* - * Const redirectedUrl = await page.url(); - * expect(redirectedUrl).to.equal(`${url}/?page=log-detail&id=${parsedFirstRowId}`); - * }); - */ + it('shows correct datatypes in respective columns', async () => { + table = await page.$$('tr'); + firstRowId = await getFirstRow(table, page); + + // Expectations of header texts being of a certain datatype + const headerDatatypes = { + runNumber: (number) => typeof number == 'number', + timeO2Start: (date) => !isNaN(Date.parse(date)), + timeO2End: (date) => !isNaN(Date.parse(date)), + }; + + // We find the headers matching the datatype keys + const headers = await page.$$('th'); + const headerIndices = {}; + for (const [index, header] of headers.entries()) { + const headerContent = await page.evaluate((element) => element.id, header); + const matchingDatatype = Object.keys(headerDatatypes).find((key) => headerContent === key); + if (matchingDatatype !== undefined) { + headerIndices[index] = matchingDatatype; + } + } + + // We expect every value of a header matching a datatype key to actually be of that datatype + const firstRowCells = await page.$$(`#${firstRowId} td`); + for (const [index, cell] of firstRowCells.entries()) { + if (Object.keys(headerIndices).includes(index)) { + const cellContent = await page.evaluate((element) => element.innerText, cell); + const expectedDatatype = headerDatatypes[headerIndices[index]](cellContent); + expect(expectedDatatype).to.be.true; + } + } + }); + + it('can navigate to a detail page', async () => { + const firstRow = await page.$('tr.clickable'); + const parsedFirstRowId = parseInt(firstRowId.slice('row'.length, firstRowId.length), 10); + + // We expect the entry page to have the same id as the id from the log overview + await firstRow.evaluate((row) => row.click()); + await page.waitForTimeout(500); + + const redirectedUrl = await page.url(); + expect(redirectedUrl).to.equal(`${url}/?page=log-detail&id=${parsedFirstRowId}`); + }); };