UnitBaseChatTableViewCellTest.swift 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. //
  2. // SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
  3. // SPDX-License-Identifier: GPL-3.0-or-later
  4. //
  5. import XCTest
  6. @testable import NextcloudTalk
  7. final class UnitBaseChatTableViewCellTest: TestBaseRealm {
  8. func testSharedDeckCardQuote() throws {
  9. let deckObject = """
  10. {
  11. "actor": {
  12. "type": "user",
  13. "id": "admin",
  14. "name": "admin"
  15. },
  16. "object": {
  17. "id": "9810",
  18. "name": "Test",
  19. "boardname": "Persönlich",
  20. "stackname": "Offen",
  21. "link": "https://nextcloud-mm.local/apps/deck/card/9810",
  22. "type": "deck-card",
  23. "icon-url": "https://nextcloud-mm.local/ocs/v2.php/apps/spreed/api/v1/room/123/avatar?v=abc"
  24. }
  25. }
  26. """
  27. updateCapabilities { cap in
  28. cap.referenceApiSupported = true
  29. }
  30. let activeAccount = NCDatabaseManager.sharedInstance().activeAccount()
  31. let roomToken = "token"
  32. let room = NCRoom()
  33. room.token = roomToken
  34. room.accountId = activeAccount.accountId
  35. let deckMessage = NCChatMessage()
  36. deckMessage.messageId = 1
  37. deckMessage.internalId = "internal-1"
  38. deckMessage.token = roomToken
  39. deckMessage.message = "existing"
  40. deckMessage.messageParametersJSONString = deckObject
  41. // Chat message with a quote
  42. let quoteMessage = NCChatMessage()
  43. quoteMessage.message = "test"
  44. quoteMessage.token = roomToken
  45. quoteMessage.parentId = "internal-1"
  46. try? realm.transaction {
  47. realm.add(room)
  48. realm.add(deckMessage)
  49. realm.add(quoteMessage)
  50. }
  51. let deckCell: BaseChatTableViewCell = .fromNib()
  52. deckCell.setup(for: deckMessage, withLastCommonReadMessage: 0)
  53. let quoteCell: BaseChatTableViewCell = .fromNib()
  54. quoteCell.setup(for: quoteMessage, withLastCommonReadMessage: 0)
  55. }
  56. }