Skip to content
This repository was archived by the owner on Mar 17, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions administrator/modules/mod_login/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<?php echo JText::_('JGLOBAL_USERNAME'); ?>
</label>
</span>
<input name="username" tabindex="1" id="mod-login-username" type="text" class="input-medium" placeholder="<?php echo JText::_('JGLOBAL_USERNAME'); ?>" size="15" autofocus="true" data-tests="username"/>
<input name="username" tabindex="1" id="mod-login-username" type="text" class="input-medium" placeholder="<?php echo JText::_('JGLOBAL_USERNAME'); ?>" size="15" autofocus="true"/>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm removing this HTML5 attribute that was added with this idea: joomla/joomla-cms#10589

But the current agreement is that we are not going to use this attributes unless is really needed. So for the moment we will use the existing IDs for locating the elements and use the AdministratorLogin Page Object to store the locators.

<a href="<?php echo JUri::root(); ?>index.php?option=com_users&view=remind" class="btn width-auto hasTooltip" title="<?php echo JText::_('MOD_LOGIN_REMIND'); ?>">
<span class="icon-help"></span>
</a>
Expand All @@ -41,7 +41,7 @@
<?php echo JText::_('JGLOBAL_PASSWORD'); ?>
</label>
</span>
<input name="passwd" tabindex="2" id="mod-login-password" type="password" class="input-medium" placeholder="<?php echo JText::_('JGLOBAL_PASSWORD'); ?>" size="15" data-tests="password"/>
<input name="passwd" tabindex="2" id="mod-login-password" type="password" class="input-medium" placeholder="<?php echo JText::_('JGLOBAL_PASSWORD'); ?>" size="15"/>
<a href="<?php echo JUri::root(); ?>index.php?option=com_users&view=reset" class="btn width-auto hasTooltip" title="<?php echo JText::_('MOD_LOGIN_RESET'); ?>">
<span class="icon-help"></span>
</a>
Expand Down Expand Up @@ -84,7 +84,7 @@
<div class="control-group">
<div class="controls">
<div class="btn-group">
<button tabindex="3" class="btn btn-primary btn-block btn-large" data-tests="log in">
<button tabindex="3" class="btn btn-primary btn-block btn-large">
<span class="icon-lock icon-white"></span> <?php echo JText::_('MOD_LOGIN_LOGIN'); ?>
</button>
</div>
Expand Down
31 changes: 0 additions & 31 deletions tests/_support/AcceptanceTester.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,37 +21,6 @@ class AcceptanceTester extends \Codeception\Actor
{
use _generated\AcceptanceTesterActions;

/**
* Install joomla CMS
*
* @Given Joomla CMS is installed
*/
public function joomlaCMSIsInstalled()
{
// throw new \Codeception\Exception\Incomplete("Step `Joomla CMS is installed` is not defined");
}

/**
* @When Login into Joomla administrator with username :arg1 and password :arg1
*/
public function loginIntoJoomlaAdministrator($username, $password)
{
$I = $this;
$I->amOnPage('administrator/');
$I->fillField(LoginPage::$usernameField, $username);
$I->fillField(LoginPage::$passwordField, $password);
$I->click(LoginPage::$loginButton);
}

/**
* @Then I see administrator dashboard
*/
public function iSeeAdministratorDashboard()
{
$I = $this;
$I->waitForText(AdminPage::$controlPanelText, 4, AdminPage::$pageTitle);
}

/**
* Method is to set Wait for page title
*
Expand Down
13 changes: 13 additions & 0 deletions tests/_support/Page/Acceptance/Administrator/ControlPanelPage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
namespace Page\Acceptance\Administrator;

use Page\Acceptance\Administrator\AdminPage;

class ControlPanelPage extends AdminPage
{
public static $url = "/administrator/index.php";

public static $pageTitle = 'Control Panel';

public static $pageTitleContext = ['class' => 'page-title'];
Copy link
Contributor

@yvesh yvesh Jun 30, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am probably still for an array here.. As else wise we are going to have thousands of public static (readability?) in pages.

public static $usefulAndShortVariableName = [
   'url'  => '/administrator/index.php',
   'pageTitle' => 'Control Panel',
   'pageTitleContext' => ['class' => 'page-title'];
];

(Better indention on the elements, GitHub does not allow me to)

// cc @javigomez, @pritalpatel, @nibra, @puneet0191

Copy link
Contributor

@yvesh yvesh Jun 30, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imo this array should be even private / protected. And we would have a method public static getLocator($title, $default = null) in the abstract class (AdminPage or whatever).

We could also make an additional shortcut method, like we have in Joomla with for example JText::_, so you later only use:

Login::_('pageTitle');

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the locator method idea, but then I don't know how we will be able to do this: https://www.youtube.com/watch?v=dV7fVtRz1SE

Copy link
Contributor

@yvesh yvesh Jun 30, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@javigomez not sure if i understand you.

public static $usefulAndShortVariableName = [
   'articleTitleField' => ['id' => 'jform_title'],
   // ...
];

$I->fillField(Article::_('articleTitleField'), $title); 

You can have an array locator in an array. Or do you mean something different?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean that with your IDE, right now you can see the value of ControlPanelPage::pageTitleContext with just Ctrl+click over the parameter. But if we do Ctrl+click at Article::_('articleTitleField') your IDE will navigate to the public function _(...) so you wont be able to easily navigate to the value.

Copy link
Contributor

@yvesh yvesh Jun 30, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@javigomez you are right, you would need to Ctrl+click on Article (or ControlPanelPage in your sample). And then look at the array (or search with Ctrl+F for articleTitleField).

PhpStorm / Shortcut trick (almost as fast as Ctrl+Click)

Shortcut lovers, can do the following: Highlight / mark articleTitleField and do Cmd + Alt + O (on Mac), Ctrl + Alt + N(on Linux). This opens search for symbol and is going to show you the variable directly.

screenshot 2016-06-30 16 01 24

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An alternative would also be to override click and fillfield AcceptanceTester methods to make it to look for the locators in the Page object before.

Copy link
Contributor

@pritalpatel pritalpatel Jun 30, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am reading it and understand what is the idea. But I am not sure which will be best for now. I think for now best and easy to work with imo is to use property instead of array and I have also found similar approach in other languages examples while I was reading about page objects.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the array / locator approach improves the readability. You still have a list of identifiers. If they are variables or array indices does not make any difference in that regard.
Also, the (untriggered) auto-completion is much more beneficial.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue created for this topic at #55. I will not include the locator method in the present pull in order to fix one issue per pull.

}
36 changes: 0 additions & 36 deletions tests/_support/Page/Acceptance/Administrator/Login.php

This file was deleted.

23 changes: 15 additions & 8 deletions tests/_support/Page/Acceptance/Administrator/LoginPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,20 @@

class LoginPage extends AdminPage
{
public static $usernameField = ['css' => 'input[data-tests="username"]'];

public static $passwordField = ['css' => 'input[data-tests="password"]'];

public static $pageTitle = ['class' => 'page-title'];

public static $loginButton = ['css' => 'button[data-tests="log in"]'];

public static $url = "/administrator/index.php";

/**
* @var array Locator for username login form textfield
*/
public static $usernameField = ['id' => 'mod-login-username'];

/**
* @var array Locator for password login form textfield
*/
public static $passwordField = ['id' => 'mod-login-password'];

/**
* @var array Locator for Log in button
*/
public static $loginButton = ['xpath' => "//button[contains(normalize-space(), 'Log in')]"];
}
31 changes: 31 additions & 0 deletions tests/_support/Step/Acceptance/Administrator/Login.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
namespace Step\Acceptance\Administrator;

use Page\Acceptance\Administrator\LoginPage;
use Page\Acceptance\Administrator\ControlPanelPage;

class Login extends \AcceptanceTester
{
/**
* @When I Login into Joomla administrator with username :arg1 and password :arg1
*/
public function loginIntoJoomlaAdministrator($username, $password)
{
$I = $this;
$I->amOnPage(LoginPage::$url);
$I->fillField(LoginPage::$usernameField, $username);
$I->fillField(LoginPage::$passwordField, $password);
$I->click(LoginPage::$loginButton);
}

/**
* @Then I should see the administrator dashboard
* @When I see the administrator dashboard
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could add a regex here or just add the two gherkin sentences that will call the Step method. See: http://codeception.com/docs/07-BDD#step-definitions

I took the option of adding the two sentences.

*/
public function iShouldSeeTheAdministratorDashboard()
{
$I = $this;
$I->waitForPageTitle(ControlPanelPage::$pageTitle, 60, ControlPanelPage::$pageTitleContext);
$I->see(ControlPanelPage::$pageTitle, ControlPanelPage::$pageTitleContext);
}
}
3 changes: 1 addition & 2 deletions tests/acceptance.suite.dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ error_level: "E_ALL & ~E_STRICT & ~E_DEPRECATED"
gherkin:
contexts:
default:
- AcceptanceTester
- Step\Acceptance\Administrator\Login
- Step\Acceptance\Administrator\User
- Page\Acceptance\Administrator\Login
- Step\Acceptance\Administrator\Content
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also have to put,

- Step\Acceptance\Administrator\Login

otherwise it will show missing snippet error.

5 changes: 2 additions & 3 deletions tests/acceptance/administratorlogin.feature
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ Feature: administrator login
I need to have a control panel

Scenario: Login in Administrator
Given Joomla CMS is installed
When Login into Joomla administrator with username "admin" and password "admin"
Then I see administrator dashboard
When I Login into Joomla administrator with username "admin" and password "admin"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that there is no Given anymore in this User Story.

Then I should see the administrator dashboard
5 changes: 2 additions & 3 deletions tests/acceptance/content.feature
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ Feature: content
I need to create modify trash publish and Unpublish content article

Background:
Given Joomla CMS is installed
When Login into Joomla administrator with username "admin" and password "admin"
Then I see administrator dashboard
When I Login into Joomla administrator with username "admin" and password "admin"
And I see the administrator dashboard

Scenario: Create an Article
Given There is a add content link
Expand Down
5 changes: 2 additions & 3 deletions tests/acceptance/users.feature
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ Feature: users
I need to create edit block unblock and delete user

Background:
Given Joomla CMS is installed
When Login into Joomla administrator with username "admin" and password "admin"
Then I see administrator dashboard
When I Login into Joomla administrator with username "admin" and password "admin"
And I see the administrator dashboard

Scenario: Verify available tabs in com_users
Given There is an user link
Expand Down
Loading