Skip to content

Commit

Permalink
Extra utility methods to test web apps
Browse files Browse the repository at this point in the history
  • Loading branch information
bouraqadi committed Feb 25, 2024
1 parent 19c1984 commit cb6d72c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
24 changes: 24 additions & 0 deletions Pharo/PharoJs-TestFramework/PjTWebAppTestCase.trait.st
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ Trait {
#category : #'PharoJs-TestFramework-Kernel'
}

{ #category : #asserting }
PjTWebAppTestCase >> assertHidden: element [

self waitUntil: [(self computedDisplayStyleOf: element) = 'none']
]

{ #category : #asserting }
PjTWebAppTestCase >> assertInnerHtmlOfElement: domElement equals: expectedValue [
self assert: domElement innerHTML equals: expectedValue
Expand All @@ -16,6 +22,12 @@ PjTWebAppTestCase >> assertInnerHtmlOfElementById: id equals: expectedValue [
equals: expectedValue
]

{ #category : #asserting }
PjTWebAppTestCase >> assertShowing: element [

self waitWhile: [ (self computedDisplayStyleOf: element) = 'none' ]
]

{ #category : #asserting }
PjTWebAppTestCase >> assertValueOfElement: domElement equals: expectedValue [
self assert: domElement value equals: expectedValue
Expand Down Expand Up @@ -52,6 +64,12 @@ PjTWebAppTestCase >> clickElementById: aString [
self clickElement: (self document getElementById: aString)
]

{ #category : #'UI handling' }
PjTWebAppTestCase >> computedDisplayStyleOf: element [

^ (self window getComputedStyle: element) display
]

{ #category : #'UI handling' }
PjTWebAppTestCase >> dispatchEvent: eventName to: htmlElement [
htmlElement dispatchEvent: (self newEvent: eventName)
Expand All @@ -70,3 +88,9 @@ PjTWebAppTestCase >> newEvent: eventName [
event initEvent: eventName with: true with: true.
^ event
]

{ #category : #accessing }
PjTWebAppTestCase >> window [

self explicitRequirement
]
6 changes: 6 additions & 0 deletions Pharo/PharoJs-TestFramework/PjWebAppTestCase.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@ Class {
PjWebAppTestCase >> document [
^document
]

{ #category : #accessing }
PjWebAppTestCase >> window [

^window
]

0 comments on commit cb6d72c

Please sign in to comment.