/*
 * Copyright (C) 2026 SHX VPN
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; either version 2 of the License, or (at your
 * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * for more details.
 */

package org.strongswan.android.ui.compose

import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithText
import androidx.test.platform.app.InstrumentationRegistry
import org.junit.Rule
import org.junit.Test
import org.strongswan.android.R
import org.strongswan.android.ui.compose.theme.ShxTheme

class TrustedNetworksScreenTest
{
	@get:Rule
	val composeRule = createComposeRule()

	private fun string(id: Int): String =
		InstrumentationRegistry.getInstrumentation().targetContext.getString(id)

	private fun setContent()
	{
		composeRule.setContent {
			ShxTheme {
				TrustedNetworksScreen(profiles = emptyList(), currentSsid = null)
			}
		}
		composeRule.waitForIdle()
	}

	@Test
	fun showsMasterToggle()
	{
		setContent()
		composeRule.onNodeWithText(
			string(R.string.auto_connect_title)
		).assertIsDisplayed()
		composeRule.onNodeWithText(
			string(R.string.auto_connect_summary)
		).assertIsDisplayed()
	}

	@Test
	fun showsProfilePickerRow()
	{
		setContent()
		composeRule.onNodeWithText(
			string(R.string.auto_connect_profile)
		).assertIsDisplayed()
	}

	@Test
	fun showsEmptyTrustedList()
	{
		setContent()
		composeRule.onNodeWithText(
			string(R.string.auto_connect_no_networks)
		).assertIsDisplayed()
	}

	@Test
	fun showsAddNetworkButton()
	{
		setContent()
		composeRule.onNodeWithText(
			string(R.string.auto_connect_add_network)
		).assertIsDisplayed()
	}
}
