1
1
import { When , Then } from "cypress-cucumber-preprocessor/steps" ;
2
+ import locales from '../../../webapp/locales'
3
+ import orderBy from 'lodash/orderBy'
2
4
5
+ const languages = orderBy ( locales , 'name' )
3
6
const narratorAvatar =
4
7
"https://s3.amazonaws.com/uifaces/faces/twitter/nerrsoft/128.jpg" ;
5
8
@@ -83,3 +86,71 @@ And("the post with title {string} has a ribbon for pinned posts", (title) => {
83
86
Then ( "I see a toaster with {string}" , ( title ) => {
84
87
cy . get ( ".iziToast-message" ) . should ( "contain" , title ) ;
85
88
} )
89
+
90
+ Then ( "I should be able to {string} a teaser image" , condition => {
91
+ let teaserImageUpload = "onourjourney.png" ;
92
+ if ( condition === 'change' ) teaserImageUpload = "humanconnection.png" ;
93
+ cy . fixture ( teaserImageUpload ) . as ( 'postTeaserImage' ) . then ( function ( ) {
94
+ cy . get ( "#postdropzone" ) . upload (
95
+ { fileContent : this . postTeaserImage , fileName : teaserImageUpload , mimeType : "image/png" } ,
96
+ { subjectType : "drag-n-drop" , force : true }
97
+ ) ;
98
+ } )
99
+ } )
100
+
101
+ Then ( 'confirm crop' , ( ) => {
102
+ cy . get ( '.crop-confirm' )
103
+ . click ( )
104
+ } )
105
+
106
+ Then ( "I add all required fields" , ( ) => {
107
+ cy . get ( 'input[name="title"]' )
108
+ . type ( 'new post' )
109
+ . get ( ".editor .ProseMirror" )
110
+ . type ( 'new post content' )
111
+ . get ( ".base-button" )
112
+ . contains ( "Just for Fun" )
113
+ . click ( )
114
+ . get ( '.ds-flex-item > .ds-form-item .ds-select ' )
115
+ . click ( )
116
+ . get ( '.ds-select-option' )
117
+ . eq ( languages . findIndex ( l => l . code === 'en' ) )
118
+ . click ( )
119
+ } )
120
+
121
+ Then ( "the post was saved successfully with the {string} teaser image" , condition => {
122
+ cy . get ( ".ds-card-content > .ds-heading" )
123
+ . should ( "contain" , condition === 'new' ? 'new post' : 'to be updated' )
124
+ . get ( ".content" )
125
+ . should ( "contain" , condition === 'new' ? 'new post content' : 'successfully updated' )
126
+ . get ( '.post-page img' )
127
+ . should ( "have.attr" , "src" )
128
+ . and ( "contains" , condition === 'new' ? "onourjourney" : "humanconnection" )
129
+ } )
130
+
131
+ Then ( "the first image should be removed from the preview" , ( ) => {
132
+ cy . fixture ( "humanconnection.png" ) . as ( 'postTeaserImage' ) . then ( function ( ) {
133
+ cy . get ( "#postdropzone" )
134
+ . children ( )
135
+ . get ( 'img.thumbnail-preview' )
136
+ . should ( 'have.length' , 1 )
137
+ . and ( 'have.attr' , 'src' )
138
+ . and ( 'contain' , this . postTeaserImage )
139
+ } )
140
+ } )
141
+
142
+ Then ( 'the post was saved successfully without a teaser image' , ( ) => {
143
+ cy . get ( ".ds-card-content > .ds-heading" )
144
+ . should ( "contain" , 'new post' )
145
+ . get ( ".content" )
146
+ . should ( "contain" , 'new post content' )
147
+ . get ( '.post-page' )
148
+ . should ( 'exist' )
149
+ . get ( '.post-page img.ds-card-image' )
150
+ . should ( 'not.exist' )
151
+ } )
152
+
153
+ Then ( 'I should be able to remove it' , ( ) => {
154
+ cy . get ( '.crop-cancel' )
155
+ . click ( )
156
+ } )
0 commit comments