From 98e2a32edaec08a988c70d06029675202d6d586b Mon Sep 17 00:00:00 2001 From: Gertjan van Oosten Date: Thu, 3 Sep 2020 13:53:00 +0200 Subject: [PATCH] NCI-Agency/anet#1964: Update tests --- client/tests/e2e/report.js | 43 +++++++++++++++++++++----------------- client/tests/util/test.js | 14 +++++++++++-- 2 files changed, 36 insertions(+), 21 deletions(-) diff --git a/client/tests/e2e/report.js b/client/tests/e2e/report.js index b67dde5b1f..7e29091bbb 100644 --- a/client/tests/e2e/report.js +++ b/client/tests/e2e/report.js @@ -40,7 +40,8 @@ test.serial("Draft and submit a report", async t => { const $locationAdvancedSelect = await pageHelpers.chooseAdvancedSelectOption( "#location", - "general hospit" + "general hospit", + 2 // choose filter "All" ) t.is( @@ -54,7 +55,8 @@ test.serial("Draft and submit a report", async t => { const $attendeesAdvancedSelect1 = await pageHelpers.chooseAdvancedSelectOption( "#attendees", - "topferness, christopf" + "topferness, christopf", + 2 // choose filter "All" ) const $attendeesTitle = await t.context.driver.findElement( @@ -94,7 +96,8 @@ test.serial("Draft and submit a report", async t => { const $attendeesAdvancedSelect2 = await pageHelpers.chooseAdvancedSelectOption( "#attendees", - "steveson, steve" + "steveson, steve", + 2 // choose filter "All" ) await $attendeesTitle.click() @@ -134,7 +137,8 @@ test.serial("Draft and submit a report", async t => { const $tasksAdvancedSelect = await pageHelpers.chooseAdvancedSelectOption( "#tasks", - "2.A" + "2.A", + 2 // choose filter "All" ) const $tasksTitle = await t.context.driver.findElement( @@ -178,13 +182,13 @@ test.serial("Draft and submit a report", async t => { "sensitive info", shortWaitMs // wait for Draftail to save the editor contents ) - const $addAuthGroupShortcutButtons = await $$( - "#meeting-details .shortcut-list button" + const $authGroupsInput = await $("#authorizationGroups") + await $authGroupsInput.click() + const $recentAuthGroups = await $$( + "#authorizationGroups-popover table tbody tr input" ) // Add all recent authorization groups - await Promise.all( - $addAuthGroupShortcutButtons.map($button => $button.click()) - ) + await Promise.all($recentAuthGroups.map($elem => $elem.click())) const $formButtonSubmit = await $("#formBottomSubmit") await t.context.driver.wait( @@ -533,12 +537,15 @@ test.serial( "Location field starts blank" ) - const $locationShortcutButton = await $("#location-shortcut-list button") - await $locationShortcutButton.click() + await $locationInput.click() + const $recentLocation = await $( + "#location-popover table tbody tr:first-child" + ) + await $recentLocation.click() t.is( await $locationInput.getAttribute("value"), "General Hospital", - "Clicking the shortcut adds a location" + "Should be able to add a recent location" ) await assertElementNotPresent( @@ -660,20 +667,18 @@ test.serial( await assertElementText(t, $advisorPosition, "EF 2.2 Advisor D") await assertElementText(t, $advisorOrg, "EF 2.2") - const $addAttendeeShortcutButtons = await $$( - "#attendees-shortcut-list button" - ) + const $attendeesInput = await $("#attendees") + await $attendeesInput.click() + const $recentAttendees = await $$("#attendees-popover table tbody tr input") // Add all recent attendees - await Promise.all( - $addAttendeeShortcutButtons.map($button => $button.click()) - ) + await Promise.all($recentAttendees.map($elem => $elem.click())) $advisorAttendeesRows = await $$(".advisorAttendeesTable tbody tr") $principalAttendeesRows = await $$(".principalAttendeesTable tbody tr") t.is( $advisorAttendeesRows.length + $principalAttendeesRows.length, 5, - "Clicking the shortcut buttons adds rows to the table" + "Should be able to add recent attendees to the table" ) const $submitButton = await $("#formBottomSubmit") diff --git a/client/tests/util/test.js b/client/tests/util/test.js index 015c6ad414..6b32e80789 100644 --- a/client/tests/util/test.js +++ b/client/tests/util/test.js @@ -48,9 +48,11 @@ test.beforeEach(t => { let builder = new webdriver.Builder() if (testEnv === "local") { const chrome = require("selenium-webdriver/chrome") + const chromeOptions = new chrome.Options().headless() + chromeOptions.addArguments("window-size=1600,1200") builder = builder .forBrowser("chrome") - .setChromeOptions(new chrome.Options().headless()) + .setChromeOptions(chromeOptions) /* * If we don't explicitly define ServiceBuilder for ChromeDriver it uses a default ServiceBuilder * which is a singleton, shared amongst different driver instances. As a result, the same @@ -287,10 +289,18 @@ test.beforeEach(t => { ) await $nextMonthDate.click() }, - async chooseAdvancedSelectOption(inputSelector, text) { + async chooseAdvancedSelectOption(inputSelector, text, filterIndex) { const popoverSelector = `${inputSelector}-popover` const $advancedSelectInput = await t.context.$(inputSelector) await $advancedSelectInput.click() + if (filterIndex) { + // select filter + const $filter = await t.context.$( + `${popoverSelector} .advanced-select-filters li:nth-child(${filterIndex}) button` + ) + await $filter.click() + await t.context.driver.sleep(shortWaitMs) // give the advanced select some time to apply the filter + } await $advancedSelectInput.sendKeys(text) await t.context.driver.sleep(shortWaitMs) // give the advanced select some time to send the request (debounce!) t.context.waitForLoadingFinished()