test(reconnection): use an iptable rule to keep browser with no connection for a second

This commit is contained in:
Anton B 2023-05-17 10:39:01 -03:00
parent 6173d2205d
commit da43baca18
3 changed files with 9 additions and 6 deletions

View File

@ -19,7 +19,7 @@ class Reconnection extends MultiUsers {
killConnection();
// chat disabled and notification bar displayed
Promise.all([
await Promise.all([
expect(chatBoxLocator).toBeDisabled({ timeout: ELEMENT_WAIT_TIME }),
this.modPage.hasElement(e.reconnectingBar),
]);

View File

@ -1,10 +1,7 @@
const { test } = require('@playwright/test');
const e = require('../core/elements');
const notificationsUtil = require('../notifications/util');
const { expect } = require('@playwright/test');
const { Reconnection } = require('./reconnection');
test.describe.parallel('Reconnection', () => {
test.describe.serial('Reconnection', () => {
test('Chat', async ({ browser, context, page }) => {
const reconnection = new Reconnection(browser, context);
await reconnection.checkRootPermission(); // check sudo permission before starting test

View File

@ -5,7 +5,13 @@ const parameters = require('../core/parameters.js');
const hostname = new URL(parameters.server).hostname;
async function killConnection() {
await exec('sudo ss -K dst ' + hostname + ' dport https');
await exec(`
sudo ss -K dst ${hostname} dport https;
sudo iptables -A OUTPUT -p tcp -d ${hostname} --dport 443 -j DROP;
sleep 1;
sudo iptables -D OUTPUT -p tcp -d ${hostname} --dport 443 -j DROP;
`);
}
exports.killConnection = killConnection;