File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11// in this file you can append custom step methods to 'I' object
22
3- // on import la fonction decodeString depuis app/js/utils/strings.mjs
4- const { encodeString } = require ( "../../../app/js/utils/strings.mjs" ) ;
5-
63module . exports = function ( ) {
74 return actor ( {
85 // Define custom steps here, use 'this' to access default methods of I.
@@ -12,13 +9,21 @@ module.exports = function () {
129 this . fillField ( "#user-input" , txt ) ;
1310 this . click ( "#send-button" ) ;
1411 } ,
15- loadAchatbot : async function ( src ) {
12+ loadAchatbot : async function ( src , isRaw = false ) {
13+ if ( isRaw ) {
14+ const encodedSrc = Buffer . from ( encodeURIComponent ( src ) ) . toString (
15+ "base64" ,
16+ ) ;
17+ this . amOnPage ( `#${ encodedSrc } ?raw=1` ) ;
18+ return ;
19+ }
20+
1621 if ( src === "#" ) {
1722 this . amOnPage ( "" ) ;
1823 return ;
1924 }
2025
21- // Si la source commence par # suivi immédiatmeent d'un caractère qui n'est pas un espace
26+ // Si la source commence par # suivi immédiatement d'un caractère qui n'est pas un espace
2227 if ( / ^ # \S / . test ( src ) ) {
2328 this . amOnPage ( src ) ;
2429 return ;
@@ -30,9 +35,7 @@ module.exports = function () {
3035 return ;
3136 }
3237
33- // Dernière possibilité : la source est un texte brut, on l'encode en base64 et on le passe en paramètre src)
34- const decodedSrc = encodeString ( src ) ;
35- this . amOnPage ( decodedSrc ) ;
38+ this . amOnPage ( "" ) ;
3639 } ,
3740 } ) ;
3841} ;
Original file line number Diff line number Diff line change 11const { I } = inject ( ) ;
22
3- Given ( "Je lance ChatMD {string}" , async ( hash ) => {
4- const src = hash ? hash . trim ( ) : "#" ;
5- I . loadAchatbot ( src ) ;
3+ Given ( "Je lance ChatMD {string}" , async ( link , rawsource ) => {
4+ const src = rawsource ? rawsource . content . trim ( ) : link ? link . trim ( ) : "#" ;
5+ const isRaw = rawsource && rawsource . content ? true : false ;
6+ I . loadAchatbot ( src , isRaw ) ;
67} ) ;
78
89When ( "Je demande {string}" , async ( question ) => {
You can’t perform that action at this time.
0 commit comments