summaryrefslogtreecommitdiff
path: root/internal/processing/account/update_test.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2021-09-11 13:19:06 +0200
committerLibravatar GitHub <noreply@github.com>2021-09-11 13:19:06 +0200
commit9dc2255a8fab8ef0bc4b9f417c6131e4c468cb9c (patch)
treeae528bf14a3475bbea264ff26e5ffded3dfadf8a /internal/processing/account/update_test.go
parentTest both dbs (#205) (diff)
downloadgotosocial-9dc2255a8fab8ef0bc4b9f417c6131e4c468cb9c.tar.xz
kim is a reply guy (#208)
* bun debug * bun trace logging hooks * more tests * fix up some stuffffff * drop the frontend cache until a proper fix is made * go fmt
Diffstat (limited to 'internal/processing/account/update_test.go')
-rw-r--r--internal/processing/account/update_test.go49
1 files changed, 46 insertions, 3 deletions
diff --git a/internal/processing/account/update_test.go b/internal/processing/account/update_test.go
index b18a5e42e..63370cd39 100644
--- a/internal/processing/account/update_test.go
+++ b/internal/processing/account/update_test.go
@@ -36,7 +36,7 @@ func (suite *AccountUpdateTestSuite) TestAccountUpdateSimple() {
locked := true
displayName := "new display name"
- note := ""
+ note := "#hello here i am!"
form := &apimodel.UpdateCredentialsRequest{
DisplayName: &displayName,
@@ -52,7 +52,7 @@ func (suite *AccountUpdateTestSuite) TestAccountUpdateSimple() {
// fields on the profile should be updated
suite.True(apiAccount.Locked)
suite.Equal(displayName, apiAccount.DisplayName)
- suite.Empty(apiAccount.Note)
+ suite.Equal(`<p><a href="http://localhost:8080/tags/hello" class="mention hashtag" rel="tag nofollow noreferrer noopener" target="_blank">#<span>hello</span></a> here i am!</p>`, apiAccount.Note)
// we should have an update in the client api channel
msg := <-suite.fromClientAPIChan
@@ -67,7 +67,50 @@ func (suite *AccountUpdateTestSuite) TestAccountUpdateSimple() {
suite.NoError(err)
suite.True(dbAccount.Locked)
suite.Equal(displayName, dbAccount.DisplayName)
- suite.Empty(dbAccount.Note)
+ suite.Equal(`<p><a href="http://localhost:8080/tags/hello" class="mention hashtag" rel="tag nofollow noreferrer noopener" target="_blank">#<span>hello</span></a> here i am!</p>`, dbAccount.Note)
+}
+
+func (suite *AccountUpdateTestSuite) TestAccountUpdateWithMention() {
+ testAccount := suite.testAccounts["local_account_1"]
+
+ locked := true
+ displayName := "new display name"
+ note := `#hello here i am!
+
+go check out @1happyturtle, they have a cool account!
+`
+ noteExpected := `<p><a href="http://localhost:8080/tags/hello" class="mention hashtag" rel="tag nofollow noreferrer noopener" target="_blank">#<span>hello</span></a> here i am!<br><br>go check out <span class="h-card"><a href="http://localhost:8080/@1happyturtle" class="u-url mention" rel="nofollow noreferrer noopener" target="_blank">@<span>1happyturtle</span></a></span>, they have a cool account!</p>`
+
+ form := &apimodel.UpdateCredentialsRequest{
+ DisplayName: &displayName,
+ Locked: &locked,
+ Note: &note,
+ }
+
+ // should get no error from the update function, and an api model account returned
+ apiAccount, err := suite.accountProcessor.Update(context.Background(), testAccount, form)
+ suite.NoError(err)
+ suite.NotNil(apiAccount)
+
+ // fields on the profile should be updated
+ suite.True(apiAccount.Locked)
+ suite.Equal(displayName, apiAccount.DisplayName)
+ suite.Equal(noteExpected, apiAccount.Note)
+
+ // we should have an update in the client api channel
+ msg := <-suite.fromClientAPIChan
+ suite.Equal(ap.ActivityUpdate, msg.APActivityType)
+ suite.Equal(ap.ObjectProfile, msg.APObjectType)
+ suite.NotNil(msg.OriginAccount)
+ suite.Equal(testAccount.ID, msg.OriginAccount.ID)
+ suite.Nil(msg.TargetAccount)
+
+ // fields should be updated in the database as well
+ dbAccount, err := suite.db.GetAccountByID(context.Background(), testAccount.ID)
+ suite.NoError(err)
+ suite.True(dbAccount.Locked)
+ suite.Equal(displayName, dbAccount.DisplayName)
+ suite.Equal(noteExpected, dbAccount.Note)
}
func TestAccountUpdateTestSuite(t *testing.T) {