import sys, time
from pathlib import Path
sys.path.append(str(Path("05_Production_Pipeline").resolve()))
from invisible_playwright import InvisiblePlaywright
from muse_invpw_driver import DEFAULT_PROFILE

def check_other_threads():
    with InvisiblePlaywright(profile_dir=DEFAULT_PROFILE, headless=True) as ctx:
        page = ctx.pages[0] if ctx.pages else ctx.new_page()
        page.goto("https://muse.ai", wait_until="domcontentloaded", timeout=30000)
        time.sleep(3)
        
        # 1. Check 'Đoạn chat chính'
        main_chat = page.locator('text="Đoạn chat chính"').first
        if main_chat.count() > 0:
            print("Clicking 'Đoạn chat chính'...")
            main_chat.click()
            time.sleep(3)
            page.screenshot(path="04_Assets/main_chat_view.png")
            print("Main chat URL:", page.url)
            print("Main chat text:", page.locator('.chat-message, [role="article"]').all_inner_texts()[:2])
            
        # 2. Check 'Tạo video Thúy Kiều chiều tà'
        chieu_ta = page.locator('text="Tạo video Thúy Kiều chiều tà"').first
        if chieu_ta.count() > 0:
            print("Clicking 'Tạo video Thúy Kiều chiều tà'...")
            chieu_ta.click()
            time.sleep(3)
            page.screenshot(path="04_Assets/chieu_ta_view.png")
            print("Chieu ta URL:", page.url)
            dl_count = page.locator('button[aria-label*="Tải video xuống"], button:has-text("Tải video xuống")').count()
            print("Chieu ta DL buttons:", dl_count)

if __name__ == '__main__':
    check_other_threads()
