File tree Expand file tree Collapse file tree 2 files changed +38
-1
lines changed
LinkDotNet.Blog.UnitTests/Web/Pages/Admin
LinkDotNet.Blog.Web/Pages/Admin Expand file tree Collapse file tree 2 files changed +38
-1
lines changed Original file line number Diff line number Diff line change 1
1
using System . Collections . Generic ;
2
2
using System . Linq ;
3
+ using System . Threading . Tasks ;
3
4
using Bunit ;
4
5
using Bunit . TestDoubles ;
5
6
using FluentAssertions ;
6
7
using LinkDotNet . Blog . Web . Pages . Admin ;
8
+ using LinkDotNet . Blog . Web . Shared ;
7
9
using LinkDotNet . Blog . Web . Shared . Services . Sitemap ;
8
10
using Microsoft . Extensions . DependencyInjection ;
9
11
using Moq ;
@@ -53,4 +55,32 @@ public void ShouldDisplaySitemap()
53
55
row . Children . First ( ) . InnerHtml . Should ( ) . Be ( "loc" ) ;
54
56
row . Children . Last ( ) . InnerHtml . Should ( ) . Be ( "Now" ) ;
55
57
}
58
+
59
+ [ Fact ]
60
+ public void ShouldShowLoadingWhenGenerating ( )
61
+ {
62
+ this . AddTestAuthorization ( ) . SetAuthorized ( "steven" ) ;
63
+ var sitemapMock = new Mock < ISitemapService > ( ) ;
64
+ Services . AddScoped ( _ => sitemapMock . Object ) ;
65
+ var sitemap = new SitemapUrlSet
66
+ {
67
+ Urls = new List < SitemapUrl >
68
+ {
69
+ new ( ) { Location = "loc" , LastModified = "Now" } ,
70
+ } ,
71
+ } ;
72
+ sitemapMock . Setup ( s => s . CreateSitemapAsync ( ) )
73
+ . Returns ( async ( ) =>
74
+ {
75
+ await Task . Delay ( 1000 ) ;
76
+ return sitemap ;
77
+ } ) ;
78
+ var cut = RenderComponent < Sitemap > ( ) ;
79
+
80
+ cut . Find ( "button" ) . Click ( ) ;
81
+
82
+ cut . FindComponents < Loading > ( ) . Count . Should ( ) . Be ( 1 ) ;
83
+ var btn = cut . Find ( "button" ) ;
84
+ btn . Attributes . Any ( a => a . Name == "disabled" ) . Should ( ) . BeTrue ( ) ;
85
+ }
56
86
}
Original file line number Diff line number Diff line change 8
8
important pages. Especially newer sites benefit from having a sitemap.xml.
9
9
The file will be created at the root of the site. To see the sitemap.xml go here: <a href =" /sitemap.xml" >sitemap.xml</a >.<br />
10
10
If you get a 404 there is currently no sitemap.xml</p >
11
- <button class =" btn btn-primary" @onclick =" CreateSitemap" >Create Sitemap</button >
11
+ <button class =" btn btn-primary" @onclick =" CreateSitemap" disabled = " @isGenerating " >Create Sitemap</button >
12
12
13
+ @if (isGenerating )
14
+ {
15
+ <Loading ></Loading >
16
+ }
13
17
@if (sitemapUrlSet != null )
14
18
{
15
19
<table class =" table table-striped table-hover h-50" >
34
38
35
39
@code {
36
40
private SitemapUrlSet sitemapUrlSet ;
41
+ private bool isGenerating ;
37
42
38
43
private async Task CreateSitemap ()
39
44
{
45
+ isGenerating = true ;
40
46
sitemapUrlSet = await sitemapService .CreateSitemapAsync ();
47
+ isGenerating = false ;
41
48
await sitemapService .SaveSitemapToFileAsync (sitemapUrlSet );
42
49
}
43
50
}
You can’t perform that action at this time.
0 commit comments