mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-07 16:28:38 +09:00
moebius#342: Columns are not sorted correctly (Natural Sort algorithm)
Issue #31 https://github.com/MoonchildProductions/moebius/pull/342
This commit is contained in:
parent
6d865bfda3
commit
8a1405d8b9
8 changed files with 218 additions and 35 deletions
|
|
@ -2,40 +2,58 @@
|
|||
// inspector table.
|
||||
"use strict";
|
||||
|
||||
const ITEMS_PER_PAGE = 50;
|
||||
|
||||
add_task(function* () {
|
||||
yield openTabAndSetupStorage(MAIN_DOMAIN + "storage-overflow.html");
|
||||
|
||||
let $ = id => gPanelWindow.document.querySelector(id);
|
||||
let $$ = sel => gPanelWindow.document.querySelectorAll(sel);
|
||||
|
||||
gUI.tree.expandAll();
|
||||
yield selectTreeItem(["localStorage", "http://test1.example.org"]);
|
||||
checkCellLength(ITEMS_PER_PAGE);
|
||||
|
||||
yield scroll();
|
||||
checkCellLength(ITEMS_PER_PAGE * 2);
|
||||
|
||||
yield scroll();
|
||||
checkCellLength(ITEMS_PER_PAGE * 3);
|
||||
|
||||
// Check that the columns are sorted in a human readable way (ascending).
|
||||
checkCellValues("ASC");
|
||||
|
||||
// Sort descending.
|
||||
clickColumnHeader("name");
|
||||
|
||||
// Check that the columns are sorted in a human readable way (descending).
|
||||
checkCellValues("DEC");
|
||||
|
||||
yield finishTests();
|
||||
});
|
||||
|
||||
function checkCellLength(len) {
|
||||
let cells = gPanelWindow.document
|
||||
.querySelectorAll("#name .table-widget-cell");
|
||||
let msg = `Table should initially display ${len} items`;
|
||||
|
||||
is(cells.length, len, msg);
|
||||
}
|
||||
|
||||
function checkCellValues(order) {
|
||||
let cells = [...gPanelWindow.document
|
||||
.querySelectorAll("#name .table-widget-cell")];
|
||||
cells.forEach(function (cell, index, arr) {
|
||||
let i = order === "ASC" ? index + 1 : arr.length - index;
|
||||
is(cell.value, `item-${i}`, `Cell value is correct (${order}).`);
|
||||
});
|
||||
}
|
||||
|
||||
function* scroll() {
|
||||
let $ = id => gPanelWindow.document.querySelector(id);
|
||||
|
||||
let table = $("#storage-table .table-widget-body");
|
||||
let cellHeight = $(".table-widget-cell").getBoundingClientRect().height;
|
||||
|
||||
is($$("#value .table-widget-cell").length, 50,
|
||||
"Table should initially display 50 items");
|
||||
let cell = $("#name .table-widget-cell");
|
||||
let cellHeight = cell.getBoundingClientRect().height;
|
||||
|
||||
let onStoresUpdate = gUI.once("store-objects-updated");
|
||||
table.scrollTop += cellHeight * 50;
|
||||
yield onStoresUpdate;
|
||||
|
||||
is($$("#value .table-widget-cell").length, 100,
|
||||
"Table should display 100 items after scrolling");
|
||||
|
||||
onStoresUpdate = gUI.once("store-objects-updated");
|
||||
table.scrollTop += cellHeight * 50;
|
||||
yield onStoresUpdate;
|
||||
|
||||
is($$("#value .table-widget-cell").length, 150,
|
||||
"Table should display 150 items after scrolling");
|
||||
|
||||
onStoresUpdate = gUI.once("store-objects-updated");
|
||||
table.scrollTop += cellHeight * 50;
|
||||
yield onStoresUpdate;
|
||||
|
||||
is($$("#value .table-widget-cell").length, 160,
|
||||
"Table should display all 160 items after scrolling");
|
||||
yield finishTests();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue