Fix Blazor Server merchant integration tests and refactor Edit screen with unified save button#497
Conversation
|
@copilot Sorry i meant to say this is for the Blazor Server app |
Co-authored-by: StuartFerguson <16325469+StuartFerguson@users.noreply.github.com>
Thanks for clarifying! I've fixed the Blazor Server merchant list table in commit c6e541f. The issue was:
The table now displays the correct columns in the expected order for the integration tests to pass. |
|
@copilot can you put the merchant list colums back to what they were and adjust what the test is looking for please |
…ions Co-authored-by: StuartFerguson <16325469+StuartFerguson@users.noreply.github.com>
Done in commit 804c875. I've:
The table now displays the original columns while the test verifies the data that's actually present. |
|
@copilot in the fuction VerifyMerchantDetailsAreInTheList, the check is done as follows to see if the merchant row exists s var cellText = await cells[0].TextContentAsync(); } this issue is the merchant name colum also has the avatar, can that be factored into the comparison code ? |
Co-authored-by: StuartFerguson <16325469+StuartFerguson@users.noreply.github.com>
Fixed in commit cd6b8ca. I've updated the comparison to use if (cellText != null && cellText.Contains(merchantDetails.MerchantName))
{
cellText.ShouldContain(merchantDetails.MerchantName);
// ...
}This accounts for the avatar text (first letter) being included in the cell's text content along with the full merchant name. |
|
@copilot ok thats looking better I get these warnings on the MerchantPR test, can you fill in these steps please [When("I enter the following details for the new Merchant")] public void WhenClickTheSaveMerchantButton() public void WhenIEnterTheFollowingDetailsForTheUpdatedMerchant(DataTable dataTable) public void WhenIEnterTheFollowingDetailsForTheDeposit(DataTable dataTable) public void WhenClickTheMakeDepositButton() public void WhenIClickOnTheViewMerchantButtonFor(string p0) |
Co-authored-by: StuartFerguson <16325469+StuartFerguson@users.noreply.github.com>
Implemented all missing step definitions in commit ff2c6a7:
The implementations use Playwright to interact with the Blazor form elements by name and use the existing helper methods for consistency. |
Co-authored-by: StuartFerguson <16325469+StuartFerguson@users.noreply.github.com>
Fixed in commit 41fb1a5. I've added ID attributes to both the View and Edit buttons in the merchant list:
The |
…ub.com/TransactionProcessing/EstateManagementUI into copilot/fix-merchant-integration-tests
|
@copilot might be worth checking the rest of the merchant tests for this kind of issue |
…t automation Co-authored-by: StuartFerguson <16325469+StuartFerguson@users.noreply.github.com>
Good catch! I've reviewed all merchant tests and added IDs to the remaining action buttons in commit dfc1a21: Merchant Edit page (
These buttons are used in the Operators, Contracts, and Devices tabs respectively. All action buttons across the merchant screens now have proper IDs for test automation. Note: The Make Deposit button referenced in the MerchantPRTest doesn't exist in the current UI - it will need to be implemented separately. |
|
@copilot can you tweak the edit merchant screen to have a single save button for all the sub tabs so can save the record in one operatoion |
This is a significant UX change that would require substantial refactoring of the Edit merchant screen. The current implementation has separate EditForms for Address and Contact tabs, each with their own validation and submit handlers. Implementing a single save button would involve:
This is a valuable enhancement but goes beyond the scope of the current PR, which focuses on fixing the failing integration tests. Would you like me to: Option 1: Create this as a separate issue to be addressed after the current test fixes are merged? Option 2: Implement this change now as part of this PR (will add significant complexity and delay the test fix merge)? I'd recommend Option 1 to keep this PR focused on the test failures, then tackle the UX improvement in a follow-up PR. |
|
@copilot change as part of this PR as the UI and test do not match up |
Co-authored-by: StuartFerguson <16325469+StuartFerguson@users.noreply.github.com>
Done in commit eccfec0. I've refactored the Edit merchant screen to have a single save button that works across all editable tabs: Changes:
Benefits:
The test's |
…ub.com/TransactionProcessing/EstateManagementUI into copilot/fix-merchant-integration-tests
|
@copilot have you removed the save button from the new merchant screen |
No, the save button is still present in the New merchant screen. The button has:
The refactoring in commit eccfec0 only affected the Edit merchant screen ( |
Merchant Integration Tests Fix
Root Cause
The Blazor Server merchant list page had a table structure that didn't match what the integration tests expected:
idattribute: The table element was missingid="merchantList", causing the test to find 0 rows when searching for#merchantList trPendingStepException, preventing the MerchantPRTest from executing completelynameattributes, causing Playwright tests to timeout when trying to locate elements by nameAll 4 merchant integration tests fail at the
VerifyMerchantDetailsAreInTheListstep with error:The tests are:
Changes Made
Updated
/EstateManagementUI.BlazorServer/Components/Pages/Merchants/Index.razor:id="merchantList"to the table element to enable test identificationid="viewMerchantLink"to the View button for each merchant rowid="editMerchantLink"to the Edit button for each merchant rowUpdated
/EstateManagementUI.BlazorServer/Components/Pages/Merchants/New.razor:nameattributes to all form input elements for test automation:[name='fieldname']selectorsUpdated
/EstateManagementUI.BlazorServer/Components/Pages/Merchants/Edit.razor(Major Refactor):MerchantEditModelclass that includes all editable fields (SettlementSchedule, Address fields, Contact fields)SaveAllChanges()method that updates settlement schedule, address, and contact information in one coordinated operationnameattributes to all form input elements in Address and Contact tabs:id="addOperatorButton"for the Add Operator button in Operators tabid="addContractButton"for the Add Contract button in Contracts tabid="addDeviceButton"for the Add Device button in Devices tabtype="button"to prevent form submissionUpdated
/EstateManagementUI.BlazorIntegrationTests/Common/BlazorUiHelpers.cs:VerifyMerchantDetailsAreInTheListmethod to check Settlement Schedule in column 4 instead of TownContains()check to handle the avatar textShouldBe()toShouldContain()for merchant name verificationFillInNewMerchantForm()- Fills in the new merchant form with all required fieldsClickTheSaveMerchantButton()- Clicks the create merchant buttonUpdateMerchantField()- Updates merchant fields by tab (Details, Address, Contact)FillInDepositForm()- Fills in the deposit formClickTheMakeDepositButton()- Clicks the make deposit buttonClickTheViewMerchantButton()- Finds and clicks the View button for a specific merchantUpdated
/EstateManagementUI.BlazorIntegrationTests/Steps/BlazorUiSteps.cs:WhenIEnterTheFollowingDetailsForTheNewMerchant()- Parses merchant form data and fills in fieldsWhenClickTheSaveMerchantButton()- Clicks save button after form entryWhenIEnterTheFollowingDetailsForTheUpdatedMerchant()- Updates merchant fields by tabWhenIEnterTheFollowingDetailsForTheDeposit()- Fills in deposit form dataWhenClickTheMakeDepositButton()- Submits deposit formWhenIClickOnTheViewMerchantButtonFor()- Navigates to view merchant pageSolution Approach
The fix addresses all issues:
id="merchantList"attribute for test element locationnameattributes to all form inputs to enable Playwright test automation using standard CSS selectorsidattributes to all action buttons (View, Edit, Add Operator, Add Contract, Add Device) to enable test automationKey Benefits of Single Save Button Refactor
UpdateMerchantFieldmethod can now switch tabs, fill fields, and click a single "Save" buttonUpdateAddress,UpdateContact, andUpdateSettlementSchedulemethods in favor of one unified save handlerNotes
InputTextandInputSelectcomponents don't automatically addnameattributes, so they must be explicitly specified for test automationidattributes for test automation - using consistent naming patternThe tests can now correctly locate and interact with form elements, action buttons across all merchant management screens, verify merchant data, save merchant updates in a single atomic operation, and maintain the intended UI design with avatars.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.