browsertest

package
v0.31.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 12, 2024 License: MIT Imports: 24 Imported by: 0

Documentation

Overview

Package test contains the test harness, which controls browser based tests. Tests should call RegisterTestFunction to register a particular test. These tests get presented to the user in the test form available at the address "/test", and the user can select a test and execute it. The form is also a repository for operations you can perform on the form being tested. A test generally should start with a call to LoadURL. Follow that with calls to control the form and check for expected results.

Index

Constants

View Source
const (
	TestButtonAction = iota + 1
	TestAllAction
)
View Source
const JsUnitTestFormId = "JsUnitTestForm"
View Source
const JsUnitTestFormPath = "/goradd/test/jsunit.g"
View Source
const StepTimeoutSeconds = 10
View Source
const TestFormId = "TestForm"
View Source
const TestFormPath = "/goradd/Test.g"

Variables

This section is empty.

Functions

func GetTestForm

func GetTestForm() page.FormI

GetTestForm returns the test form itself, if its loaded

func RegisterTestFunction

func RegisterTestFunction(name string, f testRunnerFunction)

RegisterTestFunction registers the test and presents it in the list of tests that can be performed.

func TestMarkerEvent added in v0.12.0

func TestMarkerEvent() *event.Event

func TestStepEvent

func TestStepEvent() *event.Event

Types

type JsUnitForm added in v0.2.0

type JsUnitForm struct {
	FormBase
	Results   *Panel
	RunButton *Button
}

func (*JsUnitForm) AddHeadTags added in v0.2.0

func (ctrl *JsUnitForm) AddHeadTags()

func (*JsUnitForm) AddRelatedFiles added in v0.2.0

func (f *JsUnitForm) AddRelatedFiles()

func (*JsUnitForm) DrawTemplate added in v0.2.0

func (ctrl *JsUnitForm) DrawTemplate(ctx context.Context, _w io.Writer) (err error)

func (*JsUnitForm) Init added in v0.5.0

func (f *JsUnitForm) Init(ctx context.Context, formID string)

type TestController

type TestController struct {
	control.Panel
	// contains filtered or unexported fields
}

func NewTestController

func NewTestController(parent page.ControlI, id string) *TestController

func (*TestController) DoAction added in v0.23.0

func (p *TestController) DoAction(ctx context.Context, a action.Params)

func (*TestController) Init

func (p *TestController) Init(self any, parent page.ControlI, id string)

func (*TestController) UpdateFormValues

func (p *TestController) UpdateFormValues(ctx context.Context)

type TestForm

type TestForm struct {
	FormBase
	Controller *TestController
	// contains filtered or unexported fields
}

func (*TestForm) AddHeadTags

func (ctrl *TestForm) AddHeadTags()

func (*TestForm) AssertEqual

func (form *TestForm) AssertEqual(expected, actual interface{})

AssertEqual will test that the two values are equal, and will error if they are not equal. The test will continue after this.

func (*TestForm) AssertNil added in v0.0.3

func (form *TestForm) AssertNil(v interface{})

func (*TestForm) AssertNotNil added in v0.0.3

func (form *TestForm) AssertNotNil(v interface{})

func (*TestForm) CallControlFunction added in v0.2.0

func (form *TestForm) CallControlFunction(id string, funcName string, params ...interface{}) interface{}

CallControlFunction will call the given function with the given parameters on the goradd object specified by the id. It will return the javascript result of the function call.

func (*TestForm) ChangeVal

func (form *TestForm) ChangeVal(id string, val interface{})

ChangeVal will change the value of a form object. It essentially calls the javascript .val() function on the html object with the given id, followed by sending a change event to the object. This is not quite the same thing as what happens when a user changes a value, as text boxes may send input events, and change is fired on some objects only when losing focus. However, this will simulate changing a value adequately for most situations.

func (*TestForm) CheckGroup added in v0.0.3

func (form *TestForm) CheckGroup(id string, values ...string)

CheckGroup sets the checkbox group to a list of values. Radio groups should only be given one value to check. Will uncheck anything checked in the group before checking the given values. Specify nil to uncheck everything.

func (*TestForm) ChooseListValue added in v0.3.0

func (form *TestForm) ChooseListValue(id string, value string)

func (*TestForm) ChooseListValues added in v0.3.0

func (form *TestForm) ChooseListValues(id string, values ...string)

func (*TestForm) Click

func (form *TestForm) Click(id string)

Click sends a click to the goradd control. Note that the act of clicking often causes an action, and an action will change the form

func (*TestForm) ClickHtmlItem added in v0.0.5

func (form *TestForm) ClickHtmlItem(id string)

func (*TestForm) ClickSubItem added in v0.0.4

func (form *TestForm) ClickSubItem(id string, subId string)

ClickSubItem sends a click to the html object with the given sub-id inside the given control.

func (*TestForm) CloseWindow

func (form *TestForm) CloseWindow()

func (*TestForm) ControlAttribute added in v0.2.0

func (form *TestForm) ControlAttribute(id string, attribute string) interface{}

ControlAttribute will call the .attr("attribute") function on the given html object looking for the given attribute name and will return the value.

func (*TestForm) ControlHasClass added in v0.9.3

func (form *TestForm) ControlHasClass(id string, needle string) bool

ControlHasClass will return true if the given goradd control has the given class attribute

func (*TestForm) ControlInnerHtml added in v0.9.3

func (form *TestForm) ControlInnerHtml(id string) string

ControlInnerHtml will return the inner html drawn by a goradd control

func (*TestForm) ControlValue added in v0.2.0

func (form *TestForm) ControlValue(id string) interface{}

ControlValue will call the .val() function on the given goradd object and return the result.

func (*TestForm) CreateControls added in v0.29.0

func (form *TestForm) CreateControls(ctx context.Context)

func (*TestForm) DoAction added in v0.23.0

func (form *TestForm) DoAction(ctx context.Context, a action.Params)

func (*TestForm) Done

func (form *TestForm) Done(s string)

Done marks the successful end of testing with a message.

func (*TestForm) DrawTemplate

func (ctrl *TestForm) DrawTemplate(ctx context.Context, _w io.Writer) (err error)

func (*TestForm) Error

func (form *TestForm) Error(message string)

Error will cause the test to error, but will continue performing the test.

func (*TestForm) Fatal

func (form *TestForm) Fatal(message string)

Fatal will cause a test to stop with the given messages.

func (*TestForm) Focus

func (form *TestForm) Focus(id string)

func (*TestForm) HtmlElementInfo added in v0.9.3

func (form *TestForm) HtmlElementInfo(selector string, attribute string) string

HtmlElementInfo will return the inner html drawn by a goradd control

func (*TestForm) Init added in v0.5.0

func (form *TestForm) Init(ctx context.Context, formID string)

func (*TestForm) LoadControls

func (form *TestForm) LoadControls(ctx context.Context)

func (*TestForm) LoadUrl

func (form *TestForm) LoadUrl(url string)

LoadUrl will launch a new window controlled by the test form. It will wait for the new url to be loaded in the window, and if the new url contains a goradd form, it will return the form.

func (*TestForm) Log

func (form *TestForm) Log(s string)

Log will send a message to the log. The message might not draw right away.

func (*TestForm) NoSerialize added in v0.3.0

func (form *TestForm) NoSerialize() bool

func (*TestForm) PushRedraw added in v0.3.1

func (form *TestForm) PushRedraw()

func (*TestForm) SetCheckbox added in v0.0.3

func (form *TestForm) SetCheckbox(id string, val bool)

SetCheckbox sets the given checkbox control to the given value. Use this instead of ChangeVal on checkboxes.

func (*TestForm) WaitMarker added in v0.12.0

func (form *TestForm) WaitMarker(expectedMarker string)

WaitMarker waits for a marker event before proceeding. You can use this to signal that your code has reached a specific place. To signal the marker, call FireTestMarker from a control in your application.

func (*TestForm) WaitSubmit added in v0.0.3

func (form *TestForm) WaitSubmit()

func (*TestForm) WithForm added in v0.12.0

func (form *TestForm) WithForm(f func(page.FormI))

WithForm gives you access to the current form so that you can set or get values in the form. Call it with a function that will receive the form. Do not call test functions that might cause an ajax or server call to fire from within the function.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL