-
Notifications
You must be signed in to change notification settings - Fork 8
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
Quickstrom #25
Open
marcosh
wants to merge
19
commits into
main
Choose a base branch
from
quickstrom
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Quickstrom #25
Changes from 18 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
8a3e76d
add some ids to identify elements
ab4a5bb
first sketch of specification
214490c
submit should clean form data
85fd45c
provide instructions on how to run Quickstrom
d045325
ignore Quickstrom report
af07461
add more ids and classes to html
70ec8ba
improve selectors and add actions for specification
3bd560a
resent content after addition
4082b38
add actions to add tags and contents
b91f360
add row numbers for contents table
e2201db
start testing with temporal logic
2f3547b
simplify identification of removable tag
9f25ecf
first complete version of acceptance test specification
c9620f1
filters and newTags could not increase due to duplicates
4afd667
avoid showing a new content if it doesn't satisy the filters
aa5798e
improve parameters for running quickstrom
b81b321
provide quickstrom script
d710ffb
improve `elm/README.md`
7c6ea1b
use docker-compose to run quickstrom
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/bin/sh | ||
|
||
cd elm/spec | ||
|
||
sudo rm -rf report | ||
|
||
docker stop webdriver | ||
|
||
docker run --rm -d \ | ||
--name webdriver \ | ||
--network=host \ | ||
-v /dev/shm:/dev/shm \ | ||
-v $PWD:/spec \ | ||
selenium/standalone-chrome:3.141.59-20200826 | ||
|
||
sleep 1 | ||
|
||
docker run --rm \ | ||
--network=host \ | ||
-v $PWD:/spec \ | ||
quickstrom/quickstrom \ | ||
quickstrom check \ | ||
--webdriver-host=webdriver \ | ||
--webdriver-path=/wd/hub \ | ||
--browser=chrome \ | ||
--reporter=html \ | ||
--html-report-directory=/spec/report \ | ||
--tests=10 \ | ||
--max-actions=50 \ | ||
--max-trailing-state-changes=1 \ | ||
--trailing-state-change-timeout=500 \ | ||
/spec/Tagger.spec.purs \ | ||
http://localhost:8000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
elm-stuff | ||
spec/report | ||
index.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
module Tagger where | ||
|
||
import Data.Array as Array | ||
import Data.Maybe | ||
import Data.String.CodeUnits as String | ||
import Data.Symbol | ||
|
||
import Quickstrom | ||
|
||
-- STARTING POINT | ||
|
||
readyWhen :: Selector | ||
readyWhen = "#title" | ||
|
||
-- ACTIONS | ||
|
||
register :: String -> String -> ProbabilisticAction | ||
register username password = | ||
focus "#anonymous #register input.username" | ||
`followedBy` enterText username | ||
`followedBy` focus "#anonymous #register input.password" | ||
`followedBy` enterText password | ||
`followedBy` click "#anonymous #register div.button" | ||
|
||
login :: String -> String -> ProbabilisticAction | ||
login username password = | ||
focus "#anonymous #login input.username" | ||
`followedBy` enterText username | ||
`followedBy` focus "#anonymous #login input.password" | ||
`followedBy` enterText password | ||
`followedBy` click "#anonymous #login div.button" | ||
|
||
filterByTag :: String -> ProbabilisticAction | ||
filterByTag tag = | ||
focus "#logged #filter-by-tag input" | ||
`followedBy` enterText tag | ||
`followedBy` click "#logged #filter-by-tag .button" | ||
|
||
removeTag :: ProbabilisticAction | ||
removeTag = click "#logged .removable .tag .remove" | ||
|
||
addNewTag :: String -> ProbabilisticAction | ||
addNewTag tag = | ||
focus "#logged #new-tag input" | ||
`followedBy` enterText tag | ||
`followedBy` click "#logged #new-tag .button" | ||
|
||
addNewContent :: String -> ProbabilisticAction | ||
addNewContent content = | ||
focus "#logged input#new-content" | ||
`followedBy` enterText content | ||
|
||
submitContent :: ProbabilisticAction | ||
submitContent = click "#logged #add-content > .button" | ||
|
||
actions :: Actions | ||
actions = | ||
[ register "username" "password" | ||
, register "otheruser" "otherpassword" | ||
, login "username" "password" | ||
, login "username" "wrongpassword" | ||
, login "nonexistinguser" "password" | ||
, filterByTag "tag1" | ||
, filterByTag "tag2" | ||
, filterByTag "tag3" | ||
, removeTag | ||
, addNewTag "tag1" | ||
, addNewTag "tag2" | ||
, addNewTag "tag3" | ||
, addNewContent "content1" | ||
, addNewContent "content2" | ||
, addNewContent "content3" | ||
, submitContent | ||
] | ||
|
||
-- MODEL | ||
|
||
type Tag = String | ||
|
||
type Content = {content :: String, tags :: Array Tag} | ||
|
||
-- QUERIES | ||
|
||
contentRow :: Attribute "content-row" | ||
contentRow = attribute (SProxy :: SProxy "content-row") | ||
|
||
extractTags :: String -> Array Tag | ||
extractTags i = map _.textContent (queryAll ("#logged #contents-table [tag-row=\" <> i <> \"]") {textContent}) | ||
|
||
extractContents :: Array Content | ||
extractContents = map | ||
(\r -> {content : r.textContent, tags : extractTags (fromMaybe "" r.contentRow)}) | ||
(queryAll "#logged #contents-table [content-row]" {textContent, contentRow}) | ||
|
||
extractFilters :: Array Tag | ||
extractFilters = map _.textContent (queryAll "#logged #contents #filter-by-tag .tag" {textContent}) | ||
|
||
extractNewContent :: Maybe String | ||
extractNewContent = map _.value (queryOne "#logged #add-content #new-content" {value}) | ||
|
||
extractNewTags :: Array Tag | ||
extractNewTags = map _.textContent (queryAll "#logged #add-content #new-tag .tag" {textContent}) | ||
|
||
-- STATES | ||
|
||
anonymous :: Maybe Unit | ||
anonymous = map (const unit) (queryOne "#anonymous" {}) | ||
|
||
logged :: Maybe {filters :: Array Tag, contents :: Array Content, newContent :: String, newTags :: Array Tag} | ||
logged = queryOne "#logged" {} *> ( | ||
(\filters contents newContent newTags -> {filters : filters, contents : contents, newContent : newContent, newTags : newTags}) | ||
<$> Just extractFilters | ||
<*> Just extractContents | ||
<*> extractNewContent | ||
<*> Just extractNewTags) | ||
|
||
-- ASSERTIONS | ||
|
||
titleIsTagger :: Boolean | ||
titleIsTagger = always (title == Just "Tagger") | ||
where | ||
title = map _.textContent (queryOne "#title" {textContent}) | ||
|
||
isAnonymous :: Boolean | ||
isAnonymous = isJust anonymous | ||
|
||
isLogged :: Boolean | ||
isLogged = isJust logged | ||
|
||
-- TRANSITIONS | ||
|
||
remainAmonymous :: Boolean | ||
remainAmonymous = isAnonymous && next isAnonymous | ||
|
||
logIn :: Boolean | ||
logIn = isAnonymous && next isLogged | ||
|
||
addFilter :: Boolean | ||
addFilter | ||
= Array.length extractFilters <= next (Array.length extractFilters) | ||
&& Array.length extractContents >= next (Array.length extractContents) | ||
&& unchanged extractNewContent | ||
&& unchanged extractNewTags | ||
|
||
fillNewContent :: Boolean | ||
fillNewContent | ||
= map String.length extractNewContent < next (map String.length extractNewContent) | ||
&& unchanged extractFilters | ||
&& unchanged extractContents | ||
&& unchanged extractNewTags | ||
|
||
addNewContentTag :: Boolean | ||
addNewContentTag | ||
= Array.length extractNewTags <= next (Array.length extractNewTags) | ||
&& unchanged extractFilters | ||
&& unchanged extractContents | ||
&& unchanged extractNewContent | ||
|
||
submitNewContent :: Boolean | ||
submitNewContent | ||
= next extractNewContent == Just "" | ||
&& next extractNewTags == [] | ||
&& ((next (Array.length extractContents) == Array.length extractContents + 1) || unchanged (Array.length extractContents)) | ||
&& unchanged extractFilters | ||
|
||
-- INVARIANTS | ||
|
||
proposition :: Boolean | ||
proposition | ||
= titleIsTagger | ||
&& isAnonymous | ||
&& always | ||
( remainAmonymous | ||
|| logIn | ||
|| addFilter | ||
|| fillNewContent | ||
|| addNewContentTag | ||
|| submitNewContent | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a good reason to be running in host networking mode instead of
-p 4444:4444
?I think host networking doesn't work on Mac.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see, it allows the second docker container to connect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
otherwise I guess we need a
docker-compose.yml
and a dedicated network. I just copied these from thequickstrom
documentation