Testing and requiresConfirmation

I have a RM with a table row action, that row action launches a modal with an approval action. I can get all the way up that point and it works fine in my test and will perform the approveAction, but if i add a confirmation to the approveAction, I cant seem to figure how to click the "Confirm" on the requiresConfirmation modal as it doesnt appear to have a mountAction for me to be able to call. This is wher i am so far:
Livewire::test(RftaResource\RelationManagers\ComparableUnitsRelationManager::class, [
'pageClass' => RftaResource\Pages\ViewRfta::class,
'ownerRecord' => $rfta,
])
->assertCanSeeTableRecords(collect([$comparable]))
->mountTableAction(ViewAction::class, record: $comparable->id)
->assertSee('Review Comparable Unit')
->assertSee('approveAction')
->mountTableAction('approveAction')
->callMountedTableAction() // requires confirmation
// now how do I click confirm on the requiresConfirmation() modal?
->assertHasNoTableActionErrors();
Livewire::test(RftaResource\RelationManagers\ComparableUnitsRelationManager::class, [
'pageClass' => RftaResource\Pages\ViewRfta::class,
'ownerRecord' => $rfta,
])
->assertCanSeeTableRecords(collect([$comparable]))
->mountTableAction(ViewAction::class, record: $comparable->id)
->assertSee('Review Comparable Unit')
->assertSee('approveAction')
->mountTableAction('approveAction')
->callMountedTableAction() // requires confirmation
// now how do I click confirm on the requiresConfirmation() modal?
->assertHasNoTableActionErrors();
15 Replies
LeandroFerreira
LeandroFerreira3mo ago
I think the approveAction will be triggered when you invoke the callMountedTableAction..
Mark Chaney
Mark Chaney3mo ago
@Leandro Ferreira it does and processes great if i do not have requiresConfirmation() on that action, but as soon as I add it back, it doesnt complete
LeandroFerreira
LeandroFerreira3mo ago
hum.. Is the approveAction a extraModalFooterAction?
Mark Chaney
Mark Chaney3mo ago
No, they are completely overriden with modalFooterActions()
LeandroFerreira
LeandroFerreira3mo ago
->mountTableAction('view', record: $comparable->id)
->assertSee('Approve action')
->call('mountTableAction', 'approveAction', $comparable->id)
->callMountedAction()
->callMountedTableAction()
->mountTableAction('view', record: $comparable->id)
->assertSee('Approve action')
->call('mountTableAction', 'approveAction', $comparable->id)
->callMountedAction()
->callMountedTableAction()
Mark Chaney
Mark Chaney3mo ago
that seems to work, thanks! so why this way of doing it?
LeandroFerreira
LeandroFerreira3mo ago
you have another action that should be fired. So you need to do ->call()->call()...
Mark Chaney
Mark Chaney3mo ago
right, but where are you targeting the confirmation
LeandroFerreira
LeandroFerreira3mo ago
if you inspect the code, we have two forms 1 - the approve action 2 - the confirmation
No description
LeandroFerreira
LeandroFerreira3mo ago
callMountedTableAction will submit the action
Mark Chaney
Mark Chaney3mo ago
why is the approve action not a table action if it is indeed a table action class? sorry, just trying to wrap my head around it all so i can solve future issues. The inconsistency is what throws me a bit with some of this btw, thanks for jumping in and helping me with test issues. i really appreciate it
LeandroFerreira
LeandroFerreira3mo ago
You are right, sorry. We don't need to call ->callMountedAction() callMountedTableAction will do this
Mark Chaney
Mark Chaney3mo ago
so it looks like the issue was really more with me doing
->mountTableAction('approveAction')
->mountTableAction('approveAction')
originally, which while was fine if i wanted to call just that action, but didnt allow the follow up ->callMountedTableAction() to handle the confirmation? Thus i had to do
->call('mountTableAction', 'approveAction', $comparable->id)
->call('mountTableAction', 'approveAction', $comparable->id)
instead before it? that looks to be the only difference
LeandroFerreira
LeandroFerreira3mo ago
I tried mountTableAction, but it didn’t work as expected. I’m not entirely sure why it failed, but in situations where I encounter issues with helpers, I find that using Livewire helps me achieve my results. If you encounter this issue, please feel free to submit a pull request ✌️
Mark Chaney
Mark Chaney3mo ago
got it all working now with some comments and simplified a little
Livewire::test(RftaResource\RelationManagers\ComparableUnitsRelationManager::class, [
'pageClass' => RftaResource\Pages\ViewRfta::class,
'ownerRecord' => $rfta,
])
->assertCanSeeTableRecords(collect([$comparable]))
// Mount the ViewAction modal for the specified comparable unit record
->mountTableAction(ViewAction::class, record: $comparable->id)
// Assert that the $action is present in the ViewAction modal
->assertSee($action)
// Mount the $action within the ViewAction modal
->call('mountTableAction', $action)
->setTableActionData([
'note' => $note,
])
->assertTableActionDataSet([
'note' => $note,
])
// Call the mounted table $action and handle any confirmation modals
->callMountedTableAction()
// Assert that there are no errors during the table action execution
->assertHasNoTableActionErrors();
Livewire::test(RftaResource\RelationManagers\ComparableUnitsRelationManager::class, [
'pageClass' => RftaResource\Pages\ViewRfta::class,
'ownerRecord' => $rfta,
])
->assertCanSeeTableRecords(collect([$comparable]))
// Mount the ViewAction modal for the specified comparable unit record
->mountTableAction(ViewAction::class, record: $comparable->id)
// Assert that the $action is present in the ViewAction modal
->assertSee($action)
// Mount the $action within the ViewAction modal
->call('mountTableAction', $action)
->setTableActionData([
'note' => $note,
])
->assertTableActionDataSet([
'note' => $note,
])
// Call the mounted table $action and handle any confirmation modals
->callMountedTableAction()
// Assert that there are no errors during the table action execution
->assertHasNoTableActionErrors();
Want results from more Discord servers?
Add your server
More Posts
Custom view OTP input not working(no js execution)?I'm trying to add the following tailwind otp input into a custom page view but the javascript part iHow to have HTML content inside tooltipI have requirement to have a html table with a tooltip when you hover over a table column cell, i haPseudo multi tenant setup using panels w/ a parameter (or maybe something else?)Heya everyone! I'm in the process of upgrading from Filament v2, but I have a non standard setup andHow to close action confirmation modal after form validate fails?I have a custom livewire component that has a form with rules and submit action. ```public functioSpatie Translatable plugin: Possible to have persistent LocaleSwitcher?Is it possible to have the LocaleSwitcher be persistent when navigating through List and Edit ResourFor IconColumn, only show boolean icon when true?Hi there, I have an icon column (see screenshot) but I only want an icon to display when the value iGet current value of table filterI am trying to filter the results of a SelectFilter based on the boolean value of another TableFilteUsing a custom user model in Export actionHi.. I am trying to use Admin model with export action. I see this documentation: https://filamenAm I the only one who often lands on V2 Documentation pages?Very often when using the Documentation Search bar (by Algolia) or hitting a Google result, I end onis it possible to set the existing avatar on page load?Ony my edit profile page, the user can select an avatar using the file upload component. After it's