2022-12-27 01:50:00 +02:00
|
|
|
package components
|
|
|
|
|
|
|
|
type ConfirmationAsserter struct {
|
|
|
|
input *Input
|
|
|
|
hasCheckedTitle bool
|
|
|
|
hasCheckedContent bool
|
|
|
|
}
|
|
|
|
|
2022-12-27 06:56:02 +02:00
|
|
|
func (self *ConfirmationAsserter) getViewAsserter() *View {
|
2022-12-27 07:27:36 +02:00
|
|
|
return self.input.Views().Confirmation()
|
2022-12-27 01:50:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// asserts that the confirmation view has the expected title
|
|
|
|
func (self *ConfirmationAsserter) Title(expected *matcher) *ConfirmationAsserter {
|
|
|
|
self.getViewAsserter().Title(expected)
|
|
|
|
|
|
|
|
self.hasCheckedTitle = true
|
|
|
|
|
|
|
|
return self
|
|
|
|
}
|
|
|
|
|
|
|
|
// asserts that the confirmation view has the expected content
|
|
|
|
func (self *ConfirmationAsserter) Content(expected *matcher) *ConfirmationAsserter {
|
|
|
|
self.getViewAsserter().Content(expected)
|
|
|
|
|
|
|
|
self.hasCheckedContent = true
|
|
|
|
|
|
|
|
return self
|
|
|
|
}
|
|
|
|
|
2022-12-27 02:34:41 +02:00
|
|
|
func (self *ConfirmationAsserter) Confirm() {
|
2022-12-27 01:50:00 +02:00
|
|
|
self.checkNecessaryChecksCompleted()
|
|
|
|
|
2022-12-27 07:27:36 +02:00
|
|
|
self.getViewAsserter().PressEnter()
|
2022-12-27 01:50:00 +02:00
|
|
|
}
|
|
|
|
|
2022-12-27 02:34:41 +02:00
|
|
|
func (self *ConfirmationAsserter) Cancel() {
|
2022-12-27 01:50:00 +02:00
|
|
|
self.checkNecessaryChecksCompleted()
|
|
|
|
|
2022-12-27 07:27:36 +02:00
|
|
|
self.getViewAsserter().PressEscape()
|
2022-12-27 01:50:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (self *ConfirmationAsserter) checkNecessaryChecksCompleted() {
|
|
|
|
if !self.hasCheckedContent || !self.hasCheckedTitle {
|
2022-12-27 07:27:36 +02:00
|
|
|
self.input.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
|
|
|
}
|
|
|
|
}
|