Description
System info
- Playwright Version: [v1.30]
- Operating System: [Windows 10]
- Browser: [Chromium]
- Other info:
Source code
const unformattedPrice = "11250";
await purchaseVehiclePage.enterAskingPrice(unformattedPrice);
await purchaseVehiclePage.enterTradeInPrice(unformattedPrice);
await purchaseVehiclePage.enterResalePrice(unformattedPrice);
await purchaseVehiclePage.removeFieldFocus();
const priceFields = [
purchaseVehiclePage.askingPriceField,
purchaseVehiclePage.tradeInPriceField,
purchaseVehiclePage.resalePriceField
];
let expectedFormattedPrice = Utils.removeCurrency(Utils.convertToCurrencyFormat(parseInt(unformattedPrice),
workerInfo.project.name));
for (const priceField of priceFields) {
if(workerInfo.project.name==='at') {
await expect(await priceField.inputValue()).toContain("11 250,00");
} else {
await purchaseVehicleAssertion.assertPriceFormat(priceField, expectedFormattedPrice);
}
}
Steps:
Hello, the code itself will probably not have explained much, so here's how to reproduce:
Have a value > 1000.
Have an input field that instead of a "." or a "," puts a whitespace to separate "numeric" values (which are actually string), so for example "11250" would become "11 250,00" or 1000235 would become 1 000 235,00
Grab the .inputValue() of the field after typing or filling an unformatted raw numeric value into the field.
Assert the field with expect(await element.inputValue()).toBe("11 250,00")
Expected
Since "11 250,00" which was fetched from inputValue() is the same as "11 250,00" which was set there as a string in assertions, using any of the matching assertions should correctly deduce the two fields as equal.
Actual
If the inptValue() contains a whitespace, using assertions like .toBe() or .toContain(), comparing string with identical string causes an assertion error. This issue is not reproduced if the inputValue() of the string does not contain a whitespace, so if the number is parsed to "11.250,00" any assertion asserting this inputValue() to be or contain "11.250,00" will pass.
Error: expect(received).toBe(expected) // Object.is equality
Expected: "11 250,00"
Received: "11 250,00"
141 | for (const priceField of priceFields) {
142 | if(workerInfo.project.name==='at') {
143 | await expect(await priceField.inputValue()).toBe("11 250,00");
| ^
144 | } else {
145 | await purchaseVehicleAssertion.assertPriceFormat(priceField, expectedFormattedPrice);
146 | }