Graphical PDS migrator for AT Protocol
1import { TestEnvironment } from "../utils/test-env.ts";
2import { Agent, CredentialSession } from "@atproto/api";
3import { TEST_CONFIG } from "../utils/config.ts";
4import { afterAll, beforeAll, describe, expect, it } from "@jest/globals";
5
6describe("devenv.ts", () => {
7 let env: TestEnvironment;
8 let session: CredentialSession;
9 beforeAll(async () => {
10 env = await TestEnvironment.create();
11 session = new CredentialSession(new URL(env.sourcePds.url));
12 });
13
14 afterAll(async () => {
15 await env.cleanup();
16 });
17
18 it("should create test account", async () => {
19 const result = await session.createAccount({
20 handle: TEST_CONFIG.handle,
21 password: TEST_CONFIG.password,
22 email: TEST_CONFIG.email,
23 });
24
25 expect(result.success).toBe(true);
26 expect(result.data.did).toBeDefined();
27 });
28
29 it("should request plc operation token and get token from mailbox", async () => {
30 // Start waiting for mail before making the request
31 const tokenPromise = env.awaitMail();
32
33 const result = await new Agent(session).com.atproto.identity
34 .requestPlcOperationSignature();
35 expect(result.success).toBe(true);
36
37 // Now await the token that should have been sent
38 const token = await tokenPromise;
39 expect(token).toBeDefined();
40 });
41});