feat(server): add compatibility field (#4022)

This commit is contained in:
Alex Yang
2023-08-29 16:30:59 -05:00
committed by GitHub
parent e3b105f1cd
commit 71b195d9a9
4 changed files with 74 additions and 62 deletions
+13 -31
View File
@@ -3,10 +3,9 @@ import {
createRandomUser,
deleteUser,
getLoginCookie,
loginUser,
} from '@affine-test/kit/utils/cloud';
import { openHomePage } from '@affine-test/kit/utils/load-page';
import { waitEditorLoad } from '@affine-test/kit/utils/page-logic';
import { clickSideBarCurrentWorkspaceBanner } from '@affine-test/kit/utils/sidebar';
import { expect } from '@playwright/test';
let user: {
@@ -25,38 +24,21 @@ test.afterEach(async () => {
await deleteUser(user.email);
});
test('server exist', async ({ page }) => {
await openHomePage(page);
await waitEditorLoad(page);
test('server exist', async () => {
const json = await (await fetch('http://localhost:3010')).json();
expect(json.message).toMatch(/^AFFiNE GraphQL server/);
expect(json.compatibility).toMatch(/[0-9]+\.[0-9]+\.[0-9]+(-[a-z]+)?/);
});
test('enable cloud success', async ({ page, context }) => {
await page.goto('http://localhost:8080');
await page.waitForSelector('v-line');
await clickSideBarCurrentWorkspaceBanner(page);
await page.getByTestId('cloud-signin-button').click({
delay: 200,
await loginUser(page, user, {
beforeLogin: async () => {
expect(await getLoginCookie(context)).toBeUndefined();
},
afterLogin: async () => {
expect(await getLoginCookie(context)).toBeTruthy();
await page.reload();
await waitEditorLoad(page);
expect(await getLoginCookie(context)).toBeTruthy();
},
});
await page.getByPlaceholder('Enter your email address').type(user.email, {
delay: 50,
});
await page.getByTestId('continue-login-button').click({
delay: 200,
});
await page.getByTestId('sign-in-with-password').click({
delay: 200,
});
await page.getByTestId('password-input').type('123456', {
delay: 50,
});
expect(await getLoginCookie(context)).toBeUndefined();
await page.getByTestId('sign-in-button').click();
await page.waitForTimeout(1000);
await page.reload();
await waitEditorLoad(page);
expect(await getLoginCookie(context)).toBeTruthy();
});