2022-12-27 01:50:00 +02:00
|
|
|
package components
|
|
|
|
|
2022-12-28 02:27:48 +02:00
|
|
|
type ConfirmationDriver struct {
|
2022-12-27 12:35:36 +02:00
|
|
|
t *TestDriver
|
2022-12-27 01:50:00 +02:00
|
|
|
hasCheckedTitle bool
|
|
|
|
hasCheckedContent bool
|
|
|
|
}
|
|
|
|
|
2022-12-28 02:27:48 +02:00
|
|
|
func (self *ConfirmationDriver) getViewDriver() *ViewDriver {
|
2022-12-27 12:35:36 +02:00
|
|
|
return self.t.Views().Confirmation()
|
2022-12-27 01:50:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// asserts that the confirmation view has the expected title
|
2023-06-03 07:12:31 +02:00
|
|
|
func (self *ConfirmationDriver) Title(expected *TextMatcher) *ConfirmationDriver {
|
2022-12-28 02:27:48 +02:00
|
|
|
self.getViewDriver().Title(expected)
|
2022-12-27 01:50:00 +02:00
|
|
|
|
|
|
|
self.hasCheckedTitle = true
|
|
|
|
|
|
|
|
return self
|
|
|
|
}
|
|
|
|
|
|
|
|
// asserts that the confirmation view has the expected content
|
2023-06-03 07:12:31 +02:00
|
|
|
func (self *ConfirmationDriver) Content(expected *TextMatcher) *ConfirmationDriver {
|
2022-12-28 02:27:48 +02:00
|
|
|
self.getViewDriver().Content(expected)
|
2022-12-27 01:50:00 +02:00
|
|
|
|
|
|
|
self.hasCheckedContent = true
|
|
|
|
|
|
|
|
return self
|
|
|
|
}
|
|
|
|
|
2022-12-28 02:27:48 +02:00
|
|
|
func (self *ConfirmationDriver) Confirm() {
|
2022-12-27 01:50:00 +02:00
|
|
|
self.checkNecessaryChecksCompleted()
|
|
|
|
|
2022-12-28 02:27:48 +02:00
|
|
|
self.getViewDriver().PressEnter()
|
2022-12-27 01:50:00 +02:00
|
|
|
}
|
|
|
|
|
2022-12-28 02:27:48 +02:00
|
|
|
func (self *ConfirmationDriver) Cancel() {
|
2022-12-27 01:50:00 +02:00
|
|
|
self.checkNecessaryChecksCompleted()
|
|
|
|
|
2022-12-28 02:27:48 +02:00
|
|
|
self.getViewDriver().PressEscape()
|
2022-12-27 01:50:00 +02:00
|
|
|
}
|
|
|
|
|
2022-12-28 02:27:48 +02:00
|
|
|
func (self *ConfirmationDriver) checkNecessaryChecksCompleted() {
|
2022-12-27 01:50:00 +02:00
|
|
|
if !self.hasCheckedContent || !self.hasCheckedTitle {
|
2022-12-27 12:35:36 +02:00
|
|
|
self.t.Fail("You must both check the content and title of a confirmation popup by calling Title()/Content() before calling Confirm()/Cancel().")
|
2022-12-27 01:50:00 +02:00
|
|
|
}
|
|
|
|
}
|