Skip to content

Commit

Permalink
Merge pull request #197 from ba-st/196-improve-value-changing
Browse files Browse the repository at this point in the history
Added beIdentifiable message to input views
  • Loading branch information
mtabacman committed Feb 10, 2021
2 parents a28ead9 + b193159 commit 5e5f22e
Show file tree
Hide file tree
Showing 32 changed files with 321 additions and 92 deletions.
11 changes: 11 additions & 0 deletions source/Willow-Core-Tests/AsynchronicButtonWebViewTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ Class {
#category : #'Willow-Core-Tests-WebViews'
}

{ #category : #'tests-rendering' }
AsynchronicButtonWebViewTest >> testBeIdentifiable [

| button html |

button := AsynchronicButtonWebView labeled: 'Click me!'.
button beIdentifiable.
html := self render: button.
self assert: html equals: '<button id="button-id1" type="button">Click me!</button>'
]

{ #category : #'tests-rendering' }
AsynchronicButtonWebViewTest >> testIdentifierOn [

Expand Down
14 changes: 14 additions & 0 deletions source/Willow-Core-Tests/CheckboxWebViewTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,20 @@ CheckboxWebViewTest >> newBinaryChoiceView [
^ CheckboxWebView onModel: true offModel: false
]

{ #category : #'tests-configuring' }
CheckboxWebViewTest >> testBeIdentifiable [

| html binaryChoiceView |

binaryChoiceView := self newBinaryChoiceView.
binaryChoiceView beIdentifiable.
html := self render: binaryChoiceView.

self
assert: html
equals: '<input checked name="1" id="checkbox-id2" type="checkbox"/><input name="3" type="hidden"/>'
]

{ #category : #'tests-rendering' }
CheckboxWebViewTest >> testIdentifierOn [

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -662,18 +662,19 @@ CombinedWebInteractionInterpreterTest >> testSetValueToThenTriggerChangeOf [
]

{ #category : #'tests - Configuring - DOM' }
CombinedWebInteractionInterpreterTest >> testSetValueToWithoutTriggeringChangeOnComponentWithId [
CombinedWebInteractionInterpreterTest >> testSetValueToWithoutTriggeringChangeOf [

| interpreter html id |

interpreter := self combinedInterpreter.
id := '15'.

interpreter setValueTo: [ 'Ok' ] withoutTriggeringChangeOnComponentWithId: id.

html := self
renderUsing: [ :canvas |
canvas textInput id: id.
| textInput |

textInput := canvas textInput id: id.
interpreter setValueTo: [ 'Ok' ] withoutTriggeringChangeOf: textInput.

canvas
render: okButton;
render: cancelButton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ Class {
ComponentValueSettingCommandTest >> setUp [

super setUp.
command := ComponentValueSettingCommand obtainingIdentifierFrom: [ 'id-12' ] valueFrom: [ '3' ]
command := ComponentValueSettingCommand
withoutTriggeringChangesObtainingIdentifierFrom: [ 'id-12' ]
valueFrom: [ '3' ]
]

{ #category : #'tests-accessing' }
Expand All @@ -29,8 +31,9 @@ ComponentValueSettingCommandTest >> testModelLoadingActionsWithoutSettingPreviou
script := canvas javascript.
input := canvas textInput.

( ComponentValueSettingCommand triggeringChangesOn: input withValueFrom: [ '15' ] )
modelLoadingInstructions appendTo: script on: canvas.
( ComponentValueSettingCommand
triggeringChangesObtainingIdentifierFrom: [ :theCanvas | input identifierOn: theCanvas ]
valueFrom: [ '15' ] ) modelLoadingInstructions appendTo: script on: canvas.
input script: ( canvas jQuery this onClick: script )
].

Expand All @@ -53,7 +56,7 @@ ComponentValueSettingCommandTest >> testModelLoadingActionsWithoutTriggering [
input := canvas textInput.
canvas ensureIdFor: input.
( ComponentValueSettingCommand
obtainingIdentifierFrom: [ input identifierOn: canvas ]
withoutTriggeringChangesObtainingIdentifierFrom: [ input identifierOn: canvas ]
valueFrom: [ '15' ] ) modelLoadingInstructions appendTo: script on: canvas.
input script: ( canvas jQuery this onClick: script )
].
Expand Down
13 changes: 13 additions & 0 deletions source/Willow-Core-Tests/DateFieldWebViewTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@ DateFieldWebViewTest >> changeNotifiedBy: aTextFieldWebView [
notificationWasReceived := true
]

{ #category : #tests }
DateFieldWebViewTest >> testBeIdentifiable [

| dateField html |

dateField := DateFieldWebView applying: [ :field | ].

dateField beIdentifiable.
html := self render: dateField.

self assert: html equals: '<input value="" name="1" id="date-field-id2" type="date"/>'
]

{ #category : #tests }
DateFieldWebViewTest >> testDate [

Expand Down
10 changes: 5 additions & 5 deletions source/Willow-Core-Tests/Html5ComponentSupplierTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ Html5ComponentSupplierTest >> testTableBuilderForHeadlessTable [
self
assert: html
equals:
'<table id="table-id1" class="fixed"><tbody><tr><td>1</td><td>2</td></tr><tr><td>2</td><td>3</td></tr><tr><td>3</td><td>4</td></tr></tbody></table>'
'<table class="fixed"><tbody><tr><td>1</td><td>2</td></tr><tr><td>2</td><td>3</td></tr><tr><td>3</td><td>4</td></tr></tbody></table>'
]

{ #category : #'tests-Supplying' }
Expand Down Expand Up @@ -225,7 +225,7 @@ Html5ComponentSupplierTest >> testTableBuilderWithFooter [
self
assert: html
equals:
'<table id="table-id1"><thead><th>Number</th><th>Even?</th></thead><tbody><tr><td>1</td><td>false</td></tr><tr><td>2</td><td>true</td></tr><tr><td>3</td><td>false</td></tr></tbody><tfoot><td></td><td>Fixed Footer</td></tfoot></table>'
'<table><thead><th>Number</th><th>Even?</th></thead><tbody><tr><td>1</td><td>false</td></tr><tr><td>2</td><td>true</td></tr><tr><td>3</td><td>false</td></tr></tbody><tfoot><td></td><td>Fixed Footer</td></tfoot></table>'
]

{ #category : #'tests-Supplying' }
Expand All @@ -237,7 +237,7 @@ Html5ComponentSupplierTest >> testTableBuilderWithRowCommand [

table := supplier tableBuilder
addColumn: [ :column | column rendering: [ :number | number ] ];
applyToEachRow: (PluggableTableRowCommand toExecute: [ :row :item :canvas | row id: canvas nextId ]);
applyToEachRow: ( PluggableTableRowCommand toExecute: [ :row :item :canvas | row id: canvas nextId ] );
build.

table changeContentsTo: #(1 2 3).
Expand All @@ -247,7 +247,7 @@ Html5ComponentSupplierTest >> testTableBuilderWithRowCommand [
self
assert: html
equals:
'<table id="table-id1"><tbody><tr id="id2"><td>1</td></tr><tr id="id3"><td>2</td></tr><tr id="id4"><td>3</td></tr></tbody></table>'
'<table><tbody><tr id="id1"><td>1</td></tr><tr id="id2"><td>2</td></tr><tr id="id3"><td>3</td></tr></tbody></table>'
]

{ #category : #'tests-Supplying' }
Expand Down Expand Up @@ -275,7 +275,7 @@ Html5ComponentSupplierTest >> testTableBuilderWithSimpleColumns [
self
assert: html
equals:
'<table id="table-id1"><thead><th>Number</th><th>Even?</th></thead><tbody><tr><td>1</td><td>false</td></tr><tr><td>2</td><td>true</td></tr><tr><td>3</td><td>false</td></tr></tbody></table>'
'<table><thead><th>Number</th><th>Even?</th></thead><tbody><tr><td>1</td><td>false</td></tr><tr><td>2</td><td>true</td></tr><tr><td>3</td><td>false</td></tr></tbody></table>'
]

{ #category : #'tests-Supplying' }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,21 @@ MultipleSelectionListBoxWebViewTest >> testAllowsAnySatisfying [
deny: (listBox allowsAnySatisfying: [ :element | element isZero ])
]

{ #category : #'tests-configuring' }
MultipleSelectionListBoxWebViewTest >> testBeIdentifiable [

| listBox html |

listBox := self newListBox.
listBox beIdentifiable.

html := self render: listBox.

self
assert: html
equals: '<select name="1" id="list-box-id2" multiple></select><input name="3" type="hidden"/>'
]

{ #category : #'tests-Multiple Selection-API' }
MultipleSelectionListBoxWebViewTest >> testChooseAll [

Expand Down Expand Up @@ -118,7 +133,7 @@ MultipleSelectionListBoxWebViewTest >> testChooseAllMatching [
self assert: listBox currentSelection equals: #(2 4)
]

{ #category : #tests }
{ #category : #'tests-configuring' }
MultipleSelectionListBoxWebViewTest >> testIdentifierOn [

| listBox html |
Expand Down Expand Up @@ -185,7 +200,7 @@ MultipleSelectionListBoxWebViewTest >> testNotifyChangesWhenSelectionDoesNotChan
assert: listBox currentSelection isEmpty
]

{ #category : #'tests-rendering' }
{ #category : #'tests-configuring' }
MultipleSelectionListBoxWebViewTest >> testOn [

| listBox html |
Expand Down
13 changes: 13 additions & 0 deletions source/Willow-Core-Tests/NumberFieldWebViewTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@ NumberFieldWebViewTest >> changeNotifiedBy: aTextFieldWebView [
notificationWasReceived := true
]

{ #category : #'tests-configuring' }
NumberFieldWebViewTest >> testBeIdentifiable [

| numberField html |

numberField := NumberFieldWebView applying: [ :field | ] transformingWith: IntegerCodec new.

numberField beIdentifiable.
html := self render: numberField.

self assert: html equals: '<input value="" name="1" id="number-field-id2" type="number"/>'
]

{ #category : #'tests-configuring' }
NumberFieldWebViewTest >> testIdentifierOn [

Expand Down
2 changes: 1 addition & 1 deletion source/Willow-Core-Tests/RadioGroupWebViewTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ A RadioGroupWebViewTest is a test class for testing the behavior of RadioGroupWe
"
Class {
#name : #RadioGroupWebViewTest,
#superclass : #SingleSelectionWebViewTest,
#superclass : #SingleSelectionWebViewBehaviorTest,
#category : #'Willow-Core-Tests-WebViews'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ A DropDownListWebViewTest is a test class for testing the behavior of DropDownLi
"
Class {
#name : #SingleSelectionWebViewAsDropDownListTest,
#superclass : #SingleSelectionWebViewTest,
#superclass : #SingleSelectionWebViewBehaviorTest,
#category : #'Willow-Core-Tests-WebViews'
}

Expand All @@ -14,6 +14,19 @@ SingleSelectionWebViewAsDropDownListTest >> newSingleSelectionView [
applyingToOptions: [ ]
]

{ #category : #'tests-configuring' }
SingleSelectionWebViewAsDropDownListTest >> testBeIdentifiable [

| dropDownList html |

dropDownList := self newSingleSelectionView.
dropDownList beIdentifiable.

html := self render: dropDownList.

self assert: html equals: '<select name="1" id="single-select-id2"></select>'
]

{ #category : #'tests-rendering' }
SingleSelectionWebViewAsDropDownListTest >> testCustomCommandForOptions [
| dropDownList html |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ A SingleSelectionListBoxWebViewTest is a test class for testing the behavior of
"
Class {
#name : #SingleSelectionWebViewAsListBoxTest,
#superclass : #SingleSelectionWebViewTest,
#superclass : #SingleSelectionWebViewBehaviorTest,
#category : #'Willow-Core-Tests-WebViews'
}

Expand All @@ -13,6 +13,19 @@ SingleSelectionWebViewAsListBoxTest >> newSingleSelectionView [
^ SingleSelectionWebView listBoxDisplayingAtOnce: 5
]

{ #category : #tests }
SingleSelectionWebViewAsListBoxTest >> testBeIdentifiable [

| listBox html |

listBox := self newSingleSelectionView.
listBox beIdentifiable.

html := self render: listBox.

self assert: html equals: '<select name="1" id="single-select-id2" size="5"></select>'
]

{ #category : #'tests-rendering' }
SingleSelectionWebViewAsListBoxTest >> testCustomCommandForOptions [
| dropDownList html |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
I'm an abstract test case for views implementing the single selection API
"
Class {
#name : #SingleSelectionWebViewTest,
#name : #SingleSelectionWebViewBehaviorTest,
#superclass : #BWRenderingTest,
#instVars : [
'notificationWasReceived'
Expand All @@ -11,25 +11,25 @@ Class {
}

{ #category : #testing }
SingleSelectionWebViewTest class >> isAbstract [
SingleSelectionWebViewBehaviorTest class >> isAbstract [

^self name = #SingleSelectionWebViewTest
^self name = #SingleSelectionWebViewBehaviorTest
]

{ #category : #support }
SingleSelectionWebViewTest >> changeNotifiedBy: aDropDownListWebView [
SingleSelectionWebViewBehaviorTest >> changeNotifiedBy: aDropDownListWebView [

notificationWasReceived := true
]

{ #category : #support }
SingleSelectionWebViewTest >> newSingleSelectionView [
SingleSelectionWebViewBehaviorTest >> newSingleSelectionView [

^self subclassResponsibility
]

{ #category : #'tests-Single Selection-API' }
SingleSelectionWebViewTest >> testAllowsAnySatisfying [
SingleSelectionWebViewBehaviorTest >> testAllowsAnySatisfying [

| singleSelectionView |

Expand All @@ -45,7 +45,7 @@ SingleSelectionWebViewTest >> testAllowsAnySatisfying [
]

{ #category : #'tests-Single Selection-API' }
SingleSelectionWebViewTest >> testChooseAny [
SingleSelectionWebViewBehaviorTest >> testChooseAny [

| singleSelectionView allowedElements |

Expand All @@ -65,7 +65,7 @@ SingleSelectionWebViewTest >> testChooseAny [
]

{ #category : #'tests-Single Selection-API' }
SingleSelectionWebViewTest >> testChooseEqualTo [
SingleSelectionWebViewBehaviorTest >> testChooseEqualTo [

| singleSelectionView allowedElements |

Expand All @@ -89,7 +89,7 @@ SingleSelectionWebViewTest >> testChooseEqualTo [
]

{ #category : #'tests-Single Selection-API' }
SingleSelectionWebViewTest >> testNotifyChangesTo [
SingleSelectionWebViewBehaviorTest >> testNotifyChangesTo [

| singleSelectionView |

Expand All @@ -103,7 +103,7 @@ SingleSelectionWebViewTest >> testNotifyChangesTo [
]

{ #category : #'tests-Single Selection-API' }
SingleSelectionWebViewTest >> testNotifyChangesWhenAvailableElementsChangeButContainsTheSelectedOne [
SingleSelectionWebViewBehaviorTest >> testNotifyChangesWhenAvailableElementsChangeButContainsTheSelectedOne [

| singleSelectionView |

Expand All @@ -124,7 +124,7 @@ SingleSelectionWebViewTest >> testNotifyChangesWhenAvailableElementsChangeButCon
]

{ #category : #'tests-Single Selection-API' }
SingleSelectionWebViewTest >> testNotifyChangesWhenAvailableElementsChangeButDoesNotContainTheSelectedOne [
SingleSelectionWebViewBehaviorTest >> testNotifyChangesWhenAvailableElementsChangeButDoesNotContainTheSelectedOne [

| singleSelectionView |

Expand All @@ -146,7 +146,7 @@ SingleSelectionWebViewTest >> testNotifyChangesWhenAvailableElementsChangeButDoe
]

{ #category : #'tests-Single Selection-API' }
SingleSelectionWebViewTest >> testNotifyChangesWhenSelectionChanged [
SingleSelectionWebViewBehaviorTest >> testNotifyChangesWhenSelectionChanged [

| singleSelectionView |

Expand All @@ -163,7 +163,7 @@ SingleSelectionWebViewTest >> testNotifyChangesWhenSelectionChanged [
]

{ #category : #'tests-Single Selection-API' }
SingleSelectionWebViewTest >> testNotifyChangesWhenSelectionDoesNotChange [
SingleSelectionWebViewBehaviorTest >> testNotifyChangesWhenSelectionDoesNotChange [

| singleSelectionView |

Expand All @@ -181,7 +181,7 @@ SingleSelectionWebViewTest >> testNotifyChangesWhenSelectionDoesNotChange [
]

{ #category : #'tests-Single Selection-API' }
SingleSelectionWebViewTest >> testWithCurrentSelectionDo [
SingleSelectionWebViewBehaviorTest >> testWithCurrentSelectionDo [

| singleSelectionView allowedElements |

Expand Down
Loading

0 comments on commit 5e5f22e

Please sign in to comment.