1
0
mirror of synced 2026-02-06 00:00:10 -05:00

Compare commits

...

2 Commits

Author SHA1 Message Date
Brandon Bayer
56c7933f3a Merge branch 'canary' into infinite-loop2 2021-04-23 16:11:14 -04:00
Brandon Bayer
7be9466b94 failing test 2021-04-23 16:05:02 -04:00
3 changed files with 23 additions and 5 deletions

View File

@@ -1,4 +1,5 @@
import {AppProps, ErrorFallbackProps, useQueryErrorResetBoundary} from "blitz"
import login from "app/mutations/login"
import {AppProps, ErrorFallbackProps, useMutation, useQueryErrorResetBoundary} from "blitz"
import {useRouter} from "next/router"
import {ErrorBoundary} from "react-error-boundary"
import {ReactQueryDevtools} from "react-query/devtools"
@@ -19,5 +20,19 @@ export default function App({Component, pageProps}: AppProps) {
}
function RootErrorFallback({error}: ErrorFallbackProps) {
return <div id="error">{error.name}</div>
const [loginMutation] = useMutation(login)
return (
<div>
<div id="error">{error.name}</div>
<button
id="login"
onClick={async () => {
await loginMutation()
}}
>
login
</button>
</div>
)
}

View File

@@ -1,11 +1,13 @@
import logout from "app/mutations/logout"
import getAuthenticatedBasic from "app/queries/getAuthenticatedBasic"
import {useMutation, useQuery} from "blitz"
import {Suspense} from "react"
import {Suspense, useState} from "react"
function Content() {
const [result] = useQuery(getAuthenticatedBasic, undefined)
const [state, setState] = useState(false)
const [result] = useQuery(getAuthenticatedBasic, state)
const [logoutMutation] = useMutation(logout)
return (
<div>
<div id="content">{result}</div>
@@ -13,6 +15,7 @@ function Content() {
id="logout"
onClick={async () => {
await logoutMutation()
setState(true)
}}
>
logout

View File

@@ -29,7 +29,7 @@ describe("Auth", () => {
})
afterAll(() => killApp(context.server))
describe("unauthenticated", () => {
describe("no-auth", () => {
it("should render result for open query", async () => {
const browser = await webdriver(context.appPort, "/noauth-query")
let text = await browser.elementByCss("#page").text()