@tellescope/sdk 1.9.0 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3935,6 +3935,13 @@ const run_autoreply_test = async (title: string, { expectingAutoreply } : { expe
3935
3935
  await Promise.all([
3936
3936
  sdk.api.endusers.deleteOne(enduser.id),
3937
3937
  sdk.api.chat_rooms.deleteOne(room.id),
3938
+
3939
+ // cleanup availabilities
3940
+ sdk.api.users.updateOne(sdk.userInfo.id, {
3941
+ weeklyAvailabilities: []
3942
+ }, {
3943
+ replaceObjectFields: true
3944
+ }),
3938
3945
  ...blocks.map(b => (
3939
3946
  sdk.api.availability_blocks.deleteOne(b.id)
3940
3947
  ))
@@ -3942,7 +3949,13 @@ const run_autoreply_test = async (title: string, { expectingAutoreply } : { expe
3942
3949
  }
3943
3950
 
3944
3951
  const auto_reply_tests = async () => {
3945
- log_header("Autoreply")
3952
+ // cleanup user availabilities / autoReplyEnabled to avoid conflicts
3953
+ await sdk.api.users.updateOne(sdk.userInfo.id, {
3954
+ autoReplyEnabled: false,
3955
+ weeklyAvailabilities: [],
3956
+ }, { replaceObjectFields: true })
3957
+
3958
+ log_header("Autoreply (Organization-wide)")
3946
3959
  await run_autoreply_test('No availabilities', { expectingAutoreply: false })
3947
3960
 
3948
3961
  const today = new Date()
@@ -3970,10 +3983,6 @@ const auto_reply_tests = async () => {
3970
3983
  ...activeBlockInfo,
3971
3984
  active: { to: new Date(Date.now() - 1000000) }
3972
3985
  }
3973
- const inactiveOldBlockInfo = {
3974
- ...activeBlockInfo,
3975
- dayOfWeekStartingSundayIndexedByZero: (today.getDay() + 1) % 7,
3976
- }
3977
3986
  const wrongDayBlockInfo = {
3978
3987
  ...activeBlockInfo,
3979
3988
  dayOfWeekStartingSundayIndexedByZero: (today.getDay() + 1) % 7,
@@ -4008,7 +4017,6 @@ const auto_reply_tests = async () => {
4008
4017
  await sdk.api.availability_blocks.createSome([
4009
4018
  inactiveEarly,
4010
4019
  inactiveLate,
4011
- inactiveOldBlockInfo,
4012
4020
  wrongDayBlockInfo,
4013
4021
  wrongEntityIdInfo,
4014
4022
  wrongEntityTypeBlockInfo,
@@ -4024,6 +4032,43 @@ const auto_reply_tests = async () => {
4024
4032
 
4025
4033
  await sdk.api.availability_blocks.createSome([activeBlockInfo, activeWithRange, activeBlockInfo, activeWithRange])
4026
4034
  await run_autoreply_test('Multiple active blocks', { expectingAutoreply: false })
4035
+
4036
+
4037
+ log_header("Autoreply (User)")
4038
+ await sdk.api.users.updateOne(sdk.userInfo.id, {
4039
+ autoReplyEnabled: false,
4040
+ })
4041
+
4042
+ await sdk.api.users.updateOne(sdk.userInfo.id, {
4043
+ weeklyAvailabilities: [wrongTimeBlockInfo]
4044
+ })
4045
+ await run_autoreply_test('User: Autoreply disabled', { expectingAutoreply: false })
4046
+
4047
+ await sdk.api.users.updateOne(sdk.userInfo.id, {
4048
+ autoReplyEnabled: true,
4049
+ })
4050
+
4051
+ await sdk.api.users.updateOne(sdk.userInfo.id, { weeklyAvailabilities: [wrongTimeBlockInfo] })
4052
+ await run_autoreply_test('User: One bad', { expectingAutoreply: true })
4053
+
4054
+ await sdk.api.users.updateOne(sdk.userInfo.id, {
4055
+ weeklyAvailabilities: [
4056
+ inactiveEarly,
4057
+ inactiveLate,
4058
+ wrongDayBlockInfo,
4059
+ ]
4060
+ })
4061
+ await run_autoreply_test('User: Multiple bad blocks', { expectingAutoreply: true })
4062
+
4063
+ await sdk.api.users.updateOne(sdk.userInfo.id, { weeklyAvailabilities: [activeBlockInfo] })
4064
+ await run_autoreply_test('User: One active block', { expectingAutoreply: false })
4065
+
4066
+ await sdk.api.users.updateOne(sdk.userInfo.id, { weeklyAvailabilities: [activeWithRange] })
4067
+ await run_autoreply_test('User: One active with range', { expectingAutoreply: false })
4068
+
4069
+ await sdk.api.users.updateOne(sdk.userInfo.id, { weeklyAvailabilities: [activeBlockInfo, activeWithRange, activeBlockInfo, activeWithRange] })
4070
+ await run_autoreply_test('User: Multiple active blocks', { expectingAutoreply: false })
4071
+
4027
4072
  }
4028
4073
 
4029
4074
  const NO_TEST = () => {}
@@ -4097,9 +4142,9 @@ const tests: { [K in keyof ClientModelForName]: () => void } = {
4097
4142
  ])
4098
4143
  await setup_tests()
4099
4144
  await multi_tenant_tests() // should come right after setup tests
4145
+ await auto_reply_tests()
4100
4146
  await automation_trigger_tests()
4101
4147
  await sub_organization_enduser_tests()
4102
- await auto_reply_tests()
4103
4148
  await sub_organization_tests()
4104
4149
  await self_serve_appointment_booking_tests()
4105
4150
  await filter_by_date_tests()