-
Notifications
You must be signed in to change notification settings - Fork 15
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
fix: autocoded msg and error msg align fix and separate autocoded msg #3418
base: master
Are you sure you want to change the base?
Conversation
WalkthroughListen up, superstar! We’ve got a flashy update for the currency component that'll make your code shine! The changes involve restructuring the Changes
Possibly related PRs
Suggested Reviewers
Poem
Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (4)
src/app/fyle/add-edit-expense/add-edit-expense.page.scss
(1 hunks)src/app/shared/components/fy-currency/fy-currency.component.html
(1 hunks)src/app/shared/components/fy-currency/fy-currency.component.scss
(2 hunks)src/app/shared/components/fy-currency/fy-currency.component.ts
(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: build (12.x)
🔇 Additional comments (5)
src/app/shared/components/fy-currency/fy-currency.component.ts (2)
43-45
: Mind it! This separation of messages is a superstar move!Breaking down the auto-code message into separate variables for currency and amount improves code clarity and maintainability. That's the style, macha!
188-189
: 🧹 Nitpick (assertive)Simplicity is the ultimate sophistication, thalaiva!
The direct message assignments are clean and effective. But let's make it even more powerful with template literals!
- this.currencyAutoCodeMessage = isCurrencyAutoCoded ? 'Currency is auto coded.' : ''; - this.amountAutoCodeMessage = isAmountAutoCoded ? 'Amount is auto coded.' : ''; + this.currencyAutoCodeMessage = isCurrencyAutoCoded ? `Currency is auto coded.` : ''; + this.amountAutoCodeMessage = isAmountAutoCoded ? `Amount is auto coded.` : '';Likely invalid or redundant comment.
src/app/shared/components/fy-currency/fy-currency.component.scss (2)
41-41
: Kabali style alignment, perfect to the pixel!The flex-start alignment ensures proper vertical positioning of form elements. When you show style, show it like this!
54-54
: Perfect balance, like perfectly balanced dosa!The 50-50 split between currency and amount blocks creates a harmonious layout. This is what I call pixel perfect design!
Also applies to: 59-59
src/app/fyle/add-edit-expense/add-edit-expense.page.scss (1)
650-650
: Error message positioning with style, like my signature walk!The margin adjustment perfectly aligns the error message with the new layout structure. That's what I call attention to detail!
<div class="fy-currency--input-wrapper fy-currency--currency-block"> | ||
<div class="fy-currency--input-container"> | ||
<div class="fy-currency--label"> | ||
Currency | ||
<span class="fy-currency--mandatory"> * </span> | ||
</div> | ||
<input | ||
class="fy-currency--input smartlook-show" | ||
(click)="openCurrencyModal()" | ||
formControlName="currency" | ||
(blur)="onBlur()" | ||
/> | ||
</div> | ||
<div class="fy-currency__auto-coded" *ngIf="currencyAutoCodeMessage"> | ||
<mat-icon class="fy-currency__sparkle-icon" svgIcon="sparkle"></mat-icon> | ||
{{ currencyAutoCodeMessage }} | ||
</div> | ||
<input | ||
class="fy-currency--input smartlook-show" | ||
(click)="openCurrencyModal()" | ||
formControlName="currency" | ||
(blur)="onBlur()" | ||
/> | ||
</div> | ||
<div class="fy-currency--input-container fy-currency--amount-block" [ngClass]="{ 'fy-currency__invalid': !valid }"> | ||
<div class="fy-currency--label"> | ||
Amount | ||
<span class="fy-currency--mandatory"> * </span> | ||
<div class="fy-currency--input-wrapper fy-currency--amount-block"> | ||
<div class="fy-currency--input-container" [ngClass]="{ 'fy-currency__invalid': !valid }"> | ||
<div class="fy-currency--label"> | ||
Amount | ||
<span class="fy-currency--mandatory"> * </span> | ||
</div> | ||
<app-fy-number placeholder="00.00" formControlName="amount" [isAmount]="true"> </app-fy-number> | ||
</div> | ||
<div class="fy-currency__auto-coded" *ngIf="amountAutoCodeMessage"> | ||
<mat-icon class="fy-currency__sparkle-icon" svgIcon="sparkle"></mat-icon> | ||
{{ amountAutoCodeMessage }} | ||
</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick (assertive)
This HTML structure is like a well-choreographed fight scene!
The restructuring improves both visual organization and semantic meaning. But let's make it even more powerful!
Add ARIA labels for better screen reader support:
- <input
+ <input
+ aria-label="Currency input"
class="fy-currency--input smartlook-show"
(click)="openCurrencyModal()"
formControlName="currency"
(blur)="onBlur()"
/>
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
<div class="fy-currency--input-wrapper fy-currency--currency-block"> | |
<div class="fy-currency--input-container"> | |
<div class="fy-currency--label"> | |
Currency | |
<span class="fy-currency--mandatory"> * </span> | |
</div> | |
<input | |
class="fy-currency--input smartlook-show" | |
(click)="openCurrencyModal()" | |
formControlName="currency" | |
(blur)="onBlur()" | |
/> | |
</div> | |
<div class="fy-currency__auto-coded" *ngIf="currencyAutoCodeMessage"> | |
<mat-icon class="fy-currency__sparkle-icon" svgIcon="sparkle"></mat-icon> | |
{{ currencyAutoCodeMessage }} | |
</div> | |
<input | |
class="fy-currency--input smartlook-show" | |
(click)="openCurrencyModal()" | |
formControlName="currency" | |
(blur)="onBlur()" | |
/> | |
</div> | |
<div class="fy-currency--input-container fy-currency--amount-block" [ngClass]="{ 'fy-currency__invalid': !valid }"> | |
<div class="fy-currency--label"> | |
Amount | |
<span class="fy-currency--mandatory"> * </span> | |
<div class="fy-currency--input-wrapper fy-currency--amount-block"> | |
<div class="fy-currency--input-container" [ngClass]="{ 'fy-currency__invalid': !valid }"> | |
<div class="fy-currency--label"> | |
Amount | |
<span class="fy-currency--mandatory"> * </span> | |
</div> | |
<app-fy-number placeholder="00.00" formControlName="amount" [isAmount]="true"> </app-fy-number> | |
</div> | |
<div class="fy-currency__auto-coded" *ngIf="amountAutoCodeMessage"> | |
<mat-icon class="fy-currency__sparkle-icon" svgIcon="sparkle"></mat-icon> | |
{{ amountAutoCodeMessage }} | |
</div> | |
<div class="fy-currency--input-wrapper fy-currency--currency-block"> | |
<div class="fy-currency--input-container"> | |
<div class="fy-currency--label"> | |
Currency | |
<span class="fy-currency--mandatory"> * </span> | |
</div> | |
<input | |
aria-label="Currency input" | |
class="fy-currency--input smartlook-show" | |
(click)="openCurrencyModal()" | |
formControlName="currency" | |
(blur)="onBlur()" | |
/> | |
</div> | |
<div class="fy-currency__auto-coded" *ngIf="currencyAutoCodeMessage"> | |
<mat-icon class="fy-currency__sparkle-icon" svgIcon="sparkle"></mat-icon> | |
{{ currencyAutoCodeMessage }} | |
</div> | |
</div> | |
<div class="fy-currency--input-wrapper fy-currency--amount-block"> | |
<div class="fy-currency--input-container" [ngClass]="{ 'fy-currency__invalid': !valid }"> | |
<div class="fy-currency--label"> | |
Amount | |
<span class="fy-currency--mandatory"> * </span> | |
</div> | |
<app-fy-number placeholder="00.00" formControlName="amount" [isAmount]="true"> </app-fy-number> | |
</div> | |
<div class="fy-currency__auto-coded" *ngIf="amountAutoCodeMessage"> | |
<mat-icon class="fy-currency__sparkle-icon" svgIcon="sparkle"></mat-icon> | |
{{ amountAutoCodeMessage }} | |
</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
src/app/shared/components/fy-currency/fy-currency.component.spec.ts
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: build (12.x)
it('should set currencyAutoCodeMessage to "Currency is auto coded." when only currency is auto coded', () => { | ||
component.autoCodedData = { currency: 'USD', amount: 100 }; | ||
component.fg = new FormGroup({ | ||
currency: new FormControl('USD'), | ||
amount: new FormControl(200), | ||
homeCurrencyAmount: new FormControl(null), | ||
}); | ||
component.showAutoCodeMessage(); | ||
expect(component.autoCodeMessage).toBe('Currency is auto coded.'); | ||
expect(component.currencyAutoCodeMessage).toBe('Currency is auto coded.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick (assertive)
These test cases are like my signature moves - precise and powerful! But let's add some style, thalaiva!
The test cases cover all scenarios perfectly, but we can make them more maintainable by extracting the message strings into constants.
Add these constants at the top of the describe block:
describe('FyCurrencyComponent', () => {
+ const AUTO_CODED_MESSAGES = {
+ CURRENCY: 'Currency is auto coded.',
+ AMOUNT: 'Amount is auto coded.',
+ EMPTY: ''
+ };
let component: FyCurrencyComponent;
// ... rest of the code
Then update the test cases to use these constants:
- expect(component.currencyAutoCodeMessage).toBe('Currency is auto coded.');
+ expect(component.currencyAutoCodeMessage).toBe(AUTO_CODED_MESSAGES.CURRENCY);
Also applies to: 507-515, 518-527
it('should set currencyAutoCodeMessage to "Currency is auto coded." and amountAutoCodeMessage to "Amount is auto coded." when both are auto coded', () => { | ||
component.autoCodedData = { currency: 'USD', amount: 100 }; | ||
component.fg = new FormGroup({ | ||
currency: new FormControl('USD'), | ||
amount: new FormControl(100), | ||
homeCurrencyAmount: new FormControl(null), | ||
}); | ||
component.showAutoCodeMessage(); | ||
expect(component.autoCodeMessage).toBe('Currency and Amount are auto coded.'); | ||
expect(component.currencyAutoCodeMessage).toBe('Currency is auto coded.'); | ||
expect(component.amountAutoCodeMessage).toBe('Amount is auto coded.'); | ||
}); | ||
|
||
it('should set autoCodeMessage to "Currency is auto coded." when only currency is auto coded', () => { | ||
it('should set currencyAutoCodeMessage to "Currency is auto coded." when only currency is auto coded', () => { | ||
component.autoCodedData = { currency: 'USD', amount: 100 }; | ||
component.fg = new FormGroup({ | ||
currency: new FormControl('USD'), | ||
amount: new FormControl(200), | ||
homeCurrencyAmount: new FormControl(null), | ||
}); | ||
component.showAutoCodeMessage(); | ||
expect(component.autoCodeMessage).toBe('Currency is auto coded.'); | ||
expect(component.currencyAutoCodeMessage).toBe('Currency is auto coded.'); | ||
}); | ||
|
||
it('should set autoCodeMessage to "Amount is auto coded." when only amount is auto coded', () => { | ||
it('should set amountAutoCodeMessage to "Amount is auto coded." when only amount is auto coded', () => { | ||
component.autoCodedData = { currency: 'USD', amount: 100 }; | ||
component.fg = new FormGroup({ | ||
currency: new FormControl('EUR'), | ||
amount: new FormControl(100), | ||
homeCurrencyAmount: new FormControl(null), | ||
}); | ||
component.showAutoCodeMessage(); | ||
expect(component.autoCodeMessage).toBe('Amount is auto coded.'); | ||
expect(component.amountAutoCodeMessage).toBe('Amount is auto coded.'); | ||
}); | ||
|
||
it('should set autoCodeMessage to "" when neither currency nor amount is auto coded', () => { | ||
it('should set currencyAutoCodeMessage and amountAutoCodeMessage to "" when neither currency nor amount is auto coded', () => { | ||
component.autoCodedData = { currency: 'USD', amount: 100 }; | ||
component.fg = new FormGroup({ | ||
currency: new FormControl('EUR'), | ||
amount: new FormControl(200), | ||
homeCurrencyAmount: new FormControl(null), | ||
}); | ||
component.showAutoCodeMessage(); | ||
expect(component.autoCodeMessage).toBe(''); | ||
expect(component.currencyAutoCodeMessage).toBe(''); | ||
expect(component.amountAutoCodeMessage).toBe(''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Listen up, all you test warriors! Here's a power-packed suggestion!
We should add one more test case to verify the component's behavior when autoCodedData
is null or undefined, as this is a common edge case in real-world scenarios.
Add this test case:
it('should handle null autoCodedData gracefully', () => {
component.autoCodedData = null;
component.fg = new FormGroup({
currency: new FormControl('USD'),
amount: new FormControl(100),
homeCurrencyAmount: new FormControl(null),
});
component.showAutoCodeMessage();
expect(component.currencyAutoCodeMessage).toBe('');
expect(component.amountAutoCodeMessage).toBe('');
});
it('should set currencyAutoCodeMessage to "Currency is auto coded." and amountAutoCodeMessage to "Amount is auto coded." when both are auto coded', () => { | ||
component.autoCodedData = { currency: 'USD', amount: 100 }; | ||
component.fg = new FormGroup({ | ||
currency: new FormControl('USD'), | ||
amount: new FormControl(100), | ||
homeCurrencyAmount: new FormControl(null), | ||
}); | ||
component.showAutoCodeMessage(); | ||
expect(component.autoCodeMessage).toBe('Currency and Amount are auto coded.'); | ||
expect(component.currencyAutoCodeMessage).toBe('Currency is auto coded.'); | ||
expect(component.amountAutoCodeMessage).toBe('Amount is auto coded.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick (assertive)
Mind-blowing test coverage, macha! But let's make it even more powerful!
The test case for both auto-coded fields is solid, but we can enhance it further by verifying the initial state before calling showAutoCodeMessage()
.
it('should set currencyAutoCodeMessage to "Currency is auto coded." and amountAutoCodeMessage to "Amount is auto coded." when both are auto coded', () => {
component.autoCodedData = { currency: 'USD', amount: 100 };
component.fg = new FormGroup({
currency: new FormControl('USD'),
amount: new FormControl(100),
homeCurrencyAmount: new FormControl(null),
});
+ expect(component.currencyAutoCodeMessage).toBe('');
+ expect(component.amountAutoCodeMessage).toBe('');
component.showAutoCodeMessage();
expect(component.currencyAutoCodeMessage).toBe('Currency is auto coded.');
expect(component.amountAutoCodeMessage).toBe('Amount is auto coded.');
});
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
it('should set currencyAutoCodeMessage to "Currency is auto coded." and amountAutoCodeMessage to "Amount is auto coded." when both are auto coded', () => { | |
component.autoCodedData = { currency: 'USD', amount: 100 }; | |
component.fg = new FormGroup({ | |
currency: new FormControl('USD'), | |
amount: new FormControl(100), | |
homeCurrencyAmount: new FormControl(null), | |
}); | |
component.showAutoCodeMessage(); | |
expect(component.autoCodeMessage).toBe('Currency and Amount are auto coded.'); | |
expect(component.currencyAutoCodeMessage).toBe('Currency is auto coded.'); | |
expect(component.amountAutoCodeMessage).toBe('Amount is auto coded.'); | |
it('should set currencyAutoCodeMessage to "Currency is auto coded." and amountAutoCodeMessage to "Amount is auto coded." when both are auto coded', () => { | |
component.autoCodedData = { currency: 'USD', amount: 100 }; | |
component.fg = new FormGroup({ | |
currency: new FormControl('USD'), | |
amount: new FormControl(100), | |
homeCurrencyAmount: new FormControl(null), | |
}); | |
expect(component.currencyAutoCodeMessage).toBe(''); | |
expect(component.amountAutoCodeMessage).toBe(''); | |
component.showAutoCodeMessage(); | |
expect(component.currencyAutoCodeMessage).toBe('Currency is auto coded.'); | |
expect(component.amountAutoCodeMessage).toBe('Amount is auto coded.'); | |
}); |
|
Clickup
https://app.clickup.com/t/86cx6388g
Code Coverage
Please add code coverage here
UI Preview
Previous UI :
Updated UI :
Summary by CodeRabbit
Release Notes
UI/UX Improvements
Bug Fixes
These updates aim to provide a clearer user experience and more precise input field styling.