|
| 1 | +import { expect, test } from "@playwright/test"; |
| 2 | +import { loginAsServerAdmin } from "../utils/authenticate"; |
| 3 | +import { generateUniqueUsername } from "../utils/helpers"; |
| 4 | +import { PlaywrightConnectionConfigurationsPage } from "./models/playwright-connection-configurations-page"; |
| 5 | +import { PlaywrightCreateConnectionConfigurationPage } from "./models/playwright-create-connection-configuration-page"; |
| 6 | + |
| 7 | +test.describe("4.1.1 Connection Configurations - CREATE Add", () => { |
| 8 | + let createConnectionConfigurationPage: PlaywrightCreateConnectionConfigurationPage; |
| 9 | + |
| 10 | + test.beforeEach(async ({ page }) => { |
| 11 | + await loginAsServerAdmin(page); |
| 12 | + |
| 13 | + const connectionConfigurationsPage = |
| 14 | + new PlaywrightConnectionConfigurationsPage(page); |
| 15 | + |
| 16 | + await connectionConfigurationsPage.goto(); |
| 17 | + await connectionConfigurationsPage.expectVisible(); |
| 18 | + |
| 19 | + createConnectionConfigurationPage = |
| 20 | + await connectionConfigurationsPage.navigateToCreateConnectionConfiguration(); |
| 21 | + |
| 22 | + await createConnectionConfigurationPage.expectVisible(); |
| 23 | + }); |
| 24 | + |
| 25 | + test("A Success - creates a new connection configuration with fallback", async ({ |
| 26 | + page, |
| 27 | + }) => { |
| 28 | + expect(page.url()).toContain("/connection-configurations/create"); |
| 29 | + |
| 30 | + const uniqueValue = generateUniqueUsername("e2e-4.1.1.A-Success"); |
| 31 | + |
| 32 | + await createConnectionConfigurationPage.fillForm({ |
| 33 | + name: `${uniqueValue}-config`, |
| 34 | + configurationPurposeName: "Starting an Exam", |
| 35 | + pingInterval: 5, |
| 36 | + withFallback: true, |
| 37 | + fallbackStartUrl: "https://fallback.example.com", |
| 38 | + connectionAttempts: 3, |
| 39 | + interval: 2, |
| 40 | + connectionTimeout: 10, |
| 41 | + configurationPassword: "StrongPass123!", |
| 42 | + confirmConfigurationPassword: "StrongPass123!", |
| 43 | + fallbackPassword: "Fallback123!", |
| 44 | + confirmFallbackPassword: "Fallback123!", |
| 45 | + quitPassword: "QuitPass123!", |
| 46 | + confirmQuitPassword: "QuitPass123!", |
| 47 | + }); |
| 48 | + |
| 49 | + await createConnectionConfigurationPage.expectCreateRequestSucceeded( |
| 50 | + async () => { |
| 51 | + await createConnectionConfigurationPage.submit(); |
| 52 | + }, |
| 53 | + ); |
| 54 | + |
| 55 | + await createConnectionConfigurationPage.expectRedirectToConnectionConfigurations(); |
| 56 | + }); |
| 57 | + |
| 58 | + test("B Success - creates a new connection configuration without fallback", async ({ |
| 59 | + page, |
| 60 | + }) => { |
| 61 | + expect(page.url()).toContain("/connection-configurations/create"); |
| 62 | + |
| 63 | + const uniqueValue = generateUniqueUsername("e2e-4.1.1.B-NoFallback"); |
| 64 | + |
| 65 | + await createConnectionConfigurationPage.fillForm({ |
| 66 | + name: `${uniqueValue}-config`, |
| 67 | + configurationPurposeName: "Configure a Client", |
| 68 | + pingInterval: 10, |
| 69 | + withFallback: false, |
| 70 | + configurationPassword: "StrongPass123!", |
| 71 | + confirmConfigurationPassword: "StrongPass123!", |
| 72 | + }); |
| 73 | + |
| 74 | + await createConnectionConfigurationPage.expectCreateRequestSucceeded( |
| 75 | + async () => { |
| 76 | + await createConnectionConfigurationPage.submit(); |
| 77 | + }, |
| 78 | + ); |
| 79 | + |
| 80 | + await createConnectionConfigurationPage.expectRedirectToConnectionConfigurations(); |
| 81 | + }); |
| 82 | + |
| 83 | + test("C Success - creates a new connection configuration with asymmetric-only encryption", async ({ |
| 84 | + page, |
| 85 | + }) => { |
| 86 | + expect(page.url()).toContain("/connection-configurations/create"); |
| 87 | + |
| 88 | + const uniqueValue = generateUniqueUsername("e2e-4.1.1.C-Asymmetric"); |
| 89 | + |
| 90 | + await createConnectionConfigurationPage.fillForm({ |
| 91 | + name: `${uniqueValue}-config`, |
| 92 | + configurationPurposeName: "Starting an Exam", |
| 93 | + pingInterval: 15, |
| 94 | + asymmetricOnlyEncryption: true, |
| 95 | + withFallback: false, |
| 96 | + configurationPassword: "StrongPass123!", |
| 97 | + confirmConfigurationPassword: "StrongPass123!", |
| 98 | + }); |
| 99 | + |
| 100 | + await createConnectionConfigurationPage.expectCreateRequestSucceeded( |
| 101 | + async () => { |
| 102 | + await createConnectionConfigurationPage.submit(); |
| 103 | + }, |
| 104 | + ); |
| 105 | + |
| 106 | + await createConnectionConfigurationPage.expectRedirectToConnectionConfigurations(); |
| 107 | + }); |
| 108 | + |
| 109 | + test("D Failure - asymmetric-only encryption without certificate shows server error", async ({ |
| 110 | + page, |
| 111 | + }) => { |
| 112 | + expect(page.url()).toContain("/connection-configurations/create"); |
| 113 | + }); |
| 114 | + |
| 115 | + test("E Client Validation - shows validation messages and does NOT call create API", async ({ |
| 116 | + page, |
| 117 | + }) => { |
| 118 | + expect(page.url()).toContain("/connection-configurations/create"); |
| 119 | + |
| 120 | + const REQUIRED = "This field is required"; |
| 121 | + const MUST_MATCH = "Passwords don't match\n"; |
| 122 | + const MUST_BE_URL = "Must start with http:// or https://"; |
| 123 | + |
| 124 | + // clear default numeric value so required validation can actually fail |
| 125 | + await createConnectionConfigurationPage.clearPingInterval(); |
| 126 | + |
| 127 | + await createConnectionConfigurationPage.expectNoCreateRequest( |
| 128 | + async () => { |
| 129 | + await createConnectionConfigurationPage.submit(); |
| 130 | + }, |
| 131 | + ); |
| 132 | + |
| 133 | + await createConnectionConfigurationPage.expectRequiredFieldErrors({ |
| 134 | + name: REQUIRED, |
| 135 | + configurationPurpose: REQUIRED, |
| 136 | + pingInterval: REQUIRED, |
| 137 | + }); |
| 138 | + |
| 139 | + await createConnectionConfigurationPage.toggleWithFallback(true); |
| 140 | + |
| 141 | + // clear fallback defaults so required validation can fail there too |
| 142 | + await createConnectionConfigurationPage.clearFallbackNumericFields(); |
| 143 | + |
| 144 | + await createConnectionConfigurationPage.expectNoCreateRequest( |
| 145 | + async () => { |
| 146 | + await createConnectionConfigurationPage.submit(); |
| 147 | + }, |
| 148 | + ); |
| 149 | + |
| 150 | + await createConnectionConfigurationPage.expectFallbackRequiredFieldErrors( |
| 151 | + { |
| 152 | + fallbackStartUrl: REQUIRED, |
| 153 | + connectionAttempts: REQUIRED, |
| 154 | + interval: REQUIRED, |
| 155 | + connectionTimeout: REQUIRED, |
| 156 | + }, |
| 157 | + ); |
| 158 | + |
| 159 | + await createConnectionConfigurationPage.fillFallbackStartUrl("abc"); |
| 160 | + await createConnectionConfigurationPage.blurFallbackStartUrl(); |
| 161 | + |
| 162 | + await createConnectionConfigurationPage.expectFieldError( |
| 163 | + "connectionConfigurationCreation-fallbackStartUrl-input", |
| 164 | + MUST_BE_URL, |
| 165 | + ); |
| 166 | + |
| 167 | + await createConnectionConfigurationPage.fillConfigurationPassword( |
| 168 | + "Password123!", |
| 169 | + ); |
| 170 | + await createConnectionConfigurationPage.fillConfirmConfigurationPassword( |
| 171 | + "Password456!", |
| 172 | + ); |
| 173 | + |
| 174 | + await createConnectionConfigurationPage.expectNoCreateRequest( |
| 175 | + async () => { |
| 176 | + await createConnectionConfigurationPage.submit(); |
| 177 | + }, |
| 178 | + ); |
| 179 | + |
| 180 | + await createConnectionConfigurationPage.expectFieldError( |
| 181 | + "connectionConfigurationCreation-confirmConfigurationPassword-input", |
| 182 | + MUST_MATCH, |
| 183 | + ); |
| 184 | + |
| 185 | + await createConnectionConfigurationPage.expectStillOnCreatePage(); |
| 186 | + }); |
| 187 | + |
| 188 | + test("F Server Error - duplicate name shows toast", async ({ page }) => { |
| 189 | + expect(page.url()).toContain("/connection-configurations/create"); |
| 190 | + |
| 191 | + await createConnectionConfigurationPage.fillForm({ |
| 192 | + name: "create-connection-configuration", |
| 193 | + configurationPurposeName: "Starting an Exam", |
| 194 | + pingInterval: 5, |
| 195 | + withFallback: false, |
| 196 | + configurationPassword: "StrongPass123!", |
| 197 | + confirmConfigurationPassword: "StrongPass123!", |
| 198 | + }); |
| 199 | + |
| 200 | + const resp = |
| 201 | + await createConnectionConfigurationPage.captureCreateResponse( |
| 202 | + async () => { |
| 203 | + await createConnectionConfigurationPage.submit(); |
| 204 | + }, |
| 205 | + ); |
| 206 | + |
| 207 | + expect(resp.status()).toBe(400); |
| 208 | + expect(resp.ok()).toBeFalsy(); |
| 209 | + |
| 210 | + await createConnectionConfigurationPage.expectStillOnCreatePage(); |
| 211 | + await createConnectionConfigurationPage.expectErrorToast([ |
| 212 | + "Field validation error", |
| 213 | + "Name is already being used.", |
| 214 | + ]); |
| 215 | + }); |
| 216 | +}); |
0 commit comments