Skip to content

Commit

Permalink
#1964: Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gjvoosten committed Sep 7, 2020
1 parent 1d5a778 commit 98e2a32
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 21 deletions.
43 changes: 24 additions & 19 deletions client/tests/e2e/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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")
Expand Down
14 changes: 12 additions & 2 deletions client/tests/util/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 98e2a32

Please sign in to comment.