Bug 1399897 - Fix console_table mochitest; r=Honza.
Now that we are using sibling divs for all the cells of the table,
we don't have the same notion of what is a row.
The console table test is adapted to the new component.
MozReview-Commit-ID: HcfzTaRVIcN
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_console_table.js
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_console_table.js
@@ -146,37 +146,37 @@ add_task(function* () {
".message .new-consoletable");
is(consoleTableNodes.length, testCases.length,
"console has the expected number of consoleTable items");
testCases.forEach((testCase, index) => testItem(testCase, nodes[index]));
});
function testItem(testCase, node) {
info(testCase.info);
- let columns = Array.from(node.querySelectorAll("thead th"));
- let rows = Array.from(node.querySelectorAll("tbody tr"));
+ const columns = Array.from(node.querySelectorAll("[role=columnheader]"));
+ const columnsNumber = columns.length;
+ const cells = Array.from(node.querySelectorAll("[role=gridcell]"));
is(
JSON.stringify(testCase.expected.columns),
JSON.stringify(columns.map(column => column.textContent)),
"table has the expected columns"
);
- is(testCase.expected.rows.length, rows.length,
+ // We don't really have rows since we are using a CSS grid in order to have a sticky
+ // header on the table. So we check the "rows" by dividing the number of cells by the
+ // number of columns.
+ is(testCase.expected.rows.length, cells.length / columnsNumber,
"table has the expected number of rows");
testCase.expected.rows.forEach((expectedRow, rowIndex) => {
- let row = rows[rowIndex];
- let cells = row.querySelectorAll("td");
- is(expectedRow.length, cells.length, "row has the expected number of cells");
-
- expectedRow.forEach((expectedCell, cellIndex) => {
- let cell = cells[cellIndex];
- is(expectedCell, cell.textContent, "cell has the expected content");
- });
+ const startIndex = rowIndex * columnsNumber;
+ // Slicing the cells array so we can get the current "row".
+ const rowCells = cells.slice(startIndex, startIndex + columnsNumber);
+ is(rowCells.map(x => x.textContent).join(" | "), expectedRow.join(" | "));
});
}
function findConsoleTable(node, index) {
let condition = node.querySelector(
`.message:nth-of-type(${index + 1}) .new-consoletable`);
return condition;
}