fix: align market selection checkboxes

This commit is contained in:
2026-04-24 22:10:16 +08:00
parent 7da1bcf255
commit fe60253cd3
3 changed files with 121 additions and 34 deletions
+48 -3
View File
@@ -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-"]'),