Skip to content

Commit

Permalink
rename from asserter to driver
Browse files Browse the repository at this point in the history
  • Loading branch information
jesseduffield committed Dec 28, 2022
1 parent 534703a commit 14a9747
Show file tree
Hide file tree
Showing 10 changed files with 179 additions and 179 deletions.
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
package components

type AlertAsserter struct {
type AlertDriver struct {
t *TestDriver
hasCheckedTitle bool
hasCheckedContent bool
}

func (self *AlertAsserter) getViewAsserter() *View {
func (self *AlertDriver) getViewDriver() *ViewDriver {
return self.t.Views().Confirmation()
}

// asserts that the alert view has the expected title
func (self *AlertAsserter) Title(expected *matcher) *AlertAsserter {
self.getViewAsserter().Title(expected)
func (self *AlertDriver) Title(expected *matcher) *AlertDriver {
self.getViewDriver().Title(expected)

self.hasCheckedTitle = true

return self
}

// asserts that the alert view has the expected content
func (self *AlertAsserter) Content(expected *matcher) *AlertAsserter {
self.getViewAsserter().Content(expected)
func (self *AlertDriver) Content(expected *matcher) *AlertDriver {
self.getViewDriver().Content(expected)

self.hasCheckedContent = true

return self
}

func (self *AlertAsserter) Confirm() {
func (self *AlertDriver) Confirm() {
self.checkNecessaryChecksCompleted()

self.getViewAsserter().PressEnter()
self.getViewDriver().PressEnter()
}

func (self *AlertAsserter) Cancel() {
func (self *AlertDriver) Cancel() {
self.checkNecessaryChecksCompleted()

self.getViewAsserter().PressEscape()
self.getViewDriver().PressEscape()
}

func (self *AlertAsserter) checkNecessaryChecksCompleted() {
func (self *AlertDriver) checkNecessaryChecksCompleted() {
if !self.hasCheckedContent || !self.hasCheckedTitle {
self.t.Fail("You must both check the content and title of a confirmation popup by calling Title()/Content() before calling Confirm()/Cancel().")
}
Expand Down
40 changes: 0 additions & 40 deletions pkg/integration/components/commit_message_panel_asserter.go

This file was deleted.

40 changes: 40 additions & 0 deletions pkg/integration/components/commit_message_panel_driver.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package components

type CommitMessagePanelDriver struct {
t *TestDriver
}

func (self *CommitMessagePanelDriver) getViewDriver() *ViewDriver {
return self.t.Views().CommitMessage()
}

// asserts on the text initially present in the prompt
func (self *CommitMessagePanelDriver) InitialText(expected *matcher) *CommitMessagePanelDriver {
self.getViewDriver().Content(expected)

return self
}

func (self *CommitMessagePanelDriver) Type(value string) *CommitMessagePanelDriver {
self.t.typeContent(value)

return self
}

func (self *CommitMessagePanelDriver) AddNewline() *CommitMessagePanelDriver {
self.t.press(self.t.keys.Universal.AppendNewline)

return self
}

func (self *CommitMessagePanelDriver) Clear() *CommitMessagePanelDriver {
panic("Clear method not yet implemented!")
}

func (self *CommitMessagePanelDriver) Confirm() {
self.getViewDriver().PressEnter()
}

func (self *CommitMessagePanelDriver) Cancel() {
self.getViewDriver().PressEscape()
}
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
package components

type ConfirmationAsserter struct {
type ConfirmationDriver struct {
t *TestDriver
hasCheckedTitle bool
hasCheckedContent bool
}

func (self *ConfirmationAsserter) getViewAsserter() *View {
func (self *ConfirmationDriver) getViewDriver() *ViewDriver {
return self.t.Views().Confirmation()
}

// asserts that the confirmation view has the expected title
func (self *ConfirmationAsserter) Title(expected *matcher) *ConfirmationAsserter {
self.getViewAsserter().Title(expected)
func (self *ConfirmationDriver) Title(expected *matcher) *ConfirmationDriver {
self.getViewDriver().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)
func (self *ConfirmationDriver) Content(expected *matcher) *ConfirmationDriver {
self.getViewDriver().Content(expected)

self.hasCheckedContent = true

return self
}

func (self *ConfirmationAsserter) Confirm() {
func (self *ConfirmationDriver) Confirm() {
self.checkNecessaryChecksCompleted()

self.getViewAsserter().PressEnter()
self.getViewDriver().PressEnter()
}

func (self *ConfirmationAsserter) Cancel() {
func (self *ConfirmationDriver) Cancel() {
self.checkNecessaryChecksCompleted()

self.getViewAsserter().PressEscape()
self.getViewDriver().PressEscape()
}

func (self *ConfirmationAsserter) checkNecessaryChecksCompleted() {
func (self *ConfirmationDriver) checkNecessaryChecksCompleted() {
if !self.hasCheckedContent || !self.hasCheckedTitle {
self.t.Fail("You must both check the content and title of a confirmation popup by calling Title()/Content() before calling Confirm()/Cancel().")
}
Expand Down
43 changes: 0 additions & 43 deletions pkg/integration/components/menu_asserter.go

This file was deleted.

43 changes: 43 additions & 0 deletions pkg/integration/components/menu_driver.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package components

type MenuDriver struct {
t *TestDriver
hasCheckedTitle bool
}

func (self *MenuDriver) getViewDriver() *ViewDriver {
return self.t.Views().Menu()
}

// asserts that the popup has the expected title
func (self *MenuDriver) Title(expected *matcher) *MenuDriver {
self.getViewDriver().Title(expected)

self.hasCheckedTitle = true

return self
}

func (self *MenuDriver) Confirm() {
self.checkNecessaryChecksCompleted()

self.getViewDriver().PressEnter()
}

func (self *MenuDriver) Cancel() {
self.checkNecessaryChecksCompleted()

self.getViewDriver().PressEscape()
}

func (self *MenuDriver) Select(option *matcher) *MenuDriver {
self.getViewDriver().NavigateToListItem(option)

return self
}

func (self *MenuDriver) checkNecessaryChecksCompleted() {
if !self.hasCheckedTitle {
self.t.Fail("You must check the title of a menu popup by calling Title() before calling Confirm()/Cancel().")
}
}
20 changes: 10 additions & 10 deletions pkg/integration/components/popup.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ type Popup struct {
t *TestDriver
}

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

return &ConfirmationAsserter{t: self.t}
return &ConfirmationDriver{t: self.t}
}

func (self *Popup) inConfirm() {
Expand All @@ -17,10 +17,10 @@ func (self *Popup) inConfirm() {
})
}

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

return &PromptAsserter{t: self.t}
return &PromptDriver{t: self.t}
}

func (self *Popup) inPrompt() {
Expand All @@ -30,10 +30,10 @@ func (self *Popup) inPrompt() {
})
}

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

return &AlertAsserter{t: self.t}
return &AlertDriver{t: self.t}
}

func (self *Popup) inAlert() {
Expand All @@ -44,10 +44,10 @@ func (self *Popup) inAlert() {
})
}

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

return &MenuAsserter{t: self.t}
return &MenuDriver{t: self.t}
}

func (self *Popup) inMenu() {
Expand All @@ -56,10 +56,10 @@ func (self *Popup) inMenu() {
})
}

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

return &CommitMessagePanelAsserter{t: self.t}
return &CommitMessagePanelDriver{t: self.t}
}

func (self *Popup) inCommitMessagePanel() {
Expand Down
Loading

0 comments on commit 14a9747

Please sign in to comment.