Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Behat] IBX-8636: As a QA I want to add behat coverage to user profile #1314

Merged
merged 5 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
24 changes: 21 additions & 3 deletions .github/workflows/browser-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,30 @@ on:
pull_request: ~

jobs:
admin-ui-oss-headless:
name: "AdminUI-OSS/Headless"
admin-ui-oss:
micszo marked this conversation as resolved.
Show resolved Hide resolved
name: "AdminUI-OSS"
uses: ibexa/gh-workflows/.github/workflows/browser-tests.yml@main
with:
project-edition: 'oss'
test-suite: '--profile=browser --suite=admin-ui-full --tags=@IbexaOSS,@IbexaHeadless'
test-suite: '--profile=browser --suite=admin-ui-full --tags=@IbexaOSS'
test-setup-phase-1: '--profile=setup --suite=personas --mode=standard'
test-setup-phase-2: '--profile=setup --suite=content-translation --mode=standard'
job-count: 2
timeout: 40
secrets:
SATIS_NETWORK_KEY: ${{ secrets.SATIS_NETWORK_KEY }}
SATIS_NETWORK_TOKEN: ${{ secrets.SATIS_NETWORK_TOKEN }}
TRAVIS_GITHUB_TOKEN: ${{ secrets.TRAVIS_GITHUB_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
AUTOMATION_CLIENT_ID: ${{ secrets.AUTOMATION_CLIENT_ID }}
AUTOMATION_CLIENT_INSTALLATION: ${{ secrets.AUTOMATION_CLIENT_INSTALLATION }}
AUTOMATION_CLIENT_SECRET: ${{ secrets.AUTOMATION_CLIENT_SECRET }}
admin-ui-headless:
name: "AdminUI-Headless"
uses: ibexa/gh-workflows/.github/workflows/browser-tests.yml@main
with:
project-edition: 'headless'
test-suite: '--profile=browser --suite=admin-ui-full --tags=@IbexaHeadless'
test-setup-phase-1: '--profile=setup --suite=personas --mode=standard'
test-setup-phase-2: '--profile=setup --suite=content-translation --mode=standard'
job-count: 2
Expand Down
2 changes: 2 additions & 0 deletions behat_suites.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ browser:
- Ibexa\Behat\Browser\Context\AuthenticationContext
- Ibexa\Behat\Browser\Context\DebuggingContext
- Ibexa\User\Behat\Context\UserSettingsContext
- Ibexa\AdminUi\Behat\BrowserContext\UserProfileContext

personas:
paths:
Expand Down Expand Up @@ -93,3 +94,4 @@ browser:
- Ibexa\Behat\Browser\Context\AuthenticationContext
- Ibexa\Behat\Browser\Context\DebuggingContext
- Ibexa\User\Behat\Context\UserSettingsContext
- Ibexa\AdminUi\Behat\BrowserContext\UserProfileContext
50 changes: 50 additions & 0 deletions features/standard/UserProfile.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
@IbexaHeadless @IbexaExperience @IbexaCommerce
Feature: User profile management

@javascript
Scenario: Create a new editor
Given I am logged as admin
And I'm on Content view Page for "Users/Editors"
When I start creating a new User using "Editor" content type
And I set content fields for user
| label | value |
| First name | EditorFirstName |
| Last name | EditorLastName |
| Image | image1.png |
And I set content fields for user
| label | Username | Password | Confirm password | Email | Enabled |
| User account | testeditor | Test1234pw | Test1234pw | [email protected] | Yes |
And I perform the "Create" action
Then I should be on Content view Page for "/Users/Editors/EditorFirstName EditorLastName"
And content attributes equal
| label | value |
| First name | EditorFirstName |
| Last name | EditorLastName |
| Image | image1.png |
And content attributes equal
| label | Username | Email | Enabled |
| User account | testeditor | [email protected] | Yes |

@javascript
Scenario: User profile is accessible can be edited
micszo marked this conversation as resolved.
Show resolved Hide resolved
Given I open Login page in admin SiteAccess
And I log in as "testeditor" with password "Test1234pw"
And I should be on "Dashboard" page
And I go to user profile
And I should be on "User profile" page
When I edit user profile summary
And I set content fields for user
| label | value |
| First name | EditorFirstName2 |
| Last name | EditorLastName2 |
And I switch to "About" field group
And I set content fields for user
| label | value |
| Job Title | TestJobTitle |
| Department | TestDepartment |
| Location | TestLocation |
And I perform the "Update" action
Then I should be on "User profile" page
And I should see a user profile summary with values
| Full name | Email | Job Title | Department | Location |
| EditorFirstName2 EditorLastName2 | [email protected] | TestJobTitle | TestDepartment | TestLocation |
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,5 @@ services:
Ibexa\AdminUi\Behat\BrowserContext\BookmarkContext: ~

Ibexa\AdminUi\Behat\BrowserContext\MyDraftsContext: ~

Ibexa\AdminUi\Behat\BrowserContext\UserProfileContext: ~
2 changes: 2 additions & 0 deletions src/bundle/Resources/config/services/test/pages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,5 @@ services:
Ibexa\AdminUi\Behat\Page\BookmarksPage: ~

Ibexa\AdminUi\Behat\Page\UserSettingsPage: ~

Ibexa\AdminUi\Behat\Page\UserProfilePage: ~
8 changes: 8 additions & 0 deletions src/lib/Behat/BrowserContext/NavigationContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ public function iGoToUserSettings()
$this->upperMenu->chooseFromUserDropdown('User settings');
}

/**
* @Given I go to user profile
*/
public function iGoToUserProfile(): void
{
$this->upperMenu->chooseFromUserDropdown('Profile');
}

/**
* @Then /^I should be on "?([^\"]*)"? page$/
*/
Expand Down
42 changes: 42 additions & 0 deletions src/lib/Behat/BrowserContext/UserProfileContext.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace Ibexa\AdminUi\Behat\BrowserContext;

use Behat\Behat\Context\Context;
use Behat\Gherkin\Node\TableNode;
use Ibexa\AdminUi\Behat\Page\UserProfilePage;

class UserProfileContext implements Context
micszo marked this conversation as resolved.
Show resolved Hide resolved
{
private UserProfilePage $userProfilePage;

public function __construct(UserProfilePage $userProfilePage)
{
$this->userProfilePage = $userProfilePage;
}

/**
* @Given I edit user profile summary
*/
public function editUserProfileSummary(): void
{
$this->userProfilePage->editSummary();
}

/**
* @Then I should see a user profile summary with values
*/
public function iVerifyUserProfileSummary(TableNode $table): void
{
$this->userProfilePage->verifyIsLoaded();
foreach ($table->getHash() as $row) {
$this->userProfilePage->verifyUserProfileSummary($row['Full name'], $row['Email'], $row['Job Title'], $row['Department'], $row['Location']);
}
}
}
81 changes: 81 additions & 0 deletions src/lib/Behat/Page/UserProfilePage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/

namespace Ibexa\AdminUi\Behat\Page;

use Behat\Mink\Session;
use Ibexa\Behat\API\Facade\ContentFacade;
use Ibexa\Behat\Browser\Locator\VisibleCSSLocator;
use Ibexa\Behat\Browser\Page\Page;
use Ibexa\Behat\Browser\Routing\Router;
use PHPUnit\Framework\Assert;

class UserProfilePage extends Page
micszo marked this conversation as resolved.
Show resolved Hide resolved
{
private string $locationPath;

private ContentFacade $contentFacade;

public function __construct(Session $session, Router $router, ContentFacade $contentFacade)
{
parent::__construct($session, $router);
$this->contentFacade = $contentFacade;
}

public function verifyIsLoaded(): void
{
Assert::assertEquals(
'User profile',
$this->getHTMLPage()->find($this->getLocator('pageTitle'))->getText()
);
}

public function editSummary(): void
{
$this->getHTMLPage()->find($this->getLocator('editButton'))->click();
}

public function verifyUserProfileSummary(string $fullName, string $email, string $jobTitle, string $department, string $location): void
{
$this->getHTMLPage()->setTimeout(5)->find($this->getLocator('fullName'))->assert()->textContains($fullName);
$this->getHTMLPage()->setTimeout(5)->find($this->getLocator('email'))->assert()->textEquals($email);
$this->getHTMLPage()->setTimeout(5)->find($this->getLocator('jobTitle'))->assert()->textEquals($jobTitle);
$this->getHTMLPage()->setTimeout(5)->find($this->getLocator('department'))->assert()->textEquals($department);
$this->getHTMLPage()->setTimeout(5)->find($this->getLocator('location'))->assert()->textEquals($location);
}

protected function specifyLocators(): array
{
return [
new VisibleCSSLocator('pageTitle', '.ibexa-edit-header__title,.ibexa-page-title__content'),
new VisibleCSSLocator('editButton', '.ibexa-user-profile-summary__header .ibexa-btn'),
new VisibleCSSLocator('fullName', 'div.ibexa-details__item:nth-of-type(2) .ibexa-details__item-content'),
new VisibleCSSLocator('email', 'div.ibexa-details__item:nth-of-type(3) .ibexa-details__item-content'),
new VisibleCSSLocator('jobTitle', 'div.ibexa-details__item:nth-of-type(4) .ibexa-details__item-content'),
new VisibleCSSLocator('department', 'div.ibexa-details__item:nth-of-type(5) .ibexa-details__item-content'),
new VisibleCSSLocator('location', 'div.ibexa-details__item:nth-of-type(6) .ibexa-details__item-content'),
];
}

protected function getRoute(): string
{
return sprintf(
'/user/profile/%d/view',
$this->contentFacade->getLocationByLocationURL($this->locationPath)->getId()
);
}

public function setExpectedUserData(string $locationPath): void
{
$this->locationPath = $locationPath;
}

public function getName(): string
{
return 'User profile';
}
}
Loading