summaryrefslogtreecommitdiff
path: root/internal/typeutils/internaltofrontend_test.go
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2024-12-23 17:54:44 +0000
committerLibravatar GitHub <noreply@github.com>2024-12-23 17:54:44 +0000
commitfe8d5f23072c40a407723904eb5c54234879d58a (patch)
treedf80063f3238997de7144932d2d713321164ac1b /internal/typeutils/internaltofrontend_test.go
parent[chore] Stub /api/v1/announcements implementation (#3630) (diff)
downloadgotosocial-fe8d5f23072c40a407723904eb5c54234879d58a.tar.xz
[feature] add support for clients editing statuses and fetching status revision history (#3628)
* start adding client support for making status edits and viewing history * modify 'freshest' freshness window to be 5s, add typeutils test for status -> api edits * only populate the status edits when specifically requested * start adding some simple processor status edit tests * add test editing status but adding a poll * test edits appropriately adding poll expiry handlers * finish adding status edit tests * store both new and old revision emojis in status * add code comment * ensure the requester's account is populated before status edits * add code comments for status edit tests * update status edit form swagger comments * remove unused function * fix status source test * add more code comments, move media description check back to media process in status create * fix tests, add necessary form struct tag
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))
}