Skip to content

Commit

Permalink
[Behat] IBX-4458: Added company creation test scenarios (#727)
Browse files Browse the repository at this point in the history
[Behat] IBX-4458 Added company creation test scenarios

Co-authored-by: Bogdan Mazur <bogdanmazur@ez.no>
  • Loading branch information
bogusez and Bogdan Mazur authored Mar 20, 2023
1 parent 52b2aaf commit 9b300c2
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/lib/Behat/BrowserContext/ContentUpdateContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ public function iSetFields(TableNode $table): void
$this->contentUpdateItemPage->verifyIsLoaded();
foreach ($table->getHash() as $row) {
$values = $this->filterOutNonEmptyValues($row);
$this->contentUpdateItemPage->fillFieldWithValue($row['label'], $values);
$fieldPosition = array_key_exists('fieldPosition', $values) ? (int)$values['fieldPosition'] : null;
$this->contentUpdateItemPage->fillFieldWithValue($row['label'], $values, $fieldPosition);
}
}

Expand Down
18 changes: 18 additions & 0 deletions src/lib/Behat/Component/Table/TableRow.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,22 @@ public function copy(): void
$this->element->find($this->getLocator('copy'))->click();
}

public function deactivate(): void
{
// TODO: Revisit during redesign
$this->element->find($this->getLocator('de-active'))->mouseOver();
usleep(100 * 5000); // 500ms
$this->element->find($this->getLocator('de-active'))->click();
}

public function activate(): void
{
// TODO: Revisit during redesign
$this->element->find($this->getLocator('active'))->mouseOver();
usleep(100 * 5000); // 500ms
$this->element->find($this->getLocator('active'))->click();
}

public function assign(): void
{
// TODO: Revisit during redesign
Expand Down Expand Up @@ -97,6 +113,8 @@ protected function specifyLocators(): array
new VisibleCSSLocator('checkbox', 'input[type=checkbox]'),
new VisibleCSSLocator('assign', '[data-original-title="Assign content"],[data-original-title="Assign to Users/Groups"]'),
new VisibleCSSLocator('edit', '.ibexa-icon--edit,[data-original-title="Edit"]'),
new VisibleCSSLocator('de-active', '[data-original-title="De-activate"]'),
new VisibleCSSLocator('active', '[data-original-title="Activate"]'),
new VisibleCSSLocator('copy', '[data-original-title="Copy"]'),
];
}
Expand Down
26 changes: 22 additions & 4 deletions src/lib/Behat/Page/ContentUpdateItemPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ public function getName(): string
return 'Content Update';
}

public function fillFieldWithValue(string $label, array $value): void
public function fillFieldWithValue(string $label, array $value, ?int $fieldPosition = null): void
{
$this->getField($label)->setValue($value);
$this->getField($label, $fieldPosition)->setValue($value);
}

public function close(): void
Expand All @@ -107,6 +107,7 @@ protected function specifyLocators(): array
new VisibleCSSLocator('formElement', 'form.ibexa-form, .ibexa-edit-content'),
new VisibleCSSLocator('closeButton', '.ibexa-anchor-navigation-menu__close'),
new VisibleCSSLocator('nthField', 'div.ibexa-field-edit:nth-of-type(%s)'),
new VisibleCSSLocator('nthFieldWithSection', '[data-id="%s"] div.ibexa-field-edit:nth-of-type(%s)'),
new VisibleCSSLocator('fieldGroupNthField', '[data-id="%s"] div.ibexa-field-edit:nth-of-type(%s)'),
new VisibleCSSLocator('noneditableFieldClass', 'ibexa-field-edit--eznoneditable'),
new VisibleCSSLocator('fieldOfType', '.ibexa-field-edit--%s'),
Expand Down Expand Up @@ -137,9 +138,26 @@ public function setExpectedContentDraftData(string $contentTypeIdentifier, strin
$this->locationPath = $locationPath;
}

public function getField(string $fieldName): FieldTypeComponent
public function getField(string $fieldName, ?int $fieldPosition = null): FieldTypeComponent
{
$fieldLocator = new VisibleCSSLocator('', sprintf($this->getLocator('nthField')->getSelector(), $this->getFieldPosition($fieldName)));
if ($fieldPosition === null) {
$fieldPosition = $this->getFieldPosition($fieldName);
}

$activeSections = $this->getHTMLPage()
->setTimeout(0)
->findAll(new VisibleCSSLocator('activeSection', '.ibexa-anchor-navigation-menu__sections-item-btn--active'));
$fieldLocator = $activeSections->any() ?
new VisibleCSSLocator(
'nthFieldWithSection',
sprintf(
$this->getLocator('nthFieldWithSection')->getSelector(),
$activeSections->single()->getAttribute('data-target-id'),
$fieldPosition
)
) :
new VisibleCSSLocator('', sprintf($this->getLocator('nthField')->getSelector(), $fieldPosition));

$fieldTypeIdentifier = $this->getFieldtypeIdentifier($fieldLocator, $fieldName);

foreach ($this->fieldTypeComponents as $fieldTypeComponent) {
Expand Down

0 comments on commit 9b300c2

Please sign in to comment.