From b214a88a429473b46907b7ec50202b3a9f91e344 Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Thu, 3 Sep 2026 15:05:43 +0300 Subject: [PATCH] use static appview did for e2e --- __e2e__/setupApp.yml | 17 +------ __e2e__/setupServer.js | 7 +-- dev-env/constants.ts | 1 + dev-env/test-pds.ts | 9 ++++ src/lib/constants.ts | 1 - src/view/com/testing/TestCtrls.e2e.tsx | 64 ++++++-------------------- 6 files changed, 26 insertions(+), 73 deletions(-) create mode 100644 dev-env/constants.ts diff --git a/__e2e__/setupApp.yml b/__e2e__/setupApp.yml index be1794c523..c7705951fb 100644 --- a/__e2e__/setupApp.yml +++ b/__e2e__/setupApp.yml @@ -3,22 +3,7 @@ appId: xyz.blueskyweb.app - launchApp: appId: "xyz.blueskyweb.app" clearState: true -- extendedWaitUntil: - visible: - id: e2eProxyHeaderInput - timeout: 180000 - extendedWaitUntil: visible: "Sign in" timeout: 180000 -- retry: - maxRetries: 3 - commands: - - tapOn: - id: e2eProxyHeaderInput - - eraseText - - inputText: ${output.result} - - pressKey: Enter - - extendedWaitUntil: - visible: - id: e2eSignInAlice - timeout: 10000 +- waitForAnimationToEnd diff --git a/__e2e__/setupServer.js b/__e2e__/setupServer.js index 5038197b0a..eb60ba2581 100644 --- a/__e2e__/setupServer.js +++ b/__e2e__/setupServer.js @@ -1,8 +1,5 @@ -// eslint-disable-next-line no-undef -var res = http.post('http://localhost:1986/' + SERVER_PATH, { +// eslint-disable-next-line no-undef, typescript/no-unsafe-call, typescript/no-unsafe-member-access +http.post('http://localhost:1986/' + SERVER_PATH, { headers: {'Content-Type': 'text/plain'}, body: '', }) - -// eslint-disable-next-line no-undef -output.result = json(res.body).appviewDid diff --git a/dev-env/constants.ts b/dev-env/constants.ts new file mode 100644 index 0000000000..bc8ccfe36f --- /dev/null +++ b/dev-env/constants.ts @@ -0,0 +1 @@ +export const E2E_APPVIEW_DID = 'did:plc:bw7ad3erl7btq6qwf66yqiov' diff --git a/dev-env/test-pds.ts b/dev-env/test-pds.ts index 6696868866..6e7579fee1 100644 --- a/dev-env/test-pds.ts +++ b/dev-env/test-pds.ts @@ -5,6 +5,8 @@ import path from 'node:path' import {AtUri, BskyAgent} from '@atproto/api' import {type TestBsky, TestNetwork} from '@atproto/dev-env' +import {E2E_APPVIEW_DID} from './constants.ts' + export interface TestUser { email: string did: string @@ -83,6 +85,13 @@ export async function createServer( plc: {port: port2}, }) + if (testNet.bsky.serverDid !== E2E_APPVIEW_DID) { + await testNet.close() + throw new Error( + `E2E AppView DID changed from ${E2E_APPVIEW_DID} to ${testNet.bsky.serverDid}. Update E2E_APPVIEW_DID in dev-env/constants.ts.`, + ) + } + // DISABLED - looks like dev-env added this and now it conflicts // add the test mod authority // const agent = new BskyAgent({service: pdsUrl}) diff --git a/src/lib/constants.ts b/src/lib/constants.ts index d12c5a2aed..496bc850a4 100644 --- a/src/lib/constants.ts +++ b/src/lib/constants.ts @@ -234,7 +234,6 @@ export const PUBLIC_APPVIEW_DID = 'did:web:api.bsky.app' export const PUBLIC_STAGING_APPVIEW_DID = 'did:web:api.staging.bsky.dev' export const DEV_ENV_APPVIEW = `http://localhost:2584` // always the same -export const DEV_ENV_APPVIEW_DID = `did:plc:dw4kbjf5mn7nhenabiqpkyh3` // always the same // temp hack for e2e - esb export const BLUESKY_PROXY_HEADER = { diff --git a/src/view/com/testing/TestCtrls.e2e.tsx b/src/view/com/testing/TestCtrls.e2e.tsx index e9e3436d1c..f3bcc0420d 100644 --- a/src/view/com/testing/TestCtrls.e2e.tsx +++ b/src/view/com/testing/TestCtrls.e2e.tsx @@ -1,7 +1,7 @@ -import {useState} from 'react' -import {LogBox, Pressable, TextInput, View} from 'react-native' +import {LogBox, Pressable, View} from 'react-native' import {useQueryClient} from '@tanstack/react-query' +import {E2E_APPVIEW_DID} from '../../../../dev-env/constants' import {BLUESKY_PROXY_HEADER} from '#/lib/constants' import {useSessionApi} from '#/state/session' import {useLoggedOutViewControls} from '#/state/shell/logged-out' @@ -18,24 +18,13 @@ LogBox.ignoreAllLogs() const BTN = {height: 1, width: 1, backgroundColor: 'red'} -/* - * This component is mounted inside in - * App.tsx, so it fully remounts whenever the account changes (sign-in / - * sign-out). If the "proxy configured" flag lived only in React state it would - * reset to false on every remount, hiding the sign-in buttons. Keeping it at - * module level lets it survive remounts so the sign-in buttons stay visible - * across sign-out during multi-account flows. Module state still resets when - * the app relaunches with cleared state at the start of each flow, which is the - * desired gating behavior. - */ -let hasConfiguredProxy = false +BLUESKY_PROXY_HEADER.set(`${E2E_APPVIEW_DID}#bsky_appview`) export function TestCtrls() { const queryClient = useQueryClient() const {logoutEveryAccount, login} = useSessionApi() const onboardingDispatch = useOnboardingDispatch() const {setShowLoggedOut} = useLoggedOutViewControls() - const [isProxyConfigured, setIsProxyConfigured] = useState(hasConfiguredProxy) const onPressSignInAlice = async () => { console.info('[E2E] Signing in as Alice') await login( @@ -60,47 +49,20 @@ export function TestCtrls() { ) setShowLoggedOut(false) } - const [proxyHeader, setProxyHeader] = useState('') return ( - setProxyHeader(val)} - autoComplete="off" - autoCorrect={false} - autoCapitalize="none" - onSubmitEditing={() => { - const header = `${proxyHeader}#bsky_appview` - /* - * The appview client reads `BLUESKY_PROXY_HEADER.get()` when the - * bundle builds it (see clients.ts), so setting the mutable constant - * retargets the proxy for the sign-ins below without reconfiguring - * anything: the gate above means no bundle exists yet. - */ - BLUESKY_PROXY_HEADER.set(header) - hasConfiguredProxy = true - setIsProxyConfigured(true) - }} + + - {isProxyConfigured && ( - <> - - - - )} logoutEveryAccount('Settings')}