16 import(
'lib.pkp.tests.PKPContentBaseTestCase');
18 use Facebook\WebDriver\WebDriverBy;
19 use Facebook\WebDriver\Interactions\WebDriverActions;
20 use Facebook\WebDriver\WebDriverExpectedCondition;
21 use Facebook\WebDriver\WebDriverSelect;
33 if ($data[
'type'] ==
'editedVolume' && !isset($data[
'files'])) {
35 foreach ($data[
'chapters'] as &$chapter) {
37 'fileTitle' => $chapter[
'title'],
38 'metadata' => array(
'genre' =>
'Chapter Manuscript'),
40 $chapter[
'files'] = array($chapter[
'title']);
42 $data[
'files'] = $files;
43 } elseif (isset($data[
'chapters'])) {
44 foreach ($data[
'chapters'] as &$chapter) {
45 if (!isset($chapter[
'files'])) $chapter[
'files'] = array();
51 if (isset($data[
'additionalFiles'])) {
52 $data[
'files'] = array_merge($data[
'files'], $data[
'additionalFiles']);
55 parent::createSubmission($data, $location);
64 if (isset($data[
'series'])) {
65 $this->waitForElementPresent(
'id=seriesId');
66 $this->select(
'id=seriesId',
'label=' . $this->escapeJS($data[
'series']));
68 switch ($data[
'type']) {
70 $this->click(
'id=isEditedVolume-0');
73 $this->click(
'id=isEditedVolume-1');
79 parent::_handleStep1($data);
87 parent::_handleStep3($data);
88 if (isset($data[
'chapters']))
foreach ($data[
'chapters'] as $chapter) {
90 $element = $this->waitForElementPresent($selector=
'css=[id^=component-grid-users-chapter-chaptergrid-addChapter-button-]');
91 self::$driver->executeScript(
'document.getElementById(\'' . $element->getAttribute(
'id') .
'\').scrollIntoView();
');
92 self::$driver->executeScript('window.scroll(0,50);
'); // FIXME: Give it an extra margin of pixels
93 $this->click($selector);
94 $this->waitForElementPresent('
97 foreach ($chapter[
'contributors'] as $i => $contributor) {
98 $this->click(
'//form[@id="editChapterForm"]//label[contains(text(), ' . $this->quoteXpath($contributor) .
')]');
102 $this->type(
'//form[@id=\'editChapterForm\']//input[starts-with(@id,\'title-\')]', $chapter[
'title']);
103 if (isset($chapter[
'subtitle'])) {
104 $this->type(
'//form[@id=\'editChapterForm\']//input[starts-with(@id,\'subtitle-\')]', $chapter[
'subtitle']);
107 $this->click(
'//form[@id="editChapterForm"]//button[text()="Save"]');
108 self::$driver->wait()->until(WebDriverExpectedCondition::invisibilityOfElementLocated(WebDriverBy::cssSelector(
'div.pkp_modal_panel')));
111 if (!empty($chapter[
'files'])) {
112 $this->click(
'//div[@id="chaptersGridContainer"]//a[contains(text(), ' . $this->quoteXPath($chapter[
'title']) .
')]');
113 $this->waitForElementPresent(
'//a[contains(text(),"Edit Metadata")]');
114 $this->waitForElementPresent(
'//legend[contains(text(),"Files")]');
115 foreach ($chapter[
'files'] as $file) {
116 $this->click(
'//form[@id="editChapterForm"]//label[contains(text(), ' . $this->quoteXpath($chapter[
'title']) .
')]');
118 $this->click(
'//form[@id="editChapterForm"]//button[text()="Save"]');
119 self::$driver->wait()->until(WebDriverExpectedCondition::invisibilityOfElementLocated(WebDriverBy::cssSelector(
'div.pkp_modal_panel')));
123 if (isset($chapter[
'pubId'])) {
124 $this->click(
'//div[@id="chaptersGridContainer"]//a[contains(text(), ' . $this->quoteXPath($chapter[
'title']) .
')]');
125 $this->waitForElementPresent(
'css=.ui-tabs-anchor:contains(\'Identifiers\;)');
126 $this->click(
'//a[contains(text(),\'Identifiers\')]');
127 $this->waitForElementPresent(
'css=[id^=publisherId-]');
128 $this->type(
'css=[id^=publisherId-]', $chapter[
'pubId']);
129 $this->click(
'//form[@id=\'publicIdentifiersForm\']//button[text()=\'Save\']');
130 self::$driver->wait()->until(WebDriverExpectedCondition::invisibilityOfElementLocated(WebDriverBy::cssSelector(
'div.pkp_modal_panel')));
140 return 'Book Manuscript';
148 protected function sendToReview($type =
'External', $from =
'Submission') {
151 self::$driver->executeScript(
"$('.ui-pnotify').css('display', 'none');");
152 $this->waitForElementPresent($selector =
'css=[id^=' . ($type==
'External'?
'external':
'internal') .
'Review-button-]');
153 $this->click($selector);
156 if ($type ==
'Internal' || $from !=
'Internal') {
157 $this->waitForElementPresent(
'//form[@id=\'initiateReview\']//input[@type=\'checkbox\']');
158 $this->click(
'//form[@id=\'initiateReview\']//button[contains(., \'Send to ' . $this->escapeJS($type) .
' Review\')]');
161 $this->waitForElementPresent(
'css=[id^=component-grid-files-attachment-editorselectablereviewattachmentsgrid-]');
162 $this->click(
'//button[contains(.,"Next:")]');
163 $this->waitForElementPresent(
'css=[id^=component-grid-files-review-selectablereviewrevisionsgrid-]');
164 $this->click(
'//form[@id=\'promote\']//button[contains(., \'Record Editorial Decision\')]');
166 self::$driver->wait()->until(WebDriverExpectedCondition::invisibilityOfElementLocated(WebDriverBy::cssSelector(
'div.pkp_modal_panel')));
173 self::$driver->executeScript(
'window.scrollTo(0,0);');
174 $this->click(
'//button[contains(text(), "Publish")]');
175 $this->waitForElementPresent(
'//div[contains(text(),"All publication requirements have been met. Are you sure you want to make this catalog entry public?")]');
176 $this->click(
'//div[@class="pkpWorkflow__publishModal"]//button[contains(text(),"Publish")]');