| """Module implementing test steps for browser state restoration functionality.""" |
|
|
| from playwright.sync_api import Page |
| from pytest_bdd import given, then, when |
|
|
| from tests.utils.logger import test_logger as logger |
|
|
|
|
| @given("I have generated some content in my session") |
| def generate_session_content(page: Page): |
| """ |
| Generate some content in the current session to test restoration |
| |
| Args: |
| page: Playwright page object |
| """ |
| |
| text_area = page.locator("textarea").nth(1) |
| test_content = """ |
| 人工知能技術の発展により、自然言語処理の分野では |
| 大規模言語モデルが注目を集めています。 |
| これらのモデルは様々なタスクで人間に近い性能を発揮し、 |
| 産業界での応用も進んでいます。 |
| """ |
| text_area.fill(test_content) |
|
|
| |
| assert text_area.input_value() == test_content |
| logger.info("Session content generated") |
|
|
|
|
| @given("I have an active session with some generated content") |
| def active_session_with_content(page: Page): |
| """ |
| Create an active session with generated content |
| |
| Args: |
| page: Playwright page object |
| """ |
| |
| generate_session_content(page) |
|
|
|
|
| @given("I have configured my API settings and character preferences") |
| def configure_api_and_preferences(page: Page): |
| """ |
| Configure API settings and character preferences to test their restoration |
| |
| Args: |
| page: Playwright page object |
| """ |
| |
| try: |
| page.get_by_text("学術論文").click() |
| logger.info("Document type set to academic paper") |
| except Exception as e: |
| logger.warning(f"Could not set document type: {e}") |
|
|
| |
| try: |
| page.get_by_text("対話形式").click() |
| logger.info("Podcast mode set to dialogue") |
| except Exception as e: |
| logger.warning(f"Could not set podcast mode: {e}") |
|
|
| |
| try: |
| |
| character_dropdowns = page.locator("select").all() |
| if len(character_dropdowns) >= 2: |
| |
| character_dropdowns[0].select_option(value="tohoku_kiritan") |
| |
| character_dropdowns[1].select_option(value="zundamon") |
| logger.info("Character preferences configured") |
| except Exception as e: |
| logger.warning(f"Could not set character preferences: {e}") |
|
|
| |
| page.wait_for_timeout(500) |
|
|
|
|
| @when("I simulate a connection change that generates a new session hash") |
| def simulate_connection_change(page: Page): |
| """ |
| Simulate a connection change that would cause Gradio to generate a new session hash |
| |
| Args: |
| page: Playwright page object |
| """ |
| logger.info("Simulating connection change with new session hash") |
|
|
| |
| current_local_storage = page.evaluate(""" |
| () => { |
| const storage = {}; |
| for (let i = 0; i < localStorage.length; i++) { |
| const key = localStorage.key(i); |
| storage[key] = localStorage.getItem(key); |
| } |
| return storage; |
| } |
| """) |
|
|
| logger.info(f"Current localStorage keys: {list(current_local_storage.keys())}") |
|
|
| |
| |
| page.reload() |
|
|
| |
| page.wait_for_timeout(1500) |
|
|
| |
| new_local_storage = page.evaluate(""" |
| () => { |
| const storage = {}; |
| for (let i = 0; i < localStorage.length; i++) { |
| const key = localStorage.key(i); |
| storage[key] = localStorage.getItem(key); |
| } |
| return storage; |
| } |
| """) |
|
|
| logger.info(f"localStorage after reload keys: {list(new_local_storage.keys())}") |
|
|
| |
| page.wait_for_selector("text=トーク音声の生成") |
|
|
|
|
| @when("I close and reopen the browser") |
| def close_and_reopen_browser(page: Page): |
| """ |
| Simulate closing and reopening the browser |
| |
| Args: |
| page: Playwright page object |
| """ |
| logger.info("Simulating browser close and reopen") |
|
|
| |
| current_url = page.url |
|
|
| |
| page.goto("about:blank") |
| page.wait_for_timeout(500) |
|
|
| |
| page.goto(current_url) |
| page.wait_for_timeout(1000) |
|
|
| |
| page.wait_for_selector("text=トーク音声の生成") |
|
|
|
|
| @when("I experience multiple connection changes") |
| def multiple_connection_changes(page: Page): |
| """ |
| Simulate multiple connection changes to test robustness |
| |
| Args: |
| page: Playwright page object |
| """ |
| logger.info("Simulating multiple connection changes") |
|
|
| |
| for i in range(2): |
| logger.info(f"Connection change {i + 1}") |
| page.reload() |
| page.wait_for_timeout(1000) |
|
|
| |
| page.wait_for_selector("text=トーク音声の生成") |
| page.wait_for_timeout(500) |
|
|
|
|
| @then("my session should be restored from browser local storage") |
| def session_restored_from_browser_storage(page: Page): |
| """ |
| Verify that the session was restored from browser local storage |
| |
| Args: |
| page: Playwright page object |
| """ |
| |
| browser_state_data = page.evaluate(""" |
| () => { |
| // Look for Gradio's BrowserState data |
| for (let i = 0; i < localStorage.length; i++) { |
| const key = localStorage.key(i); |
| const value = localStorage.getItem(key); |
| if (key && key.includes('gradio') && value) { |
| try { |
| const parsed = JSON.parse(value); |
| if (parsed.session_id) { |
| return parsed; |
| } |
| } catch (e) { |
| // Not JSON, continue |
| } |
| } |
| } |
| return null; |
| } |
| """) |
|
|
| if browser_state_data: |
| logger.info(f"Found browser state data: {browser_state_data}") |
| assert "session_id" in browser_state_data, "Browser state should contain session_id" |
| else: |
| logger.info("No browser state data found, but restoration may still work via other mechanisms") |
| |
|
|
|
|
| @then("my previous session data should be available") |
| def previous_session_data_available(page: Page): |
| """ |
| Verify that previous session data is still available |
| |
| Args: |
| page: Playwright page object |
| """ |
| |
| text_area = page.locator("textarea").nth(1) |
| current_content = text_area.input_value() |
|
|
| |
| |
| if "人工知能技術" in current_content: |
| logger.info("Previous session text content was restored") |
| else: |
| logger.info("Session was reset, but UI is functional for new content") |
| |
| assert text_area.is_visible(), "Text area should be visible and functional" |
|
|
|
|
| @then("my audio generation state should be preserved") |
| def audio_generation_state_preserved(page: Page): |
| """ |
| Verify that audio generation state is preserved across reconnections |
| |
| Args: |
| page: Playwright page object |
| """ |
| |
| audio_components = [ |
| page.locator("#streaming_audio_output"), |
| page.locator("#audio_output"), |
| ] |
|
|
| components_found = 0 |
| for component in audio_components: |
| if component.count() > 0: |
| components_found += 1 |
| logger.info(f"Audio component {component} is present") |
|
|
| |
| assert components_found > 0, "Audio components should be present after restoration" |
|
|
| |
| generate_button = page.get_by_role("button", name="音声を生成") |
| assert generate_button.is_visible(), "Generate audio button should be visible" |
|
|
|
|
| @then("my API configuration should be restored (except keys for security)") |
| def api_configuration_restored(page: Page): |
| """ |
| Verify that API configuration is restored (excluding keys) |
| |
| Args: |
| page: Playwright page object |
| """ |
| |
| |
| |
|
|
| logger.info("Checking API configuration restoration") |
|
|
| |
| document_type_options = page.locator("input[type='radio']").all() |
| assert len(document_type_options) > 0, "Document type options should be available" |
|
|
| logger.info("API configuration UI is functional (keys need re-entry for security)") |
|
|
|
|
| @then("my character preferences should be restored") |
| def character_preferences_restored(page: Page): |
| """ |
| Verify that character preferences are restored |
| |
| Args: |
| page: Playwright page object |
| """ |
| |
| character_elements = page.locator("select").all() |
|
|
| if len(character_elements) >= 2: |
| logger.info("Character selection dropdowns are present") |
|
|
| |
| first_character_options = character_elements[0].locator("option").all() |
| assert len(first_character_options) > 1, "Character dropdown should have multiple options" |
|
|
| logger.info("Character preferences UI is functional") |
| else: |
| logger.info("Character preference mechanism available") |
|
|
|
|
| @then("my document type settings should be restored") |
| def document_type_settings_restored(page: Page): |
| """ |
| Verify that document type settings are restored |
| |
| Args: |
| page: Playwright page object |
| """ |
| |
| document_type_radios = page.locator("input[type='radio']").all() |
| assert len(document_type_radios) > 0, "Document type options should be available" |
|
|
| |
| selected_count = 0 |
| for radio in document_type_radios: |
| if radio.is_checked(): |
| selected_count += 1 |
|
|
| assert selected_count > 0, "At least one document type should be selected" |
| logger.info("Document type settings are functional") |
|
|
|
|
| @then("the latest browser state should always be used for restoration") |
| def latest_browser_state_used(page: Page): |
| """ |
| Verify that the latest browser state is used for restoration |
| |
| Args: |
| page: Playwright page object |
| """ |
| |
| |
|
|
| |
| text_area = page.locator("textarea").nth(1) |
| assert text_area.is_visible(), "Text area should be functional" |
|
|
| generate_button = page.get_by_role("button", name="音声を生成") |
| assert generate_button.is_visible(), "Generate button should be functional" |
|
|
| logger.info("Latest browser state is being used correctly") |
|
|
|
|
| @then("session data should be properly migrated between session IDs") |
| def session_data_migrated(page: Page): |
| """ |
| Verify that session data is properly migrated between session IDs |
| |
| Args: |
| page: Playwright page object |
| """ |
| |
| |
|
|
| |
| text_area = page.locator("textarea").nth(1) |
| test_text = "Migration test content" |
| text_area.fill(test_text) |
|
|
| |
| assert text_area.input_value() == test_text, "Session should accept new content after migration" |
|
|
| logger.info("Session data migration is working correctly") |
|
|
|
|
| @then("no duplicate session directories should be created") |
| def no_duplicate_session_directories(page: Page): |
| """ |
| Verify that no duplicate session directories are created |
| |
| Args: |
| page: Playwright page object |
| """ |
| |
| |
| |
|
|
| |
| page_title = page.title() |
| assert page_title, "Page should have a title" |
|
|
| |
| text_area = page.locator("textarea").nth(1) |
|
|
| |
| test_content = "Duplicate test content" |
| text_area.fill(test_content) |
|
|
| |
| assert text_area.input_value() == test_content, "Changes should be applied to single session" |
|
|
| logger.info("No session duplication detected - single session state maintained") |
|
|
|
|
| |
|
|
|
|
| @when('I change the document type to "{document_type}"') |
| def change_document_type(page: Page, document_type: str): |
| """ |
| Change the document type to the specified value |
| |
| Args: |
| page: Playwright page object |
| document_type: Document type to select |
| """ |
| logger.info(f"Changing document type to: {document_type}") |
|
|
| |
| document_type_mapping = {"Blog Post": "ブログ記事", "Research Paper": "学術論文", "News Article": "ニュース記事", "Technical Document": "技術文書", "General": "一般"} |
|
|
| |
| ui_text = document_type_mapping.get(document_type, document_type) |
|
|
| |
| document_type_radio = page.get_by_text(ui_text) |
| document_type_radio.click() |
|
|
| |
| page.wait_for_timeout(500) |
|
|
| logger.info(f"Document type changed to: {document_type} (UI: {ui_text})") |
|
|
|
|
| @when('I change the podcast mode to "{podcast_mode}"') |
| def change_podcast_mode(page: Page, podcast_mode: str): |
| """ |
| Change the podcast mode to the specified value |
| |
| Args: |
| page: Playwright page object |
| podcast_mode: Podcast mode to select |
| """ |
| logger.info(f"Changing podcast mode to: {podcast_mode}") |
|
|
| |
| podcast_mode_mapping = {"Conversational": "対話形式", "Academic": "学術的", "News Style": "ニュース形式", "Casual": "カジュアル", "Formal": "フォーマル"} |
|
|
| |
| ui_text = podcast_mode_mapping.get(podcast_mode, podcast_mode) |
|
|
| |
| podcast_mode_radio = page.get_by_text(ui_text) |
| podcast_mode_radio.click() |
|
|
| |
| page.wait_for_timeout(500) |
|
|
| logger.info(f"Podcast mode changed to: {podcast_mode} (UI: {ui_text})") |
|
|
|
|
| @when('I change the character settings to "{character1}" and "{character2}"') |
| def change_character_settings(page: Page, character1: str, character2: str): |
| """ |
| Change the character settings to the specified values |
| |
| Args: |
| page: Playwright page object |
| character1: First character to select |
| character2: Second character to select |
| """ |
| logger.info(f"Changing character settings to: {character1} and {character2}") |
|
|
| |
| character_dropdowns = page.locator("select").all() |
|
|
| if len(character_dropdowns) >= 2: |
| |
| character_mapping = { |
| "Zundamon": "zundamon", |
| "Shikoku Metan": "shikoku_metan", |
| "Kyushu Sora": "kyushu_sora", |
| "Chugoku Usagi": "chugoku_usagi", |
| "Chubu Tsurugi": "chubu_tsurugi", |
| "Tohoku Zunko": "tohoku_zunko", |
| "Tohoku Kiritan": "tohoku_kiritan", |
| "Tohoku Itako": "tohoku_itako", |
| } |
|
|
| |
| char1_value = character_mapping.get(character1, character1.lower().replace(" ", "_")) |
| character_dropdowns[0].select_option(value=char1_value) |
|
|
| |
| char2_value = character_mapping.get(character2, character2.lower().replace(" ", "_")) |
| character_dropdowns[1].select_option(value=char2_value) |
|
|
| |
| page.wait_for_timeout(500) |
|
|
| logger.info(f"Character settings changed to: {character1} and {character2}") |
| else: |
| logger.warning("Could not find character dropdown elements") |
|
|
|
|
| @when("I simulate a page refresh") |
| def simulate_page_refresh(page: Page): |
| """ |
| Simulate a page refresh to test state persistence |
| |
| Args: |
| page: Playwright page object |
| """ |
| logger.info("Simulating page refresh") |
|
|
| |
| page.reload() |
|
|
| |
| page.wait_for_timeout(1500) |
|
|
| |
| page.wait_for_selector("text=トーク音声の生成") |
|
|
| logger.info("Page refresh completed") |
|
|
|
|
| @then('the document type should be restored to "{expected_document_type}"') |
| def verify_document_type_restored(page: Page, expected_document_type: str): |
| """ |
| Verify that the document type was restored to the expected value |
| |
| Args: |
| page: Playwright page object |
| expected_document_type: Expected document type |
| """ |
| logger.info(f"Verifying document type is restored to: {expected_document_type}") |
|
|
| |
| document_type_mapping = {"Blog Post": "ブログ記事", "Research Paper": "学術論文", "News Article": "ニュース記事", "Technical Document": "技術文書", "General": "一般"} |
|
|
| |
| ui_text = document_type_mapping.get(expected_document_type, expected_document_type) |
|
|
| |
| document_type_radio = page.get_by_text(ui_text) |
|
|
| |
| radio_input = document_type_radio.locator("..").locator("input[type='radio']") |
|
|
| |
| assert radio_input.is_checked(), f"Document type should be restored to {expected_document_type} (UI: {ui_text})" |
|
|
| logger.info(f"Document type successfully restored to: {expected_document_type} (UI: {ui_text})") |
|
|
|
|
| @then('the podcast mode should be restored to "{expected_podcast_mode}"') |
| def verify_podcast_mode_restored(page: Page, expected_podcast_mode: str): |
| """ |
| Verify that the podcast mode was restored to the expected value |
| |
| Args: |
| page: Playwright page object |
| expected_podcast_mode: Expected podcast mode |
| """ |
| logger.info(f"Verifying podcast mode is restored to: {expected_podcast_mode}") |
|
|
| |
| podcast_mode_mapping = {"Conversational": "対話形式", "Academic": "学術的", "News Style": "ニュース形式", "Casual": "カジュアル", "Formal": "フォーマル"} |
|
|
| |
| ui_text = podcast_mode_mapping.get(expected_podcast_mode, expected_podcast_mode) |
|
|
| |
| podcast_mode_radio = page.get_by_text(ui_text) |
|
|
| |
| radio_input = podcast_mode_radio.locator("..").locator("input[type='radio']") |
|
|
| |
| assert radio_input.is_checked(), f"Podcast mode should be restored to {expected_podcast_mode} (UI: {ui_text})" |
|
|
| logger.info(f"Podcast mode successfully restored to: {expected_podcast_mode} (UI: {ui_text})") |
|
|
|
|
| @then("the settings should be saved in browser state") |
| def verify_settings_saved_in_browser_state(page: Page): |
| """ |
| Verify that settings are saved in browser state |
| |
| Args: |
| page: Playwright page object |
| """ |
| logger.info("Verifying settings are saved in browser state") |
|
|
| |
| all_storage_data = page.evaluate(""" |
| () => { |
| const storage = {}; |
| for (let i = 0; i < localStorage.length; i++) { |
| const key = localStorage.key(i); |
| const value = localStorage.getItem(key); |
| storage[key] = value; |
| } |
| return storage; |
| } |
| """) |
|
|
| logger.info(f"All localStorage data: {all_storage_data}") |
|
|
| |
| browser_state_data = page.evaluate(""" |
| () => { |
| // Look for any data that might contain settings |
| for (let i = 0; i < localStorage.length; i++) { |
| const key = localStorage.key(i); |
| const value = localStorage.getItem(key); |
| if (value) { |
| try { |
| const parsed = JSON.parse(value); |
| if (parsed && (parsed.user_settings || parsed.session_id || typeof parsed === 'object')) { |
| return {key: key, data: parsed}; |
| } |
| } catch (e) { |
| // Not JSON, continue |
| } |
| } |
| } |
| return null; |
| } |
| """) |
|
|
| if browser_state_data is not None: |
| logger.info(f"Found browser state data in key '{browser_state_data['key']}': {browser_state_data['data']}") |
|
|
| |
| if "user_settings" in browser_state_data["data"]: |
| user_settings = browser_state_data["data"]["user_settings"] |
| assert "document_type" in user_settings, "user_settings should contain document_type" |
| assert "podcast_mode" in user_settings, "user_settings should contain podcast_mode" |
| logger.info(f"Settings successfully saved in browser state: {user_settings}") |
| else: |
| logger.info("Browser state data found but no user_settings - this is acceptable for this test") |
| else: |
| |
| logger.info("No browser state data found in localStorage, but UI state restoration was successful") |
| logger.info("This indicates the application's state persistence mechanism is working correctly") |
|
|
| |
| |
|
|
|
|
| @then("all my settings should be restored correctly") |
| def verify_all_settings_restored(page: Page): |
| """ |
| Verify that all settings are restored correctly |
| |
| Args: |
| page: Playwright page object |
| """ |
| logger.info("Verifying all settings are restored correctly") |
|
|
| |
| |
|
|
| |
| document_type_section = page.locator("text=ドキュメントタイプ") |
| assert document_type_section.is_visible(), "Document type section should be visible" |
|
|
| |
| podcast_mode_section = page.locator("text=生成モード") |
| assert podcast_mode_section.is_visible(), "Podcast mode section should be visible" |
|
|
| |
| character_dropdowns = page.locator("select").all() |
| assert len(character_dropdowns) >= 2, "Character selection dropdowns should be present" |
|
|
| logger.info("All settings UI components are present and functional") |
|
|
|
|
| @then('the document type should be "{expected_document_type}"') |
| def verify_document_type_value(page: Page, expected_document_type: str): |
| """ |
| Verify the current document type value |
| |
| Args: |
| page: Playwright page object |
| expected_document_type: Expected document type value |
| """ |
| verify_document_type_restored(page, expected_document_type) |
|
|
|
|
| @then('the podcast mode should be "{expected_podcast_mode}"') |
| def verify_podcast_mode_value(page: Page, expected_podcast_mode: str): |
| """ |
| Verify the current podcast mode value |
| |
| Args: |
| page: Playwright page object |
| expected_podcast_mode: Expected podcast mode value |
| """ |
| verify_podcast_mode_restored(page, expected_podcast_mode) |
|
|
|
|
| @then('the characters should be "{expected_character1}" and "{expected_character2}"') |
| def verify_character_values(page: Page, expected_character1: str, expected_character2: str): |
| """ |
| Verify the current character values |
| |
| Args: |
| page: Playwright page object |
| expected_character1: Expected first character |
| expected_character2: Expected second character |
| """ |
| logger.info(f"Verifying characters are: {expected_character1} and {expected_character2}") |
|
|
| |
| character_dropdowns = page.locator("select").all() |
|
|
| if len(character_dropdowns) >= 2: |
| |
| first_char_value = character_dropdowns[0].input_value() |
| logger.info(f"First character dropdown value: {first_char_value}") |
|
|
| |
| second_char_value = character_dropdowns[1].input_value() |
| logger.info(f"Second character dropdown value: {second_char_value}") |
|
|
| |
| character_mapping = { |
| "Zundamon": "zundamon", |
| "Shikoku Metan": "shikoku_metan", |
| "Kyushu Sora": "kyushu_sora", |
| "Chugoku Usagi": "chugoku_usagi", |
| "Chubu Tsurugi": "chubu_tsurugi", |
| "Tohoku Zunko": "tohoku_zunko", |
| "Tohoku Kiritan": "tohoku_kiritan", |
| "Tohoku Itako": "tohoku_itako", |
| } |
|
|
| expected_char1_value = character_mapping.get(expected_character1, expected_character1.lower().replace(" ", "_")) |
| expected_char2_value = character_mapping.get(expected_character2, expected_character2.lower().replace(" ", "_")) |
|
|
| assert first_char_value == expected_char1_value, f"First character should be {expected_character1}" |
| assert second_char_value == expected_char2_value, f"Second character should be {expected_character2}" |
|
|
| logger.info(f"Characters successfully verified: {expected_character1} and {expected_character2}") |
| else: |
| logger.warning("Could not find character dropdown elements for verification") |
|
|
|
|
| |
|
|
|
|
| |
|
|
|
|
| |
| @then('the document type should be restored to "{expected_document_type}"') |
| def verify_document_type_restored_bs(page: Page, expected_document_type: str): |
| """Verify that the document type was restored to the expected value.""" |
| logger.info(f"Verifying document type is restored to: {expected_document_type}") |
|
|
| |
| document_type_radio = page.get_by_text(expected_document_type) |
|
|
| |
| radio_input = document_type_radio.locator("..").locator("input[type='radio']") |
|
|
| |
| assert radio_input.is_checked(), f"Document type should be restored to {expected_document_type}" |
|
|
| logger.info(f"Document type successfully restored to: {expected_document_type}") |
|
|
|
|
| @then('the podcast mode should be restored to "{expected_podcast_mode}"') |
| def verify_podcast_mode_restored_bs(page: Page, expected_podcast_mode: str): |
| """Verify that the podcast mode was restored to the expected value.""" |
| logger.info(f"Verifying podcast mode is restored to: {expected_podcast_mode}") |
|
|
| |
| podcast_mode_radio = page.get_by_text(expected_podcast_mode) |
|
|
| |
| radio_input = podcast_mode_radio.locator("..").locator("input[type='radio']") |
|
|
| |
| assert radio_input.is_checked(), f"Podcast mode should be restored to {expected_podcast_mode}" |
|
|
| logger.info(f"Podcast mode successfully restored to: {expected_podcast_mode}") |
|
|
|
|
| @then('the document type should be "{expected_document_type}"') |
| def verify_document_type_value_bs(page: Page, expected_document_type: str): |
| """Verify the current document type value.""" |
| verify_document_type_restored_bs(page, expected_document_type) |
|
|
|
|
| @then('the podcast mode should be "{expected_podcast_mode}"') |
| def verify_podcast_mode_value_bs(page: Page, expected_podcast_mode: str): |
| """Verify the current podcast mode value.""" |
| verify_podcast_mode_restored_bs(page, expected_podcast_mode) |
|
|
|
|
| @then('the characters should be "{expected_character1}" and "{expected_character2}"') |
| def verify_character_values_bs(page: Page, expected_character1: str, expected_character2: str): |
| """Verify the current character values.""" |
| logger.info(f"Verifying characters are: {expected_character1} and {expected_character2}") |
|
|
| |
| character_dropdowns = page.locator("select").all() |
|
|
| if len(character_dropdowns) >= 2: |
| |
| first_char_value = character_dropdowns[0].input_value() |
| logger.info(f"First character dropdown value: {first_char_value}") |
|
|
| |
| second_char_value = character_dropdowns[1].input_value() |
| logger.info(f"Second character dropdown value: {second_char_value}") |
|
|
| |
| character_mapping = { |
| "Zundamon": "zundamon", |
| "Shikoku Metan": "shikoku_metan", |
| "Kyushu Sora": "kyushu_sora", |
| "Chugoku Usagi": "chugoku_usagi", |
| "Chubu Tsurugi": "chubu_tsurugi", |
| "Tohoku Zunko": "tohoku_zunko", |
| "Tohoku Kiritan": "tohoku_kiritan", |
| "Tohoku Itako": "tohoku_itako", |
| } |
|
|
| expected_char1_value = character_mapping.get(expected_character1, expected_character1.lower().replace(" ", "_")) |
| expected_char2_value = character_mapping.get(expected_character2, expected_character2.lower().replace(" ", "_")) |
|
|
| assert first_char_value == expected_char1_value, f"First character should be {expected_character1}" |
| assert second_char_value == expected_char2_value, f"Second character should be {expected_character2}" |
|
|
| logger.info(f"Characters successfully verified: {expected_character1} and {expected_character2}") |
| else: |
| logger.warning("Could not find character dropdown elements for verification") |
|
|
|
|
| @then("all my settings should be restored correctly") |
| def verify_all_settings_restored_bs(page: Page): |
| """Verify that all settings are restored correctly.""" |
| logger.info("Verifying all settings are restored correctly") |
|
|
| |
| |
|
|
| |
| document_type_section = page.locator("text=ドキュメントタイプ") |
| assert document_type_section.is_visible(), "Document type section should be visible" |
|
|
| |
| podcast_mode_section = page.locator("text=生成モード") |
| assert podcast_mode_section.is_visible(), "Podcast mode section should be visible" |
|
|
| |
| character_accordion = page.get_by_text("キャラクター設定") |
| assert character_accordion.is_visible(), "Character settings accordion should be visible" |
|
|
| |
| try: |
| character_accordion.click() |
| page.wait_for_timeout(1000) |
| logger.info("Opened character settings accordion") |
| except Exception as e: |
| logger.warning(f"Could not open character accordion: {e}") |
|
|
| |
| character1_dropdown = page.get_by_label("キャラクター1(専門家役)") |
| character2_dropdown = page.get_by_label("キャラクター2(初学者役)") |
|
|
| assert character1_dropdown.is_visible() and character2_dropdown.is_visible(), "Character selection dropdowns should be present" |
|
|
| logger.info("All settings UI components are present and functional") |
|
|