diff --git a/tests/AddBuilds.js b/tests/AddBuilds.js index 92ef2cbc..d8e1cb00 100644 --- a/tests/AddBuilds.js +++ b/tests/AddBuilds.js @@ -81,6 +81,7 @@ var password; await driver.findElement(By.id("id_login")).sendKeys(user); await driver.findElement(By.id("id_password")).sendKeys(password); await driver.findElement(By.css(".primaryAction")).click(); + await new Promise(r => setTimeout(r, 2000)); // ADD BUILDS TEST diff --git a/tests/AddEditInventory.js b/tests/AddEditInventory.js index 5a6a1896..3cfcc805 100644 --- a/tests/AddEditInventory.js +++ b/tests/AddEditInventory.js @@ -80,6 +80,7 @@ var password; await driver.findElement(By.id("id_login")).sendKeys(user); await driver.findElement(By.id("id_password")).sendKeys(password); await driver.findElement(By.css(".primaryAction")).click(); + await new Promise(r => setTimeout(r, 2000)); // ADD INVENTORY TEST @@ -284,12 +285,7 @@ var password; } await driver.findElement(By.id("field-query_c_r0")).sendKeys("Test"); await driver.findElement(By.id("searchform-submit-button")).click(); - - while ((await driver.findElements(By.css(".even a"))).length == 0) - { - await new Promise(r => setTimeout(r, 2000)); - console.log("Wait 2 seconds for Search1."); - } + await new Promise(r => setTimeout(r, 2000)); await driver.findElement(By.css(".even a")).click(); while ((await driver.findElements(By.id("action"))).length == 0) { @@ -338,15 +334,11 @@ var password; await driver.findElement(By.id("field-query_c_r0")).sendKeys("Test"); await driver.findElement(By.css("#qcard_c > .card-body")).click(); await driver.findElement(By.id("searchform-submit-button")).click(); + await new Promise(r => setTimeout(r, 2000)); await driver.findElement(By.id("searchbar-query")).click(); //search within these results await driver.findElement(By.id("searchbar-query")).sendKeys("Coastal Mooring"); await driver.findElement(By.css(".btn-outline-primary:nth-child(1)")).click(); - - while ((await driver.findElements(By.css(".even a"))).length == 0) - { - await new Promise(r => setTimeout(r, 2000)); - console.log("Wait 2 seconds for Search3."); - } + await new Promise(r => setTimeout(r, 2000)); await driver.findElement(By.css(".even a")).click(); // Add subassembly item to valid parent @@ -402,12 +394,7 @@ var password; await driver.findElement(By.id("field-query_c_r1")).sendKeys("Wifi"); await driver.findElement(By.id("searchform-submit-button")).click(); - // await new Promise(r => setTimeout(r, 8000)); - while ((await driver.findElements(By.css(".even a"))).length == 0) - { - await new Promise(r => setTimeout(r, 2000)); - console.log("Wait 2 seconds for Search5."); - } + await new Promise(r => setTimeout(r, 2000)); await driver.findElement(By.css(".even a")).click(); while ((await driver.findElements(By.id("action"))).length == 0) { diff --git a/tests/AddEditParts.js b/tests/AddEditParts.js index 8aa8078b..948a59ac 100644 --- a/tests/AddEditParts.js +++ b/tests/AddEditParts.js @@ -67,6 +67,7 @@ var password; if ((await driver.findElements(By.css("#djHideToolBarButton"))).length != 0) { await driver.findElement(By.css("#djHideToolBarButton")).click(); } + await new Promise(r => setTimeout(r, 2000)); try { @@ -82,6 +83,7 @@ var password; await driver.findElement(By.id("id_login")).sendKeys(user); await driver.findElement(By.id("id_password")).sendKeys(password); await driver.findElement(By.css(".primaryAction")).click(); + await new Promise(r => setTimeout(r, 2000)); // ADD PARTS TEST @@ -134,7 +136,8 @@ var password; await driver.findElement(By.id("id_field_default_value")).sendKeys("WHLS75-1500"); await driver.findElement(By.id("id_global_for_part_types_2")).click(); //instrument - await driver.findElement(By.css(".btn-primary")).click(); + await driver.findElement(By.css(".btn-primary")).click(); + await new Promise(r => setTimeout(r, 2000)); // Add Computerized Part Type await driver.findElement(By.id("navbarAdmintools")).click(); @@ -154,6 +157,7 @@ var password; await new Promise(r => setTimeout(r, 2000)); await driver.findElement(By.linkText("Add Part Type")).click(); await driver.findElement(By.css(".btn-primary")).click(); + await driver.wait(until.elementLocated(By.id("error_1_id_name"))); assert(await driver.findElement(By.id("error_1_id_name")).getText() == "This field is required."); await driver.findElement(By.css(".btn-light")).click(); @@ -426,6 +430,7 @@ var password; await driver.findElement(By.id("id_name")).clear(); await driver.findElement(By.id("id_name")).sendKeys(" "); await driver.findElement(By.css(".btn-primary")).click(); + await driver.wait(until.elementLocated(By.id("error_1_id_name"))); assert(await driver.findElement(By.id("error_1_id_name")).getText() == "This field is required."); // Change part type parent @@ -458,14 +463,15 @@ var password; dropdown = await driver.findElement(By.id("id_parent")); await dropdown.findElement(By.xpath("//option[. = '---------']")).click(); await driver.findElement(By.css(".btn-primary")).click(); + await new Promise(r => setTimeout(r, 2000)); // Search for Part Templates and change Part Number await driver.findElement(By.id("searchbar-query")).sendKeys("Coastal Mooring"); - await driver.findElement(By.css(".btn-outline-primary:nth-child(1)")).click(); // 22 | click | linkText=123-456-789 | + await driver.findElement(By.css(".btn-outline-primary:nth-child(1)")).click(); + await new Promise(r => setTimeout(r, 2000)); await driver.findElement(By.linkText("123-456-789")).click(); - // await new Promise(r => setTimeout(r, 20000)); // 1.6 - while ((await driver.findElements(By.id("action"))).length == 0) // 1.6 + while ((await driver.findElements(By.id("action"))).length == 0) { await new Promise(r => setTimeout(r, 2000)); console.log("Wait 2 seconds for Search1."); diff --git a/tests/AdminUser.js b/tests/AdminUser.js index 17e71ce2..205d5eeb 100644 --- a/tests/AdminUser.js +++ b/tests/AdminUser.js @@ -160,14 +160,16 @@ var password; await driver.findElement(By.id("id_login")).sendKeys("tech") await driver.findElement(By.id("id_password")).sendKeys("tech") await driver.findElement(By.css(".primaryAction")).click() + await new Promise(r => setTimeout(r, 2000)); // Verify "Account Inactive" var bodyText = await driver.findElement(By.css('body')).getText(); assert(bodyText.includes("Account Inactive")); await driver.findElement(By.id("log-in-link")).click() - await driver.findElement(By.id("id_login")).sendKeys("inv") - await driver.findElement(By.id("id_password")).sendKeys("inv") - await driver.findElement(By.css(".primaryAction")).click() + await driver.findElement(By.id("id_login")).sendKeys("inv"); + await driver.findElement(By.id("id_password")).sendKeys("inv"); + await driver.findElement(By.css(".primaryAction")).click(); + await new Promise(r => setTimeout(r, 2000)); // Verify "Account Inactive" bodyText = await driver.findElement(By.css('body')).getText(); assert(bodyText.includes("Account Inactive")); @@ -176,6 +178,7 @@ var password; await driver.findElement(By.id("id_login")).sendKeys("admin") await driver.findElement(By.id("id_password")).sendKeys("admin") await driver.findElement(By.css(".primaryAction")).click() + await new Promise(r => setTimeout(r, 2000)); // Activate users and try to login await driver.findElement(By.linkText("Users")).click() @@ -207,7 +210,8 @@ var password; // Modify My Info await driver.findElement(By.linkText("My Info")).click() await driver.findElement(By.id("id_name")).sendKeys("best technician") - await driver.findElement(By.css(".btn-primary")).click() + await driver.findElement(By.css(".btn-primary")).click() + await new Promise(r => setTimeout(r, 2000)); // Verify my info changed bodyText = await driver.findElement(By.css('body')).getText(); assert(bodyText.includes("best technician")); @@ -216,6 +220,7 @@ var password; await driver.findElement(By.linkText("E-Mail")).click() await driver.findElement(By.id("id_email")).sendKeys("tech@example.com") await driver.findElement(By.name("action_add")).click() + await new Promise(r => setTimeout(r, 2000)); // Verify screen text contains tech@example.com bodyText = await driver.findElement(By.css('body')).getText(); assert(bodyText.includes("tech@example.com")); @@ -227,6 +232,7 @@ var password; await driver.findElement(By.id("id_password1")).sendKeys("tech1234") await driver.findElement(By.id("id_password2")).sendKeys("tech1234") await driver.findElement(By.name("action")).click() + await new Promise(r => setTimeout(r, 2000)); await driver.findElement(By.linkText("Sign Out")).click() await driver.findElement(By.css(".btn-danger")).click() diff --git a/tests/CalibrationsCoefs.js b/tests/CalibrationsCoefs.js index 4c35192b..60dc86b8 100644 --- a/tests/CalibrationsCoefs.js +++ b/tests/CalibrationsCoefs.js @@ -83,6 +83,7 @@ var password; await driver.findElement(By.id("id_login")).sendKeys(user); await driver.findElement(By.id("id_password")).sendKeys(password); await driver.findElement(By.css(".primaryAction")).click(); + await new Promise(r => setTimeout(r, 2000)); // CALIBRATIONS AND COEFFICIENTS TEST @@ -298,10 +299,7 @@ var password; await driver.findElement(By.id("searchbar-query")).sendKeys("buoy"); await driver.findElement(By.id("searchbar-modelselect")).sendKeys("Part Templates"); await driver.findElement(By.css(".btn-outline-primary:nth-child(1)")).click(); - while ((await driver.findElements(By.partialLinkText("555"))).length == 0) { - await new Promise(r => setTimeout(r, 2000)); - console.log("Wait 2 seconds for Search."); - } + await new Promise(r => setTimeout(r, 2000)); await driver.findElement(By.partialLinkText("555")).click(); while ((await driver.findElements(By.linkText("Create Calibrations"))).length == 0) { await new Promise(r => setTimeout(r, 2000)); @@ -352,20 +350,15 @@ var password; await dropdown.findElement(By.xpath("//option[. = 'Exact']")).click() } await driver.findElement(By.id("searchform-submit-button")).click() - while ((await driver.findElements(By.partialLinkText("1232"))).length == 0) { - await new Promise(r => setTimeout(r, 2000)); - console.log("Wait 2 seconds for Search."); - } + await new Promise(r => setTimeout(r, 2000)); + await driver.findElement(By.partialLinkText("1232")).click(); while ((await driver.findElements(By.id("calibration-template-tab"))).length == 0) { await new Promise(r => setTimeout(r, 2000)); console.log("Wait 2 seconds for Tab3."); } await driver.findElement(By.id("calibration-template-tab")).click() - while ((await driver.findElements(By.css("#calibration-template .collapsed > .fa"))).length == 0) { - await new Promise(r => setTimeout(r, 2000)); - console.log("Wait 2 seconds for Link."); - } + await new Promise(r => setTimeout(r, 2000)); await driver.findElement(By.css("#calibration-template .collapsed > .fa")).click() await new Promise(r => setTimeout(r, 4000)); // Verify values added in the History @@ -410,11 +403,8 @@ var password; console.log("Wait 2 seconds for Calibrations link."); } await driver.findElement(By.linkText("Calibrations")).click(); - while ((await driver.findElements(By.linkText("scalib1"))).length == 0) { - await new Promise(r => setTimeout(r, 2000)); - console.log("Wait 2 seconds for Calibrations detail."); - } - + await new Promise(r => setTimeout(r, 2000)); + // Verify min and max coef values var scalib1_min = await driver.findElement(By.xpath("//td[3]")).getText(); var scalib1_max = await driver.findElement(By.xpath("//td[4]")).getText(); diff --git a/tests/Cleanup-Docker.bat b/tests/Cleanup-Docker.bat index 547111c0..0b5c8259 100644 --- a/tests/Cleanup-Docker.bat +++ b/tests/Cleanup-Docker.bat @@ -17,6 +17,6 @@ node DeleteLocations.js chrome headless admin node DeleteUser.js chrome headless admin -node DeleteAllCruises.js chrome headless admin +#node DeleteAllCruises.js chrome headless admin exit 0 \ No newline at end of file diff --git a/tests/ConstantsConfigs.js b/tests/ConstantsConfigs.js index de8a1f45..7d602507 100644 --- a/tests/ConstantsConfigs.js +++ b/tests/ConstantsConfigs.js @@ -468,6 +468,7 @@ var password; console.log("Wait 2 seconds for Approved."); } await driver.findElement(By.partialLinkText("1232")); + await new Promise(r => setTimeout(r, 2000)); //Approved Flag { diff --git a/tests/DeleteAssemblies.js b/tests/DeleteAssemblies.js index e0ff5a2c..ccaa6f68 100644 --- a/tests/DeleteAssemblies.js +++ b/tests/DeleteAssemblies.js @@ -80,11 +80,12 @@ var password; await driver.findElement(By.id("id_login")).sendKeys(user); await driver.findElement(By.id("id_password")).sendKeys(password); await driver.findElement(By.css(".primaryAction")).click(); + await new Promise(r => setTimeout(r, 2000)); // DELETE ASSEMBLIES TEST // Searches for and deletes the Assemblies added during the Add and Update Assemblies Test - while ((await driver.findElements(By.id("searchbar-query"))).length == 0) // 1.6 + while ((await driver.findElements(By.id("searchbar-query"))).length == 0) { await new Promise(r => setTimeout(r, 2000)); console.log("Wait 2 seconds for Search."); @@ -224,6 +225,7 @@ var password; await driver.findElement(By.id("navbarTemplates")).click(); await driver.findElement(By.id("navbarAdmintools")).click(); await driver.findElement(By.linkText("Edit Assembly Types")).click(); + await new Promise(r => setTimeout(r, 2000)); if ((await driver.findElements(By.xpath("//tr[*]/td[text()='Electric']"))).length != 0) { var i = 1; @@ -234,7 +236,9 @@ var password; i++; } await driver.findElement(By.css("tr:nth-child(" + i + ") .btn-danger")).click(); + await new Promise(r => setTimeout(r, 2000)); await driver.findElement(By.css(".btn-danger")).click(); + await new Promise(r => setTimeout(r, 2000)); } else console.log("Delete Assemblies failed: Electric type not found"); diff --git a/tests/DeleteCruise.js b/tests/DeleteCruise.js index 4f6465d2..72e9a4cd 100644 --- a/tests/DeleteCruise.js +++ b/tests/DeleteCruise.js @@ -83,6 +83,7 @@ var password; await driver.findElement(By.id("id_login")).sendKeys(user); await driver.findElement(By.id("id_password")).sendKeys(password); await driver.findElement(By.css(".primaryAction")).click(); + await new Promise(r => setTimeout(r, 2000)); // DELETE CRUISE/VESSEL TEST @@ -100,19 +101,16 @@ var password; await driver.findElement(By.linkText("Edit Vessel List")).click() await new Promise(r => setTimeout(r, 2000)); - // Delete all Vessels - //while ((await driver.findElements(By.css(".list-group-item:nth-child(" + 1 + ") .fa"))).length != 0) { - // Just delete 1 vessel - takes too long to delete all vessel - if ((await driver.findElements(By.css(".list-group-item:nth-child(" + 1 + ") .fa"))).length != 0) { - await driver.findElement(By.css(".list-group-item:nth-child(" + 1 + ") .fa")).click(); - await driver.findElement(By.linkText("Delete")).click(); - while ((await driver.findElements(By.css(".btn-danger"))).length == 0) { - await new Promise(r => setTimeout(r, 2000)); - console.log("Wait 2 seconds for Confirm."); - } - await driver.findElement(By.css(".btn-danger")).click(); // confirm + // Delete Maui Princess vessel + await driver.findElement(By.partialLinkText("Maui Princess")).click(); + await new Promise(r => setTimeout(r, 2000)); + await driver.findElement(By.linkText("Delete")).click(); + while ((await driver.findElements(By.css(".btn-danger"))).length == 0) { await new Promise(r => setTimeout(r, 2000)); - } + console.log("Wait 2 seconds for Confirm."); + } + await driver.findElement(By.css(".btn-danger")).click(); // confirm + await new Promise(r => setTimeout(r, 2000)); console.log("Vessel Deleted."); @@ -124,25 +122,16 @@ var password; await driver.findElement(By.linkText("Cruises")).click() await new Promise(r => setTimeout(r, 4000)); - // Just delete 1 cruise - takes too long to delete all cruises - //while ((await driver.findElements(By.xpath("//li/ul/li/a"))).length != 0) { - if ((await driver.findElements(By.xpath("//li/ul/li/a"))).length != 0) { - await driver.findElement(By.xpath("//li/ul/li/a")).click(); - - while ((await driver.findElements(By.linkText("Delete"))).length == 0) { - await new Promise(r => setTimeout(r, 2000)); - console.log("Wait 2 seconds for Delete Cruise."); - } - await driver.findElement(By.linkText("Delete")).click(); - - while ((await driver.findElements(By.css(".btn-danger"))).length == 0) { - await new Promise(r => setTimeout(r, 2000)); - console.log("Wait 2 seconds for Confirm."); - } - await driver.findElement(By.css(".btn-danger")).click(); - await new Promise(r => setTimeout(r, 4000)); - } - //} + // Delete MAUI cruise + await driver.findElement(By.partialLinkText("MAUI")).click(); + await new Promise(r => setTimeout(r, 2000)); + await driver.findElement(By.linkText("Delete")).click(); + while ((await driver.findElements(By.css(".btn-danger"))).length == 0) { + await new Promise(r => setTimeout(r, 2000)); + console.log("Wait 2 seconds for Confirm."); + } + await driver.findElement(By.css(".btn-danger")).click(); + await new Promise(r => setTimeout(r, 4000)); console.log("Cruise Deleted."); diff --git a/tests/DeleteParts.js b/tests/DeleteParts.js index 9b0890d7..1b9eff81 100644 --- a/tests/DeleteParts.js +++ b/tests/DeleteParts.js @@ -222,6 +222,7 @@ var password; } await driver.findElement(By.css("tr:nth-child(" + i + ") .btn-danger")).click(); await driver.findElement(By.css(".btn-danger")).click(); + await new Promise(r => setTimeout(r, 2000)); } else console.log("Delete Parts failed: Computerized type not found"); diff --git a/tests/ExportCruise.js b/tests/ExportCruise.js index 64fbe8a5..46c635f0 100644 --- a/tests/ExportCruise.js +++ b/tests/ExportCruise.js @@ -83,6 +83,7 @@ var password; await driver.findElement(By.id("id_login")).sendKeys(user); await driver.findElement(By.id("id_password")).sendKeys(password); await driver.findElement(By.css(".primaryAction")).click(); + await new Promise(r => setTimeout(r, 2000)); // EXPORT CRUISE/VESSEL TEST - Tests Issue #174 @@ -121,14 +122,11 @@ var password; await driver.findElement(By.id("id_R2R")).sendKeys("Yes") await driver.findElement(By.id("id_notes")).sendKeys("Deep water vessel.") await driver.findElement(By.css(".btn-primary")).click() + await new Promise(r => setTimeout(r, 2000)); console.log("Add a Vessel."); // Add a Cruise - while ((await driver.findElements(By.linkText("Cruises"))).length == 0) { - await new Promise(r => setTimeout(r, 2000)); - console.log("Wait 2 seconds for Cruises."); - } await driver.findElement(By.linkText("Cruises")).click() while ((await driver.findElements(By.id("action"))).length == 0) { await new Promise(r => setTimeout(r, 2000)); @@ -144,6 +142,7 @@ var password; await driver.findElement(By.id("id_CUID")).sendKeys("MAUI") await driver.findElement(By.id("id_friendly_name")).sendKeys("Sunset Cruise") await driver.findElement(By.id("id_vessel")).sendKeys("MP Maui Princess") + await new Promise(r => setTimeout(r, 2000)); await driver.findElement(By.id("id_cruise_start_date")).sendKeys(Key.DELETE) await driver.findElement(By.id("id_cruise_start_date")).sendKeys("11/04/2020 00:00") await driver.findElement(By.id("id_cruise_stop_date")).sendKeys("1/03/2021 00:00") @@ -151,7 +150,8 @@ var password; { const dropdown = await driver.findElement(By.id("id_location")) await dropdown.findElement(By.xpath("//option[. = ' Test']")).click() - } + } + await new Promise(r => setTimeout(r, 2000)); await driver.findElement(By.css(".controls > .btn")).click() console.log("Add a Cruise."); await new Promise(r => setTimeout(r, 4000)); @@ -181,8 +181,8 @@ var password; var data; if (myArgs[1] == 'headless') { - var rdb_ves = process.cwd() + "/shiplist.csv"; - var rdb_cru = process.cwd() + "/CruiseInformation.csv"; + var rdb_ves = "/root/Downloads/shiplist.csv"; + var rdb_cru = "/root/Downloads/CruiseInformation.csv"; } else { const execSync = require('child_process').execSync; @@ -260,6 +260,9 @@ var password; } if (!found) console.log("Export Cruise Fields Do Not Match."); + fs.unlinkSync(rdb_cru); + fs.unlinkSync(rdb_ves); + await new Promise(r => setTimeout(r, 2000)); // Close browser window driver.quit(); diff --git a/tests/ExportCustomFields.js b/tests/ExportCustomFields.js index db87ebc9..7ea504bc 100644 --- a/tests/ExportCustomFields.js +++ b/tests/ExportCustomFields.js @@ -59,7 +59,6 @@ var password; password = "Automatedtests"; } - // 2 | setWindowSize | 1304x834 | await driver.manage().window().setRect({ width: 1304, height: 834 }); // Set implict wait time in between steps await driver.manage().setTimeouts({ implicit: 2000 }); @@ -89,9 +88,7 @@ var password; // Uncheck all Global Part Types for the Custom Field - // 10 | click | id=navbarAdminTools | - await driver.findElement(By.id("navbarAdmintools")).click(); - // 4 | click | linkText=Custom Fields | + await driver.findElement(By.id("navbarAdmintools")).click(); await driver.findElement(By.linkText("Custom Fields")).click(); while ((await driver.findElements(By.linkText("Add Custom Field"))).length == 0) { @@ -143,42 +140,37 @@ var password; } i++; } - // 18 | click | css=.btn-primary | + await driver.findElement(By.css(".btn-primary")).click(); + await new Promise(r => setTimeout(r, 2000)); // Create Computerized Part Template - // 13 | click | id=navbarTemplates | await driver.findElement(By.id("navbarTemplates")).click(); - // 14 | click | linkText=Parts | await driver.wait(until.elementLocated(By.linkText("Parts"))); await driver.findElement(By.linkText("Parts")).click(); - // 15 | click | linkText=Add Part Template | - while ((await driver.findElements(By.linkText("Add Part Template"))).length == 0) // 1.6 + while ((await driver.findElements(By.linkText("Add Part Template"))).length == 0) { await new Promise(r => setTimeout(r, 2000)); console.log("Wait 2 seconds for Add Part Template1."); } await driver.findElement(By.linkText("Add Part Template")).click(); /*Get the text after ajax call*/ - // 16 | type | id=id_part_number | var part_num = "100-259-785"; - while ((await driver.findElements(By.id("id_part_number"))).length == 0) // 1.6 + while ((await driver.findElements(By.id("id_part_number"))).length == 0) { await new Promise(r => setTimeout(r, 2000)); console.log("Wait 2 seconds for Part Number."); } await driver.findElement(By.id("id_part_number")).sendKeys(part_num); - // 17 | type | id=id_name | Computerized await driver.findElement(By.id("id_name")).sendKeys("Disk Drive"); - // 18 | type | id=id_friendly_name | surface mooring await driver.findElement(By.id("id_friendly_name")).sendKeys("drive"); - // 19 | select | id=id_part_type | label=Computerized + { var dropdown = await driver.findElement(By.id("id_part_type")); await dropdown.findElement(By.xpath("//option[. = ' Computerized']")).click(); } - // 20 | click | css=.controls > .btn | + await driver.findElement(By.css(".controls > .btn")).click(); await new Promise(r => setTimeout(r, 2000)); @@ -189,14 +181,14 @@ var password; // Create Inventory with Part Template above await driver.findElement(By.linkText("Inventory")).click(); - while ((await driver.findElements(By.linkText("Add Inventory"))).length == 0) // 1.6 + while ((await driver.findElements(By.linkText("Add Inventory"))).length == 0) { await new Promise(r => setTimeout(r, 2000)); console.log("Wait 2 seconds for Add Inventory1."); } await driver.findElement(By.linkText("Add Inventory")).click(); - while ((await driver.findElements(By.id("id_part_type"))).length == 0) // 1.6 + while ((await driver.findElements(By.id("id_part_type"))).length == 0) { await new Promise(r => setTimeout(r, 2000)); console.log("Wait 2 seconds for Add Inventory2."); @@ -205,26 +197,26 @@ var password; const dropdown = await driver.findElement(By.id("id_part_type")); await dropdown.findElement(By.xpath("//option[. = '-- Computerized']")).click(); } - // 6 | select | id=id_part | label=Disk Drive + { await new Promise(r => setTimeout(r, 2000)); const dropdown = await driver.findElement(By.id("id_part")); await new Promise(r => setTimeout(r, 4000)); //New for 1.6 - This field blanked back out without timeout await dropdown.findElement(By.xpath("//option[. = 'Disk Drive']")).click(); } - // 7 | select | id=id_location | label=Test + { const dropdown = await driver.findElement(By.id("id_location")); // There's a space before Test in the option dropdown await dropdown.findElement(By.xpath("//option[. = ' Test']")).click(); } - // 8 | storeValue | id=id_serial_number | Serial_Number + // Stores the value of the Serial Number assigned await new Promise(r => setTimeout(r, 6000)); //wait here for revision & serial number to automatically fill in var Serial_Number = await driver.findElement(By.id("id_serial_number")).getAttribute("value"); await driver.findElement(By.css(".controls > .btn")).click(); - while ((await driver.findElements(By.partialLinkText("drive"))).length == 0) // 1.6 + while ((await driver.findElements(By.partialLinkText("drive"))).length == 0) { await new Promise(r => setTimeout(r, 2000)); console.log("Wait 2 seconds for Add Inventory3."); @@ -234,9 +226,7 @@ var password; // Now, check all Global Types for the Custom Field - // 10 | click | id=navbarAdminTools | await driver.findElement(By.id("navbarAdmintools")).click(); - // 4 | click | linkText=Custom Fields | await driver.findElement(By.linkText("Custom Fields")).click(); while ((await driver.findElements(By.linkText("Add Custom Field"))).length == 0) { @@ -289,7 +279,7 @@ var password; } i++; } - // 18 | click | css=.btn-primary | + await driver.findElement(By.css(".btn-primary")).click(); // await new Promise(r => setTimeout(r, 4000)); //takes a while when db is fully populated while ((await driver.findElements(By.linkText("Add Custom Field"))).length == 0) { @@ -298,20 +288,17 @@ var password; } // Search for and Export Part Items and verify "Condition" Custom Field is exported - // 3 | click | id=searchbar-query | await driver.findElement(By.id("searchbar-query")).sendKeys("Disk Drive"); - // 8 | select | id=searchbar-modelselect | label=Part Templates + { const dropdown = await driver.findElement(By.id("searchbar-modelselect")) await dropdown.findElement(By.xpath("//option[. = 'Part Templates']")).click() } - // 5 | click | css=.btn:nth-child(1) | + await driver.findElement(By.css(".btn:nth-child(1)")).click() // Downloads to Downloads Folder - // 10 | click | id=search--download-csv-button | await driver.findElement(By.id("search--download-csv-button")).click(); - // 11 | click | linkText=All (Include Hidden Columns) | await driver.findElement(By.linkText("All (Include Hidden Columns)")).click(); // Read RDB_Part.csv and verify Condition Custom Field @@ -323,7 +310,7 @@ var password; var data; if (myArgs[1] == 'headless') { - var rdb_inv = process.cwd() + "/RDB_Part.csv"; + var rdb_inv = "/root/Downloads/RDB_Part.csv"; } else { const execSync = require('child_process').execSync; @@ -370,30 +357,21 @@ var password; } // // Search for Disk Drive - // 3 | click | id=searchbar-query | await driver.findElement(By.id("searchbar-query")).sendKeys("Disk Drive"); - // 8 | select | id=searchbar-modelselect | label=Part Templates { const dropdown = await driver.findElement(By.id("searchbar-modelselect")) await dropdown.findElement(By.xpath("//option[. = 'Inventory']")).click() } - // 5 | click | css=.btn:nth-child(1) | await driver.findElement(By.css(".btn:nth-child(1)")).click() - - while ((await driver.findElements(By.id("search--download-csv-button"))).length == 0) { - await new Promise(r => setTimeout(r, 2000)); - console.log("Wait 2 seconds for Search2."); - } + await new Promise(r => setTimeout(r, 2000)); // Downloads to Downloads Folder - // 10 | click | id=search--download-csv-button | await driver.findElement(By.id("search--download-csv-button")).click(); - // 11 | click | linkText=All (Include Hidden Columns) | await driver.findElement(By.linkText("All (Include Hidden Columns)")).click(); if (myArgs[1] == 'headless') { - var rdb_inv = process.cwd() + "/RDB_Inventory.csv"; + var rdb_inv = "/root/Downloads/RDB_Inventory.csv"; } else { const execSync = require('child_process').execSync; @@ -434,6 +412,9 @@ var password; throw new Error(Serial_Number + " not found."); } + fs.unlinkSync(rdb_inv); + await new Promise(r => setTimeout(r, 2000)); + // Close browser window driver.quit(); diff --git a/tests/ImportExportInventory.js b/tests/ImportExportInventory.js index 5562e8e2..b7ab5cd2 100644 --- a/tests/ImportExportInventory.js +++ b/tests/ImportExportInventory.js @@ -213,8 +213,7 @@ var password; var data; if (myArgs[1] == 'headless') { - // Docker/Circleci puts file in the current dir - var rdb_inv = process.cwd() + "//RDB_Inventory.csv"; + var rdb_inv = "/root/Downloads/RDB_Inventory.csv"; } else { // Windows command line puts file in the User's default Downloads dir @@ -384,6 +383,9 @@ var password; console.log("Import and Try to Move Deployed Inventory NOT Successful: Error NOT Flagged."); } + fs.unlinkSync(rdb_inv); + await new Promise(r => setTimeout(r, 2000)); + // Close browser window driver.quit(); diff --git a/tests/UploadCsv.js b/tests/UploadCsv.js index 5f2e8483..5ca06605 100644 --- a/tests/UploadCsv.js +++ b/tests/UploadCsv.js @@ -110,6 +110,7 @@ var filename, filename_ext; await reviewer[2].click(); } await driver.findElement(By.id("submit")).click() + await new Promise(r => setTimeout(r, 2000)); // Wait for upload to Complete var bodyText; for (var j = 0; j < 5; j++) { @@ -131,6 +132,9 @@ var filename, filename_ext; } } + console.log("Wait for all Cruises created."); + await new Promise(r => setTimeout(r, 30000)); + // If no import error, export the Cruise file if (erroridx == 0) { @@ -143,13 +147,12 @@ var filename, filename_ext; // Export Cruises - CI Version await driver.findElement(By.id("navbarAdmintools")).click() await driver.findElement(By.linkText("Bulk Download Tool")).click() - // CI download button associated with Cruises + // CI download button associated with Cruises await driver.findElement(By.linkText("Export Cruises [CI]")).click() // Access Downloaded Cruise file if (myArgs[1] == 'headless') { - // Docker/Circleci puts file in the current dir - var rdb_cruise = process.cwd() + "//CruiseInformation.csv"; + var rdb_cruise = "/root/Downloads/CruiseInformation.csv"; } else { // Windows command line puts file in the User's default Downloads dir @@ -164,8 +167,7 @@ var filename, filename_ext; await new Promise(r => setTimeout(r, 2000)); console.log("Wait 2 seconds for File Download."); } - console.log("Wait 4 minutes for File Write."); - await new Promise(r => setTimeout(r, 240000)); //wait for file write to finish + console.log("Compare Uploaded & Exported Cruise files."); // Compare Uploaded & Exported Cruise files // read a line from upload file and find it in exported buffer to verify Cruise was created properly @@ -194,16 +196,22 @@ var filename, filename_ext; // This is the only way to compare the double quotes in the notes field if (cruise_str[4].includes(",")) { if (!(exported.includes(cruise_str[0]) && exported.includes(cruise_str[1]) - && exported.includes(cruise_str[2]) && exported.includes(cruise_str[3]))) + && exported.includes(cruise_str[2]) && exported.includes(cruise_str[3]))) { console.log("Cruise Export Missing: " + cruise_str) - if (!exported.includes(cruise_str[4])) + //console.log(cruise_str[0], cruise_str[1], cruise_str[2], cruise_str[3]); + } + if (!exported.includes(cruise_str[4])) { console.log("Cruise Export Missing: " + cruise_str[4]) + //console.log(cruise_str[4]) + } } else if (!exported.includes(cruise_str)) { console.log("Cruise Export Missing: "+cruise_str) + //console.log("entire string missing") } } } + fs.unlinkSync(rdb_cruise); // Import Vessel CSV - CI Version // My file has been modified from the asset mgmt. file - fix mara s. marian invalid char in mmsi field @@ -223,7 +231,8 @@ var filename, filename_ext; var reviewer = await driver.findElements(By.xpath("//option[. = 'tech']")); await reviewer[3].click(); } - await driver.findElement(By.id("submit")).click() + await driver.findElement(By.id("submit")).click(); + await new Promise(r => setTimeout(r, 2000)); // Wait for upload to Complete erroridx = 0; for (var j = 0; j < 5; j++) { @@ -258,8 +267,7 @@ var filename, filename_ext; // Access Downloaded Vessel file if (myArgs[1] == 'headless') { - // Docker/Circleci puts file in the current dir - var rdb_vessel = process.cwd() + "//shiplist.csv"; + var rdb_vessel = "/root/Downloads/shiplist.csv"; } else { // Windows command line puts file in the User's default Downloads dir @@ -309,7 +317,7 @@ var filename, filename_ext; } } } - + fs.unlinkSync(rdb_vessel); // Upload Calibration CSV with a single calibration and a 2D calibration // Test depends on Manufacturer Serial Number previously defined in Import Export Inventory @@ -338,6 +346,7 @@ var filename, filename_ext; await reviewer[0].click(); } await driver.findElement(By.id("submit")).click() + await new Promise(r => setTimeout(r, 2000)); // Wait for upload to Complete var bodyText; @@ -368,11 +377,10 @@ var filename, filename_ext; // Access Downloaded Calibrations file if (myArgs[1] == 'headless') { - // Docker/Circleci puts file in the current dir - var rdb_calib = process.cwd() + "//CalibrationEvents.zip" - var rdb_path = process.cwd(); - var rdb_unzip = process.cwd() + "//3604-00131-00001-20004__20160510.csv" - var rdb_ext = process.cwd() + "//3604-00131-00001-20004__20160510__scalib2.ext" + var rdb_calib = "/root/Downloads/CalibrationEvents.zip" + var rdb_path = "/root/Downloads"; + var rdb_unzip = "/root/Downloads/3604-00131-00001-20004__20160510.csv" + var rdb_ext = "/root/Downloads/3604-00131-00001-20004__20160510__scalib2.ext" } else { // Windows command line puts file in the User's default Downloads dir @@ -456,6 +464,7 @@ var filename, filename_ext; await reviewer[5].click(); } await driver.findElement(By.id("submit")).click(); + await new Promise(r => setTimeout(r, 2000)); // Wait for upload to Complete erroridx = 0; for (var j = 0; j < 5; j++) { @@ -527,6 +536,7 @@ var filename, filename_ext; await reviewer[4].click(); } await driver.findElement(By.id("submit")).click(); + await new Promise(r => setTimeout(r, 2000)); // Wait for upload to Complete erroridx = 0; for (var j = 0; j < 5; j++) { @@ -547,61 +557,6 @@ var filename, filename_ext; } } - // If no import error - if (erroridx == 0) { - // Don't trust Import Complete has actually completed - await new Promise(r => setTimeout(r, 9000)); - - // Verify Reference Designator list created on an Assembly - await driver.findElement(By.id("navbarTemplates")).click(); - await driver.findElement(By.linkText("Assemblies")).click(); - - await new Promise(r => setTimeout(r, 2000)); - // Expand Assembly Tree and Navigate to GS Surface Mooring Inventory - var j = 1; - while (true) { - if (await driver.findElement(By.xpath("//div/div/ul/li[" + j + "]")).getText() == "Mooring") { - await driver.findElement(By.xpath("//li[" + j + "]/i")).click(); - break; - } - j++; - } - await new Promise(r => setTimeout(r, 2000)); - await driver.findElement(By.xpath("//li[" + j + "]/ul/li/i")).click(); // Gs surface mooring is only mooring - await new Promise(r => setTimeout(r, 2000)); - //Expand Rev B - var j = 1; - while (true) { - if (await driver.findElement(By.xpath("//li/ul/li/ul/li[" + j + "]/a")).getText() == "Revision B") { - await driver.findElement(By.xpath("//li/ul/li/ul/li[" + j + "]/i")).click(); - break; - } - j++; - } - await new Promise(r => setTimeout(r, 1000)); - await driver.findElement(By.linkText("ADCPS-J")).click(); - await new Promise(r => setTimeout(r, 1000)); - while ((await driver.findElements(By.id("action"))).length == 0) { - await new Promise(r => setTimeout(r, 2000)); - console.log("Wait 2 seconds for Action."); - } - await driver.findElement(By.id("action")).click(); - await new Promise(r => setTimeout(r, 1000)); - await driver.findElement(By.linkText("Add Reference Designator")).click(); - { - const dropdown = await driver.findElement(By.id("id_reference_designator")); - try { - await dropdown.findElement(By.xpath("//option[. = 'CE01ISSM-MFC31-00-CPMENG000']")).click(); - console.log("Vocab.csv bulk upload successful."); - } - catch { - // Report import error if one imported reference designator is not found in dropdown list - console.log("Vocab.csv bulk upload failed - reference designator not found in list."); - } - } - } - - // Upload Sensor_bulk_load_asset_record.csv - will create a bulk upload file for the associated Inventory. // Depends upon Inventory Serial Number = Asset UID field // If Inventory with Serial Number does not exist & part number supplied in csv, an Inventory is created. @@ -624,6 +579,7 @@ var filename, filename_ext; await reviewer[5].click(); } await driver.findElement(By.id("submit")).click(); + await new Promise(r => setTimeout(r, 2000)); // Wait for upload to Complete erroridx = 0; for (var j = 0; j < 5; j++) { @@ -675,7 +631,7 @@ var filename, filename_ext; else { console.log("Upload CSV failed: CGINS-ADCPS-19061 not found."); } - } + } // Upload CP04OSSM_Deploy.csv - will create a Build. @@ -700,6 +656,7 @@ var filename, filename_ext; await reviewer[1].click(); } await driver.findElement(By.id("submit")).click(); + await new Promise(r => setTimeout(r, 2000)); // Wait for upload to Complete erroridx = 0; for (var j = 0; j < 5; j++) { @@ -725,7 +682,7 @@ var filename, filename_ext; // Don't trust Import Complete has actually completed await new Promise(r => setTimeout(r, 9000)); - // Verify bulk upload file created for the Part + // Verify bulk upload file created for the build await driver.findElement(By.id("navbarTemplates")).click(); await driver.findElement(By.linkText("Builds")).click(); await driver.findElement(By.id("searchbar-query")).click(); @@ -744,13 +701,128 @@ var filename, filename_ext; bodyText = await driver.findElement(By.css('body')).getText(); if ((bodyText.includes("Coastal Pioneer") && bodyText.includes("MAUI"))) { console.log("CP04OSSM_Deploy.csv bulk upload successful."); + erroridx = 0; } else { console.log("CP04OSSM_Deploy.csv bulk upload failed."); + erroridx = 1; } } else { console.log("Upload CSV failed.: CP04OSSM-Historical 00011 not found."); + erroridx = 1; + } + } + + // If no import error, export the Deployment file + if (erroridx == 0) { + // Don't trust Import Complete has actually imported all + await new Promise(r => setTimeout(r, 20000)); + + // Export Deployments + await driver.findElement(By.id("navbarAdmintools")).click(); + await driver.findElement(By.linkText("Bulk Download Tool")).click(); + await driver.findElement(By.linkText("Export Deployments")).click(); + + // Access Downloaded file + if (myArgs[1] == 'headless') { + // Docker puts file in the current dir + var rdb_deploy = "/root/Downloads/Deployments.zip"; + var rdb_path = "/root/Downloads"; + var rdb_unzip = "/root/Downloads/GS_Surface_Mooring_Deploy.csv" + } + else { + // Windows command line puts file in the User's default Downloads dir + const execSync = require('child_process').execSync; + var username = execSync('echo %username%', { encoding: 'utf-8' }); + username = username.replace(/[\n\r]+/g, ''); + var rdb_deploy = "C:\\Users\\" + username + "\\Downloads\\Deployments.zip"; + var rdb_path = "C:\\Users\\" + username + "\\Downloads"; + var rdb_unzip = "C:\\Users\\" + username + "\\Downloads\\GS_Surface_Mooring_Deploy.csv"; + } + + var index = 0; + while (!fs.existsSync(rdb_deploy)) // wait for file download + { + await new Promise(r => setTimeout(r, 2000)); + console.log("Wait 2 seconds for File Download."); + index++; + if (index > 10) + { + console.log("Error: Deployment download file not found"); + break; + } + } + + if (index <= 10) { + await new Promise(r => setTimeout(r, 20000)); + + // Unzip file + const unzipper = require('unzipper'); + + // await and promise required to work + await fs.createReadStream(rdb_deploy).pipe(unzipper.Extract({ path: rdb_path })).promise(); + + while (!fs.existsSync(rdb_unzip)) // wait for file extract + { + await new Promise(r => setTimeout(r, 2000)); + console.log("Wait 2 seconds for File Extract."); + } + + // Compare Uploaded & Exported files + var upload = fs.readFileSync(filename, 'utf8'); + var exported = fs.readFileSync(rdb_unzip, 'utf8'); + + var uploaded_data = $.csv.toArrays(upload); + var exported_data = $.csv.toArrays(exported); + + var single_str = uploaded_data[1]; + for (var j = 0, lth = single_str.length; j < lth; j++) { + if (!(exported.includes(single_str[j]))) { + console.log("Warning: Deployment Export Missing - " + single_str[j]); + break; + } + } + } + + // Verify Reference Designator created on Assembly + await new Promise(r => setTimeout(r, 2000)); + await driver.findElement(By.id("navbarTemplates")).click(); + await driver.findElement(By.linkText("Assemblies")).click(); + + await new Promise(r => setTimeout(r, 2000)); + // Expand Assembly Tree and Navigate to GS Surface Mooring Inventory + var j = 1; + while (true) { + if (await driver.findElement(By.xpath("//div/div/ul/li[" + j + "]")).getText() == "Mooring") { + await driver.findElement(By.xpath("//li[" + j + "]/i")).click(); + break; + } + j++; + } + await new Promise(r => setTimeout(r, 2000)); + await driver.findElement(By.xpath("//li[" + j + "]/ul/li/i")).click(); // Gs surface mooring is only mooring + await new Promise(r => setTimeout(r, 2000)); + //Expand Rev B + var j = 1; + while (true) { + if (await driver.findElement(By.xpath("//li/ul/li/ul/li[" + j + "]/a")).getText() == "Revision B") { + await driver.findElement(By.xpath("//li/ul/li/ul/li[" + j + "]/i")).click(); + break; + } + j++; + } + await new Promise(r => setTimeout(r, 2000)); + await driver.findElement(By.partialLinkText("ADCPS-J")).click(); + await new Promise(r => setTimeout(r, 2000)); + + bodyText = await driver.findElement(By.css('body')).getText(); + console.log(bodyText); + if (bodyText.includes("CP04OSSM-MFD35")) { + console.log("Vocab.csv bulk upload successful - reference designator found."); + } + else { + console.log("Vocab.csv bulk upload failed - reference designator not found."); } }