Selaa lähdekoodia

feat(tests): Adds lock room test.

factor2
damencho 4 kuukautta sitten
vanhempi
commit
5bee373091

+ 1
- 0
package.json Näytä tiedosto

@@ -226,6 +226,7 @@
226 226
     "test-ff-single": "DOTENV_CONFIG_PATH=tests/.env wdio run tests/wdio.firefox.conf.ts --spec",
227 227
     "test-ff": "DOTENV_CONFIG_PATH=tests/.env wdio run tests/wdio.firefox.conf.ts",
228 228
     "test-dev": "DOTENV_CONFIG_PATH=tests/.env wdio run tests/wdio.dev.conf.ts",
229
+    "test-dev-single": "DOTENV_CONFIG_PATH=tests/.env wdio run tests/wdio.dev.conf.ts --spec",
229 230
     "test-grid": "DOTENV_CONFIG_PATH=tests/.env wdio run tests/wdio.grid.conf.ts",
230 231
     "test-grid-single": "DOTENV_CONFIG_PATH=tests/.env wdio run tests/wdio.grid.conf.ts --spec"
231 232
   },

+ 8
- 0
tests/helpers/Participant.ts Näytä tiedosto

@@ -15,6 +15,7 @@ import LargeVideo from '../pageobjects/LargeVideo';
15 15
 import LobbyScreen from '../pageobjects/LobbyScreen';
16 16
 import Notifications from '../pageobjects/Notifications';
17 17
 import ParticipantsPane from '../pageobjects/ParticipantsPane';
18
+import PasswordDialog from '../pageobjects/PasswordDialog';
18 19
 import PreJoinScreen from '../pageobjects/PreJoinScreen';
19 20
 import SecurityDialog from '../pageobjects/SecurityDialog';
20 21
 import SettingsDialog from '../pageobjects/SettingsDialog';
@@ -505,6 +506,13 @@ export class Participant {
505 506
         return new SettingsDialog(this);
506 507
     }
507 508
 
509
+    /**
510
+     * Returns the password dialog.
511
+     */
512
+    getPasswordDialog(): PasswordDialog {
513
+        return new PasswordDialog(this);
514
+    }
515
+
508 516
     /**
509 517
      * Returns the prejoin screen.
510 518
      */

+ 1
- 0
tests/helpers/types.ts Näytä tiedosto

@@ -13,6 +13,7 @@ export type IContext = {
13 13
     p2: Participant;
14 14
     p3: Participant;
15 15
     p4: Participant;
16
+    roomKey: string;
16 17
     roomName: string;
17 18
     skipSuiteTests: boolean;
18 19
     times: any;

+ 37
- 0
tests/pageobjects/PasswordDialog.ts Näytä tiedosto

@@ -0,0 +1,37 @@
1
+import BaseDialog from './BaseDialog';
2
+
3
+const INPUT_KEY_XPATH = '//input[@name="lockKey"]';
4
+
5
+/**
6
+ * Represents the password dialog in a particular participant.
7
+ */
8
+export default class PasswordDialog extends BaseDialog {
9
+    /**
10
+     * Waiting for the dialog to appear.
11
+     */
12
+    async waitForDialog() {
13
+        const input = this.participant.driver.$(INPUT_KEY_XPATH);
14
+
15
+        await input.waitForExist({
16
+            timeout: 5000,
17
+            timeoutMsg: 'Password dialog not found'
18
+        });
19
+        await input.waitForDisplayed();
20
+    }
21
+
22
+    /**
23
+     * Sets a password and submits the dialog.
24
+     * @param password
25
+     */
26
+    async submitPassword(password: string) {
27
+        const passwordInput = this.participant.driver.$(INPUT_KEY_XPATH);
28
+
29
+        await passwordInput.waitForExist();
30
+        await passwordInput.click();
31
+        await passwordInput.clearValue();
32
+
33
+        await this.participant.driver.keys(password);
34
+
35
+        await this.clickOkButton();
36
+    }
37
+}

+ 15
- 0
tests/pageobjects/SecurityDialog.ts Näytä tiedosto

@@ -7,6 +7,7 @@ const ADD_PASSWORD_FIELD = 'info-password-input';
7 7
 const DIALOG_CONTAINER = 'security-dialog';
8 8
 const LOCAL_LOCK = 'info-password-local';
9 9
 const REMOTE_LOCK = 'info-password-remote';
10
+const REMOVE_PASSWORD = 'remove-password';
10 11
 
11 12
 /**
12 13
  * Page object for the security dialog.
@@ -133,4 +134,18 @@ export default class SecurityDialog extends BaseDialog {
133 134
             expect(validationMessage).toBe('');
134 135
         }
135 136
     }
137
+
138
+    /**
139
+     * Removes the password from the current conference through the security dialog, if a password is set.
140
+     */
141
+    async removePassword() {
142
+        if (!await this.isLocked()) {
143
+            return;
144
+        }
145
+
146
+        const removePassword = this.participant.driver.$(`.${REMOVE_PASSWORD}`);
147
+
148
+        await removePassword.waitForClickable();
149
+        await removePassword.click();
150
+    }
136 151
 }

+ 171
- 0
tests/specs/2way/lockRoom.spec.ts Näytä tiedosto

@@ -0,0 +1,171 @@
1
+import { ensureOneParticipant, ensureTwoParticipants, joinSecondParticipant } from '../../helpers/participants';
2
+
3
+/**
4
+ * 1. Lock the room (make sure the image changes to locked)
5
+ * 2. Join with a second browser/tab
6
+ * 3. Make sure we are required to enter a password.
7
+ * (Also make sure the padlock is locked)
8
+ * 4. Enter wrong password, make sure we are not joined in the room
9
+ * 5. Unlock the room (Make sure the padlock is unlocked)
10
+ * 6. Join again and make sure we are not asked for a password and that
11
+ * the padlock is unlocked.
12
+ */
13
+describe('Lock Room', () => {
14
+    it('joining the meeting', () => ensureOneParticipant(ctx));
15
+
16
+    it('locks the room', () => participant1LockRoom());
17
+
18
+    it('enter participant in locked room', async () => {
19
+        // first enter wrong pin then correct one
20
+        await joinSecondParticipant(ctx, {
21
+            skipWaitToJoin: true,
22
+            skipInMeetingChecks: true
23
+        });
24
+
25
+        const { p2 } = ctx;
26
+
27
+        // wait for password prompt
28
+        const p2PasswordDialog = p2.getPasswordDialog();
29
+
30
+        await p2PasswordDialog.waitForDialog();
31
+        await p2PasswordDialog.submitPassword(`${ctx.roomKey}1234`);
32
+
33
+        // wait for password prompt
34
+        await p2PasswordDialog.waitForDialog();
35
+        await p2PasswordDialog.submitPassword(ctx.roomKey);
36
+
37
+        await p2.waitToJoinMUC();
38
+
39
+        const p2SecurityDialog = p2.getSecurityDialog();
40
+
41
+        await p2.getToolbar().clickSecurityButton();
42
+        await p2SecurityDialog.waitForDisplay();
43
+
44
+        expect(await p2SecurityDialog.isLocked()).toBe(true);
45
+    });
46
+
47
+    it('unlock room', async () => {
48
+        // Unlock room. Check whether room is still locked. Click remove and check whether it is unlocked.
49
+        await ctx.p2.hangup();
50
+
51
+        await participant1UnlockRoom();
52
+    });
53
+
54
+    it('enter participant in unlocked room', async () => {
55
+        // Just enter the room and check that is not locked.
56
+        // if we fail to unlock the room this one will detect it
57
+        // as participant will fail joining
58
+        await ensureTwoParticipants(ctx);
59
+
60
+        const { p2 } = ctx;
61
+        const p2SecurityDialog = p2.getSecurityDialog();
62
+
63
+        await p2.getToolbar().clickSecurityButton();
64
+        await p2SecurityDialog.waitForDisplay();
65
+
66
+        expect(await p2SecurityDialog.isLocked()).toBe(false);
67
+
68
+        await p2SecurityDialog.clickCloseButton();
69
+    });
70
+
71
+    it('update locked state while participants in room', async () => {
72
+        // Both participants are in unlocked room, lock it and see whether the
73
+        // change is reflected on the second participant icon.
74
+        await participant1LockRoom();
75
+
76
+        const { p2 } = ctx;
77
+        const p2SecurityDialog = p2.getSecurityDialog();
78
+
79
+        await p2.getToolbar().clickSecurityButton();
80
+        await p2SecurityDialog.waitForDisplay();
81
+
82
+        expect(await p2SecurityDialog.isLocked()).toBe(true);
83
+
84
+        await participant1UnlockRoom();
85
+
86
+        expect(await p2SecurityDialog.isLocked()).toBe(false);
87
+    });
88
+    it('unlock after participant enter wrong password', async () => {
89
+        // P1 locks the room. Participant tries to enter using wrong password.
90
+        // P1 unlocks the room and Participant submits the password prompt with no password entered and
91
+        // should enter of unlocked room.
92
+        await ctx.p2.hangup();
93
+        await participant1LockRoom();
94
+        await joinSecondParticipant(ctx, {
95
+            skipWaitToJoin: true,
96
+            skipInMeetingChecks: true
97
+        });
98
+
99
+        const { p2 } = ctx;
100
+
101
+        // wait for password prompt
102
+        const p2PasswordDialog = p2.getPasswordDialog();
103
+
104
+        await p2PasswordDialog.waitForDialog();
105
+        await p2PasswordDialog.submitPassword(`${ctx.roomKey}1234`);
106
+
107
+        // wait for password prompt
108
+        await p2PasswordDialog.waitForDialog();
109
+
110
+        await participant1UnlockRoom();
111
+
112
+        await p2PasswordDialog.clickOkButton();
113
+        await p2.waitToJoinMUC();
114
+
115
+        const p2SecurityDialog = p2.getSecurityDialog();
116
+
117
+        await p2.getToolbar().clickSecurityButton();
118
+        await p2SecurityDialog.waitForDisplay();
119
+
120
+        expect(await p2SecurityDialog.isLocked()).toBe(false);
121
+    });
122
+});
123
+
124
+/**
125
+ * Participant1 locks the room.
126
+ */
127
+async function participant1LockRoom() {
128
+    ctx.roomKey = `${Math.trunc(Math.random() * 1_000_000)}`;
129
+
130
+    const { p1 } = ctx;
131
+    const p1SecurityDialog = p1.getSecurityDialog();
132
+
133
+    await p1.getToolbar().clickSecurityButton();
134
+    await p1SecurityDialog.waitForDisplay();
135
+
136
+    expect(await p1SecurityDialog.isLocked()).toBe(false);
137
+
138
+    await p1SecurityDialog.addPassword(ctx.roomKey);
139
+
140
+    await p1SecurityDialog.clickCloseButton();
141
+
142
+    await p1.getToolbar().clickSecurityButton();
143
+    await p1SecurityDialog.waitForDisplay();
144
+
145
+    expect(await p1SecurityDialog.isLocked()).toBe(true);
146
+
147
+    await p1SecurityDialog.clickCloseButton();
148
+}
149
+
150
+/**
151
+ * Participant1 unlocks the room.
152
+ */
153
+async function participant1UnlockRoom() {
154
+    const { p1 } = ctx;
155
+    const p1SecurityDialog = p1.getSecurityDialog();
156
+
157
+    await p1.getToolbar().clickSecurityButton();
158
+    await p1SecurityDialog.waitForDisplay();
159
+
160
+    await p1SecurityDialog.removePassword();
161
+
162
+    await p1.driver.waitUntil(
163
+        async () => !await p1SecurityDialog.isLocked(),
164
+        {
165
+            timeout: 3_000, // 3 seconds
166
+            timeoutMsg: `Timeout waiting for the room to unlock for ${p1.name}.`
167
+        }
168
+    );
169
+
170
+    await p1SecurityDialog.clickCloseButton();
171
+}

Loading…
Peruuta
Tallenna