OpenPuzzleBannerTests.swift (1260B)
1 import Foundation 2 import Testing 3 4 @testable import Crossmate 5 6 /// Covers the open-time banner reconciler. The access-revoked banner is 7 /// otherwise posted only on the live revocation transition; a puzzle revoked 8 /// in an earlier process must still surface it when reopened. 9 @Suite("OpenPuzzleBanner") 10 struct OpenPuzzleBannerTests { 11 12 @Test("Opening a revoked game yields the sticky access-revoked banner") 13 func revokedGameYieldsBanner() throws { 14 let gameID = UUID() 15 let announcements = OpenPuzzleBanner.announcements( 16 for: OpenPuzzleState(gameID: gameID, isAccessRevoked: true) 17 ) 18 #expect(announcements.count == 1) 19 let banner = try #require(announcements.first) 20 #expect(banner.id == "access-revoked-\(gameID.uuidString)") 21 #expect(banner.scope == .game(gameID)) 22 #expect(banner.severity == .error) 23 #expect(banner.dismissal == .sticky) 24 #expect(banner.blocksInput) 25 } 26 27 @Test("Opening a game with access intact yields no banners") 28 func intactGameYieldsNothing() { 29 let announcements = OpenPuzzleBanner.announcements( 30 for: OpenPuzzleState(gameID: UUID(), isAccessRevoked: false) 31 ) 32 #expect(announcements.isEmpty) 33 } 34 }