From adad456c7808a7cbb81e10e2a861328bd6a068e8 Mon Sep 17 00:00:00 2001 From: Maximiliano Tabacman Date: Tue, 9 Feb 2021 19:46:24 -0300 Subject: [PATCH 1/2] Allowed forced identification of components. --- ...inedWebInteractionInterpreterTest.class.st | 11 ++++--- .../ComponentValueSettingCommandTest.class.st | 11 ++++--- .../Html5ComponentSupplierTest.class.st | 10 +++--- .../TableWebViewTest.class.st | 33 +++++++++++-------- .../WebInteractionInterpreterTest.class.st | 14 ++++---- .../AsynchronicButtonWebView.class.st | 6 ++++ .../BinaryChoiceWebViewBehavior.class.st | 4 +-- source/Willow-Core/CheckboxWebView.class.st | 8 ++++- ...CombinedWebInteractionInterpreter.class.st | 5 ++- .../ComponentValueSettingCommand.class.st | 18 +++------- source/Willow-Core/FieldWebView.class.st | 6 ++++ .../MultipleSelectionListBoxWebView.class.st | 6 ++++ .../SingleSelectionWebView.class.st | 6 ++++ .../SynchronicSubmitButtonWebView.class.st | 6 ++++ source/Willow-Core/TableWebView.class.st | 16 ++++++--- .../Willow-Core/UnorderedListWebView.class.st | 6 ++++ source/Willow-Core/WATagBrush.extension.st | 6 ++++ .../WebInteractionInterpreter.class.st | 15 ++++++--- ...WebInteractionInterpreterBehavior.class.st | 4 +-- 19 files changed, 129 insertions(+), 62 deletions(-) diff --git a/source/Willow-Core-Tests/CombinedWebInteractionInterpreterTest.class.st b/source/Willow-Core-Tests/CombinedWebInteractionInterpreterTest.class.st index 26d106c6..fc5505d7 100644 --- a/source/Willow-Core-Tests/CombinedWebInteractionInterpreterTest.class.st +++ b/source/Willow-Core-Tests/CombinedWebInteractionInterpreterTest.class.st @@ -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 diff --git a/source/Willow-Core-Tests/ComponentValueSettingCommandTest.class.st b/source/Willow-Core-Tests/ComponentValueSettingCommandTest.class.st index 11b8aea0..d18859c0 100644 --- a/source/Willow-Core-Tests/ComponentValueSettingCommandTest.class.st +++ b/source/Willow-Core-Tests/ComponentValueSettingCommandTest.class.st @@ -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' } @@ -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 ) ]. @@ -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 ) ]. diff --git a/source/Willow-Core-Tests/Html5ComponentSupplierTest.class.st b/source/Willow-Core-Tests/Html5ComponentSupplierTest.class.st index f8cc3b1c..62335ac4 100644 --- a/source/Willow-Core-Tests/Html5ComponentSupplierTest.class.st +++ b/source/Willow-Core-Tests/Html5ComponentSupplierTest.class.st @@ -196,7 +196,7 @@ Html5ComponentSupplierTest >> testTableBuilderForHeadlessTable [ self assert: html equals: - '
12
23
34
' + '
12
23
34
' ] { #category : #'tests-Supplying' } @@ -225,7 +225,7 @@ Html5ComponentSupplierTest >> testTableBuilderWithFooter [ self assert: html equals: - '
NumberEven?
1false
2true
3false
Fixed Footer
' + '
NumberEven?
1false
2true
3false
Fixed Footer
' ] { #category : #'tests-Supplying' } @@ -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). @@ -247,7 +247,7 @@ Html5ComponentSupplierTest >> testTableBuilderWithRowCommand [ self assert: html equals: - '
1
2
3
' + '
1
2
3
' ] { #category : #'tests-Supplying' } @@ -275,7 +275,7 @@ Html5ComponentSupplierTest >> testTableBuilderWithSimpleColumns [ self assert: html equals: - '
NumberEven?
1false
2true
3false
' + '
NumberEven?
1false
2true
3false
' ] { #category : #'tests-Supplying' } diff --git a/source/Willow-Core-Tests/TableWebViewTest.class.st b/source/Willow-Core-Tests/TableWebViewTest.class.st index 460bc804..556a3bc9 100644 --- a/source/Willow-Core-Tests/TableWebViewTest.class.st +++ b/source/Willow-Core-Tests/TableWebViewTest.class.st @@ -26,12 +26,14 @@ TableWebViewTest >> testComplexTable [ column rendering: [ :number :index | index ]; applyingToEachCell: [ :cell | cell addClass willow ]; - summarizedWith: [ 'Total' ] ]; + summarizedWith: [ 'Total' ] + ]; addColumn: [ :column | column titled: 'Squared'; rendering: [ :number | number squared ]; - summarizedWith: [ :numbers | (numbers collect: #squared) sum ] ]; + summarizedWith: [ :numbers | ( numbers collect: #squared ) sum ] + ]; applyToEachRow: [ :row | row addClass willow ] asTableRowCommand; build. @@ -41,7 +43,7 @@ TableWebViewTest >> testComplexTable [ self assert: html equals: - '
Squared
11
24
Total5
' + '
Squared
11
24
Total5
' ] { #category : #'tests-container-API' } @@ -70,7 +72,7 @@ TableWebViewTest >> testDefinedByApplyingHeaderRenderedByApplyingToEachRow [ table := TableWebViewBuilder new addColumn: [ :column | column rendering: [ :number | number even ] ]; - applyToEachRow: (PluggableTableRowCommand toExecute: [ :row :item :canvas | row id: canvas nextId ]); + applyToEachRow: ( PluggableTableRowCommand toExecute: [ :row :item :canvas | row id: canvas nextId ] ); buildApplying: [ :theTable | theTable addClass willow ]. table changeContentsTo: #(1 2 3). @@ -79,7 +81,7 @@ TableWebViewTest >> testDefinedByApplyingHeaderRenderedByApplyingToEachRow [ self assert: html equals: - '
false
true
false
' + '
false
true
false
' ] { #category : #'tests-rendering' } @@ -91,12 +93,13 @@ TableWebViewTest >> testHeadedDefinedByApplying [ addColumn: [ :column | column titled: 'Is Even?'; - rendering: [ :number | number even ] ]; + rendering: [ :number | number even ] + ]; build. html := self render: table. - self assert: html equals: '
Is Even?
' + self assert: html equals: '
Is Even?
' ] { #category : #'tests-rendering' } @@ -108,13 +111,17 @@ TableWebViewTest >> testHeadedDefinedByApplyingWithContents [ addColumn: [ :column | column titled: 'Is Even?'; - rendering: [ :number | number even ] ]; + rendering: [ :number | number even ] + ]; build. table changeContentsTo: #(1 2 3). html := self render: table. - self assert: html equals: '
Is Even?
false
true
false
' + self + assert: html + equals: + '
Is Even?
false
true
false
' ] { #category : #'tests-rendering' } @@ -147,7 +154,7 @@ TableWebViewTest >> testRenderContentOn [ html := self render: table. - self assert: html equals: '
' + self assert: html equals: '
' ] { #category : #'tests-rendering' } @@ -165,7 +172,7 @@ TableWebViewTest >> testRenderContentOnWithContents [ self assert: html - equals: '
false
true
false
' + equals: '
false
true
false
' ] { #category : #'tests-rendering' } @@ -185,7 +192,7 @@ TableWebViewTest >> testRenderContentOnWithContentsAndSeveralColumns [ self assert: html equals: - '
falsetrue
truefalse
falsetrue
' + '
falsetrue
truefalse
falsetrue
' ] { #category : #'tests-rendering' } @@ -212,5 +219,5 @@ TableWebViewTest >> testTableWithFooterSupport [ self assert: html equals: - '
Is Even?
1false
2true
3false
Even count1
' + '
Is Even?
1false
2true
3false
Even count1
' ] diff --git a/source/Willow-Core-Tests/WebInteractionInterpreterTest.class.st b/source/Willow-Core-Tests/WebInteractionInterpreterTest.class.st index 34a17ae4..b6cfaf3a 100644 --- a/source/Willow-Core-Tests/WebInteractionInterpreterTest.class.st +++ b/source/Willow-Core-Tests/WebInteractionInterpreterTest.class.st @@ -663,21 +663,23 @@ WebInteractionInterpreterTest >> testSetValueToThenTriggerChangeOf [ ] { #category : #'tests - Configuring - DOM' } -WebInteractionInterpreterTest >> testSetValueToWithoutTriggeringChangeOnComponentWithId [ +WebInteractionInterpreterTest >> testSetValueToWithoutTriggeringChangeOf [ | interpreter html id | interpreter := self clickInterpreter. id := '15'. - interpreter setValueTo: [ 'Ok' ] withoutTriggeringChangeOnComponentWithId: id. html := self - apply: interpreter - toComponentDefinedBy: [ :canvas | - canvas textInput + renderUsing: [ :canvas | + | textInput | + + textInput := canvas textInput id: id; - yourself + yourself. + interpreter setValueTo: [ 'Ok' ] withoutTriggeringChangeOf: textInput. + interpreter applyTo: textInput on: canvas ]. self diff --git a/source/Willow-Core/AsynchronicButtonWebView.class.st b/source/Willow-Core/AsynchronicButtonWebView.class.st index 9675fd70..7fd6a09c 100644 --- a/source/Willow-Core/AsynchronicButtonWebView.class.st +++ b/source/Willow-Core/AsynchronicButtonWebView.class.st @@ -25,6 +25,12 @@ AsynchronicButtonWebView class >> labeled: aLabel applying: aComponentCommand [ ^ self new initializeLabeled: aLabel applying: aComponentCommand asWebComponentCommand ] +{ #category : #configuring } +AsynchronicButtonWebView >> beIdentifiable [ + + ^ identifierAssigner beRequired +] + { #category : #accessing } AsynchronicButtonWebView >> identifierOn: aCanvas [ diff --git a/source/Willow-Core/BinaryChoiceWebViewBehavior.class.st b/source/Willow-Core/BinaryChoiceWebViewBehavior.class.st index 6e536185..9283e796 100644 --- a/source/Willow-Core/BinaryChoiceWebViewBehavior.class.st +++ b/source/Willow-Core/BinaryChoiceWebViewBehavior.class.st @@ -26,13 +26,13 @@ BinaryChoiceWebViewBehavior class >> onModel: anObjectToUseWhenOn offModel: anOb { #category : #'Binary Choice-API' } BinaryChoiceWebViewBehavior >> allows: aModel [ - ^iterator includes: aModel + ^ iterator includes: aModel ] { #category : #'Binary Choice-API' } BinaryChoiceWebViewBehavior >> currentSelection [ - ^iterator current + ^ iterator current ] { #category : #initialization } diff --git a/source/Willow-Core/CheckboxWebView.class.st b/source/Willow-Core/CheckboxWebView.class.st index 32e6d478..40249582 100644 --- a/source/Willow-Core/CheckboxWebView.class.st +++ b/source/Willow-Core/CheckboxWebView.class.st @@ -48,6 +48,12 @@ CheckboxWebView class >> onModel: anObjectToUseWhenOn offModel: anObjectToUseWhe applying: aCommandToComponent ] +{ #category : #configuring } +CheckboxWebView >> beIdentifiable [ + + ^ identifierAssigner beRequired +] + { #category : #accessing } CheckboxWebView >> identifierOn: aCanvas [ @@ -84,7 +90,7 @@ CheckboxWebView >> renderContentOn: aCanvas [ interactionInterpreter applyTo: checkbox on: aCanvas ] -{ #category : #'rendering - private' } +{ #category : #'private - rendering' } CheckboxWebView >> renderOptionalLabelRelatedTo: checkbox on: aCanvas [ labelOptional diff --git a/source/Willow-Core/CombinedWebInteractionInterpreter.class.st b/source/Willow-Core/CombinedWebInteractionInterpreter.class.st index efa18fce..93ec83c3 100644 --- a/source/Willow-Core/CombinedWebInteractionInterpreter.class.st +++ b/source/Willow-Core/CombinedWebInteractionInterpreter.class.st @@ -160,11 +160,10 @@ CombinedWebInteractionInterpreter >> setValueTo: aValueProvider thenTriggerChang ] { #category : #'Configuring - DOM' } -CombinedWebInteractionInterpreter >> setValueTo: aValueProvider withoutTriggeringChangeOnComponentWithId: identifier [ +CombinedWebInteractionInterpreter >> setValueTo: aValueProvider withoutTriggeringChangeOf: aView [ self - interpretersDo: - [ :interpreter | interpreter setValueTo: aValueProvider withoutTriggeringChangeOnComponentWithId: identifier ] + interpretersDo: [ :interpreter | interpreter setValueTo: aValueProvider withoutTriggeringChangeOf: aView ] ] { #category : #Configuring } diff --git a/source/Willow-Core/ComponentValueSettingCommand.class.st b/source/Willow-Core/ComponentValueSettingCommand.class.st index c5074002..1d3b2a26 100644 --- a/source/Willow-Core/ComponentValueSettingCommand.class.st +++ b/source/Willow-Core/ComponentValueSettingCommand.class.st @@ -12,15 +12,6 @@ Class { #category : #'Willow-Core-WebInteraction' } -{ #category : #'instance creation' } -ComponentValueSettingCommand class >> obtainingIdentifierFrom: anIdentifierProvider valueFrom: aValueProvider [ - - ^ self - obtainingIdentifierFrom: aValueProvider - valueFrom: anIdentifierProvider - triggeringAction: [ :jQueryInstance | jQueryInstance ] -] - { #category : #private } ComponentValueSettingCommand class >> obtainingIdentifierFrom: aValueProvider valueFrom: anIdentifierProvider triggeringAction: aTriggeringAction [ @@ -40,14 +31,15 @@ ComponentValueSettingCommand class >> triggeringChangesObtainingIdentifierFrom: ] { #category : #'instance creation' } -ComponentValueSettingCommand class >> triggeringChangesOn: anIdentifiableView withValueFrom: aValueProvider [ +ComponentValueSettingCommand class >> withoutTriggeringChangesObtainingIdentifierFrom: anIdentifierProvider valueFrom: aValueProvider [ ^ self - triggeringChangesObtainingIdentifierFrom: [ :canvas | anIdentifiableView identifierOn: canvas ] - valueFrom: aValueProvider + obtainingIdentifierFrom: aValueProvider + valueFrom: anIdentifierProvider + triggeringAction: [ :jQueryInstance | jQueryInstance ] ] -{ #category : #'initialize-release' } +{ #category : #initialization } ComponentValueSettingCommand >> initializeObtainingIdentifierFrom: anIdentifierProvider valueFrom: aValueProvider triggeringAction: anAction [ identifierProvider := anIdentifierProvider. diff --git a/source/Willow-Core/FieldWebView.class.st b/source/Willow-Core/FieldWebView.class.st index da8e3f2e..539b1b45 100644 --- a/source/Willow-Core/FieldWebView.class.st +++ b/source/Willow-Core/FieldWebView.class.st @@ -30,6 +30,12 @@ FieldWebView class >> forComponentBuiltUsing: aComponentBuilder withInteractionD applying: aComponentCommand asWebComponentCommand ] +{ #category : #configuring } +FieldWebView >> beIdentifiable [ + + ^ identifierAssigner beRequired +] + { #category : #'Container-API' } FieldWebView >> changeContentsTo: aText [ diff --git a/source/Willow-Core/MultipleSelectionListBoxWebView.class.st b/source/Willow-Core/MultipleSelectionListBoxWebView.class.st index cbab8f60..0dd9ba6f 100644 --- a/source/Willow-Core/MultipleSelectionListBoxWebView.class.st +++ b/source/Willow-Core/MultipleSelectionListBoxWebView.class.st @@ -42,6 +42,12 @@ MultipleSelectionListBoxWebView >> allowsAnySatisfying: aMatchBlock [ ^availableElements anySatisfy: aMatchBlock ] +{ #category : #configuring } +MultipleSelectionListBoxWebView >> beIdentifiable [ + + ^ identifierAssigner beRequired +] + { #category : #'Multiple Selection-API' } MultipleSelectionListBoxWebView >> chooseAll [ diff --git a/source/Willow-Core/SingleSelectionWebView.class.st b/source/Willow-Core/SingleSelectionWebView.class.st index 8531aaa6..a06da028 100644 --- a/source/Willow-Core/SingleSelectionWebView.class.st +++ b/source/Willow-Core/SingleSelectionWebView.class.st @@ -43,6 +43,12 @@ SingleSelectionWebView class >> listBoxDisplayingAtOnce: aNumberOfElements apply applyingToOptions: anOptionCommand ] +{ #category : #configuring } +SingleSelectionWebView >> beIdentifiable [ + + ^ identifierAssigner beRequired +] + { #category : #private } SingleSelectionWebView >> configure: select unselectingAllOn: aCanvas [ diff --git a/source/Willow-Core/SynchronicSubmitButtonWebView.class.st b/source/Willow-Core/SynchronicSubmitButtonWebView.class.st index 0d25f22d..62fecf64 100644 --- a/source/Willow-Core/SynchronicSubmitButtonWebView.class.st +++ b/source/Willow-Core/SynchronicSubmitButtonWebView.class.st @@ -23,6 +23,12 @@ SynchronicSubmitButtonWebView class >> labeled: aLabel applying: aComponentComma evaluating: actionOnSubmit ] +{ #category : #configuring } +SynchronicSubmitButtonWebView >> beIdentifiable [ + + ^ identifierAssigner beRequired +] + { #category : #accessing } SynchronicSubmitButtonWebView >> identifierOn: aCanvas [ diff --git a/source/Willow-Core/TableWebView.class.st b/source/Willow-Core/TableWebView.class.st index 63624bc6..a69374fe 100644 --- a/source/Willow-Core/TableWebView.class.st +++ b/source/Willow-Core/TableWebView.class.st @@ -29,6 +29,12 @@ TableWebView class >> definedBy: aColumnRendererCollection applying: aTableComma footerRenderedBy: aFooter ] +{ #category : #configuring } +TableWebView >> beIdentifiable [ + + ^ identifierAssigner beRequired +] + { #category : #'container-API' } TableWebView >> changeContentsTo: anElementCollection [ @@ -85,12 +91,14 @@ TableWebView >> on [ TableWebView >> renderContentOn: aCanvas [ aCanvas table - id: (self identifierOn: aCanvas); + beIdentifiableUsing: identifierAssigner; interactUsing: interactionInterpreter; with: [ aCanvas render: header. - aCanvas tableBody: [ items doWithIndex: [ :item :index | self renderRowAt: index for: item on: aCanvas ] ]. - aCanvas render: footer ] - applying: commandToTable + aCanvas + tableBody: [ items doWithIndex: [ :item :index | self renderRowAt: index for: item on: aCanvas ] ]. + aCanvas render: footer + ] + applying: commandToTable ] { #category : #private } diff --git a/source/Willow-Core/UnorderedListWebView.class.st b/source/Willow-Core/UnorderedListWebView.class.st index 9908585f..22200096 100644 --- a/source/Willow-Core/UnorderedListWebView.class.st +++ b/source/Willow-Core/UnorderedListWebView.class.st @@ -23,6 +23,12 @@ UnorderedListWebView class >> applying: aComponentCommand listing: anElementColl applyingToEach: anElementCommand asWebComponentCommand ] +{ #category : #configuring } +UnorderedListWebView >> beIdentifiable [ + + ^ identifierAssigner beRequired +] + { #category : #accessing } UnorderedListWebView >> identifierOn: aCanvas [ diff --git a/source/Willow-Core/WATagBrush.extension.st b/source/Willow-Core/WATagBrush.extension.st index 0bc3bbf7..792554e2 100644 --- a/source/Willow-Core/WATagBrush.extension.st +++ b/source/Willow-Core/WATagBrush.extension.st @@ -6,6 +6,12 @@ WATagBrush >> apply: aBlockOrComponentCommand [ aBlockOrComponentCommand asWebComponentCommand applyTo: self on: canvas ] +{ #category : #'*Willow-Core' } +WATagBrush >> beIdentifiable [ + + self ensureId +] + { #category : #'*Willow-Core' } WATagBrush >> interactUsing: anInteractionInterpreter [ diff --git a/source/Willow-Core/WebInteractionInterpreter.class.st b/source/Willow-Core/WebInteractionInterpreter.class.st index a551b7db..7e1c1002 100644 --- a/source/Willow-Core/WebInteractionInterpreter.class.st +++ b/source/Willow-Core/WebInteractionInterpreter.class.st @@ -182,18 +182,25 @@ WebInteractionInterpreter >> serverDo: aCallbackBlock [ ] { #category : #'Configuring - DOM' } -WebInteractionInterpreter >> setValueTo: aValueProvider thenTriggerChangeOf: anIdentifiedView [ +WebInteractionInterpreter >> setValueTo: aValueProvider thenTriggerChangeOf: aView [ + aView beIdentifiable. interaction - onTriggerExecute: ( ComponentValueSettingCommand triggeringChangesOn: anIdentifiedView withValueFrom: aValueProvider ) + onTriggerExecute: + ( ComponentValueSettingCommand + triggeringChangesObtainingIdentifierFrom: [ :canvas | aView identifierOn: canvas ] + valueFrom: aValueProvider ) ] { #category : #'Configuring - DOM' } -WebInteractionInterpreter >> setValueTo: aValueProvider withoutTriggeringChangeOnComponentWithId: identifier [ +WebInteractionInterpreter >> setValueTo: aValueProvider withoutTriggeringChangeOf: aView [ + aView beIdentifiable. interaction onTriggerExecute: - ( ComponentValueSettingCommand obtainingIdentifierFrom: [ identifier ] valueFrom: aValueProvider ) + ( ComponentValueSettingCommand + withoutTriggeringChangesObtainingIdentifierFrom: [ :canvas | aView identifierOn: canvas ] + valueFrom: aValueProvider ) ] { #category : #Configuring } diff --git a/source/Willow-Core/WebInteractionInterpreterBehavior.class.st b/source/Willow-Core/WebInteractionInterpreterBehavior.class.st index 4c5cc8c1..ae074bbd 100644 --- a/source/Willow-Core/WebInteractionInterpreterBehavior.class.st +++ b/source/Willow-Core/WebInteractionInterpreterBehavior.class.st @@ -131,13 +131,13 @@ WebInteractionInterpreterBehavior >> serverDo: aCallbackBlock [ ] { #category : #'Configuring - DOM' } -WebInteractionInterpreterBehavior >> setValueTo: aValueProvider thenTriggerChangeOf: anIdentifiedView [ +WebInteractionInterpreterBehavior >> setValueTo: aValueProvider thenTriggerChangeOf: aView [ self subclassResponsibility ] { #category : #'Configuring - DOM' } -WebInteractionInterpreterBehavior >> setValueTo: aValueProviders withoutTriggeringChangeOnComponentWithId: identifier [ +WebInteractionInterpreterBehavior >> setValueTo: aValueProvider withoutTriggeringChangeOf: aView [ self subclassResponsibility ] From b193159834489602288e2a8ac7f7b4ae9cf978f6 Mon Sep 17 00:00:00 2001 From: Maximiliano Tabacman Date: Tue, 9 Feb 2021 23:18:44 -0300 Subject: [PATCH 2/2] Coverage for beIdentifiable --- .../AsynchronicButtonWebViewTest.class.st | 11 ++++++++ .../CheckboxWebViewTest.class.st | 14 ++++++++++ .../DateFieldWebViewTest.class.st | 13 +++++++++ ...ltipleSelectionListBoxWebViewTest.class.st | 19 +++++++++++-- .../NumberFieldWebViewTest.class.st | 13 +++++++++ .../RadioGroupWebViewTest.class.st | 2 +- ...electionWebViewAsDropDownListTest.class.st | 15 +++++++++- ...ngleSelectionWebViewAsListBoxTest.class.st | 15 +++++++++- ...ngleSelectionWebViewBehaviorTest.class.st} | 28 +++++++++---------- ...SynchronicSubmitButtonWebViewTest.class.st | 19 +++++++++++-- .../TableWebViewTest.class.st | 14 ++++++++++ .../TextFieldWebViewTest.class.st | 12 ++++++++ .../TimeFieldWebViewTest.class.st | 23 +++++++++++---- .../UnorderedListWebViewTest.class.st | 20 +++++++++++-- .../ComponentValueSettingCommand.class.st | 10 +++---- 15 files changed, 195 insertions(+), 33 deletions(-) rename source/Willow-Core-Tests/{SingleSelectionWebViewTest.class.st => SingleSelectionWebViewBehaviorTest.class.st} (82%) diff --git a/source/Willow-Core-Tests/AsynchronicButtonWebViewTest.class.st b/source/Willow-Core-Tests/AsynchronicButtonWebViewTest.class.st index a0ef6602..70035281 100644 --- a/source/Willow-Core-Tests/AsynchronicButtonWebViewTest.class.st +++ b/source/Willow-Core-Tests/AsynchronicButtonWebViewTest.class.st @@ -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: '' +] + { #category : #'tests-rendering' } AsynchronicButtonWebViewTest >> testIdentifierOn [ diff --git a/source/Willow-Core-Tests/CheckboxWebViewTest.class.st b/source/Willow-Core-Tests/CheckboxWebViewTest.class.st index 377e7d0c..ff982636 100644 --- a/source/Willow-Core-Tests/CheckboxWebViewTest.class.st +++ b/source/Willow-Core-Tests/CheckboxWebViewTest.class.st @@ -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: '' +] + { #category : #'tests-rendering' } CheckboxWebViewTest >> testIdentifierOn [ diff --git a/source/Willow-Core-Tests/DateFieldWebViewTest.class.st b/source/Willow-Core-Tests/DateFieldWebViewTest.class.st index 592e4407..493640be 100644 --- a/source/Willow-Core-Tests/DateFieldWebViewTest.class.st +++ b/source/Willow-Core-Tests/DateFieldWebViewTest.class.st @@ -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: '' +] + { #category : #tests } DateFieldWebViewTest >> testDate [ diff --git a/source/Willow-Core-Tests/MultipleSelectionListBoxWebViewTest.class.st b/source/Willow-Core-Tests/MultipleSelectionListBoxWebViewTest.class.st index e0df985c..2c6dfad5 100644 --- a/source/Willow-Core-Tests/MultipleSelectionListBoxWebViewTest.class.st +++ b/source/Willow-Core-Tests/MultipleSelectionListBoxWebViewTest.class.st @@ -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: '' +] + { #category : #'tests-Multiple Selection-API' } MultipleSelectionListBoxWebViewTest >> testChooseAll [ @@ -118,7 +133,7 @@ MultipleSelectionListBoxWebViewTest >> testChooseAllMatching [ self assert: listBox currentSelection equals: #(2 4) ] -{ #category : #tests } +{ #category : #'tests-configuring' } MultipleSelectionListBoxWebViewTest >> testIdentifierOn [ | listBox html | @@ -185,7 +200,7 @@ MultipleSelectionListBoxWebViewTest >> testNotifyChangesWhenSelectionDoesNotChan assert: listBox currentSelection isEmpty ] -{ #category : #'tests-rendering' } +{ #category : #'tests-configuring' } MultipleSelectionListBoxWebViewTest >> testOn [ | listBox html | diff --git a/source/Willow-Core-Tests/NumberFieldWebViewTest.class.st b/source/Willow-Core-Tests/NumberFieldWebViewTest.class.st index 42a98b87..94307b68 100644 --- a/source/Willow-Core-Tests/NumberFieldWebViewTest.class.st +++ b/source/Willow-Core-Tests/NumberFieldWebViewTest.class.st @@ -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: '' +] + { #category : #'tests-configuring' } NumberFieldWebViewTest >> testIdentifierOn [ diff --git a/source/Willow-Core-Tests/RadioGroupWebViewTest.class.st b/source/Willow-Core-Tests/RadioGroupWebViewTest.class.st index debd36b9..945c51f6 100644 --- a/source/Willow-Core-Tests/RadioGroupWebViewTest.class.st +++ b/source/Willow-Core-Tests/RadioGroupWebViewTest.class.st @@ -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' } diff --git a/source/Willow-Core-Tests/SingleSelectionWebViewAsDropDownListTest.class.st b/source/Willow-Core-Tests/SingleSelectionWebViewAsDropDownListTest.class.st index f4c80be4..c0b49bea 100644 --- a/source/Willow-Core-Tests/SingleSelectionWebViewAsDropDownListTest.class.st +++ b/source/Willow-Core-Tests/SingleSelectionWebViewAsDropDownListTest.class.st @@ -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' } @@ -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: '' +] + { #category : #'tests-rendering' } SingleSelectionWebViewAsDropDownListTest >> testCustomCommandForOptions [ | dropDownList html | diff --git a/source/Willow-Core-Tests/SingleSelectionWebViewAsListBoxTest.class.st b/source/Willow-Core-Tests/SingleSelectionWebViewAsListBoxTest.class.st index 5dedfbe6..1ed8d829 100644 --- a/source/Willow-Core-Tests/SingleSelectionWebViewAsListBoxTest.class.st +++ b/source/Willow-Core-Tests/SingleSelectionWebViewAsListBoxTest.class.st @@ -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' } @@ -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: '' +] + { #category : #'tests-rendering' } SingleSelectionWebViewAsListBoxTest >> testCustomCommandForOptions [ | dropDownList html | diff --git a/source/Willow-Core-Tests/SingleSelectionWebViewTest.class.st b/source/Willow-Core-Tests/SingleSelectionWebViewBehaviorTest.class.st similarity index 82% rename from source/Willow-Core-Tests/SingleSelectionWebViewTest.class.st rename to source/Willow-Core-Tests/SingleSelectionWebViewBehaviorTest.class.st index 4f38fb68..008c2746 100644 --- a/source/Willow-Core-Tests/SingleSelectionWebViewTest.class.st +++ b/source/Willow-Core-Tests/SingleSelectionWebViewBehaviorTest.class.st @@ -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' @@ -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 | @@ -45,7 +45,7 @@ SingleSelectionWebViewTest >> testAllowsAnySatisfying [ ] { #category : #'tests-Single Selection-API' } -SingleSelectionWebViewTest >> testChooseAny [ +SingleSelectionWebViewBehaviorTest >> testChooseAny [ | singleSelectionView allowedElements | @@ -65,7 +65,7 @@ SingleSelectionWebViewTest >> testChooseAny [ ] { #category : #'tests-Single Selection-API' } -SingleSelectionWebViewTest >> testChooseEqualTo [ +SingleSelectionWebViewBehaviorTest >> testChooseEqualTo [ | singleSelectionView allowedElements | @@ -89,7 +89,7 @@ SingleSelectionWebViewTest >> testChooseEqualTo [ ] { #category : #'tests-Single Selection-API' } -SingleSelectionWebViewTest >> testNotifyChangesTo [ +SingleSelectionWebViewBehaviorTest >> testNotifyChangesTo [ | singleSelectionView | @@ -103,7 +103,7 @@ SingleSelectionWebViewTest >> testNotifyChangesTo [ ] { #category : #'tests-Single Selection-API' } -SingleSelectionWebViewTest >> testNotifyChangesWhenAvailableElementsChangeButContainsTheSelectedOne [ +SingleSelectionWebViewBehaviorTest >> testNotifyChangesWhenAvailableElementsChangeButContainsTheSelectedOne [ | singleSelectionView | @@ -124,7 +124,7 @@ SingleSelectionWebViewTest >> testNotifyChangesWhenAvailableElementsChangeButCon ] { #category : #'tests-Single Selection-API' } -SingleSelectionWebViewTest >> testNotifyChangesWhenAvailableElementsChangeButDoesNotContainTheSelectedOne [ +SingleSelectionWebViewBehaviorTest >> testNotifyChangesWhenAvailableElementsChangeButDoesNotContainTheSelectedOne [ | singleSelectionView | @@ -146,7 +146,7 @@ SingleSelectionWebViewTest >> testNotifyChangesWhenAvailableElementsChangeButDoe ] { #category : #'tests-Single Selection-API' } -SingleSelectionWebViewTest >> testNotifyChangesWhenSelectionChanged [ +SingleSelectionWebViewBehaviorTest >> testNotifyChangesWhenSelectionChanged [ | singleSelectionView | @@ -163,7 +163,7 @@ SingleSelectionWebViewTest >> testNotifyChangesWhenSelectionChanged [ ] { #category : #'tests-Single Selection-API' } -SingleSelectionWebViewTest >> testNotifyChangesWhenSelectionDoesNotChange [ +SingleSelectionWebViewBehaviorTest >> testNotifyChangesWhenSelectionDoesNotChange [ | singleSelectionView | @@ -181,7 +181,7 @@ SingleSelectionWebViewTest >> testNotifyChangesWhenSelectionDoesNotChange [ ] { #category : #'tests-Single Selection-API' } -SingleSelectionWebViewTest >> testWithCurrentSelectionDo [ +SingleSelectionWebViewBehaviorTest >> testWithCurrentSelectionDo [ | singleSelectionView allowedElements | diff --git a/source/Willow-Core-Tests/SynchronicSubmitButtonWebViewTest.class.st b/source/Willow-Core-Tests/SynchronicSubmitButtonWebViewTest.class.st index c0e6efbb..e78f6d13 100644 --- a/source/Willow-Core-Tests/SynchronicSubmitButtonWebViewTest.class.st +++ b/source/Willow-Core-Tests/SynchronicSubmitButtonWebViewTest.class.st @@ -7,7 +7,22 @@ Class { #category : #'Willow-Core-Tests-WebViews' } -{ #category : #tests } +{ #category : #'tests-configuring' } +SynchronicSubmitButtonWebViewTest >> testBeIdentifiable [ + + | synchronicButton html | + + synchronicButton := SynchronicSubmitButtonWebView + labeled: 'Submit' + applying: [ :button | ] + evaluating: [ ]. + synchronicButton beIdentifiable. + html := self render: synchronicButton. + + self assert: html equals: '' +] + +{ #category : #'tests-configuring' } SynchronicSubmitButtonWebViewTest >> testIdentifierOn [ | synchronicButton html | @@ -28,7 +43,7 @@ SynchronicSubmitButtonWebViewTest >> testIdentifierOn [ equals: '' ] -{ #category : #'tests-rendering' } +{ #category : #'tests-configuring' } SynchronicSubmitButtonWebViewTest >> testOn [ | synchronicButton html | diff --git a/source/Willow-Core-Tests/TableWebViewTest.class.st b/source/Willow-Core-Tests/TableWebViewTest.class.st index 556a3bc9..1769ef5f 100644 --- a/source/Willow-Core-Tests/TableWebViewTest.class.st +++ b/source/Willow-Core-Tests/TableWebViewTest.class.st @@ -16,6 +16,20 @@ TableWebViewTest >> changeNotifiedBy: aTableWebView [ notificationWasReceived := true ] +{ #category : #'tests-rendering' } +TableWebViewTest >> testBeIdentifiable [ + + | table html | + + table := TableWebViewBuilder new + addColumn: [ :column | column rendering: [ :number | number even ] ]; + build. + table beIdentifiable. + + html := self render: table. + self assert: html equals: '
' +] + { #category : #'tests-rendering' } TableWebViewTest >> testComplexTable [ diff --git a/source/Willow-Core-Tests/TextFieldWebViewTest.class.st b/source/Willow-Core-Tests/TextFieldWebViewTest.class.st index 581baf43..327b92ff 100644 --- a/source/Willow-Core-Tests/TextFieldWebViewTest.class.st +++ b/source/Willow-Core-Tests/TextFieldWebViewTest.class.st @@ -16,6 +16,18 @@ TextFieldWebViewTest >> changeNotifiedBy: aTextFieldWebView [ notificationWasReceived := true ] +{ #category : #'tests - configuring' } +TextFieldWebViewTest >> testBeIdentifiable [ + + | textField html | + + textField := TextFieldWebView singleLineApplying: [ :field | ]. + textField beIdentifiable. + html := self render: textField. + + self assert: html equals: '' +] + { #category : #'tests - container-API' } TextFieldWebViewTest >> testContents [ diff --git a/source/Willow-Core-Tests/TimeFieldWebViewTest.class.st b/source/Willow-Core-Tests/TimeFieldWebViewTest.class.st index 1992d191..dc358ac6 100644 --- a/source/Willow-Core-Tests/TimeFieldWebViewTest.class.st +++ b/source/Willow-Core-Tests/TimeFieldWebViewTest.class.st @@ -16,7 +16,20 @@ TimeFieldWebViewTest >> changeNotifiedBy: aTextFieldWebView [ notificationWasReceived := true ] -{ #category : #support } +{ #category : #tests } +TimeFieldWebViewTest >> testBeIdentifiable [ + + | timeField html | + + timeField := TimeFieldWebView applying: [ :field | ]. + + timeField beIdentifiable. + html := self render: timeField. + + self assert: html equals: '' +] + +{ #category : #tests } TimeFieldWebViewTest >> testIdentifierOn [ | timeField html | @@ -32,7 +45,7 @@ TimeFieldWebViewTest >> testIdentifierOn [ self assert: html equals: '' ] -{ #category : #support } +{ #category : #tests } TimeFieldWebViewTest >> testNotifyChangesTo [ | timeField | @@ -45,7 +58,7 @@ TimeFieldWebViewTest >> testNotifyChangesTo [ self assert: notificationWasReceived ] -{ #category : #support } +{ #category : #tests } TimeFieldWebViewTest >> testOn [ | timeField html | @@ -61,7 +74,7 @@ TimeFieldWebViewTest >> testOn [ '' ] -{ #category : #support } +{ #category : #tests } TimeFieldWebViewTest >> testRenderContentOn [ | timeField html | @@ -73,7 +86,7 @@ TimeFieldWebViewTest >> testRenderContentOn [ self assert: html equals: '' ] -{ #category : #support } +{ #category : #tests } TimeFieldWebViewTest >> testTime [ | timeField html currentTime | diff --git a/source/Willow-Core-Tests/UnorderedListWebViewTest.class.st b/source/Willow-Core-Tests/UnorderedListWebViewTest.class.st index 5f8a04cc..866cf7b7 100644 --- a/source/Willow-Core-Tests/UnorderedListWebViewTest.class.st +++ b/source/Willow-Core-Tests/UnorderedListWebViewTest.class.st @@ -7,7 +7,23 @@ Class { #category : #'Willow-Core-Tests-WebViews' } -{ #category : #'tests-rendering' } +{ #category : #'tests-configuring' } +UnorderedListWebViewTest >> testBeIdentifiable [ + + | unorderedList html | + + unorderedList := UnorderedListWebView + applying: [ :list | ] + listing: #('spoon' 'fork') + applyingToEach: [ :listItem | ]. + unorderedList beIdentifiable. + + html := self render: unorderedList. + + self assert: html equals: '' +] + +{ #category : #'tests-configuring' } UnorderedListWebViewTest >> testIdentifierOn [ | unorderedList html | @@ -26,7 +42,7 @@ UnorderedListWebViewTest >> testIdentifierOn [ self assert: html equals: '' ] -{ #category : #'tests-rendering' } +{ #category : #'tests-configuring' } UnorderedListWebViewTest >> testOn [ | unorderedList html | diff --git a/source/Willow-Core/ComponentValueSettingCommand.class.st b/source/Willow-Core/ComponentValueSettingCommand.class.st index 1d3b2a26..94e0e524 100644 --- a/source/Willow-Core/ComponentValueSettingCommand.class.st +++ b/source/Willow-Core/ComponentValueSettingCommand.class.st @@ -13,7 +13,7 @@ Class { } { #category : #private } -ComponentValueSettingCommand class >> obtainingIdentifierFrom: aValueProvider valueFrom: anIdentifierProvider triggeringAction: aTriggeringAction [ +ComponentValueSettingCommand class >> obtainingIdentifierFrom: anIdentifierProvider valueFrom: aValueProvider triggeringAction: aTriggeringAction [ ^ self new initializeObtainingIdentifierFrom: anIdentifierProvider @@ -25,8 +25,8 @@ ComponentValueSettingCommand class >> obtainingIdentifierFrom: aValueProvider va ComponentValueSettingCommand class >> triggeringChangesObtainingIdentifierFrom: anIdentifierProvider valueFrom: aValueProvider [ ^ self - obtainingIdentifierFrom: aValueProvider - valueFrom: anIdentifierProvider + obtainingIdentifierFrom: anIdentifierProvider + valueFrom: aValueProvider triggeringAction: [ :jQueryInstance | jQueryInstance trigger: 'change' ] ] @@ -34,8 +34,8 @@ ComponentValueSettingCommand class >> triggeringChangesObtainingIdentifierFrom: ComponentValueSettingCommand class >> withoutTriggeringChangesObtainingIdentifierFrom: anIdentifierProvider valueFrom: aValueProvider [ ^ self - obtainingIdentifierFrom: aValueProvider - valueFrom: anIdentifierProvider + obtainingIdentifierFrom: anIdentifierProvider + valueFrom: aValueProvider triggeringAction: [ :jQueryInstance | jQueryInstance ] ]