Skip to content

Conversation

@pawelperek-da
Copy link
Contributor

Fixes #2733

Pull Request Checklist

Cluster Testing

  • If a cluster test is required, comment /cluster_test on this PR to request it, and ping someone with access to the DA-internal system to approve it.
  • If a hard-migration test is required (from the latest release), comment /hdm_test on this PR to request it, and ping someone with access to the DA-internal system to approve it.

PR Guidelines

  • Include any change that might be observable by our partners or affect their deployment in the release notes.
  • Specify fixed issues with Fixes #n, and mention issues worked on using #n
  • Include a screenshot for frontend-related PRs - see README or use your favorite screenshot tool

Merge Guidelines

  • Make the git commit message look sensible when squash-merging on GitHub (most likely: just copy your PR description).

const theFuture = dayjs().add(1, 'day').format(dateTimeFormatISO);

await user.type(expiryDateInput, thePast);
fireEvent.change(expiryDateInput, { target: { value: thePast } });
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fayi-da apparently that’s how we fill date fields in unit tests now 🙂
The await user.type call leaves the field in an Invalid Date state, which messes up the tests.
Kind of funny, because when I was writing my first UI tests, I remember fireEvent.change not working quite right


await waitFor(() => {
expect(screen.queryByText('Expiration must be in the future')).toBeDefined();
expect(screen.queryByText('Expiration must be in the future')).toBeInTheDocument();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fayi-da for some reason, toBeDefined was giving me both false positives and false negatives (it seems like screen.queryByText returns a DOM-like Null instead of a standard JS null). Switching to toBeInTheDocument fixed the existing test errors and revealed some new ones (e.g. apps/sv/frontend/src/components/forms/SetAmuletConfigRulesForm.tsx). I’d propose we use toBeInTheDocument from now on

field.handleChange(e.target.value as string)
}
onBlur={field.handleBlur}
placeholder="Select an action"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MUI’s <Select /> doesn’t support a placeholder prop, so it doesn’t do anything (see PR #1626), and in v7 it actually throws an error. If we want to match the Figma designs, we’ll need to hack in a placeholder manually.

>
<Grid container spacing={1}>
<Grid xs={3}>
<Grid size={{ xs: 3 }}>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Signed-off-by: Paweł Perek <[email protected]>
Signed-off-by: Paweł Perek <[email protected]>
Signed-off-by: Paweł Perek <[email protected]>
Signed-off-by: Paweł Perek <[email protected]>
Signed-off-by: Paweł Perek <[email protected]>
Signed-off-by: Paweł Perek <[email protected]>
Signed-off-by: Paweł Perek <[email protected]>
Signed-off-by: Paweł Perek <[email protected]>
Signed-off-by: Paweł Perek <[email protected]>
Signed-off-by: Paweł Perek <[email protected]>
@pawelperek-da pawelperek-da marked this pull request as ready for review October 24, 2025 20:34
maxDateTime={effectivity}
readOnly={false}
onChange={d => handleExpirationDateChange(d)}
enableAccessibleFieldDOMStructure={false}
Copy link
Contributor Author

@pawelperek-da pawelperek-da Oct 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Context: In MUI v7, the DatePickers introduced a new “accessible” structure. Instead of a simple <input />, the picker is now composed of multiple <div> elements with tab-selectable slots (year, month, day, etc.), plus a read-only <input /> managed by those <div>s.

While this approach is great for UX and accessibility, it’s absolutely horrible for integration testing. I’ve tried several methods to programmatically fill these pickers, including:

  1. sendKeys to the read-only <input /> (current approach)
  2. sendKeys to the parent <div> that manages the DatePicker
  3. sendKeys directly to individual slot <div>s (fails due to remounting)
  4. sendKeys to slot <div>s while searching for the next slot after each input
  5. js.executeScript to focus/click the managing <div> and then sendKeys (works in the browser but not in tests)
  6. js.executeScript to set the value directly in the script

...and several other variations, but none of them worked reliably.

Given that, I propose we keep using the pre-v7 non-accessible structure for now. Unfortunately it’s soft-deprecated and while it doesn’t raise warnings yet, it's planned for removal in v9, so I hope either it will be fixed until then or we will figure our some trick to fill it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SV UI Redesign Look & Feel: Initial Work

1 participant