Skip to content

Commit 8c4c929

Browse files
committed
Update config for ssr bundle
1 parent 2cb3b6d commit 8c4c929

File tree

3 files changed

+10
-15
lines changed

3 files changed

+10
-15
lines changed

InertiaCore/Models/InertiaOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ public class InertiaOptions
66

77
public bool SsrEnabled { get; set; } = false;
88
public string SsrUrl { get; set; } = "http://127.0.0.1:13714/render";
9-
public bool SsrDispatchWithoutBundle { get; set; } = false;
9+
public bool SsrEnsureBundleExists { get; set; } = true;
1010
public bool EncryptHistory { get; set; } = false;
1111
}

InertiaCore/Ssr/Gateway.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,7 @@ public Gateway(IHttpClientFactory httpClientFactory, IOptions<InertiaOptions> op
4040

4141
public bool ShouldDispatch()
4242
{
43-
return ShouldDispatchWithoutBundle() || BundleExists();
44-
}
45-
46-
private bool ShouldDispatchWithoutBundle()
47-
{
48-
return _options.Value.SsrDispatchWithoutBundle;
43+
return !_options.Value.SsrEnsureBundleExists || BundleExists();
4944
}
5045

5146
private bool BundleExists()

InertiaCoreTests/UnitTestSsrDispatch.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,31 @@ namespace InertiaCoreTests;
99
public partial class Tests
1010
{
1111
[Test]
12-
[Description("Test SSR dispatch should not dispatch by default when no bundle exists")]
12+
[Description("Test SSR dispatch should not dispatch by default when no bundle exists and bundle is required")]
1313
public void TestSsrDispatchDefaultBehaviorWithoutBundle()
1414
{
1515
var httpClientFactory = new Mock<IHttpClientFactory>();
1616
var environment = new Mock<IWebHostEnvironment>();
1717
environment.SetupGet(x => x.ContentRootPath).Returns(Path.GetTempPath());
1818

1919
var options = new Mock<IOptions<InertiaOptions>>();
20-
options.SetupGet(x => x.Value).Returns(new InertiaOptions { SsrDispatchWithoutBundle = false });
20+
options.SetupGet(x => x.Value).Returns(new InertiaOptions { SsrEnsureBundleExists = true });
2121

2222
var gateway = new Gateway(httpClientFactory.Object, options.Object, environment.Object);
2323

2424
Assert.That(gateway.ShouldDispatch(), Is.False);
2525
}
2626

2727
[Test]
28-
[Description("Test SSR dispatch should dispatch when SsrDispatchWithoutBundle is enabled")]
28+
[Description("Test SSR dispatch should dispatch when SsrEnsureBundleExists is disabled")]
2929
public void TestSsrDispatchWithoutBundleEnabled()
3030
{
3131
var httpClientFactory = new Mock<IHttpClientFactory>();
3232
var environment = new Mock<IWebHostEnvironment>();
3333
environment.SetupGet(x => x.ContentRootPath).Returns(Path.GetTempPath());
3434

3535
var options = new Mock<IOptions<InertiaOptions>>();
36-
options.SetupGet(x => x.Value).Returns(new InertiaOptions { SsrDispatchWithoutBundle = true });
36+
options.SetupGet(x => x.Value).Returns(new InertiaOptions { SsrEnsureBundleExists = false });
3737

3838
var gateway = new Gateway(httpClientFactory.Object, options.Object, environment.Object);
3939

@@ -58,7 +58,7 @@ public void TestSsrDispatchWithBundleExists()
5858
environment.SetupGet(x => x.ContentRootPath).Returns(tempDir);
5959

6060
var options = new Mock<IOptions<InertiaOptions>>();
61-
options.SetupGet(x => x.Value).Returns(new InertiaOptions { SsrDispatchWithoutBundle = false });
61+
options.SetupGet(x => x.Value).Returns(new InertiaOptions { SsrEnsureBundleExists = true });
6262

6363
var gateway = new Gateway(httpClientFactory.Object, options.Object, environment.Object);
6464

@@ -74,7 +74,7 @@ public void TestSsrDispatchWithBundleExists()
7474
}
7575

7676
[Test]
77-
[Description("Test SSR dispatch should dispatch when either bundle exists or dispatch without bundle is enabled")]
77+
[Description("Test SSR dispatch should dispatch when either bundle exists or SsrEnsureBundleExists is disabled")]
7878
public void TestSsrDispatchWithBundleAndDispatchWithoutBundleEnabled()
7979
{
8080
var tempDir = Path.GetTempPath();
@@ -91,7 +91,7 @@ public void TestSsrDispatchWithBundleAndDispatchWithoutBundleEnabled()
9191
environment.SetupGet(x => x.ContentRootPath).Returns(tempDir);
9292

9393
var options = new Mock<IOptions<InertiaOptions>>();
94-
options.SetupGet(x => x.Value).Returns(new InertiaOptions { SsrDispatchWithoutBundle = true });
94+
options.SetupGet(x => x.Value).Returns(new InertiaOptions { SsrEnsureBundleExists = false });
9595

9696
var gateway = new Gateway(httpClientFactory.Object, options.Object, environment.Object);
9797

@@ -124,7 +124,7 @@ public void TestSsrDispatchChecksMultipleBundlePaths()
124124
environment.SetupGet(x => x.ContentRootPath).Returns(tempDir);
125125

126126
var options = new Mock<IOptions<InertiaOptions>>();
127-
options.SetupGet(x => x.Value).Returns(new InertiaOptions { SsrDispatchWithoutBundle = false });
127+
options.SetupGet(x => x.Value).Returns(new InertiaOptions { SsrEnsureBundleExists = true });
128128

129129
var gateway = new Gateway(httpClientFactory.Object, options.Object, environment.Object);
130130

0 commit comments

Comments
 (0)