feat: online ci

This commit is contained in:
DarkSky
2024-11-07 12:20:08 +08:00
parent f5df67501c
commit e96f89c26b
27 changed files with 490 additions and 232 deletions

Before

Width:  |  Height:  |  Size: 608 B

After

Width:  |  Height:  |  Size: 608 B

@@ -3,7 +3,7 @@
"private": true,
"type": "module",
"scripts": {
"e2e": "yarn playwright test"
"test:e2e": "yarn playwright test"
},
"devDependencies": {
"@affine-test/kit": "workspace:*",
@@ -6,6 +6,7 @@ import type {
const config: PlaywrightTestConfig = {
testDir: './e2e',
testMatch: '**/*.spec.ts',
fullyParallel: !process.env.CI,
timeout: 120_000,
outputDir: testResultDir,
+23 -7
View File
@@ -155,18 +155,22 @@ export async function createRandomUser(): Promise<{
} as any;
}
export async function createRandomAIUser(): Promise<{
export async function createRandomAIUser(
provider?: string,
connector: typeof runPrisma = runPrisma
): Promise<{
name: string;
email: string;
password: string;
id: string;
sessionId: string;
}> {
const user = {
name: faker.internet.username(),
email: faker.internet.email().toLowerCase(),
email: faker.internet.email({ provider }).toLowerCase(),
password: '123456',
};
const result = await runPrisma(async client => {
const result = await connector(async client => {
const freeFeatureId = await client.feature
.findFirst({
where: { feature: 'free_plan_v1' },
@@ -182,7 +186,7 @@ export async function createRandomAIUser(): Promise<{
})
.then(f => f!.id);
await client.user.create({
const { id: userId } = await client.user.create({
data: {
...user,
emailVerifiedAt: new Date(),
@@ -204,11 +208,23 @@ export async function createRandomAIUser(): Promise<{
},
});
return await client.user.findUnique({
where: {
email: user.email,
const { id: sessionId } = await client.session.create({ data: {} });
await client.userSession.create({
data: {
sessionId,
userId,
// half an hour
expiresAt: new Date(Date.now() + 60 * 30 * 1000),
},
});
return await client.user
.findUnique({
where: {
email: user.email,
},
})
.then(r => ({ ...r, sessionId }));
});
cloudUserSchema.parse(result);
return {