2022-12-28 02:00:22 +02:00
|
|
|
package components
|
|
|
|
|
|
|
|
type Popup struct {
|
|
|
|
t *TestDriver
|
|
|
|
}
|
|
|
|
|
2022-12-28 02:27:48 +02:00
|
|
|
func (self *Popup) Confirmation() *ConfirmationDriver {
|
2022-12-28 02:00:22 +02:00
|
|
|
self.inConfirm()
|
|
|
|
|
2022-12-28 02:27:48 +02:00
|
|
|
return &ConfirmationDriver{t: self.t}
|
2022-12-28 02:00:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (self *Popup) inConfirm() {
|
|
|
|
self.t.assertWithRetries(func() (bool, string) {
|
|
|
|
currentView := self.t.gui.CurrentContext().GetView()
|
|
|
|
return currentView.Name() == "confirmation" && !currentView.Editable, "Expected confirmation popup to be focused"
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2022-12-28 02:27:48 +02:00
|
|
|
func (self *Popup) Prompt() *PromptDriver {
|
2022-12-28 02:00:22 +02:00
|
|
|
self.inPrompt()
|
|
|
|
|
2022-12-28 02:27:48 +02:00
|
|
|
return &PromptDriver{t: self.t}
|
2022-12-28 02:00:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (self *Popup) inPrompt() {
|
|
|
|
self.t.assertWithRetries(func() (bool, string) {
|
|
|
|
currentView := self.t.gui.CurrentContext().GetView()
|
|
|
|
return currentView.Name() == "confirmation" && currentView.Editable, "Expected prompt popup to be focused"
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2022-12-28 02:27:48 +02:00
|
|
|
func (self *Popup) Alert() *AlertDriver {
|
2022-12-28 02:00:22 +02:00
|
|
|
self.inAlert()
|
|
|
|
|
2022-12-28 02:27:48 +02:00
|
|
|
return &AlertDriver{t: self.t}
|
2022-12-28 02:00:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (self *Popup) inAlert() {
|
|
|
|
// basically the same thing as a confirmation popup with the current implementation
|
|
|
|
self.t.assertWithRetries(func() (bool, string) {
|
|
|
|
currentView := self.t.gui.CurrentContext().GetView()
|
|
|
|
return currentView.Name() == "confirmation" && !currentView.Editable, "Expected alert popup to be focused"
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2022-12-28 02:27:48 +02:00
|
|
|
func (self *Popup) Menu() *MenuDriver {
|
2022-12-28 02:00:22 +02:00
|
|
|
self.inMenu()
|
|
|
|
|
2022-12-28 02:27:48 +02:00
|
|
|
return &MenuDriver{t: self.t}
|
2022-12-28 02:00:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (self *Popup) inMenu() {
|
|
|
|
self.t.assertWithRetries(func() (bool, string) {
|
|
|
|
return self.t.gui.CurrentContext().GetView().Name() == "menu", "Expected popup menu to be focused"
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2022-12-28 02:27:48 +02:00
|
|
|
func (self *Popup) CommitMessagePanel() *CommitMessagePanelDriver {
|
2022-12-28 02:00:22 +02:00
|
|
|
self.inCommitMessagePanel()
|
|
|
|
|
2022-12-28 02:27:48 +02:00
|
|
|
return &CommitMessagePanelDriver{t: self.t}
|
2022-12-28 02:00:22 +02:00
|
|
|
}
|
|
|
|
|
2023-01-21 13:38:14 +02:00
|
|
|
func (self *Popup) CommitDescriptionPanel() *CommitMessagePanelDriver {
|
|
|
|
self.inCommitDescriptionPanel()
|
|
|
|
|
|
|
|
return &CommitMessagePanelDriver{t: self.t}
|
|
|
|
}
|
|
|
|
|
2022-12-28 02:00:22 +02:00
|
|
|
func (self *Popup) inCommitMessagePanel() {
|
|
|
|
self.t.assertWithRetries(func() (bool, string) {
|
|
|
|
currentView := self.t.gui.CurrentContext().GetView()
|
|
|
|
return currentView.Name() == "commitMessage", "Expected commit message panel to be focused"
|
|
|
|
})
|
|
|
|
}
|
2023-01-21 13:38:14 +02:00
|
|
|
|
|
|
|
func (self *Popup) inCommitDescriptionPanel() {
|
|
|
|
self.t.assertWithRetries(func() (bool, string) {
|
|
|
|
currentView := self.t.gui.CurrentContext().GetView()
|
|
|
|
return currentView.Name() == "commitDescription", "Expected commit description panel to be focused"
|
|
|
|
})
|
|
|
|
}
|