Bug 1488503: Add test for validation. r=jdescottes
☠☠ backed out by 989c91cf970e ☠ ☠
authorDaisuke Akatsuka <dakatsuka@mozilla.com>
Wed, 20 Mar 2019 01:47:54 +0000
changeset 465188 1b763fdfc0ba121950f386e15d7b72432079835d
parent 465187 4968b44840749c5f83a74c1c3e7371eb9b4159ba
child 465189 d6485b40ffd6eaed7db65f187db1898aaed273b9
push id80946
push userdakatsuka@mozilla.com
push dateWed, 20 Mar 2019 07:25:46 +0000
treeherderautoland@1b763fdfc0ba [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdescottes
bugs1488503
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1488503: Add test for validation. r=jdescottes Depends on D23993 Differential Revision: https://phabricator.services.mozilla.com/D23994
devtools/client/aboutdebugging-new/src/components/connect/NetworkLocationsForm.js
devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_connect_networklocations.js
--- a/devtools/client/aboutdebugging-new/src/components/connect/NetworkLocationsForm.js
+++ b/devtools/client/aboutdebugging-new/src/components/connect/NetworkLocationsForm.js
@@ -68,17 +68,18 @@ class NetworkLocationsForm extends PureC
     const { errorHostValue, errorMessageId } = this.state;
 
     if (!errorMessageId) {
       return null;
     }
 
     return Message(
       {
-        className: "connect-page__network-form__error-message",
+        className: "connect-page__network-form__error-message " +
+                   "qa-connect-page__network-form__error-message",
         level: MESSAGE_LEVEL.ERROR,
       },
       Localized(
         {
           id: errorMessageId,
           "$host-value": errorHostValue,
         },
         dom.p({}, errorMessageId)
--- a/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_connect_networklocations.js
+++ b/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_connect_networklocations.js
@@ -4,48 +4,60 @@
 "use strict";
 
 /**
  * Test the network locations form of the Connect page.
  * Check that a network location can be added and removed.
  */
 
 const TEST_NETWORK_LOCATION = "localhost:1111";
+const TEST_NETWORK_LOCATION_INVALID = "testnetwork";
 
 add_task(async function() {
   const { document, tab } = await openAboutDebugging();
 
   await selectConnectPage(document);
 
   let networkLocations = document.querySelectorAll(".js-network-location");
   is(networkLocations.length, 0, "By default, no network locations are displayed");
 
-  addNetworkLocation(TEST_NETWORK_LOCATION, document);
+  info("Check whether error message should show if the input value is invalid");
+  addNetworkLocation(TEST_NETWORK_LOCATION_INVALID, document);
+  await waitUntil(() =>
+    document.querySelector(".qa-connect-page__network-form__error-message"));
 
   info("Wait until the new network location is visible in the list");
+  addNetworkLocation(TEST_NETWORK_LOCATION, document);
   await waitUntil(() => document.querySelectorAll(".js-network-location").length === 1);
+  await waitUntil(() =>
+    !document.querySelector(".qa-connect-page__network-form__error-message"));
+
   networkLocations = document.querySelectorAll(".js-network-location");
-
   const networkLocationValue =
     networkLocations[0].querySelector(".js-network-location-value");
   is(networkLocationValue.textContent, TEST_NETWORK_LOCATION,
     "Added network location has the expected value");
 
-  removeNetworkLocation(TEST_NETWORK_LOCATION, document);
+  info("Check whether error message should show if the input value was duplicate");
+  addNetworkLocation(TEST_NETWORK_LOCATION, document);
+  await waitUntil(() =>
+    document.querySelector(".qa-connect-page__network-form__error-message"));
 
   info("Wait until the new network location is removed from the list");
+  removeNetworkLocation(TEST_NETWORK_LOCATION, document);
   await waitUntil(() => document.querySelectorAll(".js-network-location").length === 0);
 
   await removeTab(tab);
 });
 
 function addNetworkLocation(location, document) {
   info("Setting a value in the network form input");
   const networkLocationInput =
     document.querySelector(".js-network-form-input");
+  networkLocationInput.value = "";
   networkLocationInput.focus();
   EventUtils.sendString(location, networkLocationInput.ownerGlobal);
 
   info("Click on network form submit button");
   const networkLocationSubmitButton =
     document.querySelector(".js-network-form-submit-button");
   networkLocationSubmitButton.click();
 }