2023-08-29 13:07:05 +03:00
|
|
|
import { test } from '@affine-test/kit/playwright';
|
|
|
|
import {
|
|
|
|
createRandomUser,
|
|
|
|
deleteUser,
|
|
|
|
getLoginCookie,
|
2023-08-30 00:30:59 +03:00
|
|
|
loginUser,
|
2023-08-29 13:07:05 +03:00
|
|
|
} from '@affine-test/kit/utils/cloud';
|
2023-09-02 06:31:07 +03:00
|
|
|
import { waitForEditorLoad } from '@affine-test/kit/utils/page-logic';
|
2023-08-29 13:07:05 +03:00
|
|
|
import { expect } from '@playwright/test';
|
|
|
|
|
|
|
|
let user: {
|
|
|
|
name: string;
|
|
|
|
email: string;
|
|
|
|
password: string;
|
|
|
|
};
|
|
|
|
|
|
|
|
test.beforeEach(async () => {
|
|
|
|
user = await createRandomUser();
|
|
|
|
});
|
|
|
|
|
|
|
|
test.afterEach(async () => {
|
|
|
|
// if you want to keep the user in the database for debugging,
|
|
|
|
// comment this line
|
|
|
|
await deleteUser(user.email);
|
|
|
|
});
|
|
|
|
|
2023-08-30 00:30:59 +03:00
|
|
|
test('server exist', async () => {
|
2023-08-29 13:07:05 +03:00
|
|
|
const json = await (await fetch('http://localhost:3010')).json();
|
2023-08-30 00:30:59 +03:00
|
|
|
expect(json.compatibility).toMatch(/[0-9]+\.[0-9]+\.[0-9]+(-[a-z]+)?/);
|
2023-08-29 13:07:05 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
test('enable cloud success', async ({ page, context }) => {
|
2023-08-30 00:30:59 +03:00
|
|
|
await loginUser(page, user, {
|
|
|
|
beforeLogin: async () => {
|
|
|
|
expect(await getLoginCookie(context)).toBeUndefined();
|
|
|
|
},
|
|
|
|
afterLogin: async () => {
|
|
|
|
expect(await getLoginCookie(context)).toBeTruthy();
|
|
|
|
await page.reload();
|
2023-09-02 06:31:07 +03:00
|
|
|
await waitForEditorLoad(page);
|
2023-08-30 00:30:59 +03:00
|
|
|
expect(await getLoginCookie(context)).toBeTruthy();
|
|
|
|
},
|
2023-08-29 13:07:05 +03:00
|
|
|
});
|
|
|
|
});
|