diff --git a/packages/vuetify/src/labs/VTreeview/__tests__/VTreeview.spec.browser.tsx b/packages/vuetify/src/labs/VTreeview/__tests__/VTreeview.spec.browser.tsx index ec74dfca194..d2bee933f52 100644 --- a/packages/vuetify/src/labs/VTreeview/__tests__/VTreeview.spec.browser.tsx +++ b/packages/vuetify/src/labs/VTreeview/__tests__/VTreeview.spec.browser.tsx @@ -672,4 +672,37 @@ describe.each([ expect(el).toBeVisible() }) }) + + // https://github.com/vuetifyjs/vuetify/issues/20830 + it('should return correct isOpen state in prepend slot', async () => { + render(() => ( + + {{ + prepend: ({ isOpen }) => ({ `${isOpen}` }), + }} + + )) + + await userEvent.click(screen.getByText(/Vuetify Human Resources/)) + const itemsPrepend = screen.getAllByCSS('.v-treeview-item .v-list-item__prepend .prepend-is-open') + expect(itemsPrepend[0]).toHaveTextContent(/^true$/) + expect(itemsPrepend[1]).toHaveTextContent(/^false$/) + + await userEvent.click(screen.getByText(/Core team/)) + expect(itemsPrepend[0]).toHaveTextContent(/^true$/) + expect(itemsPrepend[1]).toHaveTextContent(/^true$/) + + await userEvent.click(screen.getByText(/Core team/)) + expect(itemsPrepend[0]).toHaveTextContent(/^true$/) + expect(itemsPrepend[1]).toHaveTextContent(/^false$/) + + await userEvent.click(screen.getByText(/Vuetify Human Resources/)) + expect(itemsPrepend[0]).toHaveTextContent(/^false$/) + expect(itemsPrepend[1]).toHaveTextContent(/^false$/) + }) })