summaryrefslogtreecommitdiff
path: root/internal/typeutils/internaltofrontend_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/typeutils/internaltofrontend_test.go')
-rw-r--r--internal/typeutils/internaltofrontend_test.go130
1 files changed, 130 insertions, 0 deletions
diff --git a/internal/typeutils/internaltofrontend_test.go b/internal/typeutils/internaltofrontend_test.go
index 0ec9ea05f..39a9bd9d4 100644
--- a/internal/typeutils/internaltofrontend_test.go
+++ b/internal/typeutils/internaltofrontend_test.go
@@ -3737,6 +3737,136 @@ func (suite *InternalToFrontendTestSuite) TestConversationToAPI() {
}`, string(b))
}
+func (suite *InternalToFrontendTestSuite) TestStatusToAPIEdits() {
+ ctx, cncl := context.WithCancel(context.Background())
+ defer cncl()
+
+ statusID := suite.testStatuses["local_account_1_status_9"].ID
+
+ status, err := suite.state.DB.GetStatusByID(ctx, statusID)
+ suite.NoError(err)
+
+ err = suite.state.DB.PopulateStatusEdits(ctx, status)
+ suite.NoError(err)
+
+ apiEdits, err := suite.typeconverter.StatusToAPIEdits(ctx, status)
+ suite.NoError(err)
+
+ b, err := json.MarshalIndent(apiEdits, "", " ")
+ suite.NoError(err)
+
+ suite.Equal(`[
+ {
+ "content": "\u003cp\u003ethis is the latest revision of the status, with a content-warning\u003c/p\u003e",
+ "spoiler_text": "edited status",
+ "sensitive": false,
+ "created_at": "2024-11-01T09:02:00.000Z",
+ "account": {
+ "id": "01F8MH1H7YV1Z7D2C8K2730QBF",
+ "username": "the_mighty_zork",
+ "acct": "the_mighty_zork",
+ "display_name": "original zork (he/they)",
+ "locked": false,
+ "discoverable": true,
+ "bot": false,
+ "created_at": "2022-05-20T11:09:18.000Z",
+ "note": "\u003cp\u003ehey yo this is my profile!\u003c/p\u003e",
+ "url": "http://localhost:8080/@the_mighty_zork",
+ "avatar": "http://localhost:8080/fileserver/01F8MH1H7YV1Z7D2C8K2730QBF/avatar/original/01F8MH58A357CV5K7R7TJMSH6S.jpg",
+ "avatar_static": "http://localhost:8080/fileserver/01F8MH1H7YV1Z7D2C8K2730QBF/avatar/small/01F8MH58A357CV5K7R7TJMSH6S.webp",
+ "avatar_description": "a green goblin looking nasty",
+ "avatar_media_id": "01F8MH58A357CV5K7R7TJMSH6S",
+ "header": "http://localhost:8080/fileserver/01F8MH1H7YV1Z7D2C8K2730QBF/header/original/01PFPMWK2FF0D9WMHEJHR07C3Q.jpg",
+ "header_static": "http://localhost:8080/fileserver/01F8MH1H7YV1Z7D2C8K2730QBF/header/small/01PFPMWK2FF0D9WMHEJHR07C3Q.webp",
+ "header_description": "A very old-school screenshot of the original team fortress mod for quake",
+ "header_media_id": "01PFPMWK2FF0D9WMHEJHR07C3Q",
+ "followers_count": 2,
+ "following_count": 2,
+ "statuses_count": 9,
+ "last_status_at": "2024-11-01",
+ "emojis": [],
+ "fields": [],
+ "enable_rss": true
+ },
+ "poll": null,
+ "media_attachments": [],
+ "emojis": []
+ },
+ {
+ "content": "\u003cp\u003ethis is the first status edit! now with content-warning\u003c/p\u003e",
+ "spoiler_text": "edited status",
+ "sensitive": false,
+ "created_at": "2024-11-01T09:01:00.000Z",
+ "account": {
+ "id": "01F8MH1H7YV1Z7D2C8K2730QBF",
+ "username": "the_mighty_zork",
+ "acct": "the_mighty_zork",
+ "display_name": "original zork (he/they)",
+ "locked": false,
+ "discoverable": true,
+ "bot": false,
+ "created_at": "2022-05-20T11:09:18.000Z",
+ "note": "\u003cp\u003ehey yo this is my profile!\u003c/p\u003e",
+ "url": "http://localhost:8080/@the_mighty_zork",
+ "avatar": "http://localhost:8080/fileserver/01F8MH1H7YV1Z7D2C8K2730QBF/avatar/original/01F8MH58A357CV5K7R7TJMSH6S.jpg",
+ "avatar_static": "http://localhost:8080/fileserver/01F8MH1H7YV1Z7D2C8K2730QBF/avatar/small/01F8MH58A357CV5K7R7TJMSH6S.webp",
+ "avatar_description": "a green goblin looking nasty",
+ "avatar_media_id": "01F8MH58A357CV5K7R7TJMSH6S",
+ "header": "http://localhost:8080/fileserver/01F8MH1H7YV1Z7D2C8K2730QBF/header/original/01PFPMWK2FF0D9WMHEJHR07C3Q.jpg",
+ "header_static": "http://localhost:8080/fileserver/01F8MH1H7YV1Z7D2C8K2730QBF/header/small/01PFPMWK2FF0D9WMHEJHR07C3Q.webp",
+ "header_description": "A very old-school screenshot of the original team fortress mod for quake",
+ "header_media_id": "01PFPMWK2FF0D9WMHEJHR07C3Q",
+ "followers_count": 2,
+ "following_count": 2,
+ "statuses_count": 9,
+ "last_status_at": "2024-11-01",
+ "emojis": [],
+ "fields": [],
+ "enable_rss": true
+ },
+ "poll": null,
+ "media_attachments": [],
+ "emojis": []
+ },
+ {
+ "content": "\u003cp\u003ethis is the original status\u003c/p\u003e",
+ "spoiler_text": "",
+ "sensitive": false,
+ "created_at": "2024-11-01T09:00:00.000Z",
+ "account": {
+ "id": "01F8MH1H7YV1Z7D2C8K2730QBF",
+ "username": "the_mighty_zork",
+ "acct": "the_mighty_zork",
+ "display_name": "original zork (he/they)",
+ "locked": false,
+ "discoverable": true,
+ "bot": false,
+ "created_at": "2022-05-20T11:09:18.000Z",
+ "note": "\u003cp\u003ehey yo this is my profile!\u003c/p\u003e",
+ "url": "http://localhost:8080/@the_mighty_zork",
+ "avatar": "http://localhost:8080/fileserver/01F8MH1H7YV1Z7D2C8K2730QBF/avatar/original/01F8MH58A357CV5K7R7TJMSH6S.jpg",
+ "avatar_static": "http://localhost:8080/fileserver/01F8MH1H7YV1Z7D2C8K2730QBF/avatar/small/01F8MH58A357CV5K7R7TJMSH6S.webp",
+ "avatar_description": "a green goblin looking nasty",
+ "avatar_media_id": "01F8MH58A357CV5K7R7TJMSH6S",
+ "header": "http://localhost:8080/fileserver/01F8MH1H7YV1Z7D2C8K2730QBF/header/original/01PFPMWK2FF0D9WMHEJHR07C3Q.jpg",
+ "header_static": "http://localhost:8080/fileserver/01F8MH1H7YV1Z7D2C8K2730QBF/header/small/01PFPMWK2FF0D9WMHEJHR07C3Q.webp",
+ "header_description": "A very old-school screenshot of the original team fortress mod for quake",
+ "header_media_id": "01PFPMWK2FF0D9WMHEJHR07C3Q",
+ "followers_count": 2,
+ "following_count": 2,
+ "statuses_count": 9,
+ "last_status_at": "2024-11-01",
+ "emojis": [],
+ "fields": [],
+ "enable_rss": true
+ },
+ "poll": null,
+ "media_attachments": [],
+ "emojis": []
+ }
+]`, string(b))
+}
+
func TestInternalToFrontendTestSuite(t *testing.T) {
suite.Run(t, new(InternalToFrontendTestSuite))
}