mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-13 21:01:21 +08:00
Add E2E tests for the JS library (#487)
* Add dependency on @stackframe/js to e2e tests * add more * add some additional logic for issuing api key * more * fix window dependency * roll it back * chore: update package versions * Make Project description field non-nullable (#483) Co-Authored-By: Konstantin Wohlwend <n2d4xc@gmail.com> * Run E2E API tests on Node v22 too * Run E2E tests on latest Node.js version * Codegen + macros for SDK docs (#456) * add extra body * Add link to Docker image to docs * Permit signUpWithCredential in non-browser environments * get the tests running * remove * fix * update the interface * Update apps/e2e/tests/js/js-helpers.ts Co-authored-by: Konsti Wohlwend <n2d4xc@gmail.com> --------- Co-authored-by: Konstantin Wohlwend <n2d4xc@gmail.com> Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Zai Shi <zaishi00@outlook.com>
This commit is contained in:
parent
38c9ddb14e
commit
8b88c7a258
@ -11,6 +11,7 @@
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
"@stackframe/js": "workspace:*",
|
||||
"@stackframe/stack-shared": "workspace:*",
|
||||
"dotenv": "^16.4.5",
|
||||
"jose": "^5.2.2",
|
||||
|
||||
7
apps/e2e/tests/js/general.test.ts
Normal file
7
apps/e2e/tests/js/general.test.ts
Normal file
@ -0,0 +1,7 @@
|
||||
import { it } from "../helpers";
|
||||
import { scaffoldProject } from "./js-helpers";
|
||||
|
||||
it("should scaffold the project", async ({ expect }) => {
|
||||
const { project } = await scaffoldProject();
|
||||
expect(project.displayName).toBe("New Project");
|
||||
});
|
||||
35
apps/e2e/tests/js/js-helpers.ts
Normal file
35
apps/e2e/tests/js/js-helpers.ts
Normal file
@ -0,0 +1,35 @@
|
||||
import { AdminProjectUpdateOptions, StackAdminApp } from '@stackframe/js';
|
||||
import { wait } from '@stackframe/stack-shared/dist/utils/promises';
|
||||
import { STACK_BACKEND_BASE_URL, STACK_INTERNAL_PROJECT_ADMIN_KEY, STACK_INTERNAL_PROJECT_CLIENT_KEY, STACK_INTERNAL_PROJECT_SERVER_KEY } from '../helpers';
|
||||
|
||||
export async function scaffoldProject(body?: AdminProjectUpdateOptions) {
|
||||
const internalApp = new StackAdminApp({
|
||||
projectId: 'internal',
|
||||
baseUrl: STACK_BACKEND_BASE_URL,
|
||||
publishableClientKey: STACK_INTERNAL_PROJECT_CLIENT_KEY,
|
||||
secretServerKey: STACK_INTERNAL_PROJECT_SERVER_KEY,
|
||||
superSecretAdminKey: STACK_INTERNAL_PROJECT_ADMIN_KEY,
|
||||
tokenStore: "memory",
|
||||
});
|
||||
|
||||
const fakeEmail = `${crypto.randomUUID()}@stack-js-test.example.com`;
|
||||
|
||||
await internalApp.signUpWithCredential({
|
||||
email: fakeEmail,
|
||||
password: "password",
|
||||
verificationCallbackUrl: "https://stack-js-test.example.com/verify",
|
||||
});
|
||||
const user = await internalApp.getUser({
|
||||
or: 'throw',
|
||||
});
|
||||
|
||||
const project = await user.createProject({
|
||||
displayName: body?.displayName || 'New Project',
|
||||
...body,
|
||||
});
|
||||
|
||||
return {
|
||||
project,
|
||||
user,
|
||||
};
|
||||
}
|
||||
@ -3574,7 +3574,7 @@ export type StackClientApp<HasTokenStore extends boolean = boolean, ProjectId ex
|
||||
|
||||
signInWithOAuth(provider: string): Promise<void>,
|
||||
signInWithCredential(options: { email: string, password: string, noRedirect?: boolean }): Promise<Result<undefined, KnownErrors["EmailPasswordMismatch"] | KnownErrors["InvalidTotpCode"]>>,
|
||||
signUpWithCredential(options: { email: string, password: string, noRedirect?: boolean }): Promise<Result<undefined, KnownErrors["UserEmailAlreadyExists"] | KnownErrors["PasswordRequirementsNotMet"]>>,
|
||||
signUpWithCredential(options: { email: string, password: string, noRedirect?: boolean, verificationCallbackUrl?: string }): Promise<Result<undefined, KnownErrors["UserEmailAlreadyExists"] | KnownErrors["PasswordRequirementsNotMet"]>>,
|
||||
signInWithPasskey(): Promise<Result<undefined, KnownErrors["PasskeyAuthenticationFailed"]| KnownErrors["InvalidTotpCode"] | KnownErrors["PasskeyWebAuthnError"]>>,
|
||||
callOAuthCallback(): Promise<boolean>,
|
||||
sendForgotPasswordEmail(email: string, options?: { callbackUrl?: string }): Promise<Result<undefined, KnownErrors["UserNotFound"]>>,
|
||||
|
||||
@ -419,6 +419,9 @@ importers:
|
||||
|
||||
apps/e2e:
|
||||
dependencies:
|
||||
'@stackframe/js':
|
||||
specifier: workspace:*
|
||||
version: link:../../packages/js
|
||||
'@stackframe/stack-shared':
|
||||
specifier: workspace:*
|
||||
version: link:../../packages/stack-shared
|
||||
|
||||
Loading…
Reference in New Issue
Block a user