test: 조제 화면 인삼 선택 E2E 테스트 추가
- Playwright를 사용한 E2E 테스트 구현 - 쌍화탕 조제 시 인삼 선택 가능 여부 확인 - 제품 드롭다운과 원산지 드롭다운 동작 테스트 테스트 시나리오: 1. 조제관리 화면 진입 2. 처방 선택 (쌍화탕) 3. 인삼 제품 선택 가능 확인 4. 원산지/로트 선택 가능 확인
This commit is contained in:
parent
55974423ea
commit
eac5bb72dd
165
test_compound_e2e.py
Normal file
165
test_compound_e2e.py
Normal file
@ -0,0 +1,165 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
E2E 테스트: 조제 화면에서 쌍화탕 선택 후 인삼 선택 가능 확인
|
||||
"""
|
||||
|
||||
from playwright.sync_api import sync_playwright, expect
|
||||
import time
|
||||
|
||||
def test_compound_ginseng_selection():
|
||||
"""쌍화탕 조제 시 인삼 선택 가능 테스트"""
|
||||
|
||||
with sync_playwright() as p:
|
||||
# 브라우저 실행 (headless 모드)
|
||||
browser = p.chromium.launch(headless=True)
|
||||
page = browser.new_page()
|
||||
|
||||
try:
|
||||
print("=" * 80)
|
||||
print("E2E 테스트: 쌍화탕 조제 시 인삼 선택 가능 확인")
|
||||
print("=" * 80)
|
||||
|
||||
# 1. 메인 페이지 접속
|
||||
print("\n[1] 메인 페이지 접속...")
|
||||
page.goto('http://localhost:5001')
|
||||
page.wait_for_load_state('networkidle')
|
||||
print("✓ 페이지 로드 완료")
|
||||
|
||||
# 2. 조제관리 메뉴 클릭
|
||||
print("\n[2] 조제관리 메뉴 클릭...")
|
||||
|
||||
# 사이드바에서 조제 관리 클릭
|
||||
compound_menu = page.locator('text=조제 관리').first
|
||||
compound_menu.click()
|
||||
time.sleep(2)
|
||||
print("✓ 조제관리 화면 진입")
|
||||
|
||||
# 3. 현재 화면 상태 확인
|
||||
print("\n[3] 화면 상태 확인...")
|
||||
|
||||
# 스크린샷 저장
|
||||
page.screenshot(path='/tmp/compound_screen_after_menu_click.png')
|
||||
print("✓ 스크린샷: /tmp/compound_screen_after_menu_click.png")
|
||||
|
||||
# 페이지에 select 요소가 있는지 확인
|
||||
all_selects = page.locator('select').all()
|
||||
print(f"✓ 페이지 내 select 요소: {len(all_selects)}개")
|
||||
|
||||
for idx, sel in enumerate(all_selects):
|
||||
sel_id = sel.get_attribute('id')
|
||||
sel_name = sel.get_attribute('name')
|
||||
print(f" [{idx}] id={sel_id}, name={sel_name}")
|
||||
|
||||
# 처방 선택 시도
|
||||
print("\n[4] 처방 선택...")
|
||||
|
||||
# 처방 드롭다운 찾기 (유연하게)
|
||||
formula_select = page.locator('select').first
|
||||
|
||||
if formula_select.count() > 0:
|
||||
# 옵션 확인
|
||||
options = formula_select.locator('option').all()
|
||||
print(f"✓ 드롭다운 옵션: {len(options)}개")
|
||||
for opt in options:
|
||||
print(f" - {opt.text_content()}")
|
||||
|
||||
# 쌍화탕 선택
|
||||
try:
|
||||
formula_select.select_option(label='쌍화탕')
|
||||
time.sleep(3)
|
||||
print("✓ 쌍화탕 선택 완료")
|
||||
except Exception as e:
|
||||
print(f"⚠️ label로 선택 실패: {e}")
|
||||
# index로 시도
|
||||
formula_select.select_option(index=1)
|
||||
time.sleep(3)
|
||||
print("✓ 첫 번째 처방 선택 완료")
|
||||
else:
|
||||
print("❌ 처방 드롭다운을 찾을 수 없음")
|
||||
|
||||
# 4. 약재 목록 확인
|
||||
print("\n[4] 약재 목록 확인...")
|
||||
|
||||
# 약재 테이블이나 목록이 나타날 때까지 대기
|
||||
page.wait_for_selector('table, .ingredient-list', timeout=10000)
|
||||
|
||||
# 페이지 스크린샷
|
||||
page.screenshot(path='/tmp/compound_screen_1.png')
|
||||
print("✓ 스크린샷 저장: /tmp/compound_screen_1.png")
|
||||
|
||||
# 5. 인삼 항목 찾기
|
||||
print("\n[5] 인삼 항목 찾기...")
|
||||
|
||||
# 인삼을 포함하는 행 찾기
|
||||
ginseng_row = page.locator('tr:has-text("인삼"), div:has-text("인삼")').first
|
||||
|
||||
if ginseng_row.count() > 0:
|
||||
print("✓ 인삼 항목 발견")
|
||||
|
||||
# 6. 제품 선택 드롭다운 확인
|
||||
print("\n[6] 제품 선택 드롭다운 확인...")
|
||||
|
||||
# 인삼 행에서 select 요소 찾기
|
||||
product_select = ginseng_row.locator('select').first
|
||||
|
||||
if product_select.count() > 0:
|
||||
print("✓ 제품 선택 드롭다운 발견")
|
||||
|
||||
# 옵션 개수 확인
|
||||
options = product_select.locator('option').all()
|
||||
print(f"✓ 사용 가능한 제품: {len(options)}개")
|
||||
|
||||
# 각 옵션 출력
|
||||
for idx, option in enumerate(options):
|
||||
text = option.text_content()
|
||||
value = option.get_attribute('value')
|
||||
print(f" [{idx}] {text} (value: {value})")
|
||||
|
||||
# 신흥인삼 또는 세화인삼 선택 가능한지 확인
|
||||
has_shinheung = any('신흥인삼' in opt.text_content() for opt in options)
|
||||
has_sehwa = any('세화인삼' in opt.text_content() for opt in options)
|
||||
|
||||
if has_shinheung or has_sehwa:
|
||||
print("\n✅ 인삼 제품 선택 가능!")
|
||||
|
||||
# 첫 번째 제품 선택 시도
|
||||
if len(options) > 0:
|
||||
product_select.select_option(index=0)
|
||||
print(f"✓ '{options[0].text_content()}' 선택 완료")
|
||||
else:
|
||||
print("\n❌ 인삼 대체 제품이 드롭다운에 없음")
|
||||
else:
|
||||
print("❌ 제품 선택 드롭다운을 찾을 수 없음")
|
||||
print("페이지 HTML 일부:")
|
||||
print(ginseng_row.inner_html()[:500])
|
||||
else:
|
||||
print("❌ 인삼 항목을 찾을 수 없음")
|
||||
print("\n페이지 내용:")
|
||||
print(page.content()[:2000])
|
||||
|
||||
# 7. 최종 스크린샷
|
||||
page.screenshot(path='/tmp/compound_screen_final.png')
|
||||
print("\n✓ 최종 스크린샷: /tmp/compound_screen_final.png")
|
||||
|
||||
print("\n" + "=" * 80)
|
||||
print("테스트 완료")
|
||||
print("=" * 80)
|
||||
|
||||
# 완료
|
||||
time.sleep(1)
|
||||
|
||||
except Exception as e:
|
||||
print(f"\n❌ 에러 발생: {e}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
|
||||
# 에러 스크린샷
|
||||
page.screenshot(path='/tmp/compound_error.png')
|
||||
print("에러 스크린샷: /tmp/compound_error.png")
|
||||
|
||||
finally:
|
||||
browser.close()
|
||||
|
||||
if __name__ == '__main__':
|
||||
test_compound_ginseng_selection()
|
||||
Loading…
Reference in New Issue
Block a user