Skip to content

Commit

Permalink
Added test
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalbaljet committed Oct 25, 2024
1 parent 21554b2 commit 78398c9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
3 changes: 3 additions & 0 deletions demo-app/resources/js/Pages/Visit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ export default function Visit() {
<button onClick={() => visitModal('/data', { method: 'post', data: { message: 'Hi again!' } })} type="button">
Open Route Modal
</button>
<button onClick={() => visitModal('/users/1/edit', { navigate: true })} type="button">
Open Route Modal With Navigate
</button>
</div>
</Container>
<Modal name="local">
Expand Down
6 changes: 5 additions & 1 deletion demo-app/resources/js/Pages/Visit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ import { Modal, visitModal } from '@inertiaui/modal-vue'
Open Local Modal
</button>

<button @click="visitModal('/data', { method: 'post', data: {message: 'Hi again!'}})" type="button">
<button @click="visitModal('/data', { method: 'post', data: { message: 'Hi again!' } })" type="button">
Open Route Modal
</button>

<button @click="visitModal('/users/1/edit', { navigate: true })" type="button">
Open Route Modal With Navigate
</button>
</div>
</Container>

Expand Down
16 changes: 16 additions & 0 deletions demo-app/tests/Browser/VisitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,20 @@ public function it_can_programmatically_visit_a_modal(bool $navigate)
->assertSeeIn('.im-modal-content', 'Hi again!');
});
}

#[Test]
public function it_can_programmatically_visit_a_modal_and_use_browser_navigation()
{
$this->browse(function (Browser $browser) {

$browser->visit('/visit')
->waitForText('Visit programmatically')
->press('Open Route Modal With Navigate')
->waitFor('.im-modal-content')
->assertPathIs('/users/1/edit')
->click('.im-close-button')
->waitUntilMissing('.im-dialog')
->waitForLocation('/visit');
});
}
}

0 comments on commit 78398c9

Please sign in to comment.