2023-03-22 03:46:52 +08:00
|
|
|
const { expect } = require('@playwright/test');
|
|
|
|
const { MultiUsers } = require('../user/multiusers');
|
|
|
|
const e = require('../core/elements');
|
|
|
|
const { killConnection } = require('./util');
|
2023-05-11 03:51:05 +08:00
|
|
|
const { runScript } = require('../core/util');
|
|
|
|
const { ELEMENT_WAIT_TIME } = require('../core/constants');
|
2023-03-22 03:46:52 +08:00
|
|
|
|
|
|
|
class Reconnection extends MultiUsers {
|
|
|
|
constructor(browser, context) {
|
|
|
|
super(browser, context);
|
|
|
|
}
|
|
|
|
|
|
|
|
async chat() {
|
|
|
|
// chat enabled
|
|
|
|
await this.modPage.waitForSelector(e.chatBox);
|
|
|
|
const chatBoxLocator = this.modPage.getLocator(e.chatBox);
|
|
|
|
await expect(chatBoxLocator).toBeEnabled();
|
|
|
|
|
|
|
|
killConnection();
|
|
|
|
|
2023-05-11 03:51:05 +08:00
|
|
|
// chat disabled and notification bar displayed
|
2023-05-17 21:39:01 +08:00
|
|
|
await Promise.all([
|
2023-05-11 03:51:05 +08:00
|
|
|
expect(chatBoxLocator).toBeDisabled({ timeout: ELEMENT_WAIT_TIME }),
|
|
|
|
this.modPage.hasElement(e.reconnectingBar),
|
|
|
|
]);
|
2023-03-22 03:46:52 +08:00
|
|
|
|
|
|
|
// reconnected -> chat enabled
|
|
|
|
await expect(chatBoxLocator).toBeEnabled();
|
2023-05-11 03:51:05 +08:00
|
|
|
await this.modPage.wasRemoved(e.notificationBannerBar);
|
2023-03-22 03:46:52 +08:00
|
|
|
}
|
|
|
|
|
2023-05-11 03:51:05 +08:00
|
|
|
async microphone() {
|
2023-03-22 03:46:52 +08:00
|
|
|
// join audio
|
|
|
|
await this.modPage.waitAndClick(e.joinAudio);
|
|
|
|
await this.modPage.joinMicrophone();
|
|
|
|
|
|
|
|
// mute is available
|
|
|
|
const muteMicButtonLocator = this.modPage.getLocator(e.muteMicButton);
|
|
|
|
await expect(muteMicButtonLocator).toBeEnabled();
|
|
|
|
|
|
|
|
killConnection();
|
2023-05-11 03:51:05 +08:00
|
|
|
await this.modPage.hasElement(e.reconnectingBar);
|
2023-03-22 03:46:52 +08:00
|
|
|
|
2023-05-11 03:51:05 +08:00
|
|
|
// reconnected
|
|
|
|
await this.modPage.wasRemoved(e.notificationBannerBar);
|
2023-03-22 03:46:52 +08:00
|
|
|
|
2023-05-11 03:51:05 +08:00
|
|
|
// audio connection should keep connected
|
|
|
|
await this.modPage.hasElement(e.muteMicButton);
|
|
|
|
await this.modPage.hasElement(e.isTalking);
|
|
|
|
}
|
2023-03-22 03:46:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
exports.Reconnection = Reconnection;
|