forum-test.sh 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #!/usr/bin/env bash
  2. set -e
  3. SCRIPT_PATH="$(dirname "${BASH_SOURCE[0]}")"
  4. cd $SCRIPT_PATH
  5. export AUTO_CONFIRM=true
  6. export OCLIF_TS_NODE=0
  7. yarn workspace @joystream/cli build
  8. CLI=../bin/run
  9. # Init forum lead
  10. GROUP=forumWorkingGroup yarn workspace api-scripts initialize-lead
  11. # Add integration tests lead key (in case the script is executed after ./start.sh)
  12. yarn joystream-cli account:forget --name "Test forum lead key" || true
  13. yarn joystream-cli account:import --suri //testing//worker//Forum//0 --name "Test forum lead key" --password ""
  14. # Assume leader is the first worker
  15. LEADER_WORKER_ID="0"
  16. # Create test categories
  17. CATEGORY_1_ID=`${CLI} forum:createCategory -t "Test category 1" -d "Test category 1 description"`
  18. CATEGORY_2_ID=`${CLI} forum:createCategory -t "Test category 2" -d "Test category 2 description" -p ${CATEGORY_1_ID}`
  19. # Create test threads
  20. THREAD_1_ID=`${CLI} forum:createThread \
  21. --categoryId ${CATEGORY_1_ID}\
  22. --title "Test thread 1"\
  23. --tags "tag1" "tag2" "tag3"\
  24. --text "Test thread 1 initial post text"`
  25. THREAD_2_ID=`${CLI} forum:createThread \
  26. --categoryId ${CATEGORY_2_ID}\
  27. --title "Test thread 2"\
  28. --tags "tag1" "tag2" "tag3"\
  29. --text "Test thread 2 initial post text"`
  30. # Create test posts
  31. POST_1_ID=`${CLI} forum:addPost \
  32. --categoryId ${CATEGORY_1_ID}\
  33. --threadId ${THREAD_1_ID}\
  34. --text "Test post 1"\
  35. --editable`
  36. POST_2_ID=`${CLI} forum:addPost \
  37. --categoryId ${CATEGORY_2_ID}\
  38. --threadId ${THREAD_2_ID}\
  39. --text "Test post 2"\
  40. --editable`
  41. # Update category modrator permissions
  42. ${CLI} forum:updateCategoryModeratorStatus --categoryId ${CATEGORY_1_ID} --workerId ${LEADER_WORKER_ID} --status active
  43. # Update category archival status as lead
  44. ${CLI} forum:updateCategoryArchivalStatus --categoryId ${CATEGORY_1_ID} --archived yes --context Leader
  45. # Update category archival status as moderator
  46. ${CLI} forum:updateCategoryArchivalStatus --categoryId ${CATEGORY_1_ID} --archived no --context Moderator
  47. # Move thread as lead
  48. ${CLI} forum:moveThread --categoryId ${CATEGORY_1_ID} --threadId ${THREAD_1_ID} --newCategoryId ${CATEGORY_2_ID} --context Leader
  49. # Move thread as moderator
  50. ${CLI} forum:moveThread --categoryId ${CATEGORY_2_ID} --threadId ${THREAD_2_ID} --newCategoryId ${CATEGORY_1_ID} --context Moderator
  51. # Set stickied threads as lead
  52. ${CLI} forum:setStickiedThreads --categoryId ${CATEGORY_1_ID} --threadIds ${THREAD_2_ID} --context Leader
  53. # Set stickied threads as moderator
  54. ${CLI} forum:setStickiedThreads --categoryId ${CATEGORY_2_ID} --threadIds ${THREAD_1_ID} --context Moderator
  55. # Moderate post as lead
  56. ${CLI} forum:moderatePost \
  57. --categoryId ${CATEGORY_2_ID}\
  58. --threadId ${THREAD_1_ID}\
  59. --postId ${POST_1_ID}\
  60. --rationale "Leader test"\
  61. --context Leader
  62. # Moderate post as moderator
  63. ${CLI} forum:moderatePost \
  64. --categoryId ${CATEGORY_1_ID}\
  65. --threadId ${THREAD_2_ID}\
  66. --postId ${POST_2_ID}\
  67. --rationale "Moderator test"\
  68. --context Moderator
  69. # Moderate thread as lead
  70. ${CLI} forum:moderateThread --categoryId ${CATEGORY_2_ID} --threadId ${THREAD_1_ID} --rationale "Leader test" --context Leader
  71. # Moderate thread as moderator
  72. ${CLI} forum:moderateThread --categoryId ${CATEGORY_1_ID} --threadId ${THREAD_2_ID} --rationale "Moderator test" --context Moderator
  73. # Delete category as moderator
  74. ${CLI} forum:deleteCategory --categoryId ${CATEGORY_2_ID} --context Moderator
  75. # Delete category as lead
  76. ${CLI} forum:deleteCategory --categoryId ${CATEGORY_1_ID} --context Leader
  77. # Forget test lead account
  78. yarn joystream-cli account:forget --name "Test forum lead key"