Commit ae0ecd04 authored by Fabrice Gangler's avatar Fabrice Gangler 🎨 Committed by Matthieu FAURE
Browse files

TEST: improve tests for edit user account

Check if user can modify his account
and use the buttons afterwards

Refs: #898
parent 540b2e2d
......@@ -262,6 +262,41 @@ class UserAdministrationCheckActionsCest
$I->seeElement('div.message.success');
}
/**
* Commun to edit a connected user account
* to modify information such as name, url, description, email and avatar.
*
* Here we add an url and a word as description.
* If the username is provided, it is also updated.
*
* @param AcceptanceTester $I
* @param string $username default: ''
*/
private function commonEditeUserAccount(AcceptanceTester $I, string $username = '')
{
$updateData = [
'url' => 'http://localhost:8080/users/284',
'description' => 'administration',
];
$checkNewName = false;
if (!empty($username)) {
$updateData['username'] = $username;
$checkNewName = true;
}
$lang = $this->lang;
$I->click("a[href=\"/$lang/users/edit/284\"]"); // Edit user's button
$I->canSeeInCurrentUrl('/users/edit/284');
$I->submitForm('#editInformationAccountForm', $updateData);
$I->canSeeInCurrentUrl('/users/284');
$I->seeElement('div.message.success');
if ($checkNewName === true) {
$I->see($username, ['css' => '#userPageFirstTitle']);
$I->see($username, ['css' => 'li a']);
}
}
/**
* Edit a connected user account to modify information such as name, url, description, email and avatar.
* Here we add an url and a word as description.
......@@ -273,21 +308,65 @@ class UserAdministrationCheckActionsCest
* @return void
*/
public function editeUserAccount(AcceptanceTester $I)
{
$this->commonEditeUserAccount($I);
}
/**
* Edit a connected user account to modify name, url and description
* and then declare as user of software
*
* @group userAccount
* @group userAccount_edit
*
* @param AcceptanceTester $I codeception variable
* @return void
*/
public function editAccountAndDeclareUserOf(AcceptanceTester $I)
{
$lang = $this->lang;
$I->click("a[href=\"/$lang/users/edit/284\"]"); // Edit user's button
$I->canSeeInCurrentUrl('/users/edit/284');
$I->submitForm(
'#editInformationAccountForm',
[
'url' => 'http://localhost:8080/users/284',
'description' => 'administration',
]
);
$I->canSeeInCurrentUrl('/users/284');
$oldName = 'dev-collectivite';
$newName = 'dev-coll4ectivite updated';
$softwareId = 163;
$softwareToAddAsUser = "//a[@href=\"/$lang/softwares/$softwareId\"]"; // software Atom
// rename user
$this->commonEditeUserAccount($I, $newName);
// declare user of
$I->click('//*[@id="softwaresPage"]'); // button 'Logiciels'
$I->click($softwareToAddAsUser);
$I->seeInCurrentUrl("/$lang/softwares/$softwareId");
$I->dontSee($oldName, ['css' => 'ol li']);
$I->dontSee($newName, ['css' => 'ol li']);
$I->click("//*[@id=\"btn_Softwares-usersSoftware-$softwareId\"]"); // button : 'Se déclarer utilisateur'
$I->seeElement('div.message.success');
$I->seeInCurrentUrl("/$lang/mappingForm/$softwareId");
// Checks on software page
$I->click('//*[@id="softwaresPage"]'); // button 'Logiciels'
$I->click($softwareToAddAsUser);
$I->seeInCurrentUrl("/$lang/softwares/$softwareId");
$I->seeElement("//*[@id=\"btn_Softwares-deleteUsersSoftware-$softwareId\"]");
$I->dontSee($oldName, ['css' => 'ol li']);
$I->see($newName, ['css' => 'ol li']);
// rename the user and no longer be a user of the software
$this->commonEditeUserAccount($I, $oldName);
$I->click('//*[@id="softwaresPage"]'); // button 'Logiciels'
$I->click($softwareToAddAsUser);
$I->seeInCurrentUrl("/$lang/softwares/$softwareId");
$I->see($oldName, ['css' => 'ol li']);
$I->dontSee($newName, ['css' => 'ol li']);
$I->click("//*[@id=\"btn_Softwares-deleteUsersSoftware-$softwareId\"]"); // button : 'ne plus être utilisateur'
$I->seeElement('div.message.success');
$I->dontSee($oldName, ['css' => 'ol li']);
$I->dontSee($newName, ['css' => 'ol li']);
}
/**
* When trying to modify another user's data (by changing the id in the url),
* verify that we can't even see the form
......
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