LibreChat/e2e/specs/mock/scenarios/input-number-reset.spec.ts
Marco Beretta f2be28de6a
🪞 fix: Mirror Shared Primitives for Right-to-Left Layouts (#17265)
* fix: Mirror Shared Primitives For RTL Layouts

* fix: Import the Direction Helper Relatively in InfoHoverCard

* test: Cover Mirrored Switch and Dialog Close in RTL

* fix: Keep the Focused Sign-In Label Inside Its Field in RTL

* fix: Mirror by Element Direction and Re-Resolve Side Placement on Open

* test: Pin RTL Scenarios to the Element Direction and Expect a Trailing Number Input

* fix: Keep Time Column Arrow Keys Vertical in RTL

* fix: Keep :dir() Selectors Through CSS Minification

* chore: Declare lightningcss for the Client Build Config

* fix: Keep SelectDropDown Left and Right Icon Sides Physical

* fix: Fall Back to the dir Attribute Where :dir() Is Unsupported

* fix: Leave Nested LTR Islands Unmirrored in the dir Attribute Fallback

* fix: Resolve the Slider Direction From Its Nearest dir

* fix: Resolve the Nearest dir at Any Depth in the :dir() Fallback

* fix: Re-Resolve the Slider Direction When a dir Attribute Changes

* fix: Keep the Provider Direction for a Slider Without a dir Ancestor

* fix: Read an Automatic dir From the Computed Direction for the Slider

* fix: Prefer the Computed Direction When Resolving an Element's Direction

* fix: Re-Resolve the Slider Under a dir=auto Boundary When Its Content Changes

* fix: Keep the Mirrored Combobox Placement Across Rerenders

* refactor: Let the Slider Read Its Direction From the Radix Provider

* fix: Space a Trailing Combobox Option Icon From Its Label
2026-10-20 16:19:38 +02:00

63 lines
2.2 KiB
TypeScript

import { expect, test } from '@playwright/test';
import type { Page } from '@playwright/test';
import { NEW_CHAT_PATH } from '../helpers';
/**
* The `option` InputNumber variant resets the input rc-input-number nests in its wrapper. The reset
* ships with the component's own stylesheet, so any consumer of `@librechat/client` gets it, and
* the app renders the nested input exactly as it did when the rule lived in the app stylesheet.
*/
type Mode = 'light' | 'dark';
type Reset = { width: string; borderStyle: string; background: string; textAlign: string };
async function probeReset(page: Page, mode: Mode): Promise<Reset> {
await page.addInitScript((appearance) => {
localStorage.setItem('color-theme', appearance);
}, mode);
await page.goto(NEW_CHAT_PATH, { timeout: 15000 });
await expect(page.getByRole('textbox', { name: 'Message input' })).toBeVisible({
timeout: 30000,
});
await expect(page.locator('html')).toHaveClass(mode === 'dark' ? /\bdark\b/ : /\blight\b/);
return page.evaluate(() => {
const wrapper = document.createElement('div');
wrapper.style.width = '120px';
wrapper.className = 'reset-rc-number-input reset-rc-number-input-text-right';
const input = document.createElement('input');
input.style.border = '1px solid red';
wrapper.append(input);
document.body.append(wrapper);
const style = getComputedStyle(input);
const result = {
width: style.width,
borderStyle: style.borderTopStyle,
background: style.backgroundColor,
textAlign: style.textAlign,
};
wrapper.remove();
return result;
});
}
const EXPECTED: Reset = {
width: '120px',
borderStyle: 'none',
background: 'rgba(0, 0, 0, 0)',
/** The trailing edge: the right in an LTR page, the left in RTL. */
textAlign: 'end',
};
test.describe('InputNumber option reset', () => {
test('the nested input is reset in the light theme @scenario:input-number-reset-light', async ({
page,
}) => {
expect(await probeReset(page, 'light')).toEqual(EXPECTED);
});
test('the nested input is reset in the dark theme @scenario:input-number-reset-dark', async ({
page,
}) => {
expect(await probeReset(page, 'dark')).toEqual(EXPECTED);
});
});