@cometchat/skills 4.0.0 → 4.2.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.
- package/README.md +42 -2
- package/bin/install.js +448 -57
- package/package.json +1 -1
- package/skills/cometchat/SKILL.md +337 -80
- package/skills/cometchat-a11y/SKILL.md +476 -0
- package/skills/cometchat-android-v5/SKILL.md +1 -1
- package/skills/cometchat-android-v5-calls/SKILL.md +413 -0
- package/skills/cometchat-android-v5-calls/references/README.md +53 -0
- package/skills/cometchat-android-v5-calls/references/add-calls-to-existing-chat.md +195 -0
- package/skills/cometchat-android-v5-calls/references/audio-controls.md +91 -0
- package/skills/cometchat-android-v5-calls/references/background-handling.md +168 -0
- package/skills/cometchat-android-v5-calls/references/call-layouts.md +123 -0
- package/skills/cometchat-android-v5-calls/references/call-logs.md +113 -0
- package/skills/cometchat-android-v5-calls/references/call-session.md +274 -0
- package/skills/cometchat-android-v5-calls/references/custom-ui.md +150 -0
- package/skills/cometchat-android-v5-calls/references/event-listeners.md +123 -0
- package/skills/cometchat-android-v5-calls/references/group-calls.md +205 -0
- package/skills/cometchat-android-v5-calls/references/idle-timeout.md +111 -0
- package/skills/cometchat-android-v5-calls/references/in-call-chat.md +134 -0
- package/skills/cometchat-android-v5-calls/references/join-session.md +120 -0
- package/skills/cometchat-android-v5-calls/references/migration-v4-to-v5.md +206 -0
- package/skills/cometchat-android-v5-calls/references/participant-management.md +110 -0
- package/skills/cometchat-android-v5-calls/references/picture-in-picture.md +106 -0
- package/skills/cometchat-android-v5-calls/references/raise-hand.md +242 -0
- package/skills/cometchat-android-v5-calls/references/recording.md +101 -0
- package/skills/cometchat-android-v5-calls/references/ringing-integration.md +152 -0
- package/skills/cometchat-android-v5-calls/references/screen-sharing.md +82 -0
- package/skills/cometchat-android-v5-calls/references/server-fcm-voip.md +215 -0
- package/skills/cometchat-android-v5-calls/references/session-settings.md +121 -0
- package/skills/cometchat-android-v5-calls/references/setup.md +137 -0
- package/skills/cometchat-android-v5-calls/references/share-invite.md +151 -0
- package/skills/cometchat-android-v5-calls/references/video-controls.md +87 -0
- package/skills/cometchat-android-v5-calls/references/voip-calling.md +526 -0
- package/skills/cometchat-android-v5-components/SKILL.md +1 -1
- package/skills/cometchat-android-v5-core/SKILL.md +1 -1
- package/skills/cometchat-android-v5-customization/SKILL.md +1 -1
- package/skills/cometchat-android-v5-extensions/SKILL.md +1 -1
- package/skills/cometchat-android-v5-features/SKILL.md +1 -1
- package/skills/cometchat-android-v5-placement/SKILL.md +1 -1
- package/skills/cometchat-android-v5-production/SKILL.md +1 -1
- package/skills/cometchat-android-v5-push/SKILL.md +1 -1
- package/skills/cometchat-android-v5-testing/SKILL.md +1 -1
- package/skills/cometchat-android-v5-theming/SKILL.md +1 -1
- package/skills/cometchat-android-v5-troubleshooting/SKILL.md +1 -1
- package/skills/cometchat-android-v6/SKILL.md +1 -1
- package/skills/cometchat-android-v6-builder-settings/SKILL.md +1 -1
- package/skills/cometchat-android-v6-calls/SKILL.md +375 -0
- package/skills/cometchat-android-v6-calls/references/add-calls-to-existing-chat.md +97 -0
- package/skills/cometchat-android-v6-calls/references/call-layouts.md +91 -0
- package/skills/cometchat-android-v6-calls/references/call-session.md +163 -0
- package/skills/cometchat-android-v6-calls/references/device-management.md +171 -0
- package/skills/cometchat-android-v6-calls/references/group-calls.md +191 -0
- package/skills/cometchat-android-v6-calls/references/idle-timeout.md +107 -0
- package/skills/cometchat-android-v6-calls/references/in-call-chat.md +136 -0
- package/skills/cometchat-android-v6-calls/references/raise-hand.md +186 -0
- package/skills/cometchat-android-v6-calls/references/ringing-integration.md +176 -0
- package/skills/cometchat-android-v6-calls/references/server-fcm-voip.md +127 -0
- package/skills/cometchat-android-v6-calls/references/share-invite.md +105 -0
- package/skills/cometchat-android-v6-compose-components/SKILL.md +2 -2
- package/skills/cometchat-android-v6-compose-customization/SKILL.md +1 -1
- package/skills/cometchat-android-v6-compose-placement/SKILL.md +1 -1
- package/skills/cometchat-android-v6-compose-theming/SKILL.md +1 -1
- package/skills/cometchat-android-v6-core/SKILL.md +1 -1
- package/skills/cometchat-android-v6-events/SKILL.md +1 -1
- package/skills/cometchat-android-v6-extensions/SKILL.md +1 -1
- package/skills/cometchat-android-v6-features/SKILL.md +1 -1
- package/skills/cometchat-android-v6-kotlin-components/SKILL.md +1 -1
- package/skills/cometchat-android-v6-kotlin-customization/SKILL.md +1 -1
- package/skills/cometchat-android-v6-kotlin-placement/SKILL.md +1 -1
- package/skills/cometchat-android-v6-kotlin-theming/SKILL.md +1 -1
- package/skills/cometchat-android-v6-migration/SKILL.md +398 -0
- package/skills/cometchat-android-v6-production/SKILL.md +1 -1
- package/skills/cometchat-android-v6-push/SKILL.md +1 -1
- package/skills/cometchat-android-v6-testing/SKILL.md +1 -1
- package/skills/cometchat-android-v6-troubleshooting/SKILL.md +1 -1
- package/skills/cometchat-angular-calls/SKILL.md +511 -0
- package/skills/cometchat-angular-calls/references/add-calls-to-existing-chat.md +95 -0
- package/skills/cometchat-angular-calls/references/call-layouts.md +106 -0
- package/skills/cometchat-angular-calls/references/call-session.md +167 -0
- package/skills/cometchat-angular-calls/references/custom-ui.md +231 -0
- package/skills/cometchat-angular-calls/references/device-management.md +135 -0
- package/skills/cometchat-angular-calls/references/group-calls.md +412 -0
- package/skills/cometchat-angular-calls/references/idle-timeout.md +145 -0
- package/skills/cometchat-angular-calls/references/in-call-chat.md +148 -0
- package/skills/cometchat-angular-calls/references/lazy-loading-pitfalls.md +205 -0
- package/skills/cometchat-angular-calls/references/migration-v4-to-v5.md +53 -0
- package/skills/cometchat-angular-calls/references/ngzone-and-async-callbacks.md +183 -0
- package/skills/cometchat-angular-calls/references/picture-in-picture.md +285 -0
- package/skills/cometchat-angular-calls/references/raise-hand.md +167 -0
- package/skills/cometchat-angular-calls/references/recording-screen-share.md +267 -0
- package/skills/cometchat-angular-calls/references/ringing-integration.md +131 -0
- package/skills/cometchat-angular-calls/references/server-web-push-vapid.md +100 -0
- package/skills/cometchat-angular-calls/references/share-invite.md +116 -0
- package/skills/cometchat-angular-components/SKILL.md +1 -1
- package/skills/cometchat-angular-core/SKILL.md +1 -1
- package/skills/cometchat-angular-customization/SKILL.md +1 -1
- package/skills/cometchat-angular-features/SKILL.md +1 -1
- package/skills/cometchat-angular-patterns/SKILL.md +1 -1
- package/skills/cometchat-angular-placement/SKILL.md +1 -1
- package/skills/cometchat-angular-production/SKILL.md +1 -1
- package/skills/cometchat-angular-push/SKILL.md +403 -0
- package/skills/cometchat-angular-testing/SKILL.md +333 -0
- package/skills/cometchat-angular-theming/SKILL.md +1 -1
- package/skills/cometchat-angular-troubleshooting/SKILL.md +1 -1
- package/skills/cometchat-astro-patterns/SKILL.md +1 -1
- package/skills/cometchat-calls/SKILL.md +358 -0
- package/skills/cometchat-calls/references/use-case-broadcast.md +194 -0
- package/skills/cometchat-calls/references/use-case-marketplace.md +158 -0
- package/skills/cometchat-calls/references/use-case-support.md +190 -0
- package/skills/cometchat-calls/references/use-case-team.md +169 -0
- package/skills/cometchat-calls/references/use-case-telehealth.md +154 -0
- package/skills/cometchat-components/SKILL.md +1 -1
- package/skills/cometchat-core/SKILL.md +1 -1
- package/skills/cometchat-customization/SKILL.md +2 -2
- package/skills/cometchat-features/SKILL.md +2 -2
- package/skills/cometchat-flutter-v5/SKILL.md +1 -1
- package/skills/cometchat-flutter-v5-calls/SKILL.md +325 -94
- package/skills/cometchat-flutter-v5-calls/references/add-calls-to-existing-chat.md +169 -0
- package/skills/cometchat-flutter-v5-calls/references/call-layouts.md +98 -0
- package/skills/cometchat-flutter-v5-calls/references/call-session.md +330 -0
- package/skills/cometchat-flutter-v5-calls/references/device-management.md +120 -0
- package/skills/cometchat-flutter-v5-calls/references/group-calls.md +187 -0
- package/skills/cometchat-flutter-v5-calls/references/idle-timeout.md +97 -0
- package/skills/cometchat-flutter-v5-calls/references/in-call-chat.md +132 -0
- package/skills/cometchat-flutter-v5-calls/references/migration-v4-to-v5.md +160 -0
- package/skills/cometchat-flutter-v5-calls/references/raise-hand.md +244 -0
- package/skills/cometchat-flutter-v5-calls/references/ringing-integration.md +193 -0
- package/skills/cometchat-flutter-v5-calls/references/server-push-bridge.md +101 -0
- package/skills/cometchat-flutter-v5-calls/references/share-invite.md +142 -0
- package/skills/cometchat-flutter-v5-conversations/SKILL.md +1 -1
- package/skills/cometchat-flutter-v5-core/SKILL.md +1 -1
- package/skills/cometchat-flutter-v5-customization/SKILL.md +1 -1
- package/skills/cometchat-flutter-v5-events/SKILL.md +1 -1
- package/skills/cometchat-flutter-v5-messages/SKILL.md +1 -1
- package/skills/cometchat-flutter-v5-production/SKILL.md +1 -1
- package/skills/cometchat-flutter-v5-push/SKILL.md +1 -1
- package/skills/cometchat-flutter-v5-testing/SKILL.md +390 -0
- package/skills/cometchat-flutter-v5-theming/SKILL.md +1 -1
- package/skills/cometchat-flutter-v5-troubleshooting/SKILL.md +1 -1
- package/skills/cometchat-flutter-v5-users-groups/SKILL.md +1 -1
- package/skills/cometchat-flutter-v6/SKILL.md +1 -1
- package/skills/cometchat-flutter-v6-calls/SKILL.md +308 -243
- package/skills/cometchat-flutter-v6-calls/references/add-calls-to-existing-chat.md +134 -0
- package/skills/cometchat-flutter-v6-calls/references/call-layouts.md +102 -0
- package/skills/cometchat-flutter-v6-calls/references/call-session.md +229 -0
- package/skills/cometchat-flutter-v6-calls/references/device-management.md +99 -0
- package/skills/cometchat-flutter-v6-calls/references/group-calls.md +190 -0
- package/skills/cometchat-flutter-v6-calls/references/idle-timeout.md +80 -0
- package/skills/cometchat-flutter-v6-calls/references/in-call-chat.md +122 -0
- package/skills/cometchat-flutter-v6-calls/references/raise-hand.md +268 -0
- package/skills/cometchat-flutter-v6-calls/references/ringing-integration.md +171 -0
- package/skills/cometchat-flutter-v6-calls/references/server-push-bridge.md +93 -0
- package/skills/cometchat-flutter-v6-calls/references/share-invite.md +102 -0
- package/skills/cometchat-flutter-v6-components/SKILL.md +1 -1
- package/skills/cometchat-flutter-v6-conversations/SKILL.md +1 -1
- package/skills/cometchat-flutter-v6-core/SKILL.md +1 -1
- package/skills/cometchat-flutter-v6-customization/SKILL.md +1 -1
- package/skills/cometchat-flutter-v6-events/SKILL.md +1 -1
- package/skills/cometchat-flutter-v6-features/SKILL.md +1 -1
- package/skills/cometchat-flutter-v6-messages/SKILL.md +1 -1
- package/skills/cometchat-flutter-v6-migration/SKILL.md +1 -1
- package/skills/cometchat-flutter-v6-placement/SKILL.md +1 -1
- package/skills/cometchat-flutter-v6-production/SKILL.md +1 -1
- package/skills/cometchat-flutter-v6-push/SKILL.md +452 -0
- package/skills/cometchat-flutter-v6-testing/SKILL.md +319 -0
- package/skills/cometchat-flutter-v6-theming/SKILL.md +1 -1
- package/skills/cometchat-flutter-v6-troubleshooting/SKILL.md +1 -1
- package/skills/cometchat-flutter-v6-users-groups/SKILL.md +1 -1
- package/skills/cometchat-i18n/SKILL.md +358 -0
- package/skills/cometchat-ios/SKILL.md +5 -5
- package/skills/cometchat-ios-calls/SKILL.md +409 -0
- package/skills/cometchat-ios-calls/references/add-calls-to-existing-chat.md +172 -0
- package/skills/cometchat-ios-calls/references/avaudiosession-routing.md +189 -0
- package/skills/cometchat-ios-calls/references/call-layouts.md +136 -0
- package/skills/cometchat-ios-calls/references/call-session.md +221 -0
- package/skills/cometchat-ios-calls/references/callkit-and-pushkit.md +353 -0
- package/skills/cometchat-ios-calls/references/custom-ui.md +322 -0
- package/skills/cometchat-ios-calls/references/device-management.md +171 -0
- package/skills/cometchat-ios-calls/references/group-calls.md +396 -0
- package/skills/cometchat-ios-calls/references/idle-timeout.md +185 -0
- package/skills/cometchat-ios-calls/references/in-call-chat.md +183 -0
- package/skills/cometchat-ios-calls/references/migration-v4-to-v5.md +138 -0
- package/skills/cometchat-ios-calls/references/picture-in-picture.md +246 -0
- package/skills/cometchat-ios-calls/references/raise-hand.md +239 -0
- package/skills/cometchat-ios-calls/references/recording-screen-share.md +339 -0
- package/skills/cometchat-ios-calls/references/ringing-integration.md +142 -0
- package/skills/cometchat-ios-calls/references/server-apns-pushkit.md +267 -0
- package/skills/cometchat-ios-calls/references/share-invite.md +152 -0
- package/skills/cometchat-ios-calls/references/swiftui-uikit-hosting.md +246 -0
- package/skills/cometchat-ios-calls/references/voip-cert-setup.md +166 -0
- package/skills/cometchat-ios-components/SKILL.md +1 -1
- package/skills/cometchat-ios-core/SKILL.md +1 -1
- package/skills/cometchat-ios-customization/SKILL.md +1 -1
- package/skills/cometchat-ios-features/SKILL.md +1 -1
- package/skills/cometchat-ios-placement/SKILL.md +1 -1
- package/skills/cometchat-ios-production/SKILL.md +1 -1
- package/skills/cometchat-ios-push/SKILL.md +1 -1
- package/skills/cometchat-ios-testing/SKILL.md +371 -0
- package/skills/cometchat-ios-theming/SKILL.md +1 -1
- package/skills/cometchat-ios-troubleshooting/SKILL.md +1 -1
- package/skills/cometchat-native-bare-patterns/SKILL.md +45 -3
- package/skills/cometchat-native-calls/SKILL.md +599 -0
- package/skills/cometchat-native-calls/references/add-calls-to-existing-chat.md +203 -0
- package/skills/cometchat-native-calls/references/call-layouts.md +124 -0
- package/skills/cometchat-native-calls/references/call-session.md +182 -0
- package/skills/cometchat-native-calls/references/custom-ui.md +250 -0
- package/skills/cometchat-native-calls/references/device-management.md +135 -0
- package/skills/cometchat-native-calls/references/expo-vs-bare.md +179 -0
- package/skills/cometchat-native-calls/references/group-calls.md +291 -0
- package/skills/cometchat-native-calls/references/idle-timeout.md +128 -0
- package/skills/cometchat-native-calls/references/in-call-chat.md +143 -0
- package/skills/cometchat-native-calls/references/migration-v4-to-v5.md +72 -0
- package/skills/cometchat-native-calls/references/picture-in-picture.md +276 -0
- package/skills/cometchat-native-calls/references/raise-hand.md +203 -0
- package/skills/cometchat-native-calls/references/recording-screen-share.md +290 -0
- package/skills/cometchat-native-calls/references/ringing-integration.md +118 -0
- package/skills/cometchat-native-calls/references/server-push-bridge.md +135 -0
- package/skills/cometchat-native-calls/references/server-push-payloads.md +193 -0
- package/skills/cometchat-native-calls/references/share-invite.md +144 -0
- package/skills/cometchat-native-calls/references/voip-push-end-to-end.md +317 -0
- package/skills/cometchat-native-components/SKILL.md +1 -1
- package/skills/cometchat-native-core/SKILL.md +1 -1
- package/skills/cometchat-native-customization/SKILL.md +1 -1
- package/skills/cometchat-native-expo-patterns/SKILL.md +18 -1
- package/skills/cometchat-native-features/SKILL.md +1 -1
- package/skills/cometchat-native-placement/SKILL.md +1 -1
- package/skills/cometchat-native-production/SKILL.md +1 -1
- package/skills/cometchat-native-push/SKILL.md +1 -1
- package/skills/cometchat-native-testing/SKILL.md +1 -1
- package/skills/cometchat-native-theming/SKILL.md +1 -1
- package/skills/cometchat-native-troubleshooting/SKILL.md +1 -1
- package/skills/cometchat-nextjs-patterns/SKILL.md +1 -1
- package/skills/cometchat-placement/SKILL.md +29 -1
- package/skills/cometchat-production/SKILL.md +1 -1
- package/skills/cometchat-react-calls/SKILL.md +539 -0
- package/skills/cometchat-react-calls/references/add-calls-to-existing-chat.md +145 -0
- package/skills/cometchat-react-calls/references/call-layouts.md +161 -0
- package/skills/cometchat-react-calls/references/call-session.md +235 -0
- package/skills/cometchat-react-calls/references/custom-ui.md +201 -0
- package/skills/cometchat-react-calls/references/device-management.md +206 -0
- package/skills/cometchat-react-calls/references/group-calls.md +262 -0
- package/skills/cometchat-react-calls/references/idle-timeout.md +175 -0
- package/skills/cometchat-react-calls/references/in-call-chat.md +212 -0
- package/skills/cometchat-react-calls/references/migration-v4-to-v5.md +172 -0
- package/skills/cometchat-react-calls/references/picture-in-picture.md +245 -0
- package/skills/cometchat-react-calls/references/raise-hand.md +238 -0
- package/skills/cometchat-react-calls/references/recording-screen-share.md +143 -0
- package/skills/cometchat-react-calls/references/ringing-integration.md +255 -0
- package/skills/cometchat-react-calls/references/server-web-push-vapid.md +241 -0
- package/skills/cometchat-react-calls/references/share-invite.md +176 -0
- package/skills/cometchat-react-calls/references/testing-calls-on-web.md +198 -0
- package/skills/cometchat-react-calls/references/voip-and-web-push.md +165 -0
- package/skills/cometchat-react-patterns/SKILL.md +56 -8
- package/skills/cometchat-react-push/SKILL.md +448 -0
- package/skills/cometchat-react-router-patterns/SKILL.md +1 -1
- package/skills/cometchat-react-testing/SKILL.md +404 -0
- package/skills/cometchat-theming/SKILL.md +3 -3
- package/skills/cometchat-troubleshooting/SKILL.md +2 -2
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cometchat-angular-testing
|
|
3
|
+
description: Testing patterns for CometChat Angular UI Kit v4 in Angular 12-15 projects. Covers Karma (default Angular test runner) and Jest (jest-preset-angular alternative), TestBed configuration with CometChatUIKitModule mocking, NgZone-aware async assertions, Cypress for e2e flows with WebSocket waits, and CI configuration. Sister skill of cometchat-angular-calls/references for the calls-specific testing patterns.
|
|
4
|
+
license: "MIT"
|
|
5
|
+
compatibility: "Angular 12-15 (LTS focus on 15); Karma + Jasmine (default) OR Jest + jest-preset-angular; Cypress >= 13; @cometchat/chat-uikit-angular ^4.x"
|
|
6
|
+
allowed-tools: "shell, file-read, file-search, file-list, ask-user"
|
|
7
|
+
metadata:
|
|
8
|
+
author: "CometChat"
|
|
9
|
+
version: "4.0.0"
|
|
10
|
+
tags: "cometchat angular testing karma jest cypress testbed ngzone async fakeasync changedetection mocking"
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Purpose
|
|
14
|
+
|
|
15
|
+
Test recipes for CometChat Angular UI Kit integrations. Covers both Angular runners (Karma — default; Jest — preferred by many teams), TestBed patterns specific to NgZone-driven components, and Cypress for full e2e.
|
|
16
|
+
|
|
17
|
+
**Read these other skills first:**
|
|
18
|
+
- `cometchat-angular-core` — init service, APP_INITIALIZER pattern
|
|
19
|
+
- `cometchat-angular-patterns` — module setup, lazy loading
|
|
20
|
+
- `cometchat-angular-calls/references/ngzone-and-async-callbacks.md` — NgZone primer (carries over to test patterns)
|
|
21
|
+
|
|
22
|
+
**Ground truth:**
|
|
23
|
+
- Angular testing — https://angular.io/guide/testing
|
|
24
|
+
- jest-preset-angular — https://github.com/thymikee/jest-preset-angular
|
|
25
|
+
- Cypress for Angular — https://docs.cypress.io/guides/component-testing/angular/overview
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## 1. Karma vs Jest — pick one
|
|
30
|
+
|
|
31
|
+
| Criterion | Karma (default) | Jest |
|
|
32
|
+
|---|---|---|
|
|
33
|
+
| Comes with `ng new` | ✓ | ✗ (manual setup) |
|
|
34
|
+
| Speed | Slower (real browser) | Faster (jsdom) |
|
|
35
|
+
| Real browser parity | Higher | Lower (no real CSS, no real layout) |
|
|
36
|
+
| Snapshot testing | Possible (jasmine-jest-snapshot) | First-class |
|
|
37
|
+
| CI complexity | Need ChromeHeadless | Pure Node |
|
|
38
|
+
|
|
39
|
+
The skill defaults to Karma if the project already uses it, Jest if greenfield.
|
|
40
|
+
|
|
41
|
+
### Karma setup (default Angular)
|
|
42
|
+
|
|
43
|
+
Already configured by `ng new`. The skill writes test files only.
|
|
44
|
+
|
|
45
|
+
### Jest setup
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npm install -D jest @types/jest jest-preset-angular @angular-builders/jest
|
|
49
|
+
ng add @angular-builders/jest
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
`jest.config.js`:
|
|
53
|
+
|
|
54
|
+
```js
|
|
55
|
+
module.exports = {
|
|
56
|
+
preset: "jest-preset-angular",
|
|
57
|
+
setupFilesAfterEach: ["<rootDir>/setup-jest.ts"],
|
|
58
|
+
globalSetup: "jest-preset-angular/global-setup",
|
|
59
|
+
testPathIgnorePatterns: ["/node_modules/", "/dist/", "/cypress/"],
|
|
60
|
+
};
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
`setup-jest.ts`:
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
import "jest-preset-angular/setup-jest";
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
`angular.json` test command becomes `ng test --code-coverage`.
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## 2. TestBed setup with CometChat module
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
// chat.component.spec.ts
|
|
77
|
+
import { ComponentFixture, TestBed } from "@angular/core/testing";
|
|
78
|
+
import { CUSTOM_ELEMENTS_SCHEMA } from "@angular/core";
|
|
79
|
+
import { ChatComponent } from "./chat.component";
|
|
80
|
+
import { CometChatInitService } from "../services/cometchat-init.service";
|
|
81
|
+
|
|
82
|
+
describe("ChatComponent", () => {
|
|
83
|
+
let fixture: ComponentFixture<ChatComponent>;
|
|
84
|
+
let component: ChatComponent;
|
|
85
|
+
let initService: jasmine.SpyObj<CometChatInitService>;
|
|
86
|
+
|
|
87
|
+
beforeEach(async () => {
|
|
88
|
+
initService = jasmine.createSpyObj("CometChatInitService", ["init", "login"]);
|
|
89
|
+
initService.init.and.returnValue(Promise.resolve());
|
|
90
|
+
initService.login.and.returnValue(Promise.resolve({ uid: "cometchat-uid-1" }));
|
|
91
|
+
|
|
92
|
+
await TestBed.configureTestingModule({
|
|
93
|
+
declarations: [ChatComponent],
|
|
94
|
+
providers: [
|
|
95
|
+
{ provide: CometChatInitService, useValue: initService },
|
|
96
|
+
],
|
|
97
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA], // critical — UI Kit selectors
|
|
98
|
+
}).compileComponents();
|
|
99
|
+
|
|
100
|
+
fixture = TestBed.createComponent(ChatComponent);
|
|
101
|
+
component = fixture.componentInstance;
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it("calls init on construction", () => {
|
|
105
|
+
fixture.detectChanges();
|
|
106
|
+
expect(initService.init).toHaveBeenCalled();
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
`CUSTOM_ELEMENTS_SCHEMA` makes the test ignore unknown elements (the `<cometchat-*>` selectors in templates). Without it, every test fails with "is not a known element."
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## 3. NgZone + fakeAsync for SDK callbacks
|
|
116
|
+
|
|
117
|
+
The Calls SDK fires callbacks outside Angular's zone (cf. `cometchat-angular-calls/references/ngzone-and-async-callbacks.md`). Tests for components subscribing to those callbacks need `fakeAsync` + `tick`:
|
|
118
|
+
|
|
119
|
+
```ts
|
|
120
|
+
import { fakeAsync, tick } from "@angular/core/testing";
|
|
121
|
+
|
|
122
|
+
it("renders error when SDK fails", fakeAsync(() => {
|
|
123
|
+
initService.login.and.returnValue(Promise.reject(new Error("401 Unauthorized")));
|
|
124
|
+
|
|
125
|
+
fixture.detectChanges();
|
|
126
|
+
tick(); // flush pending promises
|
|
127
|
+
fixture.detectChanges(); // re-render after state change
|
|
128
|
+
|
|
129
|
+
const errorEl = fixture.nativeElement.querySelector(".error-message");
|
|
130
|
+
expect(errorEl.textContent).toContain("401");
|
|
131
|
+
}));
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
For SDK callbacks dispatched via `setTimeout` or `requestAnimationFrame`, `tick(N)` advances by N ms.
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## 4. Mocking `@cometchat/chat-uikit-angular`
|
|
139
|
+
|
|
140
|
+
The UI Kit is heavy — full module imports inflate test bundles and trigger zone-related warnings in jsdom. Mock at the module level:
|
|
141
|
+
|
|
142
|
+
```ts
|
|
143
|
+
// __mocks__/cometchat-uikit-angular.ts
|
|
144
|
+
import { Component, NgModule, NO_ERRORS_SCHEMA } from "@angular/core";
|
|
145
|
+
|
|
146
|
+
@Component({ selector: "cometchat-conversations", template: "<div>conversations</div>" })
|
|
147
|
+
export class CometChatConversationsStub {}
|
|
148
|
+
|
|
149
|
+
@Component({ selector: "cometchat-message-list", template: "<div>message-list</div>" })
|
|
150
|
+
export class CometChatMessageListStub {}
|
|
151
|
+
|
|
152
|
+
@Component({ selector: "cometchat-message-composer", template: "<div>composer</div>" })
|
|
153
|
+
export class CometChatMessageComposerStub {}
|
|
154
|
+
|
|
155
|
+
@Component({ selector: "cometchat-message-header", template: "<div>header</div>" })
|
|
156
|
+
export class CometChatMessageHeaderStub {}
|
|
157
|
+
|
|
158
|
+
@NgModule({
|
|
159
|
+
declarations: [
|
|
160
|
+
CometChatConversationsStub,
|
|
161
|
+
CometChatMessageListStub,
|
|
162
|
+
CometChatMessageComposerStub,
|
|
163
|
+
CometChatMessageHeaderStub,
|
|
164
|
+
],
|
|
165
|
+
exports: [
|
|
166
|
+
CometChatConversationsStub,
|
|
167
|
+
CometChatMessageListStub,
|
|
168
|
+
CometChatMessageComposerStub,
|
|
169
|
+
CometChatMessageHeaderStub,
|
|
170
|
+
],
|
|
171
|
+
})
|
|
172
|
+
export class CometChatUIKitModuleStub {}
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
In a test:
|
|
176
|
+
|
|
177
|
+
```ts
|
|
178
|
+
await TestBed.configureTestingModule({
|
|
179
|
+
declarations: [ChatComponent],
|
|
180
|
+
imports: [CometChatUIKitModuleStub],
|
|
181
|
+
providers: [/* ... */],
|
|
182
|
+
}).compileComponents();
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
For Jest, alias the module path:
|
|
186
|
+
|
|
187
|
+
```js
|
|
188
|
+
// jest.config.js
|
|
189
|
+
moduleNameMapper: {
|
|
190
|
+
"^@cometchat/chat-uikit-angular$": "<rootDir>/__mocks__/cometchat-uikit-angular.ts",
|
|
191
|
+
}
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
For Karma, less straightforward — typically you import the stub module directly in the test file and let TypeScript's structural typing handle it.
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
## 5. Standalone components (Angular 14+)
|
|
199
|
+
|
|
200
|
+
```ts
|
|
201
|
+
import { ComponentFixture, TestBed } from "@angular/core/testing";
|
|
202
|
+
import { ChatComponent } from "./chat.component";
|
|
203
|
+
|
|
204
|
+
describe("ChatComponent (standalone)", () => {
|
|
205
|
+
let fixture: ComponentFixture<ChatComponent>;
|
|
206
|
+
|
|
207
|
+
beforeEach(async () => {
|
|
208
|
+
await TestBed.configureTestingModule({
|
|
209
|
+
imports: [ChatComponent], // standalone components imported, not declared
|
|
210
|
+
providers: [{ provide: CometChatInitService, useValue: { init: () => Promise.resolve() } }],
|
|
211
|
+
}).compileComponents();
|
|
212
|
+
|
|
213
|
+
fixture = TestBed.createComponent(ChatComponent);
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
## 6. Cypress e2e
|
|
221
|
+
|
|
222
|
+
### Install
|
|
223
|
+
|
|
224
|
+
```bash
|
|
225
|
+
npm install -D cypress
|
|
226
|
+
npx cypress open # generates cypress/ scaffold
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### `cypress.config.ts`
|
|
230
|
+
|
|
231
|
+
```ts
|
|
232
|
+
import { defineConfig } from "cypress";
|
|
233
|
+
|
|
234
|
+
export default defineConfig({
|
|
235
|
+
e2e: {
|
|
236
|
+
baseUrl: process.env.E2E_BASE_URL ?? "http://localhost:4200",
|
|
237
|
+
supportFile: "cypress/support/e2e.ts",
|
|
238
|
+
specPattern: "cypress/e2e/**/*.cy.ts",
|
|
239
|
+
defaultCommandTimeout: 10_000, // generous for WebSocket-driven assertions
|
|
240
|
+
},
|
|
241
|
+
});
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### Two-window chat smoke
|
|
245
|
+
|
|
246
|
+
Cypress doesn't natively support multi-window tests. Workaround: open a second browser context via Playwright OR test with two iframes. Most teams use Playwright for cross-window tests — keep Cypress for single-window smoke.
|
|
247
|
+
|
|
248
|
+
```ts
|
|
249
|
+
// cypress/e2e/chat.cy.ts
|
|
250
|
+
describe("chat smoke", () => {
|
|
251
|
+
it("logs in and sees the conversation list", () => {
|
|
252
|
+
cy.visit("/");
|
|
253
|
+
cy.window().then((win) => {
|
|
254
|
+
win.localStorage.setItem("cc-test-uid", "cometchat-uid-1");
|
|
255
|
+
});
|
|
256
|
+
cy.reload();
|
|
257
|
+
|
|
258
|
+
cy.contains("Welcome").should("be.visible");
|
|
259
|
+
cy.visit("/messages");
|
|
260
|
+
cy.contains("Conversations", { timeout: 10_000 }).should("be.visible");
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
it("sends a message and sees it in the thread", () => {
|
|
264
|
+
cy.visit("/messages");
|
|
265
|
+
cy.contains("cometchat-uid-2").click();
|
|
266
|
+
cy.get("input[placeholder='Type a message']").type("Hello");
|
|
267
|
+
cy.contains("Send").click();
|
|
268
|
+
cy.contains("Hello", { timeout: 5_000 }).should("be.visible");
|
|
269
|
+
});
|
|
270
|
+
});
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
For two-user tests, prefer Playwright — see `cometchat-react-testing/SKILL.md`.
|
|
274
|
+
|
|
275
|
+
---
|
|
276
|
+
|
|
277
|
+
## 7. Anti-patterns
|
|
278
|
+
|
|
279
|
+
1. **Skipping `CUSTOM_ELEMENTS_SCHEMA`** in TestBed. Every test fails with "is not a known element" for `<cometchat-*>` selectors.
|
|
280
|
+
2. **Using `ngOnInit()` directly in tests.** Always go through `fixture.detectChanges()` so Angular's lifecycle runs the way it does in production.
|
|
281
|
+
3. **Mocking `CometChat.init`** with a synchronous return value. Real init returns a Promise; sync mocks mask race conditions in your code.
|
|
282
|
+
4. **`async` test bodies without `await`** on the assertion. The test passes (trivially) because the assertion never ran. Use `fakeAsync` + `tick` or proper `await fixture.whenStable()`.
|
|
283
|
+
5. **Hardcoding test user UIDs** in templates. Use a service injection so tests can override.
|
|
284
|
+
6. **Running Karma in CI without `--watch=false --browsers=ChromeHeadless`.** Default `ng test` watches forever; CI hangs.
|
|
285
|
+
|
|
286
|
+
## 8. CI configuration
|
|
287
|
+
|
|
288
|
+
```yaml
|
|
289
|
+
# .github/workflows/test.yml
|
|
290
|
+
name: tests
|
|
291
|
+
on: [push, pull_request]
|
|
292
|
+
|
|
293
|
+
jobs:
|
|
294
|
+
test:
|
|
295
|
+
runs-on: ubuntu-latest
|
|
296
|
+
steps:
|
|
297
|
+
- uses: actions/checkout@v4
|
|
298
|
+
- uses: actions/setup-node@v4
|
|
299
|
+
with: { node-version: 20, cache: npm }
|
|
300
|
+
- run: npm ci
|
|
301
|
+
|
|
302
|
+
# Karma
|
|
303
|
+
- run: npm run test -- --watch=false --browsers=ChromeHeadless --code-coverage
|
|
304
|
+
# OR Jest
|
|
305
|
+
# - run: npm run test -- --ci --coverage
|
|
306
|
+
|
|
307
|
+
- run: npx cypress run
|
|
308
|
+
env:
|
|
309
|
+
E2E_BASE_URL: http://localhost:4200
|
|
310
|
+
# ng serve in background:
|
|
311
|
+
# - run: npx concurrently "ng serve" "wait-on http://localhost:4200 && npx cypress run"
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
Use a dedicated test CometChat App ID in CI — never share with production.
|
|
315
|
+
|
|
316
|
+
---
|
|
317
|
+
|
|
318
|
+
## 9. Verification checklist
|
|
319
|
+
|
|
320
|
+
- [ ] `karma.conf.js` (Angular default) OR `jest.config.js` (Jest path) configured
|
|
321
|
+
- [ ] At least one test using `CUSTOM_ELEMENTS_SCHEMA` for components that render `<cometchat-*>`
|
|
322
|
+
- [ ] At least one test asserting "init runs and resolves before component is usable"
|
|
323
|
+
- [ ] At least one test asserting "error state renders when SDK throws"
|
|
324
|
+
- [ ] `CometChatInitService` mocked, not the real one
|
|
325
|
+
- [ ] No hardcoded App ID / Auth Key in test files
|
|
326
|
+
- [ ] CI runs unit + e2e separately with dedicated test app credentials
|
|
327
|
+
- [ ] `--watch=false` flag in CI Karma command (otherwise hangs)
|
|
328
|
+
|
|
329
|
+
## 10. Pointers
|
|
330
|
+
|
|
331
|
+
- `cometchat-angular-calls/references/ngzone-and-async-callbacks.md` — calls testing
|
|
332
|
+
- `cometchat-angular-core` — init service to mock against
|
|
333
|
+
- `cometchat-angular-troubleshooting` — common test failures
|
|
@@ -3,7 +3,7 @@ name: cometchat-angular-theming
|
|
|
3
3
|
description: "CometChatThemeService palette — color tokens, light/dark mode, typography, per-component style objects, and CSS variable overrides for the CometChat Angular UI Kit v4."
|
|
4
4
|
license: "MIT"
|
|
5
5
|
compatibility: "Angular >=12 <=15; @cometchat/chat-uikit-angular ^4; @cometchat/chat-sdk-javascript ^4"
|
|
6
|
-
allowed-tools: "
|
|
6
|
+
allowed-tools: "shell, file-read, file-search, file-list, ask-user"
|
|
7
7
|
metadata:
|
|
8
8
|
author: "CometChat"
|
|
9
9
|
version: "3.0.0"
|
|
@@ -3,7 +3,7 @@ name: cometchat-angular-troubleshooting
|
|
|
3
3
|
description: "Diagnose CometChat Angular UI Kit v4 integration failures — init/login, CUSTOM_ELEMENTS_SCHEMA, assets config, module imports, height/layout issues, Angular Universal SSR, v3-to-v4 upgrade, and production auth errors."
|
|
4
4
|
license: "MIT"
|
|
5
5
|
compatibility: "Angular >=12 <=15; @cometchat/chat-uikit-angular ^4; @cometchat/chat-sdk-javascript ^4"
|
|
6
|
-
allowed-tools: "
|
|
6
|
+
allowed-tools: "shell, file-read, file-search, file-list, ask-user"
|
|
7
7
|
metadata:
|
|
8
8
|
author: "CometChat"
|
|
9
9
|
version: "3.0.0"
|
|
@@ -3,7 +3,7 @@ name: cometchat-astro-patterns
|
|
|
3
3
|
description: "Framework-specific patterns for integrating CometChat React UI Kit v6 into Astro projects using React islands. Covers client:only rendering, island communication, CSS handling, and common pitfalls."
|
|
4
4
|
license: "MIT"
|
|
5
5
|
compatibility: "Node.js >=18; React >=18; Astro >=3; @astrojs/react; @cometchat/chat-uikit-react ^6; @cometchat/chat-sdk-javascript ^4"
|
|
6
|
-
allowed-tools: "
|
|
6
|
+
allowed-tools: "shell, file-read, file-search, file-list"
|
|
7
7
|
metadata:
|
|
8
8
|
author: "CometChat"
|
|
9
9
|
version: "3.0.0"
|