Skip to content

Commit

Permalink
refactor: ♻️❌ Add buttons to confirm the income and expense input
Browse files Browse the repository at this point in the history
- Don't change the DSL, clicking the buttons is a part of `record_income` and `record_expense` actions. This is why not mentioning UI in the DSL matters, as it allows us to refactor the UI without changing the tests.
- Modify the `record_income` and `record_expense` actions to include the button clicks.
- Implement the buttons in production code.
- Tests should be still failing due to forced fail in verify function ❌.
  • Loading branch information
Jakub Sobolewski committed Jan 20, 2025
1 parent 8f6ad28 commit 6530b7e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
15 changes: 15 additions & 0 deletions app/main.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
box::use(
shiny[
actionButton,
bootstrapPage,
moduleServer,
NS,
Expand All @@ -21,6 +22,13 @@ ui <- function(id) {
.cssSelector = "input",
"data-test" = "income"
),
actionButton(
ns("record_income"),
"Record Income"
) |>
tagAppendAttributes(
"data-test" = "record-income"
),
numericInput(
ns("expense"),
label = "Expense",
Expand All @@ -29,6 +37,13 @@ ui <- function(id) {
tagAppendAttributes(
.cssSelector = "input",
"data-test" = "expense"
),
actionButton(
ns("record_expense"),
"Record Expense"
) |>
tagAppendAttributes(
"data-test" = "record-expense"
)
)
}
Expand Down
6 changes: 6 additions & 0 deletions tests/acceptance/dsl.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,17 @@ AppDriver <- R6Class(
self$session |>
selenider$find_element("[data-test='income']") |>
selenider$elem_set_value(amount)
self$session |>
selenider$find_element("[data-test='record-income']") |>
selenider$elem_click()
},
record_expense = function(amount) {
self$session |>
selenider$find_element("[data-test='expense']") |>
selenider$elem_set_value(amount)
self$session |>
selenider$find_element("[data-test='record-expense']") |>
selenider$elem_click()
}
)
)
Expand Down

0 comments on commit 6530b7e

Please sign in to comment.