@@ -28,7 +28,6 @@ const mocks = vi.hoisted(() => ({
2828 pickElement : vi . fn ( ) ,
2929 addPreviewAnnotation : vi . fn ( ) ,
3030 addImage : vi . fn ( ) ,
31- toast : vi . fn ( ) ,
3231 pictureInPicture : false ,
3332 showEmptyState : false ,
3433 loading : false ,
@@ -136,10 +135,6 @@ vi.mock(import("~/browser/browserRecording"), async (original) => ({
136135 findActiveBrowserRecordingRuntimeTabId : ( ) => mocks . recordingRuntimeTabId ,
137136 useActiveBrowserRecordingTabIds : ( ) => mocks . recordingTabIds ,
138137} ) ) ;
139- vi . mock ( import ( "~/components/ui/toast" ) , async ( original ) => {
140- const actual = await original ( ) ;
141- return { ...actual , toastManager : { ...actual . toastManager , add : mocks . toast } } ;
142- } ) ;
143138vi . mock ( import ( "./useDiscoveredLocalServers" ) , async ( original ) => ( {
144139 ...( await original ( ) ) ,
145140 useDiscoveredLocalServers : ( ) => mocks . servers ,
@@ -162,6 +157,7 @@ import { previewRuntimeTabId } from "~/browser/previewRuntimeTabId";
162157import { usePreviewMiniPlayerStore } from "~/previewMiniPlayerStore" ;
163158import { dispatchPreviewAction } from "./previewActionBus" ;
164159import { PreviewView } from "./PreviewView" ;
160+ import { ToastProvider } from "~/components/ui/toast" ;
165161
166162const TEST_THREAD_REF = {
167163 environmentId : EnvironmentId . make ( "environment-1" ) ,
@@ -219,6 +215,23 @@ function setup() {
219215}
220216
221217describe ( "PreviewView" , ( ) => {
218+ it . each ( [ "mailto:[email protected] " , "http://" ] ) ( 219+ "reports rejected address %s without navigating or recording it" ,
220+ async ( address ) => {
221+ setup ( ) ;
222+ await using _screen = await render ( < ToastProvider timeout = { 0 } > { view ( ) } </ ToastProvider > ) ;
223+ const input = page . getByPlaceholder ( "Search or enter URL" ) ;
224+ await input . fill ( address ) ;
225+ await userEvent . keyboard ( "{Enter}" ) ;
226+
227+ await expect . element ( page . getByText ( "Could not open this address" ) ) . toBeVisible ( ) ;
228+ await expect . element ( page . getByText ( "Enter an http or https URL." ) ) . toBeVisible ( ) ;
229+ expect ( mocks . navigate ) . not . toHaveBeenCalled ( ) ;
230+ expect ( mocks . recordVisitForThread ) . not . toHaveBeenCalled ( ) ;
231+ await userEvent . click ( page . getByRole ( "button" , { name : "Dismiss notification" } ) ) ;
232+ } ,
233+ ) ;
234+
222235 it ( "retains the annotation locally when its own environment loses access during capture" , async ( ) => {
223236 setup ( ) ;
224237 const picked = annotation ( "annotation-revoked" ) ;
0 commit comments