chore: add testid for debug

Signed-off-by: Innei <i@innei.in>
This commit is contained in:
Innei 2024-09-25 20:03:30 +08:00
parent ea6fbc27e6
commit 5104ad1964
No known key found for this signature in database
GPG Key ID: 0F62D33977F021F7
4 changed files with 17 additions and 2 deletions

View File

@ -187,7 +187,11 @@ export function DiscoverForm({ type }: { type: string }) {
return (
<>
<Form {...form}>
<form onSubmit={form.handleSubmit(onSubmit)} className="w-[512px] space-y-8">
<form
onSubmit={form.handleSubmit(onSubmit)}
className="w-[512px] space-y-8"
data-testid="discover-form"
>
<FormField
control={form.control}
name="keyword"
@ -225,7 +229,7 @@ export function DiscoverForm({ type }: { type: string }) {
)}
/>
)}
<div className="center flex">
<div className="center flex" data-testid="discover-form-actions">
<Button disabled={!form.formState.isValid} type="submit" isLoading={mutation.isPending}>
{info[type].showModal ? t("discover.preview") : t("words.search")}
</Button>

View File

@ -212,6 +212,7 @@ export const EntryContentRender: Component<{ entryId: string }> = ({ entryId, cl
key={entry.entries.id}
>
<article
data-testid="entry-render"
onContextMenu={stopPropagation}
className="relative m-auto min-w-0 max-w-[550px] @3xl:max-w-[70ch]"
>

View File

@ -1,4 +1,5 @@
import { registerGlobalContext } from "@follow/shared/bridge"
import { env } from "@follow/shared/env"
import { useEffect, useLayoutEffect } from "react"
import { useTranslation } from "react-i18next"
import { toast } from "sonner"
@ -28,6 +29,12 @@ export const ExtensionExposeProvider = () => {
},
toast,
getApiUrl() {
return env.VITE_API_URL
},
getWebUrl() {
return window.location.origin
},
})
}, [])

View File

@ -25,6 +25,9 @@ interface RenderGlobalContext {
/// Utils
toast: typeof toast
// URL
getWebUrl: () => string
getApiUrl: () => string
}
export const registerGlobalContext = (context: Partial<RenderGlobalContext>) => {