Store: remove all mentions of window.Store (#127077)

* Store: remove all mentions of window.Store

* Apply suggestion from @BenyFilho

Co-authored-by: BenyFilho <168232825+BenyFilho@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: BenyFilho <168232825+BenyFilho@users.noreply.github.com>

---------

Co-authored-by: BenyFilho <168232825+BenyFilho@users.noreply.github.com>
This commit is contained in:
Rajeh Taher 2026-03-01 21:49:21 +02:00 • committed by GitHub
commit 883d7e4eda
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 522 additions and 754 deletions

View file

@ -84,8 +84,8 @@ describe('Client', function() {
});
});
describe('Authentication', function() {
it('should emit QR code if not authenticated', async function() {
describe('Authentication', function () {
it('should emit QR code if not authenticated', async function () {
this.timeout(25000);
const callback = sinon.spy();
@ -107,7 +107,7 @@ describe('Client', function() {
const qrCallback = sinon.spy();
const disconnectedCallback = sinon.spy();
const client = helper.createClient({options: {qrMaxRetries: 2}});
const client = helper.createClient({ options: { qrMaxRetries: 2 } });
client.on('qr', qrCallback);
client.on('disconnected', disconnectedCallback);
@ -119,7 +119,7 @@ describe('Client', function() {
expect(disconnectedCallback.calledOnceWith('Max qrcode retries reached')).to.eql(true);
});
it('should authenticate with existing session', async function() {
it('should authenticate with existing session', async function () {
this.timeout(40000);
const authenticatedCallback = sinon.spy();
@ -137,6 +137,7 @@ describe('Client', function() {
await client.initialize();
expect(authenticatedCallback.called).to.equal(true);
expect(readyCallback.called).to.equal(true);
expect(qrCallback.called).to.equal(false);
@ -163,71 +164,6 @@ describe('Client', function() {
console.log(`WA Version: ${version}`);
});
describe('Expose Store', function() {
it('exposes the store', async function() {
const exposed = await client.pupPage.evaluate(() => {
return Boolean(window.Store);
});
expect(exposed).to.equal(true);
});
it('exposes all required WhatsApp Web internal models', async function() {
const expectedModules = [
'AppState',
'BlockContact',
'Call',
'Chat',
'ChatState',
'Cmd',
'Conn',
'Contact',
'DownloadManager',
'EphemeralFields',
'Features',
'GroupMetadata',
'GroupParticipants',
'GroupUtils',
'Invite',
'InviteInfo',
'JoinInviteV4',
'Label',
'MediaObject',
'MediaPrep',
'MediaTypes',
'MediaUpload',
'MessageInfo',
'Msg',
'MsgKey',
'OpaqueData',
'QueryOrder',
'QueryProduct',
'PresenceUtils',
'ProfilePic',
'QueryExist',
'QueryProduct',
'QueryOrder',
'SendClear',
'SendDelete',
'SendMessage',
'SendSeen',
'StatusUtils',
'UploadUtils',
'UserConstructor',
'VCard',
'Validators',
'WidFactory',
'findCommonGroups',
'sendReactionToMsg',
];
const loadedModules = await client.pupPage.evaluate((expectedModules) => {
return expectedModules.filter(m => Boolean(window.Store[m]));
}, expectedModules);
expect(loadedModules).to.have.members(expectedModules);
});
});
describe('Send Messages', function () {
it('can send a message', async function() {

View file

@ -5,6 +5,7 @@ require('dotenv').config();
const remoteId = process.env.WWEBJS_TEST_REMOTE_ID;
if(!remoteId) throw new Error('The WWEBJS_TEST_REMOTE_ID environment variable has not been set.');
function createClient({authenticated, options: additionalOpts}={}) {
const options = {};