Skip to content

Commit

Permalink
Fixed tests that were affected by Seaside escaping /
Browse files Browse the repository at this point in the history
  • Loading branch information
mtabacman committed Jul 1, 2024
1 parent 91d317b commit 96f558a
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -697,14 +697,14 @@ CombinedWebInteractionInterpreterTest >> testShowLoadingNotificationDisplayingAp
showLoadingNotificationDisplaying: 'Loading...'
applying: [ :view | view addClass willow ].
html := self renderUsing: [ :canvas |
canvas
render: okButton;
render: cancelButton
canvas
render: okButton;
render: cancelButton
].
self
assert: html
equals:
'<button id="button-id2" type="button">Ok</button><button id="button-id4" type="button">Cancel</button><script type="text/javascript">$("#button-id2").click(function(event){$("#willow-notification-section").html("<div class=\"willow\">Loading...</div>");Willow.callServer({"complete":function(){$("#willow-notification-section").html("")},"url":"/","data":"1"})});$("#button-id4").click(function(event){$("#willow-notification-section").html("<div class=\"willow\">Loading...</div>");Willow.callServer({"complete":function(){$("#willow-notification-section").html("")},"url":"/","data":"3"})});</script>'
'<button id="button-id2" type="button">Ok</button><button id="button-id4" type="button">Cancel</button><script type="text/javascript">$("#button-id2").click(function(event){$("#willow-notification-section").html("<div class=\"willow\">Loading...<\/div>");Willow.callServer({"complete":function(){$("#willow-notification-section").html("")},"url":"/","data":"1"})});$("#button-id4").click(function(event){$("#willow-notification-section").html("<div class=\"willow\">Loading...<\/div>");Willow.callServer({"complete":function(){$("#willow-notification-section").html("")},"url":"/","data":"3"})});</script>'
]

{ #category : 'tests - Configuring - DOM' }
Expand All @@ -714,17 +714,16 @@ CombinedWebInteractionInterpreterTest >> testShowLoadingNotificationStyledAsAll

interpreter := self combinedInterpreter.

interpreter showLoadingNotificationStyledAsAll: #().
html := self
renderUsing: [ :canvas |
canvas
render: okButton;
render: cancelButton
].
interpreter showLoadingNotificationStyledAsAll: #( ).
html := self renderUsing: [ :canvas |
canvas
render: okButton;
render: cancelButton
].
self
assert: html
equals:
'<button id="button-id2" type="button">Ok</button><button id="button-id4" type="button">Cancel</button><script type="text/javascript">$("#button-id2").click(function(event){$("#willow-notification-section").html("<div>Loading...</div>");Willow.callServer({"complete":function(){$("#willow-notification-section").html("")},"url":"/","data":"1"})});$("#button-id4").click(function(event){$("#willow-notification-section").html("<div>Loading...</div>");Willow.callServer({"complete":function(){$("#willow-notification-section").html("")},"url":"/","data":"3"})});</script>'
'<button id="button-id2" type="button">Ok</button><button id="button-id4" type="button">Cancel</button><script type="text/javascript">$("#button-id2").click(function(event){$("#willow-notification-section").html("<div>Loading...<\/div>");Willow.callServer({"complete":function(){$("#willow-notification-section").html("")},"url":"/","data":"1"})});$("#button-id4").click(function(event){$("#willow-notification-section").html("<div>Loading...<\/div>");Willow.callServer({"complete":function(){$("#willow-notification-section").html("")},"url":"/","data":"3"})});</script>'
]

{ #category : 'tests - Configuring - DOM' }
Expand Down
19 changes: 9 additions & 10 deletions source/Willow-Core-Tests/DialogOpeningCommandTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,20 @@ DialogOpeningCommandTest >> testModelLoadingInstructions [

| html |

html := self
renderUsing: [ :canvas |
| script anchor |
html := self renderUsing: [ :canvas |
| script anchor |

script := canvas javascript.
anchor := canvas anchor.
canvas ensureIdFor: anchor.
command modelLoadingInstructions appendTo: script on: canvas.
anchor script: ( canvas jQuery this onClick: script )
].
script := canvas javascript.
anchor := canvas anchor.
canvas ensureIdFor: anchor.
command modelLoadingInstructions appendTo: script on: canvas.
anchor script: ( canvas jQuery this onClick: script )
].

self
assert: html
equals:
'<a id="a-id1"></a><script type="text/javascript">$("#a-id1").click(function(){$("#willow-dialog-section").append("<dialog open></dialog>")});</script>'
'<a id="a-id1"></a><script type="text/javascript">$("#a-id1").click(function(){$("#willow-dialog-section").append("<dialog open><\/dialog>")});</script>'
]

{ #category : 'tests-accessing' }
Expand Down
20 changes: 12 additions & 8 deletions source/Willow-Core-Tests/LoadingNotificationCommandTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -49,28 +49,32 @@ LoadingNotificationCommandTest >> testModelLoadingInstructions [
LoadingNotificationCommandTest >> testPriorityActions [

| command html |
command := LoadingNotificationCommand onPageTopWithClasses: #().

command := LoadingNotificationCommand onPageTopWithClasses: #( ).

html := self renderedContentUsingPriorityActionsOf: command.

self
assert: html
equals: '<a id="a-id1"></a><script type="text/javascript">$("#a-id1").click(function(){$("#willow-notification-section").html("<div>Loading...</div>");$.ajax({"complete":function(){$("#willow-notification-section").html("")}})});</script>'
equals:
'<a id="a-id1"></a><script type="text/javascript">$("#a-id1").click(function(){$("#willow-notification-section").html("<div>Loading...<\/div>");$.ajax({"complete":function(){$("#willow-notification-section").html("")}})});</script>'
]

{ #category : 'tests-accessing' }
LoadingNotificationCommandTest >> testPriorityActionsWithCustomView [

| command html |

command := LoadingNotificationCommand displaying: [ :canvas | canvas span: 'Processing...' ] applying: [ :div | div addClass loading ].


command := LoadingNotificationCommand
displaying: [ :canvas | canvas span: 'Processing...' ]
applying: [ :div | div addClass loading ].

html := self renderedContentUsingPriorityActionsOf: command.

self
assert: html
equals: '<a id="a-id1"></a><script type="text/javascript">$("#a-id1").click(function(){$("#willow-notification-section").html("<div class=\"willow-loading\"><span>Processing...</span></div>");$.ajax({"complete":function(){$("#willow-notification-section").html("")}})});</script>'
equals:
'<a id="a-id1"></a><script type="text/javascript">$("#a-id1").click(function(){$("#willow-notification-section").html("<div class=\"willow-loading\"><span>Processing...<\/span><\/div>");$.ajax({"complete":function(){$("#willow-notification-section").html("")}})});</script>'
]

{ #category : 'tests-testing' }
Expand Down
20 changes: 11 additions & 9 deletions source/Willow-Core-Tests/PeriodicallyRenderedWebViewTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,21 @@ PeriodicallyRenderedWebViewTest >> testScriptToRefreshAndRenderContentOn [

counter := 0.
periodicallyRenderedView := PeriodicallyRenderedWebView
evaluating: [ counter := counter + 1 ]
every: 500
millisecondsThenRendering: [ :canvas |
canvas
render: 'Count: ';
render: counter;
break ].
evaluating: [ counter := counter + 1 ]
every: 500
millisecondsThenRendering: [ :canvas |
canvas
render: 'Count: ';
render: counter;
break
].

self render: periodicallyRenderedView.
"This is kind of hacky but there's no other way to test it without a proper AJAX call"
html := self renderUsing: [ :canvas | canvas div script: (periodicallyRenderedView scriptToRefreshAndRenderContentOn: canvas) ].
html := self renderUsing: [ :canvas |
canvas div script: ( periodicallyRenderedView scriptToRefreshAndRenderContentOn: canvas ) ].
self
assert: html
equals:
'<div id="id3"></div><script type="text/javascript">$("#id3").html("Count: 2<br/><script type=\"text/javascript\">$.ajax({\"url\":\"/\",\"data\":\"2\"});</script>");</script>'
'<div id="id3"></div><script type="text/javascript">$("#id3").html("Count: 2<br/><script type=\"text/javascript\">$.ajax({\"url\":\"/\",\"data\":\"2\"});<\/script>");</script>'
]
17 changes: 8 additions & 9 deletions source/Willow-Core-Tests/RenderingCommandTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,19 @@ RenderingCommandTest >> testModelLoadingInstructions [

| html |

html := self
renderUsing: [ :canvas |
| script |
html := self renderUsing: [ :canvas |
| script |

script := canvas javascript.
identifiedView identifierOn: canvas.
command modelLoadingInstructions appendTo: script on: canvas.
canvas anchor script: ( canvas jQuery this onClick: script )
].
script := canvas javascript.
identifiedView identifierOn: canvas.
command modelLoadingInstructions appendTo: script on: canvas.
canvas anchor script: ( canvas jQuery this onClick: script )
].

self
assert: html
equals:
'<a id="id3"></a><script type="text/javascript">$("#id3").click(function(){$("#container-id1").html("<span>Test</span>")});</script>'
'<a id="id3"></a><script type="text/javascript">$("#id3").click(function(){$("#container-id1").html("<span>Test<\/span>")});</script>'
]

{ #category : 'tests-accessing' }
Expand Down
23 changes: 11 additions & 12 deletions source/Willow-Core-Tests/TemporarilyDisablingCommandTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,22 @@ TemporarilyDisablingCommandTest >> testPriorityActions [

| command html |

command := TemporarilyDisablingCommand
transformingCurrentViewInto: [ :canvas | canvas span apply: [ :span | span addClass loading ] ].
html := self
renderUsing: [ :canvas |
| asynchronousCall anchor |
command := TemporarilyDisablingCommand transformingCurrentViewInto: [ :canvas |
canvas span apply: [ :span | span addClass loading ] ].
html := self renderUsing: [ :canvas |
| asynchronousCall anchor |

asynchronousCall := canvas jQuery ajax.
command priorityActions do: [ :action | action value: asynchronousCall value: canvas ].
anchor := canvas anchor.
canvas ensureIdFor: anchor.
anchor script: ( canvas jQuery this onClick: asynchronousCall )
].
asynchronousCall := canvas jQuery ajax.
command priorityActions do: [ :action | action value: asynchronousCall value: canvas ].
anchor := canvas anchor.
canvas ensureIdFor: anchor.
anchor script: ( canvas jQuery this onClick: asynchronousCall )
].

self
assert: html
equals:
'<a id="a-id1"></a><script type="text/javascript">$("#a-id1").click(function(){if(componentToDisable.attr("data-willow-events-disabled")!=="disabled"){componentToDisable.attr("data-willow-events-disabled","disabled").addClass("willow-disabled-component").attr("data-original-html",componentToDisable.html()).attr("disabled",true).html("<span class=\"willow-loading\"></span>");$.ajax({"complete":function(){componentToDisable.removeAttr("data-willow-events-disabled").attr("disabled",false).removeClass("willow-disabled-component").html(componentToDisable.attr("data-original-html"))}})}});</script>'
'<a id="a-id1"></a><script type="text/javascript">$("#a-id1").click(function(){if(componentToDisable.attr("data-willow-events-disabled")!=="disabled"){componentToDisable.attr("data-willow-events-disabled","disabled").addClass("willow-disabled-component").attr("data-original-html",componentToDisable.html()).attr("disabled",true).html("<span class=\"willow-loading\"><\/span>");$.ajax({"complete":function(){componentToDisable.removeAttr("data-willow-events-disabled").attr("disabled",false).removeClass("willow-disabled-component").html(componentToDisable.attr("data-original-html"))}})}});</script>'
]

{ #category : 'tests-testing' }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ WebInteractionInterpreterTest >> testShowLoadingNotificationDisplayingApplying [
self
assert: html
equals:
'<input id="input-id2" type="text"/><script type="text/javascript">$("#input-id2").change(function(event){$("#willow-notification-section").html("<div class=\"willow\">Loading...</div>");Willow.callServer({"complete":function(){$("#willow-notification-section").html("")},"url":"/","data":"1"})});</script>'
'<input id="input-id2" type="text"/><script type="text/javascript">$("#input-id2").change(function(event){$("#willow-notification-section").html("<div class=\"willow\">Loading...<\/div>");Willow.callServer({"complete":function(){$("#willow-notification-section").html("")},"url":"/","data":"1"})});</script>'
]

{ #category : 'tests - Configuring - DOM' }
Expand All @@ -769,7 +769,7 @@ WebInteractionInterpreterTest >> testShowLoadingNotificationStyledAsAll [
self
assert: html
equals:
'<input id="input-id2" type="text"/><script type="text/javascript">$("#input-id2").change(function(event){$("#willow-notification-section").html("<div class=\"willow\">Loading...</div>");Willow.callServer({"complete":function(){$("#willow-notification-section").html("")},"url":"/","data":"1"})});</script>'
'<input id="input-id2" type="text"/><script type="text/javascript">$("#input-id2").change(function(event){$("#willow-notification-section").html("<div class=\"willow\">Loading...<\/div>");Willow.callServer({"complete":function(){$("#willow-notification-section").html("")},"url":"/","data":"1"})});</script>'
]

{ #category : 'tests - Configuring - DOM' }
Expand Down

0 comments on commit 96f558a

Please sign in to comment.