22 scroll,
33 click,
44 type,
5+ fake,
56 replace,
67 open,
78 waitForResults,
@@ -20,7 +21,18 @@ const {
2021 elBorder,
2122} = require ( './cypressFunctions' ) ;
2223
24+ const faker = require ( 'faker' ) ;
25+ const changeCase = require ( 'change-case' ) ;
26+
2327const REGEX = require ( '../common/regex' ) ;
28+ const regexBuilder = require ( '../common/regexBuilder' ) ;
29+ const {
30+ r,
31+ string,
32+ int,
33+ elInEl,
34+ page,
35+ } = regexBuilder ;
2436
2537module . exports = ( ) => {
2638 // ex: I scroll to the bottom the "Modal"
@@ -38,6 +50,210 @@ module.exports = () => {
3850 // I type "toli" into the "Username Input" on the "SignIn form"
3951 When ( REGEX . TYPE , type ) ;
4052
53+
54+ // When I type a fake internet email as "email" in the "Username Field" in the "Register Form"
55+ // And I click "Submit" in the "Register Form"
56+ // And I re-type the "email" in the "Username Field" in the "Login Form"
57+ // And I click "Submit" in the "Login Form"
58+ // Then I should be redirected to the "Home Page"
59+ // And I should see "someelement" containing "email"
60+ // ex: I type a fake internet username as "userName" into the "Username Input"
61+ // I re-type "userName" into "Username"
62+ // When(REGEX.FAKE, fake);
63+
64+ // most faker methods
65+ let fakerCategories = {
66+ "address" : [
67+ "cardinalDirection" ,
68+ "city" ,
69+ "cityPrefix" ,
70+ "citySuffix" ,
71+ "country" ,
72+ "countryCode" ,
73+ "county" ,
74+ "direction" ,
75+ "latitude" ,
76+ "longitude" ,
77+ // "nearbyGPSCoordinate", requires comparsion cords
78+ "ordinalDirection" ,
79+ "secondaryAddress" ,
80+ "state" ,
81+ "stateAbbr" ,
82+ "streetAddress" ,
83+ "streetName" ,
84+ "streetPrefix" ,
85+ "streetSuffix" ,
86+ "zipCode" ,
87+ "zipCodeByState"
88+ ] ,
89+ "commerce" : [
90+ "department" ,
91+ "price" ,
92+ "product" ,
93+ "productAdjective" ,
94+ "productMaterial" ,
95+ "productName"
96+ ] ,
97+ "company" : [
98+ "bs" ,
99+ "bsAdjective" ,
100+ "bsBuzz" ,
101+ "bsNoun" ,
102+ "catchPhrase" ,
103+ "catchPhraseAdjective" ,
104+ "catchPhraseDescriptor" ,
105+ "catchPhraseNoun" ,
106+ "companyName" ,
107+ "companySuffix" ,
108+ "suffixes"
109+ ] ,
110+ "database" : [
111+ "collation" ,
112+ "column" ,
113+ "engine" ,
114+ "type"
115+ ] ,
116+ "date" : [
117+ // "between", ƒ (from, to), needs params
118+ "future" ,
119+ "month" ,
120+ "past" ,
121+ "recent" ,
122+ "soon" ,
123+ "weekday"
124+ ] ,
125+ "finance" : [
126+ "account" ,
127+ "accountName" ,
128+ "amount" ,
129+ "bic" ,
130+ "bitcoinAddress" ,
131+ "creditCardCVV" ,
132+ "creditCardNumber" ,
133+ "currencyCode" ,
134+ "currencyName" ,
135+ "currencySymbol" ,
136+ "ethereumAddress" ,
137+ "iban" ,
138+ "mask" ,
139+ "routingNumber" ,
140+ "transactionType"
141+ ] ,
142+ "git" : [
143+ "branch" ,
144+ "commitEntry" ,
145+ "commitMessage" ,
146+ "commitSha" ,
147+ "shortSha"
148+ ] ,
149+ "hacker" : [
150+ "abbreviation" ,
151+ "adjective" ,
152+ "ingverb" ,
153+ "noun" ,
154+ "phrase" ,
155+ "verb"
156+ ] ,
157+ // "helpers", these aren't usable
158+ // "A fake image"
159+ // "A fake image of <keyword> [with a size of <width> by <height>]"
160+ // "A fake data uri" // [[height, width], color]
161+ // // "A fake data uri of <green> with a size of <width> by <height>"
162+ // "A fake image url"
163+ // "image": [
164+ // ]
165+ "internet" : [
166+ "domainName" ,
167+ "domainSuffix" ,
168+ "domainWord" ,
169+ "email" ,
170+ "exampleEmail" ,
171+ "ip" ,
172+ "ipv6" ,
173+ "mac" ,
174+ "password" ,
175+ "protocol" ,
176+ "url" ,
177+ "userAgent" ,
178+ "userName"
179+ ] ,
180+ "lorem" : [
181+ "lines" ,
182+ "paragraph" ,
183+ "paragraphs" ,
184+ "sentence" ,
185+ "sentences" ,
186+ "slug" ,
187+ "text" ,
188+ "word" ,
189+ "words"
190+ ] ,
191+ "name" : [
192+ // "findName",
193+ "firstName" ,
194+ "gender" ,
195+ "jobArea" ,
196+ "jobDescriptor" ,
197+ "jobTitle" ,
198+ "jobType" ,
199+ "lastName" ,
200+ "prefix" ,
201+ "suffix" ,
202+ "title"
203+ ] ,
204+ "phone" : [
205+ "phoneFormats" ,
206+ "phoneNumber"
207+ ] ,
208+ "random" : [
209+ "alpha" ,
210+ "alphaNumeric" ,
211+ "arrayElement" ,
212+ "arrayElements" ,
213+ "boolean" ,
214+ "float" ,
215+ "hexaDecimal" ,
216+ // "image", same as image
217+ "locale" ,
218+ "number" ,
219+ // "objectElement", selects property from object
220+ "uuid" ,
221+ "word" ,
222+ "words"
223+ ] ,
224+ "system" : [
225+ "commonFileExt" ,
226+ "commonFileName" ,
227+ "commonFileType" ,
228+ "directoryPath" ,
229+ "fileExt" ,
230+ "fileName" ,
231+ "filePath" ,
232+ "fileType" ,
233+ "mimeType" ,
234+ "semver"
235+ ] ,
236+ "vehicle" : [
237+ "fuel" ,
238+ "manufacturer" ,
239+ "model" ,
240+ "type" ,
241+ "vehicle" ,
242+ "vin"
243+ ]
244+ } ;
245+
246+ Object . keys ( fakerCategories ) . forEach ( function ( category ) {
247+
248+ fakerCategories [ category ] . forEach ( function ( categoryKey ) {
249+ let categoryKeyName = changeCase . capitalCase ( categoryKey ) ;
250+
251+ When ( r ( `I type a fake (?:a|an)?\\s?${ categoryKeyName } as ${ string } ${ elInEl } ` ) , function ( asName , input , parent ) {
252+ fake ( asName , faker [ category ] [ categoryKey ] ( ) , input , parent )
253+ } ) ;
254+ } ) ;
255+ } ) ;
256+
41257 // ex: When I replace the contents of "Username" with "toli"
42258 // When I replace the contents of "Username" inside of the "Login Modal" with "toli"
43259 When ( REGEX . REPLACE , replace ) ;
@@ -56,6 +272,8 @@ module.exports = () => {
56272 // This is experimental and not part of the official API
57273 When ( REGEX . DRAG_ABOVE , dragAbove ) ;
58274
275+
276+
59277 Then ( REGEX . COMPARE_SNAPSHOT , compareSnapshot ) ;
60278 Then ( REGEX . COMPARE_EL_SNAPSHOT , compareElSnapshot ) ;
61279 Then ( REGEX . COMPARE_SNAPSHOT_NAMED , compareNamedSnapshot )
0 commit comments