Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions apps/web/src/layouts/task-board/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,49 @@ describe("laneVisibility", () => {
expect(hideable).toEqual([]);
});

/**
* The last way a card could vanish. A card the board cannot place — a
* Studio-native one on a converted board, or any status no column accounts
* for — gets its own lane at the end rather than being hidden or re-filed
* under a column we picked. Re-filing is a decision only the org can make;
* hiding is the invisibility this exists to prevent.
*/
test("gives a card the board cannot place a lane of its own", () => {
const { lanes, hidden, hideable } = laneVisibility({
columns: [{ key: "BACKLOG" }, { key: "Fazendo" }],
deliveryEnabled: false,
shownLanes: shown,
occupied: ["Fazendo", "triage", "done"],
});
expect(lanes).toEqual(["BACKLOG", "Fazendo", "done", "triage"]);
expect(hidden).toEqual([]);
expect(hideable).toEqual([]);
});

test("the extra lane goes away once its last card leaves", () => {
expect(
laneVisibility({
columns: [{ key: "BACKLOG" }],
deliveryEnabled: false,
shownLanes: shown,
occupied: [],
}).lanes,
).toEqual(["BACKLOG"]);
});

/** Studio's own board accounts for every canonical status, so nothing is
* ever unplaced there and this cannot start inventing lanes. */
test("never invents a lane on the board Studio ships", () => {
expect(
laneVisibility({
columns: CANONICAL,
deliveryEnabled: true,
shownLanes: STATUSES,
occupied: ["triage", "done", "archived"],
}).lanes,
).toEqual(STATUSES);
});

test("draws nothing for a board with no columns yet", () => {
expect(
laneVisibility({
Expand Down
16 changes: 15 additions & 1 deletion apps/web/src/layouts/task-board/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,21 @@ export function laneVisibility({
HIDDEN_STATUSES.includes(s) || (!deliveryEnabled && isDeliveryLane(s)),
);
const hidden = hideable.filter((s) => !shownLanes.includes(s));
return { lanes: known.filter((s) => !hidden.includes(s)), hidden, hideable };

// A status no column accounts for, but cards are sitting in. Appended as its
// own lane rather than hidden or re-filed: a card the board cannot place is
// still the org's card, and rendering it under a column we picked would be
// us deciding something only they can. Deliberately not hideable — hiding it
// is the invisibility this exists to prevent. It goes away when the last card
// leaves, the same way a column the tracker dropped does.
const placed = new Set(known);
const unplaced = [...new Set(occupied)].filter((s) => !placed.has(s)).sort();

return {
lanes: [...known.filter((s) => !hidden.includes(s)), ...unplaced],
hidden,
hideable,
};
}

export const PRIORITIES: TaskBoardItemPriority[] = [
Expand Down
Loading