summaryrefslogtreecommitdiffstats
path: root/pkg/integration/components/popup.go
blob: 46df83e235729c213579156cefa16d68bf476c2b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package components

type Popup struct {
	t *TestDriver
}

func (self *Popup) Confirmation() *ConfirmationDriver {
	self.inConfirm()

	return &ConfirmationDriver{t: self.t}
}

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"
	})
}

func (self *Popup) Prompt() *PromptDriver {
	self.inPrompt()

	return &PromptDriver{t: self.t}
}

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"
	})
}

func (self *Popup) Alert() *AlertDriver {
	self.inAlert()

	return &AlertDriver{t: self.t}
}

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"
	})
}

func (self *Popup) Menu() *MenuDriver {
	self.inMenu()

	return &MenuDriver{t: self.t}
}

func (self *Popup) inMenu() {
	self.t.assertWithRetries(func() (bool, string) {
		return self.t.gui.CurrentContext().GetView().Name() == "menu", "Expected popup menu to be focused"
	})
}

func (self *Popup) CommitMessagePanel() *CommitMessagePanelDriver {
	self.inCommitMessagePanel()

	return &CommitMessagePanelDriver{t: self.t}
}

func (self *Popup) CommitDescriptionPanel() *CommitMessagePanelDriver {
	self.inCommitDescriptionPanel()

	return &CommitMessagePanelDriver{t: self.t}
}

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"
	})
}

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"
	})
}