fix: align market selection checkboxes
This commit is contained in:
@@ -307,6 +307,28 @@ describe("market-dom-sync", () => {
|
||||
expect(readAuthorNames()).toEqual(["达人 A", "达人 B"]);
|
||||
});
|
||||
|
||||
test("inserts the selection column before the native author column", () => {
|
||||
document.body.innerHTML = buildRealMarketGridFixture();
|
||||
|
||||
const table = syncMarketTable(document);
|
||||
if (!table) {
|
||||
throw new Error("Expected market table");
|
||||
}
|
||||
|
||||
expect(readAuthorSectionColumnKeys()).toEqual(["selection", "author"]);
|
||||
});
|
||||
|
||||
test("keeps the selection cells aligned to the native author row heights", () => {
|
||||
document.body.innerHTML = buildRealMarketGridFixture();
|
||||
|
||||
const table = syncMarketTable(document);
|
||||
if (!table) {
|
||||
throw new Error("Expected market table");
|
||||
}
|
||||
|
||||
expect(readSelectionCellHeights()).toEqual(["120px", "120px"]);
|
||||
});
|
||||
|
||||
test("uses native-like alignment styles for plugin cells", () => {
|
||||
document.body.innerHTML = buildRealMarketGridFixtureWithScopedAttributes();
|
||||
|
||||
@@ -962,14 +984,37 @@ function readSelectionRowCheckboxCount() {
|
||||
}
|
||||
|
||||
function readAuthorNames() {
|
||||
const authorColumn = document.querySelector(
|
||||
'[data-testid="author-section"] .content-column'
|
||||
);
|
||||
const authorColumn = Array.from(
|
||||
document.querySelectorAll('[data-testid="author-section"] > .content-column')
|
||||
).find((column) => (column as HTMLElement).querySelector("a")) as Element | null;
|
||||
return readVisualCells(authorColumn).map(
|
||||
(cell) => cell.querySelector("a")?.textContent?.trim() ?? ""
|
||||
);
|
||||
}
|
||||
|
||||
function readAuthorSectionColumnKeys() {
|
||||
return Array.from(
|
||||
document.querySelectorAll('[data-testid="author-section"] > .content-column'),
|
||||
(column) => {
|
||||
const element = column as HTMLElement;
|
||||
if (element.dataset.marketColumnGroup) {
|
||||
return element.dataset.marketColumnGroup;
|
||||
}
|
||||
|
||||
return element.querySelector("a") ? "author" : "unknown";
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function readSelectionCellHeights() {
|
||||
return Array.from(
|
||||
document.querySelectorAll(
|
||||
'[data-testid="author-section"] [data-market-column-group="selection"] > .content-cell'
|
||||
),
|
||||
(cell) => (cell as HTMLElement).style.height
|
||||
);
|
||||
}
|
||||
|
||||
function readAuthorRowHiddenStates() {
|
||||
return Array.from(
|
||||
document.querySelectorAll('[data-testid^="author-cell-"]'),
|
||||
|
||||
Reference in New Issue
Block a user