Skip to content

Commit

Permalink
Merge pull request #8677 from nick-prater/contact-bank-account-testing
Browse files Browse the repository at this point in the history
Field labels and BDD tests for Bank Account screen
  • Loading branch information
nick-prater authored Feb 28, 2025
2 parents 3ce15b8 + fbcc9be commit fdb29a0
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 15 deletions.
13 changes: 10 additions & 3 deletions UI/Contact/divs/bank_act.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,23 @@
<lsmb-text title="[% text('BIC/SWIFT Code') %]"
name="bic"
value="[% request.bic %]"
size="20" ></lsmb-text>
size="20"
label="[% text('BIC/SWIFT Code') %]"
required
></lsmb-text>
<lsmb-text title="[% text('Bank Account') %]"
name="iban"
value="[% request.iban %]"
size="20"
required ></lsmb-text>
label="[% text('Account Number') %]"
required
></lsmb-text>
<lsmb-text title="[% text('Remark') %]"
name="remark"
value="[% request.remark %]"
size="30" ></lsmb-text>
size="30"
label="[% text('Remark') %]"
></lsmb-text>
</div>
<div>
[% PROCESS button element_data = {
Expand Down
25 changes: 25 additions & 0 deletions xt/66-cucumber/02-contacts/bank_account.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
@weasel
Feature: Add Entity
As a LedgerSMB user I want to add a bank account to an entity, edit that
bank account, then delete it.

Background:
Given a standard test company
And a logged in admin user

Scenario: Create a company and add a bank account to it
When I navigate the menu and select the item at "Contacts > Add Entity"
Then I should see the Edit Contact screen
And I expect the "Company" tab to be selected
When I enter "Company A" into "Name"
And I select "Germany" from the drop down "Country"
And I press "Save"
And I select the "Bank Accounts" tab
Then I expect the "Bank Accounts" tab to be selected
When I enter "DEUTDEFF500" into the "BIC/SWIFT Code" field
And I enter "DE89370400440532013000" into the "Account Number" field
And I enter "A remark" into the "Remark" field
And I press "Save"
Then I expect the Bank Accounts table to contain 1 row
And I expect the 'BIC/SWIFT Code' column to contain 'DEUTDEFF500' for Account Number 'DE89370400440532013000'
And I expect the 'Remark' column to contain 'A remark' for Account Number 'DE89370400440532013000'
41 changes: 34 additions & 7 deletions xt/66-cucumber/02-contacts/step_definitions/pageobject_steps.pl
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,27 @@
};


Then qr/^I expect the Accounts table to contain (\d+) rows?$/, sub {
my $wanted_row_count = $1;
Then qr/^I expect the (.+) table to contain (\d+) rows?$/, sub {
my $table_name = $1;
my $wanted_row_count = $2;

my %table_ids =(
'Accounts' => 'credit_accounts_list',
'Bank Accounts' => 'bank_account_list',
);

my $table_id = $table_ids{$table_name}
or die qq{no id defined for "$table_name" table};

my @rows = S->{ext_wsl}->page->body->maindiv->content->find_all(
'.//table[@id="credit_accounts_list"]/tbody/tr'
".//table[\@id='$table_id']/tbody/tr"
);
my $row_count = scalar @rows;


my $page = S->{ext_wsl}->page->body->maindiv->content;


is($row_count, $wanted_row_count, "Accounts table contains $wanted_row_count rows");
};

Expand All @@ -33,12 +47,25 @@
When qr/^I press "(.+)"$/, sub {
my $button_text = $1;
my $page = S->{ext_wsl}->page->body->maindiv->content;
my $active_pane = $page->find(
'.//div[@role="tabpanel" and contains(@class,"dijitVisible")]'
);
$active_pane->find(
$page->active_pane->find(
".//*[\@role='button']/*[text()='$button_text']"
)->click;
};


When qr/^I enter "(.+)" into the "(.+)" field$/, sub {
my $text = $1;
my $field_name = $2;
my $page = S->{ext_wsl}->page->body->maindiv->content;

my $label = $page->active_pane->find(
".//label[text()='$field_name']"
);
my $field_id = $label->get_attribute('for');
my $field = $page->active_pane->find(
".//input[\@id='$field_id']"
);
$field->send_keys($text);
};

1;
13 changes: 13 additions & 0 deletions xt/lib/PageObject/App/Contacts/EditContact.pm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use PageObject;
use Moose;
use namespace::autoclean;
extends 'PageObject';
with 'PageObject::App::Roles::Dynatable';

__PACKAGE__->self_register(
'edit_contact',
Expand All @@ -24,6 +25,15 @@ sub _verify {
}


sub active_pane {
my $self = shift;
my $element = $self->find(
'.//div[@role="tabpanel" and contains(@class,"dijitVisible")]'
);
return $element;
}


sub find_tab {
my $self = shift;
my $tab_text = shift;
Expand All @@ -48,5 +58,8 @@ sub tab_is_selected {
}





__PACKAGE__->meta->make_immutable;
1;
32 changes: 28 additions & 4 deletions xt/lib/PageObject/App/Roles/Dynatable.pm
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,28 @@ use PageObject;
use Moose::Role;
use namespace::autoclean;

has table => (
is => 'rw',
isa => 'Weasel::Element',
builder => 'find_table',
lazy => 1,
);


# find_table()
#
# Builder for `table` property
# Returns first visible dynatable element on the page

sub find_table {
my $self = shift;

return $self->find(
'.//table[contains(@class, "dynatable") '.
'and not(ancestor::*[contains(@class, "dijitHidden")])]'
);
}


# title ()
#
Expand Down Expand Up @@ -39,9 +61,10 @@ sub find_heading {

sub _extract_column_headings {
my $self = shift;

my @heading_nodes = $self->find_all('.//table/thead/tr/th
| .//table/thead/tr/td');
my @heading_nodes = $self->table->find_all(
'.//thead/tr/th | '.
'.//thead/tr/td'
);
return map { $_->get_text } @heading_nodes;;
}

Expand All @@ -56,7 +79,7 @@ sub rows {
my $self = shift;

my @headings = $self->_extract_column_headings;
my @rows = $self->find_all('.//table[contains(@class, "dynatable")]/tbody/tr');
my @rows = $self->table->find_all('.//tbody/tr');

return map {
my @cells = $_->find_all('./td | ./th');
Expand All @@ -68,4 +91,5 @@ sub rows {
}



1;
2 changes: 1 addition & 1 deletion xt/lib/Pherkin/Extension/pageobject_steps/report_steps.pl
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
};


Then qr/I expect the '(.*)' report column to contain '(.*)' for (.*) '(.*)'/, sub {
Then qr/I expect the '(.*)'\s+(?:report )?column to contain '(.*)'\s+for (.*) '(.*)'/, sub {
my @rows = S->{ext_wsl}->page->body->maindiv->content->rows;
my $column = $1;
my $value = $2;
Expand Down

0 comments on commit fdb29a0

Please sign in to comment.