Skip to content

Commit 2cee1c2

Browse files
Add progress config
1 parent 8a603ce commit 2cee1c2

File tree

10 files changed

+880
-798
lines changed

10 files changed

+880
-798
lines changed

demo-app/resources/js/Pages/LoadingProp.jsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1-
import { ModalLink } from '@inertiaui/modal-react';
1+
import { ModalLink, putConfig } from '@inertiaui/modal-react';
22
import Container from './Container';
33

44
export default function LoadingProp() {
5+
const params = new URLSearchParams(window.location.search);
6+
7+
putConfig({
8+
progress: params.get('progress') === 'false'
9+
? false
10+
: { delay: parseInt(params.get('delay') ?? 0) }
11+
})
12+
513
return (
614
<Container>
715
<div className="flex justify-between">
@@ -18,4 +26,4 @@ export default function LoadingProp() {
1826
</ModalLink>
1927
</Container>
2028
);
21-
}
29+
}

demo-app/resources/js/Pages/LoadingProp.vue

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
<script setup>
22
import Container from './Container.vue'
3-
import { ModalLink } from '@inertiaui/modal-vue'
3+
import { ModalLink, putConfig } from '@inertiaui/modal-vue'
4+
5+
const params = new URLSearchParams(window.location.search);
6+
7+
putConfig({
8+
progress: params.get('progress') === 'false'
9+
? false
10+
: { delay: parseInt(params.get('delay') ?? 0) }
11+
})
412
</script>
513
614
<template>

demo-app/tests/Browser/ProgressBarTest.php

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,42 @@
99
class ProgressBarTest extends DuskTestCase
1010
{
1111
#[Test]
12-
public function it_shows_the_inertia_progress_bar()
12+
public function it_shows_the_inertia_progress_bar_after_delay()
1313
{
1414
if (Support::isInertiaV1()) {
1515
return $this->markTestSkipped('Proress Bar API not supported in Inertia v1');
1616
}
1717

1818
$this->browse(function (Browser $browser) {
19-
$browser->visit('/loading-prop')
19+
$browser->visit('/loading-prop?delay=250')
2020
->waitForText('Loading Prop')
2121
->clickLink('Open Slideover')
22+
->assertNotPresent('#nprogress')
23+
->waitForModal();
24+
25+
$browser->visit('/loading-prop?delay=250')
26+
->waitForText('Loading Prop')
27+
->clickLink('Open Slideover')
28+
->pause(250)
2229
->assertPresent('#nprogress')
2330
->waitForModal()
2431
->waitUntilMissing('#nprogress');
2532
});
2633
}
34+
35+
#[Test]
36+
public function it_does_not_show_the_inertia_progress_bar_if_disabled()
37+
{
38+
if (Support::isInertiaV1()) {
39+
return $this->markTestSkipped('Proress Bar API not supported in Inertia v1');
40+
}
41+
42+
$this->browse(function (Browser $browser) {
43+
$browser->visit('/loading-prop?progress=false')
44+
->waitForText('Loading Prop')
45+
->clickLink('Open Slideover')
46+
->assertNotPresent('#nprogress')
47+
->waitForModal();
48+
});
49+
}
2750
}

0 commit comments

Comments
 (0)