From 2a54781ce0e9f0764a9bb70008ef7c7798a1f5e0 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Thu, 28 Aug 2025 06:20:06 -0500 Subject: Update dev env (#8921) * Update dev-env * Integrate appviewDid value from dev-env * Use correct env value to disable policy update overlay * Remove log --- .eslintrc.js | 2 + __e2e__/mock-server.ts | 13 +- __e2e__/setupApp.yml | 5 + __e2e__/setupServer.js | 5 +- jest/test-pds.ts | 4 +- package.json | 2 +- src/components/PolicyUpdateOverlay/context.tsx | 4 +- src/env/common.ts | 2 +- src/lib/constants.ts | 6 +- src/view/com/testing/TestCtrls.e2e.tsx | 18 +- yarn.lock | 270 ++++++++++++++----------- 11 files changed, 205 insertions(+), 126 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index b9c89c3d5..04914bde6 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -111,6 +111,8 @@ module.exports = { 'bskyembed', 'src/locale/locales/_build/', 'src/locale/locales/**/*.js', + '*.e2e.ts', + '*.e2e.tsx', ], settings: { componentWrapperFunctions: ['observer'], diff --git a/__e2e__/mock-server.ts b/__e2e__/mock-server.ts index b5f13a87f..d4be040df 100644 --- a/__e2e__/mock-server.ts +++ b/__e2e__/mock-server.ts @@ -1,7 +1,7 @@ import {createServer as createHTTPServer} from 'node:http' import {parse} from 'node:url' -import {createServer, TestPDS} from '../jest/test-pds' +import {createServer, type TestPDS} from '../jest/test-pds' async function main() { let server: TestPDS @@ -509,7 +509,16 @@ async function main() { } } console.log('Ready') - return res.writeHead(200).end(server.pdsUrl) + return res + .writeHead(200, { + 'content-type': 'application/json', + }) + .end( + JSON.stringify({ + pdsUrl: server.pdsUrl, + appviewDid: server.appviewDid, + }), + ) } catch (e) { console.error('Error!', e) return res.writeHead(500).end() diff --git a/__e2e__/setupApp.yml b/__e2e__/setupApp.yml index 25f9aa847..728d548fb 100644 --- a/__e2e__/setupApp.yml +++ b/__e2e__/setupApp.yml @@ -11,3 +11,8 @@ appId: xyz.blueskyweb.app - swipe: from: "Bluesky" direction: DOWN +- tapOn: + id: e2eProxyHeaderInput +- inputText: ${output.result} +- pressKey: Enter +- hideKeyboard diff --git a/__e2e__/setupServer.js b/__e2e__/setupServer.js index 7b1fb9574..dedf4ffa9 100644 --- a/__e2e__/setupServer.js +++ b/__e2e__/setupServer.js @@ -1,5 +1,8 @@ // eslint-disable-next-line -http.post('http://localhost:1986/' + SERVER_PATH, { +var res = http.post('http://localhost:1986/' + SERVER_PATH, { headers: {'Content-Type': 'text/plain'}, body: '', }) + +// eslint-disable-next-line +output.result = json(res.body).appviewDid diff --git a/jest/test-pds.ts b/jest/test-pds.ts index 962bb7b48..98933a063 100644 --- a/jest/test-pds.ts +++ b/jest/test-pds.ts @@ -1,5 +1,5 @@ import {AtUri, BskyAgent} from '@atproto/api' -import {TestBsky, TestNetwork} from '@atproto/dev-env' +import {type TestBsky, TestNetwork} from '@atproto/dev-env' import fs from 'fs' import net from 'net' import path from 'path' @@ -13,6 +13,7 @@ export interface TestUser { } export interface TestPDS { + appviewDid: string pdsUrl: string mocker: Mocker close: () => Promise @@ -112,6 +113,7 @@ export async function createServer( ) return { + appviewDid: testNet.bsky.serverDid, pdsUrl, mocker: new Mocker(testNet, pdsUrl, pic), async close() { diff --git a/package.json b/package.json index 73e9d7a02..5dc5ef96a 100644 --- a/package.json +++ b/package.json @@ -224,7 +224,7 @@ "zod": "^3.20.2" }, "devDependencies": { - "@atproto/dev-env": "^0.3.160", + "@atproto/dev-env": "^0.3.167", "@babel/core": "^7.26.0", "@babel/preset-env": "^7.26.0", "@babel/runtime": "^7.26.0", diff --git a/src/components/PolicyUpdateOverlay/context.tsx b/src/components/PolicyUpdateOverlay/context.tsx index abb058d3c..3c65ae375 100644 --- a/src/components/PolicyUpdateOverlay/context.tsx +++ b/src/components/PolicyUpdateOverlay/context.tsx @@ -12,6 +12,7 @@ import { type PolicyUpdateState, usePolicyUpdateState, } from '#/components/PolicyUpdateOverlay/usePolicyUpdateState' +import {ENV} from '#/env' const Context = createContext<{ state: PolicyUpdateState @@ -45,8 +46,7 @@ export function Provider({children}: {children?: ReactNode}) { const [isReadyToShowOverlay, setIsReadyToShowOverlay] = useState(false) const state = usePolicyUpdateState({ // only enable the policy update overlay in non-test environments - enabled: - isReadyToShowOverlay && hasSession && process.env.NODE_ENV !== 'test', + enabled: isReadyToShowOverlay && hasSession && ENV !== 'e2e', }) const ctx = useMemo( diff --git a/src/env/common.ts b/src/env/common.ts index 69451fd7e..7b64c35a6 100644 --- a/src/env/common.ts +++ b/src/env/common.ts @@ -11,7 +11,7 @@ export const RELEASE_VERSION: string = process.env.EXPO_PUBLIC_RELEASE_VERSION || packageJson.version /** - * The env the app is running in e.g. development, testflight, production + * The env the app is running in e.g. development, testflight, production, e2e */ export const ENV: string = process.env.EXPO_PUBLIC_ENV diff --git a/src/lib/constants.ts b/src/lib/constants.ts index 727d4b052..b6b06ee7f 100644 --- a/src/lib/constants.ts +++ b/src/lib/constants.ts @@ -214,7 +214,11 @@ 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 BLUESKY_PROXY_HEADER: ProxyHeaderValue = `${BLUESKY_PROXY_DID}#bsky_appview` +// temp hack for e2e - esb +export let BLUESKY_PROXY_HEADER: ProxyHeaderValue = `${BLUESKY_PROXY_DID}#bsky_appview` +export function setBlueskyProxyHeader(header: ProxyHeaderValue) { + BLUESKY_PROXY_HEADER = header +} export const BLUESKY_SERVICE_HEADERS = { 'atproto-proxy': BLUESKY_PROXY_HEADER, diff --git a/src/view/com/testing/TestCtrls.e2e.tsx b/src/view/com/testing/TestCtrls.e2e.tsx index 3273cf195..8e39e28c0 100644 --- a/src/view/com/testing/TestCtrls.e2e.tsx +++ b/src/view/com/testing/TestCtrls.e2e.tsx @@ -1,8 +1,10 @@ -import {LogBox, Pressable, View} from 'react-native' +import {useState} from 'react' +import {LogBox, Pressable, View, TextInput} from 'react-native' import {useQueryClient} from '@tanstack/react-query' +import {setBlueskyProxyHeader} from '#/lib/constants' import {useModalControls} from '#/state/modals' -import {useSessionApi} from '#/state/session' +import {useSessionApi, useAgent} from '#/state/session' import {useLoggedOutViewControls} from '#/state/shell/logged-out' import {useOnboardingDispatch} from '#/state/shell/onboarding' import {navigate} from '../../../Navigation' @@ -18,6 +20,7 @@ LogBox.ignoreAllLogs() const BTN = {height: 1, width: 1, backgroundColor: 'red'} export function TestCtrls() { + const agent = useAgent() const queryClient = useQueryClient() const {logoutEveryAccount, login} = useSessionApi() const {openModal} = useModalControls() @@ -45,8 +48,19 @@ export function TestCtrls() { ) setShowLoggedOut(false) } + const [proxyHeader, setProxyHeader] = useState('') return ( + setProxyHeader(val as any)} + onSubmitEditing={() => { + const header = `${proxyHeader}#bsky_appview` + setBlueskyProxyHeader(header as any) + agent.configureProxy(header as any) + }} + style={BTN} + />