MDL-55528 assignfeedback_editpdf: Add step to check all pages loaded

This commit is contained in:
Andrew Nicols 2017-03-07 10:11:01 +08:00
parent f7a9f1dd0e
commit 3bd0d4397c
3 changed files with 26 additions and 2 deletions

View File

@ -130,7 +130,7 @@ Feature: In an assignment, teacher can annotate PDF files during grading
And I navigate to "View all submissions" in current page administration
And I click on "Edit" "link" in the "Student 2" "table_row"
And I click on "Grade" "link" in the "Student 2" "table_row"
And I wait until the page is ready
And I wait for the complete PDF to load
And I click on ".linebutton" "css_element"
And I draw on the pdf
And I press "Save changes"

View File

@ -78,4 +78,28 @@ class behat_assignfeedback_editpdf extends behat_base {
$this->getSession()->executeScript($js);
sleep(1);
}
/**
* I wait for all pages in the PDF document to be converted to images and loaded.
*
* @Given /^I wait for the complete PDF to load$/
*/
public function i_wait_for_all_editpdf_pages_to_load() {
// No need to wait if not running JS.
if (!$this->running_javascript()) {
return;
}
// Ensure that the document is ready, and all pages are loaded.
$conditions = [
'typeof M !== "undefined"',
'typeof M.assignfeedback_editpdf !== "undefined"',
'typeof M.assignfeedback_editpdf.instance !== "undefined"',
'M.assignfeedback_editpdf.instance.documentstatus === 2',
'M.assignfeedback_editpdf.instance.pagecount === M.assignfeedback_editpdf.instance.pages.length',
];
$js = implode(' && ', $conditions);
$this->getSession()->wait(self::TIMEOUT * 1000, "({$js})");
}
}

View File

@ -51,7 +51,7 @@ Feature: In a group assignment, teacher can annotate PDF files for all users
And I follow "Test assignment name"
And I navigate to "View all submissions" in current page administration
And I click on "Grade" "link" in the "Submitted for grading" "table_row"
And I wait until the page is ready
And I wait for the complete PDF to load
And I click on ".navigate-next-button" "css_element"
And I wait until the page is ready
And I click on ".stampbutton" "css_element"