Skip to content

Conversation

@yuliiakaras
Copy link
Collaborator

@yuliiakaras yuliiakaras commented Jan 10, 2025

#7892

Summary by CodeRabbit

Release Notes

  • UI/UX Improvements

    • Refined responsive design with adjusted font sizes and layout for better readability.
    • Updated paragraph alignment and styling in the confirmation page for improved text presentation.
  • Localization Updates

    • Enhanced support chat messaging in English and Ukrainian for user inquiries.
    • Refined environmental messaging tone to promote collaborative care for the environment.
  • Performance

    • Improved location name handling across multiple components.
    • Optimized multilingual location name retrieval for better clarity and consistency.
  • Bug Fixes

    • Corrected location name display for specific cities like Kyiv.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 10, 2025

Walkthrough

The pull request introduces modifications across multiple files in the UBS (Unified Booking System) application, focusing on location handling, user interface styling, and localization. The changes primarily involve refining how location names are displayed, adjusting responsive design parameters, and updating support-related text in both English and Ukrainian languages. The modifications aim to improve user experience by providing more precise location representations and more engaging support-related messaging.

Changes

File Change Summary
src/app/ubs/ubs/components/ubs-confirm-page/ubs-confirm-page.component.html Paragraph element class changed from p-40 to d-flex justify-content-center for centered content alignment.
src/app/ubs/ubs/components/ubs-main-page/ubs-main-page.component.scss Responsive design updates: increased form field width, reduced font sizes for various elements on different screen sizes.
src/app/ubs/ubs/components/ubs-main-page/ubs-main-page.component.ts Properties and constructor parameters marked as readonly; updated getActiveLocationsToShow method to use orderService.getLocationName.
src/app/ubs/ubs/components/ubs-order-details/ubs-order-details.component.spec.ts Updated test case expectation for currentLocation to simplify location representation.
src/app/ubs/ubs/components/ubs-order-details/ubs-order-details.component.ts Visibility of $destroy changed to private readonly; updated currentLocation initialization logic.
src/app/ubs/ubs/components/ubs-order-details/ubs-order-location-popup/ubs-order-location-popup.component.ts Added readonly to constructor parameters; updated getLocations method to use orderService.getLocationName.
src/assets/i18n/ubs/en.json Updated support-related text to emphasize support chat.
src/assets/i18n/ubs/ua.json Modified description and support-related text with more environmentally-focused and proactive messaging.
src/app/ubs/ubs/services/order.service.ts Introduced getLocationName method and standaloneCities property; constructor parameters updated to readonly.
src/app/chat/component/chat-message/chat-message.component.spec.ts Added mock implementation for TranslateService in tests.
src/app/chat/service/socket/socket.service.spec.ts Integrated TranslateService mock and removed UserService.
src/app/main/component/shared/components/form-base/form-base.component.spec.ts Added TranslateService mock to test setup.
src/app/ubs/ubs/components/ubs-confirm-page/ubs-confirm-page.component.spec.ts Added getUserId method to fakeLocalStorageService mock.
src/app/ubs/ubs/components/ubs-order-details/ubs-order-certificate/ubs-order-certificate.component.spec.ts Added getUserId method to localStorageService mock.
src/app/ubs/ubs/services/order.service.spec.ts Added tests for getLocationName method in OrderService.

Possibly related PRs

  • [Feat] #7967 add client chat #3512: The changes in the main PR regarding the ubs-confirm-page.component.html involve modifications to the layout and content presentation, which may relate to the client chat feature introduced in this PR, enhancing user interaction and support options.
  • [Feat] #7970 Settings and functionality of different profile privacy states  #3521: The updates in the main PR that simplify the content displayed in the confirmation page could be connected to the privacy settings and functionalities introduced in this PR, as both aim to improve user experience and interface clarity.

Suggested reviewers

  • kryzanivska-nastya
  • Lokankara

Poem

🐰 A Rabbit's Location Tale 🌍
In Kyiv's streets, no region's name,
Our code now dances with linguistic flame,
Flexbox centers, fonts resize with grace,
Support chat whispers in a friendly embrace,
Multilingual magic, our rabbit's delight! 🌈

Finishing Touches

  • 📝 Generate Docstrings (Beta)

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (3)
src/app/ubs/ubs/components/ubs-order-details/ubs-order-details.component.ts (1)

303-307: Consider reusing location name formatting logic.

The current implementation duplicates the logic for handling standalone cities that exists in UbsMainPageComponent. Consider extracting this logic into a shared service to maintain consistency and reduce code duplication.

Example implementation:

// location.service.ts
@Injectable({
  providedIn: 'root'
})
export class LocationService {
  private readonly standaloneCities = ['Kyiv', 'Київ'];

  getLocationName(location: string, region: string): string {
    return this.standaloneCities.includes(location) ? location : `${location}, ${region}`;
  }
}

Then inject and use this service in both components:

-  this.currentLocation =
-    location.nameEn === 'Kyiv'
-      ? this.langService.getLangValue(location.nameUk, location.nameEn)
-      : this.langService.getLangValue(location.nameUk, location.nameEn) +
-        ', ' +
-        this.langService.getLangValue(region.nameUk, region.nameEn);
+  const locationName = this.locationService.getLocationName(
+    this.langService.getLangValue(location.nameUk, location.nameEn),
+    this.langService.getLangValue(region.nameUk, region.nameEn)
+  );
+  this.currentLocation = locationName;
src/app/ubs/ubs/components/ubs-order-details/ubs-order-details.component.spec.ts (1)

296-296: Remove duplicate test case.

There are two identical test cases for initLocation method that verify the same behavior. Consider removing one of them to maintain a clean test suite.

Also applies to: 317-317

src/app/ubs/ubs/components/ubs-order-details/ubs-order-location-popup/ubs-order-location-popup.component.ts (1)

111-115: Consider making the city name comparison more maintainable.

The hard-coded string comparison with 'Kyiv' might be fragile. Consider:

  1. Moving special city names to a configuration constant
  2. Adding null/undefined checks for the location and region parameters
+ private readonly STANDALONE_CITIES = ['Kyiv'];
+
  private getLocationName(location: { nameUk: string; nameEn: string }, region: { nameUk: string; nameEn: string }): string {
+   if (!location || !region) {
+     return '';
+   }
-   return location.nameEn === 'Kyiv'
+   return this.STANDALONE_CITIES.includes(location.nameEn)
      ? this.getLangValue(location.nameUk, location.nameEn)
      : this.getLangValue(location.nameUk, location.nameEn) + ', ' + this.getLangValue(region.nameUk, region.nameEn);
  }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 487e4c0 and a54812b.

📒 Files selected for processing (8)
  • src/app/ubs/ubs/components/ubs-confirm-page/ubs-confirm-page.component.html (1 hunks)
  • src/app/ubs/ubs/components/ubs-main-page/ubs-main-page.component.scss (2 hunks)
  • src/app/ubs/ubs/components/ubs-main-page/ubs-main-page.component.ts (3 hunks)
  • src/app/ubs/ubs/components/ubs-order-details/ubs-order-details.component.spec.ts (2 hunks)
  • src/app/ubs/ubs/components/ubs-order-details/ubs-order-details.component.ts (1 hunks)
  • src/app/ubs/ubs/components/ubs-order-details/ubs-order-location-popup/ubs-order-location-popup.component.ts (4 hunks)
  • src/assets/i18n/ubs/en.json (1 hunks)
  • src/assets/i18n/ubs/ua.json (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/app/ubs/ubs/components/ubs-confirm-page/ubs-confirm-page.component.html
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build (18.x)
🔇 Additional comments (8)
src/app/ubs/ubs/components/ubs-main-page/ubs-main-page.component.scss (2)

103-106: Verify layout on small screens.

The increased minimum width (320px) for form fields could potentially cause overflow or layout issues on very small screens.

Please test the layout on various small screen sizes (320px-375px) to ensure:

  1. No horizontal scrolling is introduced
  2. Form fields remain properly aligned
  3. Text remains readable without truncation

122-122: LGTM! Font size adjustment improves readability.

The reduction in font size for location names on medium screens (17px) maintains good readability while better utilizing the available space.

src/app/ubs/ubs/components/ubs-main-page/ubs-main-page.component.ts (2)

53-53: LGTM! Good approach to define standalone cities.

The array of standalone cities is well-defined and makes it easy to maintain the list of cities that should be displayed without region names.


272-273: LGTM! Clean implementation of location name formatting.

The getLocationName method provides a clean and consistent way to format location names. The implementation correctly handles both standalone cities and cities that need region names.

Also applies to: 282-284

src/assets/i18n/ubs/ua.json (1)

Line range hint 1-1000: Verify city name display changes.

The PR objective mentions changing city name display (#7892), but the changes are about support chat messaging. Let's verify if there are any city-related strings that need attention.

src/app/ubs/ubs/components/ubs-order-details/ubs-order-location-popup/ubs-order-location-popup.component.ts (3)

12-12: LGTM! Clean import of LanguageService.

The import follows Angular's best practices for dependency injection.


35-39: LGTM! Good use of readonly for dependency injection.

Making dependencies readonly is a TypeScript best practice that prevents accidental reassignment and improves code safety.


95-97: Verify location name parsing in changeLocation method.

The changeLocation method splits the location name by comma to extract the city name, which might break with the new location name format from getLocationName. Consider using a more robust approach:

  changeLocation(id: number, locationName: string): number {
    this.selectedLocationId = id;
-   this.currentLocation = locationName.split(',')[0];
+   this.currentLocation = locationName.split(',')[0].trim();
    return id;
  }

Run this script to verify the impact:

Also applies to: 166-170

✅ Verification successful

Current location name parsing is correct and safe

The getLocationName method consistently formats locations as either a standalone city name (for Kyiv) or "city, region" with a comma separator. The current split(',')[0] operation in changeLocation safely extracts the city name in both cases. No changes are needed.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other instances of location name parsing
rg -l 'split.*,.*\[0\]' | xargs rg -A 5 'split.*,.*\[0\]'

Length of output: 2263


Script:

#!/bin/bash
# Search for getLocationName implementation
ast-grep --pattern 'getLocationName($$$) {
  $$$
}'

Length of output: 53


Script:

#!/bin/bash
# Search for getLocationName method with context
rg -A 5 "getLocationName" 

Length of output: 3220

}

private getLocationName(location: { nameUk: string; nameEn: string }, region: { nameUk: string; nameEn: string }): string {
return location.nameEn === 'Kyiv'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid repeating the this.getLangValue function calls and it can be made more concise and clear:

  const locationName = this.getLangValue(location.nameUk, location.nameEn);
  const regionName = this.getLangValue(region.nameUk, region.nameEn);
  return location.nameEn === 'Kyiv' ? locationName : `${locationName}, ${regionName}`;

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🧹 Nitpick comments (2)
src/app/ubs/ubs/services/order.service.ts (1)

34-35: Consider making standaloneCities more maintainable.

The hardcoded array of standalone cities could be moved to a configuration file or enum to make it more maintainable and reusable across the application.

src/app/main/component/shared/components/form-base/form-base.component.spec.ts (1)

24-27: Consider enhancing the mock TranslateService implementation.

While the current mock implementation is functional, consider these improvements:

  1. Use different mock values for different translation keys to better simulate real scenarios
  2. Add error cases to test error handling

Here's a suggested enhancement:

  const mockTranslateService = {
-   get: jasmine.createSpy('get').and.returnValue(of('mockTranslation')),
-   instant: jasmine.createSpy('instant').and.returnValue('mockTranslation')
+   get: jasmine.createSpy('get').and.callFake((key: string) => 
+     of(key === 'ERROR.KEY' ? null : `translated.${key}`)),
+   instant: jasmine.createSpy('instant').and.callFake((key: string) => 
+     key === 'ERROR.KEY' ? null : `translated.${key}`)
  };
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a54812b and c02bc2a.

📒 Files selected for processing (11)
  • src/app/chat/component/chat-message/chat-message.component.spec.ts (1 hunks)
  • src/app/chat/service/socket/socket.service.spec.ts (2 hunks)
  • src/app/main/component/shared/components/form-base/form-base.component.spec.ts (3 hunks)
  • src/app/ubs/ubs/components/ubs-confirm-page/ubs-confirm-page.component.spec.ts (1 hunks)
  • src/app/ubs/ubs/components/ubs-main-page/ubs-main-page.component.ts (3 hunks)
  • src/app/ubs/ubs/components/ubs-order-details/ubs-order-certificate/ubs-order-certificate.component.spec.ts (3 hunks)
  • src/app/ubs/ubs/components/ubs-order-details/ubs-order-details.component.spec.ts (1 hunks)
  • src/app/ubs/ubs/components/ubs-order-details/ubs-order-details.component.ts (3 hunks)
  • src/app/ubs/ubs/components/ubs-order-details/ubs-order-location-popup/ubs-order-location-popup.component.ts (2 hunks)
  • src/app/ubs/ubs/services/order.service.spec.ts (4 hunks)
  • src/app/ubs/ubs/services/order.service.ts (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • src/app/ubs/ubs/components/ubs-order-details/ubs-order-details.component.spec.ts
  • src/app/ubs/ubs/components/ubs-order-details/ubs-order-details.component.ts
  • src/app/ubs/ubs/components/ubs-order-details/ubs-order-location-popup/ubs-order-location-popup.component.ts
  • src/app/ubs/ubs/components/ubs-main-page/ubs-main-page.component.ts
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build (18.x)
🔇 Additional comments (7)
src/app/ubs/ubs/components/ubs-order-details/ubs-order-certificate/ubs-order-certificate.component.spec.ts (2)

8-8: LGTM! TranslateStore import added for localization support

The addition of TranslateStore aligns with the PR's objective of improving city name display.


57-57: LGTM! TranslateStore provider added

The provider configuration ensures proper translation support for the component.

src/app/chat/component/chat-message/chat-message.component.spec.ts (1)

8-9: LGTM! Well-structured test setup for translations.

The mock implementation properly covers both synchronous and asynchronous translation methods, following testing best practices.

Also applies to: 14-17, 23-23

src/app/chat/service/socket/socket.service.spec.ts (1)

10-11: Verify the removal of UserService provider.

While the translation service setup looks good, please verify that the UserService provider was intentionally removed and isn't needed by the SocketService or its tests.

Also applies to: 21-24, 32-35

src/app/main/component/shared/components/form-base/form-base.component.spec.ts (3)

11-11: LGTM: Import statement is correctly placed.

The TranslateService import is appropriately added and necessary for the translation functionality being tested.


38-39: LGTM: Provider configuration is correct.

The TranslateService provider is properly configured in the TestBed setup, following Angular testing best practices.


Line range hint 52-66: Verify translation functionality test coverage.

While TranslateService has been added to the test setup, there don't appear to be any tests specifically verifying its usage. Consider adding test cases that verify the component's interaction with translations.

Let's check for translation usage in the component:

Comment on lines +30 to +35
const localStorageService = jasmine.createSpyObj('localStorageService', [
'getCurrentLanguage',
'languageSubject',
'getUbsOrderData',
'getUserId'
]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Remove unused mock method getUserId

The getUserId mock method is defined but never used in either the component implementation or test cases. Consider removing it from the mock definition to maintain clean code.

🔗 Analysis chain

Verify test coverage for getUserId usage

The mock has been extended with getUserId, but there are no visible test cases verifying its usage.

Let's verify the component's usage of getUserId:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for getUserId usage in the component
rg "getUserId" "src/app/ubs/ubs/components/ubs-order-details/ubs-order-certificate/ubs-order-certificate.component.ts"

Length of output: 116


Script:

#!/bin/bash
# Search for getUserId usage in the spec file
rg "getUserId" "src/app/ubs/ubs/components/ubs-order-details/ubs-order-certificate/ubs-order-certificate.component.spec.ts" -A 3

# Search for test descriptions that might relate to user ID
rg "describe|it\(" "src/app/ubs/ubs/components/ubs-order-details/ubs-order-certificate/ubs-order-certificate.component.spec.ts"

Length of output: 431

Comment on lines +31 to +32
'removeUBSExistingOrderId',
'getUserId'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Remove unused getUserId mock from LocalStorageService

The getUserId mock method is not used by the UbsConfirmPageComponent. It should be removed to maintain clean and relevant test specifications.

🔗 Analysis chain

Add test coverage for getUserId functionality

The mock service has been extended with getUserId, but there are no test cases verifying its usage in the component.

Let's verify the component's usage of getUserId:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for getUserId usage in the component
rg "getUserId" "src/app/ubs/ubs/components/ubs-confirm-page/ubs-confirm-page.component.ts"

# If found, we should add test cases to verify the functionality

Length of output: 88


Script:

#!/bin/bash
# Check component class definition and inheritance
rg "export class UbsConfirmPageComponent" -A 2 "src/app/ubs/ubs/components/ubs-confirm-page/ubs-confirm-page.component.ts"

# Search for getUserId usage in related files
rg "getUserId" --type ts "src/app/ubs/ubs/"

Length of output: 838

Comment on lines +76 to +78
private getName(input: { nameUk: string; nameEn: string } | string): string {
return typeof input === 'string' ? input : this.langService.getLangValue(input.nameUk, input.nameEn);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add input validation to getName method.

The method should handle undefined/null inputs and validate object properties.

Consider this implementation:

 private getName(input: { nameUk: string; nameEn: string } | string): string {
+  if (!input) {
+    return '';
+  }
+  if (typeof input === 'object' && (!input.nameUk || !input.nameEn)) {
+    return '';
+  }
   return typeof input === 'string' ? input : this.langService.getLangValue(input.nameUk, input.nameEn);
 }
📝 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.

Suggested change
private getName(input: { nameUk: string; nameEn: string } | string): string {
return typeof input === 'string' ? input : this.langService.getLangValue(input.nameUk, input.nameEn);
}
private getName(input: { nameUk: string; nameEn: string } | string): string {
if (!input) {
return '';
}
if (typeof input === 'object' && (!input.nameUk || !input.nameEn)) {
return '';
}
return typeof input === 'string' ? input : this.langService.getLangValue(input.nameUk, input.nameEn);
}

Comment on lines +69 to +74
getLocationName(location: { nameUk: string; nameEn: string } | string, region: { nameUk: string; nameEn: string } | string): string {
const locationName = this.getName(location);
const regionName = this.getName(region);

return this.standaloneCities.includes(locationName) ? locationName : `${locationName}, ${regionName}`;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add input validation to getLocationName method.

The method should handle undefined/null inputs to prevent runtime errors.

Consider this implementation:

 getLocationName(location: { nameUk: string; nameEn: string } | string, region: { nameUk: string; nameEn: string } | string): string {
+  if (!location || !region) {
+    return '';
+  }
   const locationName = this.getName(location);
   const regionName = this.getName(region);

   return this.standaloneCities.includes(locationName) ? locationName : `${locationName}, ${regionName}`;
 }
📝 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.

Suggested change
getLocationName(location: { nameUk: string; nameEn: string } | string, region: { nameUk: string; nameEn: string } | string): string {
const locationName = this.getName(location);
const regionName = this.getName(region);
return this.standaloneCities.includes(locationName) ? locationName : `${locationName}, ${regionName}`;
}
getLocationName(location: { nameUk: string; nameEn: string } | string, region: { nameUk: string; nameEn: string } | string): string {
if (!location || !region) {
return '';
}
const locationName = this.getName(location);
const regionName = this.getName(region);
return this.standaloneCities.includes(locationName) ? locationName : `${locationName}, ${regionName}`;
}

Comment on lines +253 to +272
it('should return locationName when it is in standaloneCities', () => {
const location = 'Kyiv';
const region = 'Ukraine';
const result = service.getLocationName(location, region);
expect(result).toBe('Kyiv');
});

it('should return "locationName, regionName" when locationName is not in standaloneCities', () => {
const location = 'Lviv';
const region = 'Ukraine';
const result = service.getLocationName(location, region);
expect(result).toBe('Lviv, Ukraine');
});

it('should handle object input for location and region', () => {
const location = { nameUk: 'Львів', nameEn: 'Lviv' };
const region = { nameUk: 'Україна', nameEn: 'Ukraine' };
const result = service.getLocationName(location, region);
expect(result).toBe('Lviv, Ukraine');
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add test cases for edge cases in getLocationName.

The current test coverage should be expanded to include:

  • Null/undefined inputs
  • Invalid object inputs (missing properties)
  • Empty string inputs

Consider adding these test cases:

it('should handle null/undefined inputs', () => {
  expect(service.getLocationName(null, null)).toBe('');
  expect(service.getLocationName(undefined, undefined)).toBe('');
});

it('should handle invalid object inputs', () => {
  const invalidLocation = { nameUk: null, nameEn: null };
  const invalidRegion = { nameUk: '', nameEn: '' };
  expect(service.getLocationName(invalidLocation, invalidRegion)).toBe('');
});

it('should handle empty string inputs', () => {
  expect(service.getLocationName('', '')).toBe('');
});

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
62.2% Coverage on New Code (required ≥ 75%)

See analysis details on SonarQube Cloud

@yuliiakaras yuliiakaras merged commit 1d2269c into dev Jan 13, 2025
2 of 3 checks passed
@yuliiakaras yuliiakaras deleted the bugfix/#7892-change-city-name-display branch January 13, 2025 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants