Commit d05c312e authored by Son Nguyen's avatar Son Nguyen
Browse files

Implement the behat step for checking if pieforms is still processing



Bug 1405274

- Remove all steps: I wait for "n" seconds to make the tests run faster


Change-Id: I5f4a384b4d4df1841519daff95e06d110f7ef0f9
Signed-off-by: default avatarSon Nguyen <son.nguyen@catalyst.net.nz>
parent 13a85f79
......@@ -139,6 +139,8 @@ PieformManager = new PieformManager();
*/
function Pieform(data) {//{{{
var self = this;
this.SUBMITTING = 0;
this.COMPLETE = 1;
this.init = function() {//{{{
if (self.data.checkDirtyChange) {
......@@ -150,6 +152,7 @@ function Pieform(data) {//{{{
}//}}}
this.processForm = function(e) {//{{{
self.updateStatus(self.SUBMITTING);
PieformManager.signal('onsubmit', self.data.name);
// Call the presubmit callback, if there is one
......@@ -181,6 +184,7 @@ function Pieform(data) {//{{{
// If canceling the form, redirect away
if (data.returnCode == -2) {
window.location = data.location;
self.updateStatus(self.COMPLETE);
return;
}
......@@ -258,6 +262,8 @@ function Pieform(data) {//{{{
&& self.data.postSubmitCallback != '') {
window[self.data.postSubmitCallback]($(self.data.name), self.clickedButton, e);
}
self.updateStatus(self.COMPLETE);
}
}//}}}
......@@ -293,6 +299,30 @@ function Pieform(data) {//{{{
});
}//}}}
/**
* Update the status of processing pieform.
*
* @return Boolean - True if succeeded
*/
this.updateStatus = function(status) {
if (self.data.name !== false) {
switch (status) {
case self.SUBMITTING:
SubmittingPieforms.push(self.data.name);
return true;
break;
case self.COMPLETE:
var index = SubmittingPieforms.indexOf(self.data.name);
if (index >= 0) {
SubmittingPieforms.splice(index, 1);
return true;
}
break;
}
}
return false;
};
// A reference to the iframe that submissions are made through
this.iframe = null;
......@@ -303,4 +333,11 @@ function Pieform(data) {//{{{
this.data = data;
addLoadEvent(self.init);
}//}}}
/**
* @var SubmittingPieforms - The keys are the list of all submitting pieforms.
* @type Object
*/
SubmittingPieforms = [];
......@@ -52,7 +52,7 @@ class BehatBase extends Behat\MinkExtension\Context\RawMinkContext {
/**
* The JS code to check that the page is ready.
*/
const PAGE_READY_JS = '(document.readyState === "complete")';
const PAGE_READY_JS = '(SubmittingPieforms && SubmittingPieforms.length === 0) && (document.readyState === "complete")';
/**
* Locates url, based on provided path.
......
......@@ -46,5 +46,4 @@ Feature: Mahara users can have their profile
When I fill in "occupation" with "Software Engineer"
When I fill in "industry" with "it"
When I press "Save profile"
When I wait until the page is ready
Then I should see "Profile saved successfully"
......@@ -14,7 +14,6 @@ Feature: Mahara users can change their account settings
And I fill in "password1" with "Passwordnew"
And I fill in "password2" with "Passwordnew"
And I press "Save"
And I wait "1" seconds
Then I should see "Preferences saved"
Scenario: Change notifications
......@@ -23,5 +22,4 @@ Feature: Mahara users can change their account settings
And I follow "Notifications"
And I select "Email" from "activity_viewaccess"
And I press "Save"
And I wait "1" seconds
Then I should see "Preferences saved"
......@@ -18,9 +18,7 @@ Feature: Mahara users can create their blogs
| tagssideblockmaxtags | 10 |
And I check "multipleblogs"
And I press "Save"
And I wait "1" seconds
When I go to "artefact/blog/index.php"
And I wait until the page is ready
Then I should see "Journals"
When I click on "Create journal"
And I fill in the following:
......
......@@ -17,10 +17,8 @@ Feature: Mahara users can participate in groups
Scenario: Join a group
Given I log in as "userE" with password "Password1"
When I go to "group/find.php"
And I wait "1" seconds
Then I should see "group 01"
When I click on "group 01"
Then I should see "About"
When I press "Join this group"
And I wait "1" seconds
Then I should see "You are now a group member."
......@@ -17,5 +17,4 @@ Feature: Mahara users can be a member of an institution
Scenario: Register to an institution
Given I log in as "userB" with password "Password1"
When I go to "account/institutions.php"
And I wait "1" seconds
Then I should see "Request membership of an institution"
\ No newline at end of file
......@@ -16,12 +16,10 @@ Feature: Mahara admins can add users via CSV files
Scenario: As a site admin, add users via CSV file
Given I log in as "userA" with password "Password1"
When I go to "admin/users/uploadcsv.php"
And I wait "1" seconds
Then I should see "Add users by CSV"
When I attach the file "users.csv" to "uploadcsv_file"
And I uncheck "uploadcsv_forcepasswordchange"
And I uncheck "uploadcsv_emailusers"
And I press "uploadcsv_submit"
And I wait "1" seconds
Then I should see "Your CSV file was processed successfully."
Then I should see "New users added: 5."
\ No newline at end of file
......@@ -29,9 +29,7 @@ Feature: Mahara users can manage their pages
Scenario: List and edit my portfolio pages
Given I log in as "userD" with password "Password1"
When I go to "view/index.php"
And I wait "1" seconds
Then I should see "Page 01"
And I should see "Page 02"
And I click on "Edit content and layout" in "Page 01" row
And I wait "1" seconds
And I should see "Edit content"
\ No newline at end of file
......@@ -29,5 +29,4 @@ Feature: Mahara users can share their pages
Then I should see "D's Page 01"
And I should see "D's Page 02"
And I click on "Edit access" in "D's Page 01" row
And I wait "1" seconds
And I should see "Edit access"
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment