Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use wait statements to make the CORS test more reliable #1404

Merged
merged 1 commit into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
helpers
getCORSResultText

(Delay forMilliseconds: 300) wait.
^ self waitUntilNoBPNoSuchElementExceptionIn: [ ((driver findElementByID: 'result') findElementByTagName: 'p') getText ]
Original file line number Diff line number Diff line change
Expand Up @@ -7,49 +7,41 @@ testCORSFilterFunctionalTest

self assert: (driver findElementByID: 'allowed-origins') getText equals: 'None'.
(((driver findElementByID: 'get-requests') findElementsByTagName: 'button') detect: [ :button | button getText = 'Same Origin' ]) click.
(Delay forMilliseconds: 300) wait.
self assert: ((driver findElementByID: 'result') findElementByTagName: 'p') getText equals: 'Success'.
self assert: self getCORSResultText equals: 'Success'.

(((driver findElementByID: 'get-requests') findElementsByTagName: 'button') detect: [ :button | button getText = 'Cross Origin' ]) click.
(Delay forMilliseconds: 300) wait.
self assert: ((driver findElementByID: 'result') findElementByTagName: 'p') getText equals: 'Error'.
self assert: self getCORSResultText equals: 'Error'.

"Now test with cross-origin allowed"
((driver findElementsByTagName: 'button') detect: [ :button | button getText = 'Allow other origin' ]) click.

(((driver findElementByID: 'get-requests') findElementsByTagName: 'button') detect: [ :button | button getText = 'Same Origin' ]) click.
(Delay forMilliseconds: 300) wait.
self assert: ((driver findElementByID: 'result') findElementByTagName: 'p') getText equals: 'Success'.
self assert: self getCORSResultText equals: 'Success'.

(((driver findElementByID: 'get-requests') findElementsByTagName: 'button') detect: [ :button | button getText = 'Cross Origin' ]) click.
(Delay forMilliseconds: 300) wait.
self assert: ((driver findElementByID: 'result') findElementByTagName: 'p') getText equals: 'Success'.
self assert: self getCORSResultText equals: 'Success'.

"the following statement is to circumvent testing issue with the dev toolbar being over the delete buttons"
(driver findElementByID: 'result') moveToElement.
(((driver findElementByID: 'delete-requests') findElementsByTagName: 'button') detect: [ :button | button getText = 'Same Origin' ]) click.
(Delay forMilliseconds: 300) wait.
self assert: ((driver findElementByID: 'result') findElementByTagName: 'p') getText equals: 'Success'.
self assert: self getCORSResultText equals: 'Success'.

"the following statement is to circumvent testing issue with the dev toolbar being over the delete buttons"
(driver findElementByID: 'result') moveToElement.
(((driver findElementByID: 'delete-requests') findElementsByTagName: 'button') detect: [ :button | button getText = 'Cross Origin' ]) click.
(Delay forMilliseconds: 300) wait.
self assert: ((driver findElementByID: 'result') findElementByTagName: 'p') getText equals: 'Error'.
self assert: self getCORSResultText equals: 'Error'.

((driver findElementsByTagName: 'button') detect: [ :button | button getText = 'Allow DELETE' ]) click.

"the following statement is to circumvent testing issue with the dev toolbar being over the delete buttons"
(driver findElementByID: 'result') moveToElement.
(((driver findElementByID: 'delete-requests') findElementsByTagName: 'button')
detect: [ :button | button getText = 'Same Origin' ]) click.
(Delay forMilliseconds: 300) wait.
self assert: ((driver findElementByID: 'result') findElementByTagName: 'p') getText equals: 'Success'.
self assert: self getCORSResultText equals: 'Success'.

"the following statement is to circumvent testing issue with the dev toolbar being over the delete buttons"
(driver findElementByID: 'result') moveToElement.
(((driver findElementByID: 'delete-requests') findElementsByTagName: 'button') detect: [ :button | button getText = 'Cross Origin' ]) click.
(Delay forMilliseconds: 300) wait.
self assert: ((driver findElementByID: 'result') findElementByTagName: 'p') getText equals: 'Success'.
self assert: self getCORSResultText equals: 'Success'.

] ensure: [ WACORSResourceExample unregister; unregisterCorsAdaptor ]
Loading