diff --git a/e2e/calculator.spec.js b/e2e/calculator.spec.js
index 4bbe59f..b82ba35 100644
--- a/e2e/calculator.spec.js
+++ b/e2e/calculator.spec.js
@@ -67,6 +67,9 @@ test("current values are subtracted from totals and kept during recalculation",
await expect(subtractCurrent).toHaveAttribute("aria-pressed", "true");
await expect(current).toBeFocused();
await expect(totalLabel).toBeVisible();
+ await expect(tool.locator(".calculator-result-field")).toHaveClass(/has-current/);
+ await expect(tool.locator(".calculator-result").getByText("Résultat", { exact: true })).toHaveCount(0);
+ await expect(tool.locator(".calculator-result-field > span")).toHaveText("Résultat");
const expressionBounds = await expression.boundingBox();
const currentBounds = await current.boundingBox();
expect(currentBounds.x).toBeCloseTo(expressionBounds.x, 0);
@@ -94,6 +97,7 @@ test("current values are subtracted from totals and kept during recalculation",
await expect(tool.locator(".calculator-result strong")).toHaveAttribute("aria-label", "160");
await subtractCurrent.click();
await expect(current).toHaveCount(0);
+ await expect(tool.locator(".calculator-result-field")).not.toHaveClass(/has-current/);
await expect(tool.locator(".calculator-result strong")).toHaveAttribute("aria-label", "180");
});
diff --git a/e2e/style-layouts.spec.js b/e2e/style-layouts.spec.js
index 7dc8ffe..d687f75 100644
--- a/e2e/style-layouts.spec.js
+++ b/e2e/style-layouts.spec.js
@@ -9,7 +9,7 @@ async function columns(locator, count) {
test("calculator layout follows the tool width rather than its location", async ({ page }) => {
await page.setViewportSize({ width: 1280, height: 900 });
- await mountStyles(page, ``);
+ await mountStyles(page, ``);
const tool = page.locator('[data-module-type="calculator"]');
const calculator = tool.locator(".calculator-module");
const card = tool.locator(".calculator-card");
@@ -20,9 +20,19 @@ test("calculator layout follows the tool width rather than its location", async
await columns(calculator, 1);
await columns(card, 2);
await expect(tool.locator(".calculator-field")).toHaveCSS("grid-column-start", "1");
- await expect(tool.locator(".calculator-result")).toHaveCSS("grid-column-start", "2");
+ await expect(tool.locator(".calculator-result-field")).toHaveCSS("grid-column-start", "2");
+ await expect(tool.locator(".calculator-result")).toHaveCSS("height", "36px");
+ await expect(tool.locator(".calculator-result")).toHaveCSS("min-height", "36px");
+ const resultValue = tool.locator(".calculator-result strong");
+ const compactResultFontSize = Number.parseFloat(await computed(resultValue, "font-size"));
+ await expect(tool.locator(".calculator-result")).toHaveCSS("padding-top", "7px");
+ await tool.locator(".calculator-result-field").evaluate((element) => { element.classList.add("has-current"); });
+ await expect.poll(async () => Number.parseFloat(await computed(tool.locator(".calculator-result"), "height"))).toBeGreaterThan(36);
+ await expect.poll(async () => Number.parseFloat(await computed(resultValue, "font-size"))).toBeGreaterThan(compactResultFontSize);
+ await expect(tool.locator(".calculator-result")).toHaveCSS("padding-top", "12px");
await tool.evaluate((element) => { element.style.width = "480px"; });
await columns(card, 1);
+ await expect(tool.locator(".calculator-result")).toHaveCSS("min-height", "72px");
});
for (const width of [1280, 900, 390]) {
diff --git a/website/src/features/toolboxes/modules/CalculatorModule.jsx b/website/src/features/toolboxes/modules/CalculatorModule.jsx
index 4afb250..a3fd6a8 100644
--- a/website/src/features/toolboxes/modules/CalculatorModule.jsx
+++ b/website/src/features/toolboxes/modules/CalculatorModule.jsx
@@ -306,11 +306,13 @@ export function CalculatorModule({ toolboxId, moduleId, context, textExchangeOpe
/>
)}
-
+
{textContent.resultLabel || "Résultat"}
-
-
-
+
+
+
+
+