fix(web-test): stop group header carry-forward leaking into unrelated columns

When a spreadsheet has 3 header levels (group → detail → codes), the
carry-forward logic for merged group headers would bleed into columns
belonging to different top-level groups. Detect a "super-row" above the
group row and reset carry-forward when a new top-level header starts.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Nick Shirokov
2026-04-04 18:51:10 +03:00
parent e5697d6f5c
commit b008c820f9
+14 -1
View File
@@ -1066,12 +1066,23 @@ function buildSpreadsheetMapping(allCells) {
const detailRow = rows[detailIdx];
const groupRow = groupIdx >= 0 ? rows[groupIdx] : null;
// Detect optional third header level above group row (bounds carry-forward)
let superRow = null;
if (groupIdx > 0 && nonEmpty(rows[groupIdx - 1]) >= 2) {
superRow = rows[groupIdx - 1];
}
// Build column names (group + detail merge)
const groupFilled = new Array(maxCol + 1).fill('');
if (groupRow) {
let cur = '';
for (let c = 0; c <= maxCol; c++) {
if (groupRow[c]) cur = groupRow[c];
if (groupRow[c]) {
cur = groupRow[c];
} else if (superRow && superRow[c]) {
// New top-level header starts here — stop carry-forward
cur = '';
}
groupFilled[c] = cur;
}
}
@@ -1091,6 +1102,8 @@ function buildSpreadsheetMapping(allCells) {
colNames.push(needPrefix ? `${group} / ${detail}` : detail);
} else if (group) {
colNames.push(group);
} else if (superRow && superRow[c]) {
colNames.push(superRow[c]);
} else {
colNames.push(null);
}