Edan
Edan
SSolara
Created by Edan on 1/18/2025 in #questions-issues
Testing button click
I'm using an accordion widget (v.ExpansionPanels), where each step has a Button(label="Confirm", ...) that, on click, bubbles up a state change, which, among other things, moves the accordion to the next step. This works as expected in the frontend. However, it does not seem to work in the test.
def test_step_change_on_confirm(self):
"""Test that the wizard step changes on confirm button click."""
self._assert_step_state(0, State.READY)
self._assert_step_state(1, State.INIT)

confirm_button = next(
filter(
lambda btn: "Confirm" in btn.children,
self.rc.find(v.Btn).widgets,
),
None,
)
confirm_button.click()

self._assert_step_state(0, State.SUCCESS)
self._assert_step_state(1, State.CONFIGURED) # works in the frontend, but fails here

def _assert_step_state(self, index, state):
step = self.rc.find(v.ExpansionPanel).widgets[index]
header = step.children[0]
container = header.children[0]
icon = container.children[0]
assert f"background-color: {BG_COLORS[state]}" in header.style_
assert icon.children == [STATE_ICONS[state]]
def test_step_change_on_confirm(self):
"""Test that the wizard step changes on confirm button click."""
self._assert_step_state(0, State.READY)
self._assert_step_state(1, State.INIT)

confirm_button = next(
filter(
lambda btn: "Confirm" in btn.children,
self.rc.find(v.Btn).widgets,
),
None,
)
confirm_button.click()

self._assert_step_state(0, State.SUCCESS)
self._assert_step_state(1, State.CONFIGURED) # works in the frontend, but fails here

def _assert_step_state(self, index, state):
step = self.rc.find(v.ExpansionPanel).widgets[index]
header = step.children[0]
container = header.children[0]
icon = container.children[0]
assert f"background-color: {BG_COLORS[state]}" in header.style_
assert icon.children == [STATE_ICONS[state]]
Is there some special way of testing a button's click? Note that it does change the confirmed step's state to SUCCESS. But the accordion does not move to the next step (should be indicated by the following step moving to a CONFIGURED step). Again, this works in the frontend. Just not in the test. While we're at it, ideally, I'd like to check that the accordion selected index has changed. This is possible with ipywidgets.Accordion, which exposes its selected_index trait. But ipyvuetify.ExpansionPanels does not seem to do so. I tried value (hopeful) and v_model (less hopefull), but neither worked.
1 replies
SSolara
Created by Edan on 8/16/2024 in #questions-issues
Style order
I'm having some difficulty sorting through the order of CSS loading. I'm using the Style "component" to load css files from my assets folder. They load no problem and show up in the expected order in the <head> section. However, they are overridden by vuetify classes, which I presume are somehow loaded after. But I can't see where this is happening. Post-serve JS? Could you please assist. Also, great if you have some advice regarding handling CSS, and maybe SCSS, which I am currently using locally. When I work in React, installing sass allows me to use SCSS, but again, I'm sure on the exact mechanics that make this happen. Thanks 🙂
4 replies