@wppconnect/wa-js 4.1.2-alpha.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.
@@ -121,4 +121,4 @@
121
121
 
122
122
  /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
123
123
 
124
- /*! wppconnect-team/wa-js v4.1.2-alpha.0 */
124
+ /*! wppconnect-team/wa-js v4.2.0 */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wppconnect/wa-js",
3
- "version": "4.1.2-alpha.0",
3
+ "version": "4.2.0",
4
4
  "description": "WPPConnect/WA-JS is an open-source project with the aim of exporting functions from WhatsApp Web",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -0,0 +1,171 @@
1
+ /*!
2
+ * Copyright 2021 WPPConnect Team
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ // Smoke tests: validate the WPP bundle loads against the live WhatsApp Web
18
+ // page and that every public module still exposes the functions we ship in
19
+ // the README. They run unauthenticated (no QR scan needed) — the WhatsApp
20
+ // bundle resolves modules before login, and the loader flips `WPP.isReady`
21
+ // as soon as that is done. These tests catch the most common breakage:
22
+ // WhatsApp Web ships an update and one of our patched modules disappears
23
+ // or is renamed.
24
+
25
+ import { expect, test } from './wpp-test';
26
+
27
+ const expectedFunctions: Record<string, string[]> = {
28
+ blocklist: ['all', 'blockContact', 'isBlocked', 'unblockContact'],
29
+ cart: ['add', 'clear', 'get', 'remove', 'submit', 'update'],
30
+ catalog: [
31
+ 'createProduct',
32
+ 'delProducts',
33
+ 'editProduct',
34
+ 'getMyCatalog',
35
+ 'getProductById',
36
+ 'getProducts',
37
+ ],
38
+ chat: ['deleteMessage', 'get', 'sendFileMessage', 'sendTextMessage'],
39
+ community: [
40
+ 'addSubgroups',
41
+ 'create',
42
+ 'deactivate',
43
+ 'getParticipants',
44
+ 'getSubgroups',
45
+ 'removeSubgroups',
46
+ ],
47
+ conn: [
48
+ 'getBuildConstants',
49
+ 'getStreamData',
50
+ 'isAuthenticated',
51
+ 'logout',
52
+ ],
53
+ contact: [
54
+ 'get',
55
+ 'getCommonGroups',
56
+ 'getStatus',
57
+ 'list',
58
+ 'queryWidExists',
59
+ ],
60
+ group: [
61
+ 'addParticipants',
62
+ 'canAdd',
63
+ 'canDemote',
64
+ 'canPromote',
65
+ 'create',
66
+ 'demoteParticipants',
67
+ 'getAllGroups',
68
+ 'getGroupInfoFromInviteCode',
69
+ 'promoteParticipants',
70
+ 'removeParticipants',
71
+ ],
72
+ labels: [
73
+ 'addNewLabel',
74
+ 'addOrRemoveLabels',
75
+ 'deleteLabel',
76
+ 'editLabel',
77
+ 'getAllLabels',
78
+ 'getLabelById',
79
+ ],
80
+ newsletter: [
81
+ 'create',
82
+ 'destroy',
83
+ 'edit',
84
+ 'follow',
85
+ 'getSubscribers',
86
+ 'mute',
87
+ 'search',
88
+ 'unfollow',
89
+ ],
90
+ order: ['accept', 'decline', 'get', 'update'],
91
+ privacy: [
92
+ 'get',
93
+ 'setAbout',
94
+ 'setAddGroup',
95
+ 'setLastSeen',
96
+ 'setOnline',
97
+ 'setProfilePic',
98
+ 'setReadReceipts',
99
+ 'setStatus',
100
+ ],
101
+ profile: [
102
+ 'getMyProfileName',
103
+ 'getMyProfilePicture',
104
+ 'getMyStatus',
105
+ 'isBusiness',
106
+ 'setMyProfileName',
107
+ 'setMyProfilePicture',
108
+ 'setMyStatus',
109
+ ],
110
+ status: [
111
+ 'get',
112
+ 'getMyStatus',
113
+ 'sendImageStatus',
114
+ 'sendReadStatus',
115
+ 'sendTextStatus',
116
+ 'sendVideoStatus',
117
+ ],
118
+ };
119
+
120
+ test.describe('smoke: bundle injection', () => {
121
+ test('WPP global is exposed and reports ready', async ({ page }) => {
122
+ const probe = await page.evaluate(() => ({
123
+ hasWPP: typeof (window as any).WPP === 'object',
124
+ isReady: (window as any).WPP?.isReady === true,
125
+ isInjected: (window as any).WPP?.isInjected === true,
126
+ version: (window as any).WPP?.version,
127
+ license: (window as any).WPP?.license,
128
+ }));
129
+
130
+ expect(probe.hasWPP).toBe(true);
131
+ expect(probe.isInjected).toBe(true);
132
+ expect(probe.isReady).toBe(true);
133
+ expect(probe.version).toMatch(/^\d+\.\d+\.\d+/);
134
+ expect(probe.license).toBe('Apache-2.0');
135
+ });
136
+
137
+ test('event emitter helpers are wired on WPP', async ({ page }) => {
138
+ const eventApi = await page.evaluate(() => {
139
+ const wpp = (window as any).WPP;
140
+ return ['on', 'off', 'once', 'emit', 'waitFor'].map(
141
+ (name) => typeof wpp?.[name]
142
+ );
143
+ });
144
+
145
+ expect(eventApi).toEqual(['function', 'function', 'function', 'function', 'function']);
146
+ });
147
+ });
148
+
149
+ test.describe('smoke: module surface', () => {
150
+ for (const [moduleName, fns] of Object.entries(expectedFunctions)) {
151
+ test(`WPP.${moduleName} exposes its public functions`, async ({ page }) => {
152
+ const result = await page.evaluate(
153
+ ({ moduleName, fns }) => {
154
+ const mod = (window as any).WPP?.[moduleName];
155
+ if (!mod) {
156
+ return { exists: false, missing: fns };
157
+ }
158
+ const missing = fns.filter((fn) => typeof mod[fn] !== 'function');
159
+ return { exists: true, missing };
160
+ },
161
+ { moduleName, fns }
162
+ );
163
+
164
+ expect(result.exists, `WPP.${moduleName} is missing`).toBe(true);
165
+ expect(
166
+ result.missing,
167
+ `WPP.${moduleName} is missing functions: ${result.missing.join(', ')}`
168
+ ).toEqual([]);
169
+ });
170
+ }
171
+ });