Skip to content

Resolves #8#35

Merged
GyeongHoKim merged 9 commits intodevelopfrom
feature/kakao-map
Mar 16, 2025
Merged

Resolves #8#35
GyeongHoKim merged 9 commits intodevelopfrom
feature/kakao-map

Conversation

@GyeongHoKim
Copy link
Owner

@GyeongHoKim GyeongHoKim commented Mar 16, 2025

User description

Close #8


PR Type

Enhancement, Tests


Description

  • Implement kakao-map web component

  • Add map context for component communication

  • Include comprehensive event handling and map controls

  • Add extensive component tests


Changes walkthrough 📝

Relevant files
Enhancement
7 files
map.ts
Implement Kakao Map web component                                               
+413/-0 
map-context.ts
Create map context for sharing map instance                           
+4/-0     
index.ts
Export map context                                                                             
+1/-0     
latlng.d.ts
Define LatLng type interface                                                         
+8/-0     
point.d.ts
Define Point type interface                                                           
+8/-0     
index.ts
Export map component                                                                         
+1/-0     
index.ts
Add map component exports                                                               
+1/-0     
Tests
1 files
map.component.ts
Add comprehensive map component tests                                       
+291/-0 
Configuration changes
1 files
component-index.html
Update test environment styles                                                     
+13/-1   
Dependencies
3 files
package.json
Add dependency and test scripts                                                   
+5/-0     
package.json
Add npm-run-all dev dependency                                                     
+1/-0     
pnpm-lock.yaml
Update lockfile with new dependencies                                       
+271/-0 

Need help?
  • Type /help how to ... in the comments thread for any questions about PR-Agent usage.
  • Check out the documentation for more information.
  • - @lit/context 라이브러리 의존성 추가
    - 카카오 맵 컨텍스트 생성을 위한 map-context.ts 파일 구현
    - 컨텍스트 관련 인덱스 파일 생성
    - 카카오 맵 생성 시 map-created 이벤트가 발생하는지 확인하는 테스트 케이스 구현
    - component-index.html 파일에 스타일 추가 및 데이터 속성 수정
    - 카카오 맵 컴포넌트를 위한 map.ts 파일 구현
    - 맵 관련 속성과 이벤트 처리 로직 추가
    - LatLng 및 Point 타입 정의 추가
    - map-context.ts에 MapContext 타입 추가
    - index.ts에서 맵 컴포넌트와 관련된 모듈 내보내기
    … to .gitignore
    
    - package.json에 Cypress 테스트 스크립트 추가
    - .gitignore에 스크린샷 디렉토리 추가
    - 카카오 맵 컴포넌트의 다양한 이벤트(위치 이동, 줌, 클릭 등)에 대한 테스트 케이스 추가
    - 드래그 가능 및 줌 가능 속성에 대한 테스트 구현
    - 맵 타입 ID 속성 처리 테스트 추가
    - mapTypeId 속성을 문자열에서 숫자로 변경하고, 속성 변환 로직 추가
    - kakao.maps.MapTypeId에 대한 변환 기능 구현
    @GyeongHoKim GyeongHoKim requested a review from Copilot March 16, 2025 07:38
    @GyeongHoKim GyeongHoKim self-assigned this Mar 16, 2025
    @GyeongHoKim GyeongHoKim added the feature I added new feature, please review my code label Mar 16, 2025
    Copy link

    Copilot AI left a comment

    Choose a reason for hiding this comment

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

    Pull Request Overview

    This PR resolves issue #8 by adding comprehensive Cypress tests for the Kakao map component and updating context and export modules accordingly.

    • Added Cypress tests to verify event handling (map-created, click, dragging, zoom, etc.) in the Kakao map component.
    • Introduced a map context via lit's createContext.
    • Updated package export indices to include the new map components and context.

    Reviewed Changes

    Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.

    Show a summary per file
    File Description
    packages/kakao-map-components/cypress/src/components/map/map.component.ts Added event-based Cypress tests for the Kakao map component.
    packages/kakao-map-components/src/context/map-context.ts Added a new context for the Kakao map using lit's createContext.
    packages/kakao-map-components/src/context/index.ts Exported the new map context.
    packages/kakao-map-components/src/components/map/index.ts Exported the Kakao map component.
    packages/kakao-map-components/src/index.ts Updated index exports to include the map component.
    Comments suppressed due to low confidence (1)

    packages/kakao-map-components/cypress/src/components/map/map.component.ts:7

    • [nitpick] The test title 'should fires map-created event when map is created' contains a grammatical error. Consider changing it to 'should fire map-created event when map is created'.
     7 +  it('should fires map-created event when map is created', () => {
    

    @github-actions
    Copy link

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    🎫 Ticket compliance analysis ✅

    8 - PR Code Verified

    Compliant requirements:

    • Implement a kakao-map web component
    • Add functionality for component communication
    • Include event handling for map interactions
    • Include comprehensive component tests

    Requires further human verification:

    • Add map controls - while the component supports map type controls, it's not clear if all required map controls (zoom, scale, etc.) are implemented
    ⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
    🧪 PR contains tests
    🔒 Security concerns

    Sensitive information exposure:
    The appkey for the Kakao Maps API appears to be passed directly as a property to the component in tests. While this might be handled securely in the actual API loader component, ensure the appkey isn't exposed in client-side code or logs, and consider using environment variables for testing rather than hardcoding even in test files.

    ⚡ Recommended focus areas for review

    Error Handling

    The map component lacks error handling for API failures or invalid configurations. Consider adding try/catch blocks and proper error events.

    }
    
    connectedCallback() {
      super.connectedCallback();
      this._container = document.createElement('div');
      this._container.id = `${SIGNATURE}_Map_Container`;
      this._container.style.width = '100%';
      this._container.style.height = '100%';
      this.appendChild(this._container);
    
      if (window.kakao && window.kakao.maps) {
        this._initializeMap();
      } else {
        const apiLoader = this.closest('kakao-api-loader');
        if (apiLoader) {
          apiLoader.addEventListener('kakao-api-loaded', () => {
            if (window.kakao && window.kakao.maps) {
              this._initializeMap();
            }
          }, { once: true });
        } else {
          throw new Error('Kakao Maps API is not loaded');
        }
      }
    }
    Memory Leaks

    Event listeners are added but may not be properly cleaned up in all scenarios, particularly if the component is disconnected before the API is loaded.

    private _addEventListeners(type: string, handler: Function) {
      if (!this._map) return;
    
      kakao.maps.event.addListener(this._map, type, handler as any);
      this._eventListeners.set(type, handler as any);
    }
    
    private _removeEventListeners() {
      if (!this._map) return;
    
      this._eventListeners.forEach((handler, type) => {
        kakao.maps.event.removeListener(this._map!, type, handler);
      });
    
      this._eventListeners.clear();
    }
    Type Safety

    Several places use type assertions (!) or non-null assertions without proper validation, which could lead to runtime errors.

      if (!this.center) return null;
    
      if ('lat' in this.center) {
        return new kakao.maps.LatLng(this.center.lat, this.center.lng);
      } else if ('x' in this.center) {
        return new kakao.maps.Coords(this.center.x, this.center.y).toLatLng();
      }
    
      return null;
    }

    @github-actions
    Copy link

    PR Code Suggestions ✨

    @GyeongHoKim
    Copy link
    Owner Author

    1. Misspelling on Test nickname

    will be fixed

    1. Error Handling

    will be fixed

    1. Memory Leak

    It won't be fixed.
    kakao-map should be rendered as child component of kakao-api-loader, or rendered after the kakao-api-loaded event.

    1. Type safety

    will be fixed

    - 카카오맵 컴포넌트에 에러 처리 메서드 추가
    - KakaoMapError, KakaoMapAPIError, KakaoMapContainerError, KakaoMapOptionsError 클래스 구현
    - LatLng 및 Point 타입을 확인하는 타입 가드 함수 추가
    - 에러 발생 시 'kakao-map-error' 이벤트 전파 기능 추가
    @GyeongHoKim GyeongHoKim requested a review from Copilot March 16, 2025 08:32
    Copy link

    Copilot AI left a comment

    Choose a reason for hiding this comment

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

    Pull Request Overview

    This PR resolves #8 by implementing a Kakao Map web component along with a shared map context and comprehensive tests for event handling and map controls.

    • Introduces the KakaoMap web component with map controls and events.
    • Adds a map context for component communication.
    • Provides extensive component tests to verify proper event handling.

    Reviewed Changes

    Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.

    Show a summary per file
    File Description
    packages/kakao-map-components/cypress/src/components/map/map.component.ts Adds comprehensive tests covering various map events and properties.
    packages/kakao-map-components/src/context/map-context.ts Sets up a shared map context using Lit's createContext.
    packages/kakao-map-components/src/types/errors.ts Defines custom error types for handling KakaoMap errors.
    packages/kakao-map-components/src/types/guards.ts Implements type guards for LatLng and Point interfaces.
    packages/kakao-map-components/src/context/index.ts Exports map context for ease of use.
    packages/kakao-map-components/src/components/map/index.ts Exports the KakaoMap component.
    packages/kakao-map-components/src/index.ts Updates index exports to include the map component.

    cy.get('@created').should('be.called');
    });

    it('should fires proper events when moving location', () => {
    Copy link

    Copilot AI Mar 16, 2025

    Choose a reason for hiding this comment

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

    [nitpick] Change 'should fires' to 'should fire' in the test description for grammatical correctness.

    Suggested change
    it('should fires proper events when moving location', () => {
    it('should fire proper events when moving location', () => {

    Copilot uses AI. Check for mistakes.
    cy.get('@idle').should('be.called');
    });

    it('should fires proper events when zooming map', () => {
    Copy link

    Copilot AI Mar 16, 2025

    Choose a reason for hiding this comment

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

    [nitpick] Change 'should fires' to 'should fire' in the test description for grammatical correctness.

    Suggested change
    it('should fires proper events when zooming map', () => {
    it('should fire proper events when zooming map', () => {

    Copilot uses AI. Check for mistakes.
    cy.get('@idle').should('be.called');
    });

    it('should fires proper events when clicking map', () => {
    Copy link

    Copilot AI Mar 16, 2025

    Choose a reason for hiding this comment

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

    [nitpick] Change 'should fires' to 'should fire' in the test description for grammatical correctness.

    Suggested change
    it('should fires proper events when clicking map', () => {
    it('should fire proper events when clicking map', () => {

    Copilot uses AI. Check for mistakes.
    @GyeongHoKim GyeongHoKim merged commit dbc9ad6 into develop Mar 16, 2025
    5 checks passed
    @GyeongHoKim GyeongHoKim deleted the feature/kakao-map branch March 16, 2025 08:36
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Labels

    feature I added new feature, please review my code Review effort 4/5

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    1 participant