Bug 1488503: Add test for validation. r=jdescottes
authorDaisuke Akatsuka <dakatsuka@mozilla.com>
Thu, 21 Mar 2019 08:26:59 +0000
changeset 465398 5841b4e9959374c8d594e50bf1141d36edb5ced8
parent 465397 4354c226d3388236c307849644c135f9532f3d4a
child 465399 6f59938c2690754fbc974587b3b267f79fe00ef1
push id35738
push userccoroiu@mozilla.com
push dateThu, 21 Mar 2019 21:59:09 +0000
treeherdermozilla-central@7eb8e627961c [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();
 }