99} = require ( './constants' ) ;
1010
1111function login ( user ) {
12- console . log ( '[login] START user=' , user ? 'yes' : 'no' , 'netlifySiteURL=' , user ?. netlifySiteURL || 'none' ) ;
12+ console . log (
13+ '[login] START user=' ,
14+ user ? 'yes' : 'no' ,
15+ 'netlifySiteURL=' ,
16+ user ?. netlifySiteURL || 'none' ,
17+ ) ;
1318 cy . viewport ( 1200 , 1200 ) ;
1419 if ( user ) {
1520 console . log ( '[login] About to cy.visit("/")' ) ;
@@ -40,7 +45,7 @@ function login(user) {
4045 cy . contains ( 'button' , 'Login' ) . click ( ) ;
4146 }
4247 console . log ( '[login] Waiting for New Post link' ) ;
43- cy . contains ( 'a' , 'New Post' , { timeout : 60000 } ) . then ( ( ) => {
48+ cy . contains ( 'a' , '+ Post' , { timeout : 60000 } ) . then ( ( ) => {
4449 console . log ( '[login] New Post link found - COMPLETE' ) ;
4550 } ) ;
4651}
@@ -126,20 +131,12 @@ function assertUnpublishedChangesInEditor() {
126131
127132function goToEntry ( entry ) {
128133 goToCollections ( ) ;
129- cy . get ( 'a h2' )
130- . first ( )
131- . contains ( entry . title )
132- . click ( ) ;
134+ cy . get ( 'a h2' ) . first ( ) . contains ( entry . title ) . click ( ) ;
133135}
134136
135137function updateWorkflowStatus ( { title } , fromColumnHeading , toColumnHeading ) {
136- cy . contains ( 'h2' , fromColumnHeading )
137- . parent ( )
138- . contains ( 'a' , title )
139- . drag ( ) ;
140- cy . contains ( 'h2' , toColumnHeading )
141- . parent ( )
142- . drop ( ) ;
138+ cy . contains ( 'h2' , fromColumnHeading ) . parent ( ) . contains ( 'a' , title ) . drag ( ) ;
139+ cy . contains ( 'h2' , toColumnHeading ) . parent ( ) . drop ( ) ;
143140 assertNotification ( notifications . updated ) ;
144141}
145142
@@ -192,9 +189,7 @@ function assertPublishedEntry(entry) {
192189 } ) ;
193190 } ) ;
194191 } else {
195- cy . get ( 'a h2' )
196- . first ( )
197- . contains ( entry . title ) ;
192+ cy . get ( 'a h2' ) . first ( ) . contains ( entry . title ) ;
198193 }
199194}
200195
@@ -226,9 +221,7 @@ function assertEntryDeleted(entry) {
226221}
227222
228223function assertWorkflowStatus ( { title } , status ) {
229- cy . contains ( 'h2' , status )
230- . parent ( )
231- . contains ( 'a' , title ) ;
224+ cy . contains ( 'h2' , status ) . parent ( ) . contains ( 'a' , title ) ;
232225}
233226
234227function updateWorkflowStatusInEditor ( newStatus ) {
@@ -284,12 +277,8 @@ function populateEntry(entry, onDone = flushClockAndSave) {
284277 cy . get ( '@bodyEditor' ) . clear ( { force : true } ) ;
285278 cy . get ( '@bodyEditor' ) . type ( value , { force : true } ) ;
286279 } else {
287- cy . get ( `[id^="${ key } -field"]` )
288- . first ( )
289- . clear ( { force : true } ) ;
290- cy . get ( `[id^="${ key } -field"]` )
291- . first ( )
292- . type ( value , { force : true } ) ;
280+ cy . get ( `[id^="${ key } -field"]` ) . first ( ) . clear ( { force : true } ) ;
281+ cy . get ( `[id^="${ key } -field"]` ) . first ( ) . type ( value , { force : true } ) ;
293282 }
294283 }
295284
@@ -298,7 +287,7 @@ function populateEntry(entry, onDone = flushClockAndSave) {
298287
299288function newPost ( ) {
300289 // click even if covered by toast
301- cy . contains ( 'a' , 'New Post' ) . click ( { force : true } ) ;
290+ cy . contains ( 'a' , '+ Post' ) . click ( { force : true } ) ;
302291}
303292
304293function createPost ( entry ) {
@@ -425,9 +414,7 @@ function duplicatePostAndPublish(entry1) {
425414
426415function updateExistingPostAndExit ( fromEntry , toEntry ) {
427416 goToWorkflow ( ) ;
428- cy . contains ( 'h2' , fromEntry . title )
429- . parent ( )
430- . click ( { force : true } ) ;
417+ cy . contains ( 'h2' , fromEntry . title ) . parent ( ) . click ( { force : true } ) ;
431418 populateEntry ( toEntry ) ;
432419 exitEditor ( ) ;
433420 goToWorkflow ( ) ;
@@ -436,9 +423,7 @@ function updateExistingPostAndExit(fromEntry, toEntry) {
436423
437424function unpublishEntry ( entry ) {
438425 goToCollections ( ) ;
439- cy . contains ( 'h2' , entry . title )
440- . parent ( )
441- . click ( { force : true } ) ;
426+ cy . contains ( 'h2' , entry . title ) . parent ( ) . click ( { force : true } ) ;
442427 selectDropdownItem ( 'Published' , 'Unpublish' ) ;
443428 assertNotification ( notifications . unpublished ) ;
444429 goToWorkflow ( ) ;
@@ -500,9 +485,7 @@ function validateListFields({ name, description }) {
500485 cy . contains ( 'button' , 'Save' ) . click ( ) ;
501486 assertNotification ( notifications . error . missingField ) ;
502487 assertFieldErrorStatus ( 'Authors' , colorError ) ;
503- cy . get ( 'div[class*=SortableListItem]' )
504- . eq ( 2 )
505- . as ( 'listControl' ) ;
488+ cy . get ( 'div[class*=SortableListItem]' ) . eq ( 2 ) . as ( 'listControl' ) ;
506489 assertFieldErrorStatus ( 'Name' , colorError , { scope : cy . get ( '@listControl' ) } ) ;
507490 assertColorOn ( 'background-color' , colorError , {
508491 type : 'label' ,
@@ -511,12 +494,8 @@ function validateListFields({ name, description }) {
511494 isMarkdown : true ,
512495 } ) ;
513496 assertListControlErrorStatus ( [ colorError , colorError ] , '@listControl' ) ;
514- cy . get ( 'input' )
515- . eq ( 2 )
516- . type ( name ) ;
517- cy . getMarkdownEditor ( )
518- . eq ( 2 )
519- . type ( description ) ;
497+ cy . get ( 'input' ) . eq ( 2 ) . type ( name ) ;
498+ cy . getMarkdownEditor ( ) . eq ( 2 ) . type ( description ) ;
520499 flushClockAndSave ( ) ;
521500 assertNotification ( notifications . saved ) ;
522501 assertFieldErrorStatus ( 'Authors' , colorNormal ) ;
@@ -529,16 +508,8 @@ function validateNestedListFields() {
529508 // add first city list item
530509 cy . contains ( 'button' , 'hotel locations' ) . click ( ) ;
531510 cy . contains ( 'button' , 'cities' ) . click ( ) ;
532- cy . contains ( 'label' , 'City' )
533- . parents ( )
534- . next ( )
535- . first ( )
536- . type ( 'Washington DC' ) ;
537- cy . contains ( 'label' , 'Number of Hotels in City' )
538- . parents ( )
539- . next ( )
540- . first ( )
541- . type ( '5' ) ;
511+ cy . contains ( 'label' , 'City' ) . parents ( ) . next ( ) . first ( ) . type ( 'Washington DC' ) ;
512+ cy . contains ( 'label' , 'Number of Hotels in City' ) . parents ( ) . next ( ) . first ( ) . type ( '5' ) ;
542513 cy . contains ( 'button' , 'city locations' ) . click ( ) ;
543514
544515 // add second city list item
@@ -556,9 +527,7 @@ function validateNestedListFields() {
556527 . next ( )
557528 . first ( )
558529 . type ( 'Boston' ) ;
559- cy . get ( '@secondCitiesListControl' )
560- . contains ( 'button' , 'city locations' )
561- . click ( ) ;
530+ cy . get ( '@secondCitiesListControl' ) . contains ( 'button' , 'city locations' ) . click ( ) ;
562531
563532 cy . contains ( 'button' , 'Save' ) . click ( ) ;
564533 assertNotification ( notifications . error . missingField ) ;
@@ -612,11 +581,7 @@ function validateNestedListFields() {
612581 assertListControlErrorStatus ( [ colorError , colorError ] , '@firstCityLocationsListControl' ) ;
613582 assertListControlErrorStatus ( [ colorError , colorError ] , '@secondCityLocationsListControl' ) ;
614583
615- cy . contains ( 'label' , 'Hotel Name' )
616- . parents ( )
617- . next ( )
618- . first ( )
619- . type ( 'The Ritz Carlton' ) ;
584+ cy . contains ( 'label' , 'Hotel Name' ) . parents ( ) . next ( ) . first ( ) . type ( 'The Ritz Carlton' ) ;
620585 cy . contains ( 'button' , 'Save' ) . click ( ) ;
621586 assertNotification ( notifications . error . missingField ) ;
622587 assertListControlErrorStatus ( [ colorNormal , textColorNormal ] , '@firstCitiesListControl' ) ;
@@ -634,11 +599,7 @@ function validateNestedListFields() {
634599 . next ( )
635600 . first ( )
636601 . type ( 'Grand Hyatt' ) ;
637- cy . contains ( 'label' , 'Country' )
638- . parents ( )
639- . next ( )
640- . first ( )
641- . type ( 'United States' ) ;
602+ cy . contains ( 'label' , 'Country' ) . parents ( ) . next ( ) . first ( ) . type ( 'United States' ) ;
642603 flushClockAndSave ( ) ;
643604 assertNotification ( notifications . saved ) ;
644605}
@@ -664,9 +625,7 @@ function validateNestedListFieldsAndExit(setting) {
664625}
665626
666627function assertFieldValidationError ( { message, fieldLabel } ) {
667- cy . contains ( 'label' , fieldLabel )
668- . siblings ( 'ul[class*=ControlErrorsList]' )
669- . contains ( message ) ;
628+ cy . contains ( 'label' , fieldLabel ) . siblings ( 'ul[class*=ControlErrorsList]' ) . contains ( message ) ;
670629 assertFieldErrorStatus ( fieldLabel , colorError ) ;
671630}
672631
@@ -689,21 +648,14 @@ function assertListControlErrorStatus(colors = ['', ''], alias) {
689648 cy . get ( alias ) . within ( ( ) => {
690649 // assert list item border has correct color
691650 assertColorOn ( 'border-right-color' , colors [ 0 ] , {
692- el : cy
693- . root ( )
694- . children ( )
695- . eq ( 2 ) ,
651+ el : cy . root ( ) . children ( ) . eq ( 2 ) ,
696652 } ) ;
697653 // collapse list item
698- cy . get ( 'button[class*=TopBarButton-button]' )
699- . first ( )
700- . click ( ) ;
654+ cy . get ( 'button[class*=TopBarButton-button]' ) . first ( ) . click ( ) ;
701655 // assert list item label text has correct color
702656 assertColorOn ( 'color' , colors [ 1 ] , { el : cy . get ( 'div[class*=NestedObjectLabel]' ) . first ( ) } ) ;
703657 // uncollapse list item
704- cy . get ( 'button[class*=TopBarButton-button]' )
705- . first ( )
706- . click ( ) ;
658+ cy . get ( 'button[class*=TopBarButton-button]' ) . first ( ) . click ( ) ;
707659 } ) ;
708660}
709661
0 commit comments