/*
 * SPDX-License-Identifier: GPL-3.0-or-later
 */
package com.runicgateway.app.ui.notifications

import com.runicgateway.app.core.push.PushStreams
import com.runicgateway.app.data.api.dto.NotificationStreamDto
import com.runicgateway.app.ui.navigation.Routes
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Test

/**
 * Tests the pure push helpers: the stream → deep-link route map (PLAN.md §11 work
 * item 7) and the personal-stream gating (a personal stream needs a linked account).
 */
class NotificationRoutingTest {

    @Test fun deepLinkRoutesMapEachStreamToItsScreen() {
        assertEquals(Routes.NEWS, Routes.forStream(PushStreams.NEWS_POST))
        assertEquals(Routes.SHARD, Routes.forStream(PushStreams.SERVER_STATUS))
        assertEquals(Routes.SHARD, Routes.forStream(PushStreams.CHAMP_START))
        assertEquals(Routes.SHARD, Routes.forStream(PushStreams.IDOC_WARNING))
        assertEquals(Routes.SHARD, Routes.forStream(PushStreams.GOVERNOR_ELECTION))
        assertEquals(Routes.PLAYER_VENDORS, Routes.forStream(PushStreams.VENDOR_SALE))
        assertEquals(Routes.PLAYER_HOUSES, Routes.forStream(PushStreams.HOUSE_IDOC))
        assertEquals(Routes.ACCOUNT, Routes.forStream(PushStreams.ACCOUNT_LOGIN))
    }

    @Test fun unknownStreamFallsBackToHome() {
        assertEquals(Routes.HOME, Routes.forStream("something.new"))
    }

    @Test fun personalStreamNeedsLinkedAccount() {
        val personal = NotificationStreamDto(id = "vendor.sale", personal = true, requiresLinkedAccount = true)
        assertFalse(streamSelectable(personal, hasLinkedAccount = false))
        assertTrue(streamSelectable(personal, hasLinkedAccount = true))
    }

    @Test fun generalStreamIsAlwaysSelectable() {
        val general = NotificationStreamDto(id = "news.post", personal = false, requiresLinkedAccount = false)
        assertTrue(streamSelectable(general, hasLinkedAccount = false))
    }
}
