refactor: enforce frontend view model boundaries
This commit is contained in:
@@ -23,27 +23,34 @@ it("keeps expanded positions vertical while other positions adapt to the viewpor
|
||||
"bonds",
|
||||
"other",
|
||||
];
|
||||
|
||||
const width = window.innerWidth;
|
||||
expect([375, 1280]).toContain(width);
|
||||
|
||||
for (const kind of kinds) {
|
||||
const otherType = kind === "bonds" ? "BOND" : "FUND";
|
||||
const positions: AccountPagePosition[] = [1, 2, 3].map(index => ((/* eslint-disable unicorn/no-null -- Fixture preserves the production contract’s explicit null values. */
|
||||
{
|
||||
absoluteReturn: null,
|
||||
averagePurchasePrice: null,
|
||||
currentValue: { currency: "RUB", value: "1000" },
|
||||
displayName: `Инструмент ${index}`,
|
||||
figi: null,
|
||||
isin: null,
|
||||
logoName: null,
|
||||
logoSrc: null,
|
||||
quantity: "10",
|
||||
returnText: null,
|
||||
shareText: null,
|
||||
ticker: null,
|
||||
type: kind === "stocks" ? "STOCK" : otherType,
|
||||
}
|
||||
/* eslint-enable unicorn/no-null */)));
|
||||
|
||||
const positions: AccountPagePosition[] = [1, 2, 3].map(
|
||||
/* eslint-disable unicorn/no-null -- Fixture preserves the production contract’s explicit null values. */
|
||||
index =>
|
||||
({
|
||||
absoluteReturn: null,
|
||||
averagePurchasePrice: null,
|
||||
currentValue: { currency: "RUB", value: "1000" },
|
||||
displayName: `Инструмент ${index}`,
|
||||
figi: null,
|
||||
isin: null,
|
||||
logoName: null,
|
||||
logoSrc: null,
|
||||
quantity: "10",
|
||||
returnText: null,
|
||||
shareText: null,
|
||||
ticker: null,
|
||||
type: kind === "stocks" ? "STOCK" : otherType,
|
||||
}),
|
||||
/* eslint-enable unicorn/no-null */
|
||||
);
|
||||
|
||||
const { unmount } = render(
|
||||
<MantineProvider
|
||||
cssVariablesResolver={cssVariablesResolver}
|
||||
@@ -61,15 +68,19 @@ it("keeps expanded positions vertical while other positions adapt to the viewpor
|
||||
/>
|
||||
</MantineProvider>,
|
||||
);
|
||||
|
||||
const bounds = positions.map(position =>
|
||||
screen.getByText(position.displayName).getBoundingClientRect(),
|
||||
);
|
||||
|
||||
const context = `${kind} at ${width}px`;
|
||||
|
||||
for (const [index, current] of bounds.entries()) {
|
||||
expect(current.width, context).toBeGreaterThan(0);
|
||||
expect(current.height, context).toBeGreaterThan(0);
|
||||
if (index === 0) continue;
|
||||
const previous = bounds[index - 1];
|
||||
|
||||
if (kind === "other" && width === 1280) {
|
||||
// eslint-disable-next-line vitest/no-conditional-expect -- The fixed table case selects the expected outcome; every case asserts its own branch.
|
||||
expect(current.top, context).toBeCloseTo(previous.top, 0);
|
||||
@@ -83,6 +94,7 @@ it("keeps expanded positions vertical while other positions adapt to the viewpor
|
||||
expect(current.top, context).toBeGreaterThan(previous.bottom);
|
||||
}
|
||||
}
|
||||
|
||||
unmount();
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user