Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 2.1 #41

Merged
merged 123 commits into from
Mar 27, 2024
Merged
Changes from 1 commit
Commits
Show all changes
123 commits
Select commit Hold shift + click to select a range
5b27ea5
Add canonical domain support (#37)
danieljsummers Jul 9, 2023
5f5927c
First cut of Docker files (#38)
danieljsummers Jul 9, 2023
9dd6ab7
Add Sqlite Docker file
danieljsummers Jul 19, 2023
ab9f2f5
Use PG lib data source singleton
danieljsummers Jul 28, 2023
42d3280
Add redirect rule to data stores (#39)
danieljsummers Jul 29, 2023
3ef4499
Add redirect index page (#39)
danieljsummers Jul 29, 2023
dc6b066
Rule add/edit/move/delete works (#39)
danieljsummers Jul 31, 2023
693a1df
Redirect plain-text rules (#39)
danieljsummers Jul 31, 2023
f43c431
Verify regex rules work correctly (#39)
danieljsummers Aug 1, 2023
79c3044
Add doc link to redirect page (#39)
danieljsummers Aug 1, 2023
b84a0f7
Add chapter data type (#6)
danieljsummers Aug 1, 2023
715e545
Update deps
danieljsummers Dec 13, 2023
ec2d43a
WIP on SQLite/JSON data
danieljsummers Dec 13, 2023
7071d60
WIP on module/member conversion
danieljsummers Dec 15, 2023
5fe2077
WIP on module/member conversion
danieljsummers Dec 16, 2023
d8ce59a
WIP on module/member conversion
danieljsummers Dec 16, 2023
c3d615d
WIP on module/member conversion
danieljsummers Dec 16, 2023
8ec84e8
WIP on module/member conversion
danieljsummers Dec 16, 2023
cb02055
WIP on formatting
danieljsummers Dec 17, 2023
a439430
Update Postgres data implementation
danieljsummers Dec 17, 2023
58b83b8
WIP on SQLite JSON documents
danieljsummers Dec 17, 2023
2062840
WIP on SQLite JSON documents
danieljsummers Dec 18, 2023
e04c8b5
First cut of SQLite JSON doc complete
danieljsummers Dec 18, 2023
d330c97
WIP on SQLite doc library
danieljsummers Dec 19, 2023
bb4252f
WIP on SQLite doc library
danieljsummers Dec 19, 2023
f461b10
First cut of SQLite doc library
danieljsummers Dec 20, 2023
7fb68d5
Rename SQLite helper file
danieljsummers Dec 20, 2023
e8d6379
Migrate Postgres data to new library
danieljsummers Dec 31, 2023
1a50c68
Migrate SQLite data to new library
danieljsummers Dec 31, 2023
dee2222
Register serliazer for SQLite
danieljsummers Dec 31, 2023
b69b6c3
WIP on testing SQLite data store
danieljsummers Jan 4, 2024
5a3d9f0
Rework migration; add PG 2.1 changes
danieljsummers Jan 4, 2024
3226f88
Implement /data and /themes directories (#38)
danieljsummers Jan 5, 2024
75e13a5
Add chapters waypoint flag (#6)
danieljsummers Jan 5, 2024
2c052c1
Add test project
danieljsummers Jan 6, 2024
cac1174
Add CommentStatus and ExplicitRating tests
danieljsummers Jan 6, 2024
5c08049
Finish SupportTypes tests
danieljsummers Jan 7, 2024
5126e20
Add tests for DataTypes
danieljsummers Jan 7, 2024
6622529
Add some view model tests
danieljsummers Jan 8, 2024
dc80388
Add more view model tests
danieljsummers Jan 9, 2024
8ec7610
Tweak domain tests
danieljsummers Jan 9, 2024
ba42f84
Add DisplayUser tests
danieljsummers Jan 10, 2024
10affa2
Add EditCategoryModel tests
danieljsummers Jan 11, 2024
29cbf48
Split tests into separate files
danieljsummers Jan 11, 2024
29167ec
Add podcast/user edit model tests
danieljsummers Jan 11, 2024
12c46c8
Add edit page model tests
danieljsummers Jan 13, 2024
888f56e
WIP on edit post model tests
danieljsummers Jan 14, 2024
cb94222
Finish edit post model tests
danieljsummers Jan 15, 2024
cbe391f
Add edit redirect tests
danieljsummers Jan 16, 2024
9da9a94
Add tests through mng rev
danieljsummers Jan 19, 2024
da5918b
Update admin/default templates
danieljsummers Jan 20, 2024
d50056c
Finish view model tests
danieljsummers Jan 20, 2024
a0ab99f
Add unquoted relative URL support
danieljsummers Jan 20, 2024
5ce84e1
Fix SQLite page list query
danieljsummers Jan 20, 2024
d1a9606
Tweak admin theme changes
danieljsummers Jan 20, 2024
cfb3c3a
Add JSON converter tests
danieljsummers Jan 21, 2024
ffe6713
Add converter / utils tests
danieljsummers Jan 21, 2024
1345074
Add framework for SQLite data tests
danieljsummers Jan 21, 2024
3835ed9
Rearrange test files
danieljsummers Jan 21, 2024
182b33a
Add Category tests, implement for SQLite
danieljsummers Jan 22, 2024
13994a2
Convert to rc2 of doc lib
danieljsummers Jan 24, 2024
19777c7
Add Postgres Category tests
danieljsummers Jan 25, 2024
d09a5e1
Add data test for Page.Add
danieljsummers Jan 26, 2024
f701fc9
Add data test for Page.All
danieljsummers Jan 26, 2024
0e8044b
Add RethinkDB tests
danieljsummers Jan 27, 2024
3f269ed
Add Page Find[Full]ById tests
danieljsummers Jan 28, 2024
c319ff1
Add tests for pages via permalinks
danieljsummers Jan 28, 2024
f60139d
Add more page tests
danieljsummers Jan 29, 2024
0a53e27
Add page-of-page and update tests
danieljsummers Jan 29, 2024
990b72b
Finish page data tests
danieljsummers Jan 30, 2024
78c1c5e
Add framework for post tests
danieljsummers Jan 31, 2024
24d49e2
Add tests through post curr permalink
danieljsummers Jan 31, 2024
84460b4
Add post FindFull* tests
danieljsummers Feb 2, 2024
05d49e6
Finish post data tests
danieljsummers Feb 3, 2024
8183da7
Add tag mapping tests
danieljsummers Feb 3, 2024
b1a0c20
Add theme tests
danieljsummers Feb 3, 2024
ff05bc8
Add theme asset tests
danieljsummers Feb 3, 2024
34315a1
Add upload tests
danieljsummers Feb 3, 2024
ac9df44
Add user add/find-by-[email|id] tests
danieljsummers Feb 3, 2024
16f7396
Finish user tests
danieljsummers Feb 4, 2024
f25426d
Add web log tests
danieljsummers Feb 4, 2024
d378f69
Add chapter source fields (#6)
danieljsummers Feb 6, 2024
90bca34
WIP on chapter list page (#6)
danieljsummers Feb 8, 2024
12b23ea
WIP on chapter edit page (#6)
danieljsummers Feb 9, 2024
1463247
WIP on chapter edit form (#6)
danieljsummers Feb 11, 2024
d3c89da
WIP on chapter edit form (#6)
danieljsummers Feb 11, 2024
6a5285c
WIP on saving chapters (#6)
danieljsummers Mar 4, 2024
43a700e
WIP on chapter flow (#6)
danieljsummers Mar 10, 2024
641a749
Complete chapter edit page (#6)
danieljsummers Mar 10, 2024
8103957
WIP on ?chapters handler for posts (#6)
danieljsummers Mar 11, 2024
5b8a632
Complete main chapter functionality (#6)
danieljsummers Mar 11, 2024
90e6f78
Migrate post list template
danieljsummers Mar 11, 2024
5f114c7
Move redirect/tag map templates to GVE
danieljsummers Mar 12, 2024
b99cd5b
Migrate more templates to GVE
danieljsummers Mar 13, 2024
e9bd3b2
Migrate web log settings page to GVE
danieljsummers Mar 13, 2024
cac7b1d
Migrate page list template to GVE
danieljsummers Mar 14, 2024
b85cae2
Tweak to chapter edit template
danieljsummers Mar 15, 2024
91046c6
Migrate custom feed page to GVE
danieljsummers Mar 15, 2024
3998399
Migrate several templates to GVE
danieljsummers Mar 15, 2024
ddab491
First cut of common edit model
danieljsummers Mar 15, 2024
ec04fea
Migrate page edit to GVE
danieljsummers Mar 16, 2024
a448339
Migrate post edit to GVE
danieljsummers Mar 16, 2024
6459931
Eliminate final admin theme Liquid resources
danieljsummers Mar 16, 2024
54e46fd
Remove unneeded types
danieljsummers Mar 16, 2024
4301788
Bug fixes with new admin forms
danieljsummers Mar 16, 2024
31d49d4
Fix "add category" button (#40)
danieljsummers Mar 17, 2024
f181f83
Misc admin theme tweaks
danieljsummers Mar 17, 2024
ac332a6
Fix Docker builds (#38)
danieljsummers Mar 20, 2024
dce80fd
Fix theme zipping in Docker (#38)
danieljsummers Mar 23, 2024
c20628b
Update deps before release
danieljsummers Mar 23, 2024
895b2a7
Update build files
danieljsummers Mar 23, 2024
2fe104f
Add GitHub Actions YAML
danieljsummers Mar 23, 2024
add6a80
Add Rethink URI, run tests after cd
danieljsummers Mar 23, 2024
5c7e897
Enable .NET 7
danieljsummers Mar 23, 2024
eaa1824
Enable .NET 8
danieljsummers Mar 23, 2024
ad49c95
Add release packaging
danieljsummers Mar 23, 2024
5ba05bd
Add CI flag to build
danieljsummers Mar 23, 2024
aa2707d
Use matrix for publish job
danieljsummers Mar 24, 2024
c9a097a
Fix indentation
danieljsummers Mar 24, 2024
d28b18a
Remove name from artifact upload
danieljsummers Mar 24, 2024
5fc3d11
Include matrix vars in artifact name
danieljsummers Mar 24, 2024
2439d01
Fix indents in CI YAML
danieljsummers Mar 24, 2024
d8024ac
Add chapter ref to feed (#6)
danieljsummers Mar 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add tests through mng rev
danieljsummers committed Jan 19, 2024
commit 9da9a94947fe106323ec5e0ccc37909c966808c4
120 changes: 56 additions & 64 deletions src/MyWebLog.Domain/ViewModels.fs
Original file line number Diff line number Diff line change
@@ -847,14 +847,13 @@ type EditRssModel = {
} with

/// Create an edit model from a set of RSS options
static member FromRssOptions (rss: RssOptions) = {
IsFeedEnabled = rss.IsFeedEnabled
FeedName = rss.FeedName
ItemsInFeed = defaultArg rss.ItemsInFeed 0
IsCategoryEnabled = rss.IsCategoryEnabled
IsTagEnabled = rss.IsTagEnabled
Copyright = defaultArg rss.Copyright ""
}
static member FromRssOptions (rss: RssOptions) =
{ IsFeedEnabled = rss.IsFeedEnabled
FeedName = rss.FeedName
ItemsInFeed = defaultArg rss.ItemsInFeed 0
IsCategoryEnabled = rss.IsCategoryEnabled
IsTagEnabled = rss.IsTagEnabled
Copyright = defaultArg rss.Copyright "" }

/// Update RSS options from values in this model
member this.UpdateOptions (rss: RssOptions) =
@@ -881,11 +880,10 @@ type EditTagMapModel = {
} with

/// Create an edit model from the tag mapping
static member FromMapping (tagMap: TagMap) : EditTagMapModel = {
Id = string tagMap.Id
Tag = tagMap.Tag
UrlValue = tagMap.UrlValue
}
static member FromMapping (tagMap: TagMap) : EditTagMapModel =
{ Id = string tagMap.Id
Tag = tagMap.Tag
UrlValue = tagMap.UrlValue }

/// Whether this is a new tag mapping
member this.IsNew =
@@ -924,17 +922,16 @@ type EditUserModel = {
} with

/// Construct a user edit form from a web log user
static member FromUser (user: WebLogUser) = {
Id = string user.Id
AccessLevel = string user.AccessLevel
Url = defaultArg user.Url ""
Email = user.Email
FirstName = user.FirstName
LastName = user.LastName
PreferredName = user.PreferredName
Password = ""
PasswordConfirm = ""
}
static member FromUser (user: WebLogUser) =
{ Id = string user.Id
AccessLevel = string user.AccessLevel
Url = defaultArg user.Url ""
Email = user.Email
FirstName = user.FirstName
LastName = user.LastName
PreferredName = user.PreferredName
Password = ""
PasswordConfirm = "" }

/// Is this a new user?
member this.IsNew =
@@ -989,22 +986,20 @@ type ManagePermalinksModel = {
} with

/// Create a permalink model from a page
static member FromPage (page: Page) = {
Id = string page.Id
Entity = "page"
CurrentTitle = page.Title
CurrentPermalink = string page.Permalink
Prior = page.PriorPermalinks |> List.map string |> Array.ofList
}
static member FromPage (page: Page) =
{ Id = string page.Id
Entity = "page"
CurrentTitle = page.Title
CurrentPermalink = string page.Permalink
Prior = page.PriorPermalinks |> List.map string |> Array.ofList }

/// Create a permalink model from a post
static member FromPost (post: Post) = {
Id = string post.Id
Entity = "post"
CurrentTitle = post.Title
CurrentPermalink = string post.Permalink
Prior = post.PriorPermalinks |> List.map string |> Array.ofList
}
static member FromPost (post: Post) =
{ Id = string post.Id
Entity = "post"
CurrentTitle = post.Title
CurrentPermalink = string post.Permalink
Prior = post.PriorPermalinks |> List.map string |> Array.ofList }


/// View model to manage revisions
@@ -1024,20 +1019,18 @@ type ManageRevisionsModel = {
} with

/// Create a revision model from a page
static member FromPage webLog (page: Page) = {
Id = string page.Id
Entity = "page"
CurrentTitle = page.Title
Revisions = page.Revisions |> List.map (DisplayRevision.FromRevision webLog) |> Array.ofList
}
static member FromPage webLog (page: Page) =
{ Id = string page.Id
Entity = "page"
CurrentTitle = page.Title
Revisions = page.Revisions |> List.map (DisplayRevision.FromRevision webLog) |> Array.ofList }

/// Create a revision model from a post
static member FromPost webLog (post: Post) = {
Id = string post.Id
Entity = "post"
CurrentTitle = post.Title
Revisions = post.Revisions |> List.map (DisplayRevision.FromRevision webLog) |> Array.ofList
}
static member FromPost webLog (post: Post) =
{ Id = string post.Id
Entity = "post"
CurrentTitle = post.Title
Revisions = post.Revisions |> List.map (DisplayRevision.FromRevision webLog) |> Array.ofList }


/// View model for posts in a list
@@ -1081,20 +1074,19 @@ type PostListItem = {
} with

/// Create a post list item from a post
static member FromPost (webLog: WebLog) (post: Post) = {
Id = string post.Id
AuthorId = string post.AuthorId
Status = string post.Status
Title = post.Title
Permalink = string post.Permalink
PublishedOn = post.PublishedOn |> Option.map webLog.LocalTime |> Option.toNullable
UpdatedOn = webLog.LocalTime post.UpdatedOn
Text = addBaseToRelativeUrls webLog.ExtraPath post.Text
CategoryIds = post.CategoryIds |> List.map string
Tags = post.Tags
Episode = post.Episode
Metadata = post.Metadata
}
static member FromPost (webLog: WebLog) (post: Post) =
{ Id = string post.Id
AuthorId = string post.AuthorId
Status = string post.Status
Title = post.Title
Permalink = string post.Permalink
PublishedOn = post.PublishedOn |> Option.map webLog.LocalTime |> Option.toNullable
UpdatedOn = webLog.LocalTime post.UpdatedOn
Text = addBaseToRelativeUrls webLog.ExtraPath post.Text
CategoryIds = post.CategoryIds |> List.map string
Tags = post.Tags
Episode = post.Episode
Metadata = post.Metadata }


/// View model for displaying posts
234 changes: 232 additions & 2 deletions src/MyWebLog.Tests/ViewModelsTests.fs
Original file line number Diff line number Diff line change
@@ -611,8 +611,8 @@ let editPostModelTests = testList "EditPostModel" [
EpisodeDescription = Some "Episode 322" } }
testList "FromPost" [
test "succeeds for empty post" {
let model = EditPostModel.FromPost WebLog.Empty { Post.Empty with Id = PostId "lalala" }
Expect.equal model.PostId "lalala" "PostId not filled properly"
let model = EditPostModel.FromPost WebLog.Empty { Post.Empty with Id = PostId "la-la-la" }
Expect.equal model.PostId "la-la-la" "PostId not filled properly"
Expect.equal model.Title "" "Title not filled properly"
Expect.equal model.Permalink "" "Permalink not filled properly"
Expect.equal model.Source "HTML" "Source not filled properly"
@@ -849,6 +849,231 @@ let editRedirectRuleModelTests = testList "EditRedirectRuleModel" [
}
]

/// Unit tests for the EditRssModel type
let editRssModelTests = testList "EditRssModel" [
testList "FromRssOptions" [
test "succeeds with minimal options" {
let model = EditRssModel.FromRssOptions RssOptions.Empty
Expect.isTrue model.IsFeedEnabled "IsFeedEnabled should have been set"
Expect.equal model.FeedName "feed.xml" "FeedName not filled properly"
Expect.equal model.ItemsInFeed 0 "ItemsInFeed not filled properly"
Expect.isTrue model.IsCategoryEnabled "IsCategoryEnabled should have been set"
Expect.isTrue model.IsTagEnabled "IsTagEnabled should have been set"
Expect.equal model.Copyright "" "Copyright not filled properly"
}
test "succeeds with full options" {
let model =
EditRssModel.FromRssOptions
{ RssOptions.Empty with
IsFeedEnabled = false
FeedName = "custom.xml"
ItemsInFeed = Some 82
IsCategoryEnabled = false
IsTagEnabled = false
Copyright = Some "yep" }
Expect.isFalse model.IsFeedEnabled "IsFeedEnabled should not have been set"
Expect.equal model.FeedName "custom.xml" "FeedName not filled properly"
Expect.equal model.ItemsInFeed 82 "ItemsInFeed not filled properly"
Expect.isFalse model.IsCategoryEnabled "IsCategoryEnabled should not have been set"
Expect.isFalse model.IsTagEnabled "IsTagEnabled should not have been set"
Expect.equal model.Copyright "yep" "Copyright not filled properly"
}
]
testList "UpdateOptions" [
test "succeeds with minimal options" {
let opts =
{ IsFeedEnabled = true
FeedName = "blah.xml"
ItemsInFeed = 0
IsCategoryEnabled = true
IsTagEnabled = true
Copyright = "" }.UpdateOptions RssOptions.Empty
Expect.isTrue opts.IsFeedEnabled "IsFeedEnabled should have been set"
Expect.equal opts.FeedName "blah.xml" "FeedName not filled properly"
Expect.isNone opts.ItemsInFeed "ItemsInFeed should not have had a value"
Expect.isTrue opts.IsCategoryEnabled "IsCategoryEnabled should have been set"
Expect.isTrue opts.IsTagEnabled "IsTagEnabled should have been set"
Expect.isNone opts.Copyright "Copyright should not have had a value"
}
test "succeeds with full options" {
let opts =
{ IsFeedEnabled = false
FeedName = "again.xml"
ItemsInFeed = 22
IsCategoryEnabled = false
IsTagEnabled = false
Copyright = "none" }.UpdateOptions RssOptions.Empty
Expect.isFalse opts.IsFeedEnabled "IsFeedEnabled should not have been set"
Expect.equal opts.FeedName "again.xml" "FeedName not filled properly"
Expect.equal opts.ItemsInFeed (Some 22) "ItemsInFeed not filled properly"
Expect.isFalse opts.IsCategoryEnabled "IsCategoryEnabled should not have been set"
Expect.isFalse opts.IsTagEnabled "IsTagEnabled should not have been set"
Expect.equal opts.Copyright (Some "none") "Copyright not filled properly"
}
]
]

/// Unit tests for the EditTagMapModel type
let editTagMapModelTests = testList "EditTagMapModel" [
test "FromMapping succeeds" {
let model =
EditTagMapModel.FromMapping
{ Id = TagMapId "howdy"; Tag = "f#"; UrlValue = "f-sharp"; WebLogId = WebLogId "" }
Expect.equal model.Id "howdy" "Id not filled properly"
Expect.equal model.Tag "f#" "Tag not filled properly"
Expect.equal model.UrlValue "f-sharp" "UrlValue not filled properly"
}
testList "IsNew" [
test "succeeds when tag mapping is new" {
Expect.isTrue
(EditTagMapModel.FromMapping { TagMap.Empty with Id = TagMapId "new" }).IsNew
"IsNew should have been set"
}
test "succeeds when tag mapping is not new" {
Expect.isFalse
(EditTagMapModel.FromMapping { TagMap.Empty with Id = TagMapId "ancient" }).IsNew
"IsNew should not have been set"
}
]
]

/// Unit tests for the EditUserModel type
let editUserModelTests = testList "EditUserModel" [
testList "FromUser" [
test "succeeds when the user does not have a URL" {
let model =
EditUserModel.FromUser
{ WebLogUser.Empty with
Id = WebLogUserId "test"
AccessLevel = Editor
Email = "test@example.com"
FirstName = "Test"
LastName = "User"
PreferredName = "Tester" }
Expect.equal model.Id "test" "Id not filled properly"
Expect.equal model.AccessLevel "Editor" "AccessLevel not filled properly"
Expect.equal model.Url "" "Url not filled properly"
Expect.equal model.Email "test@example.com" "Email not filled properly"
Expect.equal model.FirstName "Test" "FirstName not filled properly"
Expect.equal model.LastName "User" "LastName not filled properly"
Expect.equal model.PreferredName "Tester" "PreferredName not filled properly"
Expect.equal model.Password "" "Password not filled properly"
Expect.equal model.PasswordConfirm "" "PasswordConfirm not filled properly"
}
test "succeeds when the user has a URL" {
let model = EditUserModel.FromUser { WebLogUser.Empty with Url = Some "https://test.me" }
Expect.equal model.Url "https://test.me" "Url not filled properly"
}
]
testList "IsNew" [
test "succeeds when the user is new" {
Expect.isTrue
(EditUserModel.FromUser { WebLogUser.Empty with Id = WebLogUserId "new" }).IsNew
"IsNew should have been set"
}
test "succeeds when the user is not new" {
Expect.isFalse
(EditUserModel.FromUser { WebLogUser.Empty with Id = WebLogUserId "not-new" }).IsNew
"IsNew should not have been set"
}
]
testList "UpdateUser" [
let model =
{ Id = "test-user"
AccessLevel = "WebLogAdmin"
Email = "again@example.com"
Url = ""
FirstName = "Another"
LastName = "One"
PreferredName = "Happy"
Password = "my-password"
PasswordConfirm = "my-password" }
test "succeeds when user has no URL" {
let user = model.UpdateUser WebLogUser.Empty
Expect.equal user.AccessLevel WebLogAdmin "AccessLevel not filled properly"
Expect.equal user.Email "again@example.com" "Email not filled properly"
Expect.isNone user.Url "Url should not have had a value"
Expect.equal user.FirstName "Another" "FirstName not filled properly"
Expect.equal user.LastName "One" "LastName not filled properly"
Expect.equal user.PreferredName "Happy" "FirstName not filled properly"
}
test "succeeds when user has a URL" {
let user = { model with Url = "https://over.there" }.UpdateUser WebLogUser.Empty
Expect.equal user.Url (Some "https://over.there") "Url not filled properly"
}
]
]

/// Unit tests for the ManagePermalinksModel type
let managePermalinksModelTests = testList "ManagePermalinksModel" [
test "FromPage succeeds" {
let model =
ManagePermalinksModel.FromPage
{ Page.Empty with
Id = PageId "links"
Title = "My Awesome Page"
Permalink = Permalink "2018/02/my-awesome-page.html"
PriorPermalinks = [ Permalink "2018/02/my-awesome-pages.html"; Permalink "2018/02/oops.html" ] }
Expect.equal model.Id "links" "Id not filled properly"
Expect.equal model.Entity "page" "Entity not filled properly"
Expect.equal model.CurrentTitle "My Awesome Page" "CurrentTitle not filled properly"
Expect.equal model.CurrentPermalink "2018/02/my-awesome-page.html" "CurrentPermalink not filled properly"
Expect.equal model.Prior [| "2018/02/my-awesome-pages.html"; "2018/02/oops.html" |] "Prior not filled properly"
}
test "FromPost succeeds" {
let model =
ManagePermalinksModel.FromPost
{ Post.Empty with
Id = PostId "test"
Title = "Errata"
Permalink = Permalink "2020/01/errata.html"
PriorPermalinks = [ Permalink "2020/01/errors.html"; Permalink "2020/01/whoops.html" ] }
Expect.equal model.Id "test" "Id not filled properly"
Expect.equal model.Entity "post" "Entity not filled properly"
Expect.equal model.CurrentTitle "Errata" "CurrentTitle not filled properly"
Expect.equal model.CurrentPermalink "2020/01/errata.html" "CurrentPermalink not filled properly"
Expect.equal model.Prior [| "2020/01/errors.html"; "2020/01/whoops.html" |] "Prior not filled properly"
}
]

/// Unit tests for the ManageRevisionsModel type
let manageRevisionsModelTests = testList "ManageRevisionsModel" [
test "FromPage succeeds" {
let revisions =
[ { AsOf = Noda.epoch + Duration.FromDays 24; Text = Html "<strong>wow</strong>" }
{ AsOf = Noda.epoch + Duration.FromDays 20; Text = Html "<p>huh</p>" } ]
let model =
ManageRevisionsModel.FromPage
{ WebLog.Empty with TimeZone = "Etc/GMT+1" }
{ Page.Empty with Id = PageId "revs"; Title = "A Revised Page"; Revisions = revisions }
Expect.equal model.Id "revs" "Id not filled properly"
Expect.equal model.Entity "page" "Entity not filled properly"
Expect.equal model.CurrentTitle "A Revised Page" "CurrentTitle not filled properly"
Expect.equal model.Revisions.Length 2 "There should be two revisions"
Expect.equal
model.Revisions[0].AsOfLocal
((revisions[0].AsOf - Duration.FromHours 1).ToDateTimeUtc())
"AsOfLocal not filled properly"
}
test "FromPost succeeds" {
let revisions =
[ { AsOf = Noda.epoch + Duration.FromDays 13; Text = Html "<p>again</p>" }
{ AsOf = Noda.epoch + Duration.FromDays 12; Text = Html "<p>original</p>" } ]
let model =
ManageRevisionsModel.FromPost
{ WebLog.Empty with TimeZone = "Etc/GMT-3" }
{ Post.Empty with Id = PostId "altered"; Title = "Round Two"; Revisions = revisions }
Expect.equal model.Id "altered" "Id not filled properly"
Expect.equal model.Entity "post" "Entity not filled properly"
Expect.equal model.CurrentTitle "Round Two" "CurrentTitle not filled properly"
Expect.equal model.Revisions.Length 2 "There should be two revisions"
Expect.equal
model.Revisions[0].AsOfLocal
((revisions[0].AsOf + Duration.FromHours 3).ToDateTimeUtc())
"AsOfLocal not filled properly"
}
]

/// All tests in the Domain.ViewModels file
let all = testList "ViewModels" [
addBaseToRelativeUrlsTests
@@ -864,4 +1089,9 @@ let all = testList "ViewModels" [
editPageModelTests
editPostModelTests
editRedirectRuleModelTests
editRssModelTests
editTagMapModelTests
editUserModelTests
managePermalinksModelTests
manageRevisionsModelTests
]