11import '../support/commands.js' ;
22
3+ function firstStep ( ) {
4+ cy . get ( 'input[id^="checklist-"]' ) . click ( { multiple : true } ) ;
5+ cy . get ( 'input[id=privacyConsent]' ) . click ( ) ;
6+ cy . get ( '#submitStep1Form button.submitFormButton' ) . click ( ) ;
7+ }
8+
9+ function addGalleyFile ( file ) {
10+ cy . get ( 'a:contains("Add galley")' ) . click ( ) ;
11+ cy . wait ( 2000 ) ;
12+ cy . get ( 'div.pkp_modal_panel' ) . then ( $modalDiv => {
13+ cy . wait ( 3000 ) ;
14+ cy . get ( 'div.pkp_modal_panel input[id^="label-"]' ) . type ( 'PDF' , { delay : 0 } ) ;
15+ cy . get ( 'div.pkp_modal_panel button:contains("Save")' ) . click ( ) ;
16+ cy . wait ( 2000 ) ;
17+ } ) ;
18+ cy . get ( 'select[id=genreId]' ) . select ( file . genre ) ;
19+ cy . fixture ( file . file , 'base64' ) . then ( fileContent => {
20+ cy . get ( 'input[type=file]' ) . upload (
21+ { fileContent, 'fileName' : file . fileName , 'mimeType' : 'application/pdf' , 'encoding' : 'base64' }
22+ ) ;
23+ } ) ;
24+ cy . get ( 'button' ) . contains ( 'Continue' ) . click ( ) ;
25+ cy . wait ( 2000 ) ;
26+ for ( const field in file . metadata ) {
27+ cy . get ( 'input[id^="' + Cypress . $ . escapeSelector ( field ) + '"]:visible,textarea[id^="' + Cypress . $ . escapeSelector ( field ) + '"]' ) . type ( file . metadata [ field ] , { delay : 0 } ) ;
28+ cy . get ( 'input[id^="language"' ) . click ( { force : true } ) ;
29+ }
30+ cy . get ( 'button' ) . contains ( 'Continue' ) . click ( ) ;
31+ cy . get ( 'button' ) . contains ( 'Complete' ) . click ( ) ;
32+ }
33+
34+ function secondStep ( submissionData ) {
35+ for ( let file of submissionData . files ) {
36+ addGalleyFile ( file ) ;
37+ }
38+ cy . get ( '#submitStep2Form button.submitFormButton' ) . click ( ) ;
39+ }
40+
41+ function thirdStep ( submissionData ) {
42+ cy . get ( 'input[id^="title-en_US-"' ) . type ( submissionData . title , { delay : 0 } ) ;
43+ cy . get ( 'label' ) . contains ( 'Title' ) . click ( ) ;
44+ cy . get ( 'textarea[id^="abstract-en_US"]' ) . then ( node => {
45+ cy . setTinyMceContent ( node . attr ( 'id' ) , submissionData . abstract ) ;
46+ } ) ;
47+ cy . get ( 'ul[id^="en_US-keywords-"]' ) . then ( node => {
48+ for ( let keyword of submissionData . keywords ) {
49+ node . tagit ( 'createTag' , keyword ) ;
50+ }
51+ } ) ;
52+ cy . waitJQuery ( ) ;
53+ cy . get ( '#submitStep3Form button:contains("Save and continue"):visible' ) . click ( ) ;
54+ }
55+
56+ function fourthStep ( ) {
57+ cy . waitJQuery ( ) ;
58+ cy . get ( 'form[id=submitStep4Form] button:contains("Finish Submission")' ) . click ( ) ;
59+ cy . wait ( 1000 ) ;
60+ cy . get ( 'button.pkpModalConfirmButton' ) . click ( ) ;
61+ }
62+
63+ function createNewSubmission ( submissionData ) {
64+ cy . get ( 'a:contains("Make a New Submission"), div#myQueue a:contains("New Submission")' ) . click ( ) ;
65+
66+ firstStep ( submissionData ) ;
67+ secondStep ( submissionData ) ;
68+ thirdStep ( submissionData ) ;
69+ fourthStep ( ) ;
70+ cy . waitJQuery ( ) ;
71+ cy . get ( 'h2:contains("Submission complete")' ) ;
72+ }
73+
374describe ( 'Embed PDF viewer' , function ( ) {
4- it ( 'Checks presence of PDF embed viewer at workflows' , function ( ) {
75+ let submissionData ;
76+
77+ before ( function ( ) {
78+ submissionData = {
79+ title : 'New designs for aircraft engines' ,
80+ abstract : 'An example abstract.' ,
81+ keywords : [ 'aircraft' , 'engines' , 'mechanical design' ] ,
82+ files : [ {
83+ 'file' : 'dummy.pdf' ,
84+ 'fileName' : 'design_aircraft_engines.pdf' ,
85+ 'genre' : Cypress . env ( 'defaultGenre' )
86+ } ]
87+ }
88+ } ) ;
89+
90+ it ( 'Creates new submission with PDF' , function ( ) {
91+ cy . login ( 'ckwantes' , null , 'publicknowledge' ) ;
92+ createNewSubmission ( submissionData ) ;
93+ } ) ;
94+ it ( 'Checks presence of PDF embed viewer at workflow' , function ( ) {
595 cy . login ( 'dbarnes' , null , 'publicknowledge' ) ;
6- cy . findSubmission ( 'archive ' , 'Arguments About Arguments' ) ;
96+ cy . findSubmission ( 'active ' , submissionData . title ) ;
797
898 cy . get ( '#publication-button' ) . click ( ) ;
999 cy . get ( '#galleys-button' ) . click ( ) ;
10100
11101 cy . contains ( 'a' , 'PDF' ) ;
12102 cy . get ( '#pdfEmbedViewer' ) . should ( 'exist' ) ;
13103 } ) ;
104+ it ( 'PDF embed viewer is not affected by metadata editing' , function ( ) {
105+ cy . login ( 'dbarnes' , null , 'publicknowledge' ) ;
106+ cy . findSubmission ( 'active' , submissionData . title ) ;
107+
108+ cy . get ( '#publication-button' ) . click ( ) ;
109+ cy . get ( '#galleys-button' ) . click ( ) ;
110+ cy . wait ( 3000 ) ;
111+ cy . contains ( 'a' , 'PDF' ) ;
112+ cy . get ( '#pdfEmbedViewer' ) . should ( 'exist' ) ;
113+
114+ cy . get ( '#titleAbstract-button' ) . click ( ) ;
115+ cy . get ( 'input[id^="titleAbstract-title-control-en_US"' ) . type ( ' plus text' , { delay : 0 } ) ;
116+ cy . contains ( 'button' , 'Save' ) . click ( ) ;
117+ cy . wait ( 3000 ) ;
118+
119+ cy . get ( '#galleys-button' ) . click ( ) ;
120+ cy . contains ( 'a' , 'PDF' ) ;
121+ cy . get ( '#pdfEmbedViewer' ) . should ( 'exist' ) ;
122+ } ) ;
14123} ) ;
0 commit comments