VikasMahato

Unit_test

Jan 23rd, 2018
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Check Topsites add
  2. test_newtab(
  3.   // it should be able to click the topsites edit button to reveal the edit topsites modal and overlay.
  4.   function topsites_edit() {
  5.     //Find the edit topsites button
  6.     const topsitesEditBtn = content.document.querySelector(".edit-topsites-button button");
  7.     topsitesEditBtn.click();
  8.  
  9.     let found = content.document.querySelector(".edit-topsites");
  10.     ok(found && !found.hidden, "Should find a visible topsites edit menu");
  11.  
  12.     found = content.document.querySelector(".modal-overlay");
  13.     ok(found && !found.hidden, "Should find a visible overlay");
  14.  
  15.     //Find the "Add" button
  16.     const topsitesAddBtn = content.document.querySelector(".add");
  17.     topsitesAddBtn.click();
  18.  
  19.     // Write field title
  20.     let fieldTitle = content.document.querySelector(".field.title input");
  21.     ok(fieldTitle && !fieldTitle.hidden, "Should find field title input");
  22.    
  23.     fieldTitle.value = "Youtube";
  24.     is(fieldTitle.value, "Youtube", "The field title should match");
  25.  
  26.     // Write field url
  27.     let fieldURL = content.document.querySelector(".field.url input");
  28.     ok(fieldURL && !fieldURL.hidden, "Should find field url input");
  29.    
  30.     fieldURL.value = "https://www.youtube.com/";
  31.     is(fieldURL.value, "https://www.youtube.com/", "The field title should match");
  32.  
  33.     //Click the "Add" button
  34.     const addBtn = content.document.querySelector(".done.add");
  35.     addBtn.click();
  36.  
  37.     //Check if the URL matches
  38.     let topSite = content.document.querySelector(".top-site-outer:nth-child(1) a");
  39.     is("https://www.youtube.com/", topSite.getAttribute("href"), "URL should match");
  40.   }
  41. );
Add Comment
Please, Sign In to add comment