From 8825678ca9e25630693859717db600dbce61e820 Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Sat, 2 Sep 2023 00:11:10 -0500 Subject: [PATCH] test: add name change test (#4125) --- .../setting-modal/setting-sidebar/index.tsx | 6 ++- tests/affine-cloud/e2e/basic.spec.ts | 52 ++++++++++++++----- 2 files changed, 45 insertions(+), 13 deletions(-) diff --git a/apps/core/src/components/affine/setting-modal/setting-sidebar/index.tsx b/apps/core/src/components/affine/setting-modal/setting-sidebar/index.tsx index 96ad905602..0ada4bd2e4 100644 --- a/apps/core/src/components/affine/setting-modal/setting-sidebar/index.tsx +++ b/apps/core/src/components/affine/setting-modal/setting-sidebar/index.tsx @@ -50,7 +50,11 @@ export const UserInfo = ({ }: UserInfoProps): ReactElement => { const user = useCurrentUser(); return ( -
+
{ 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); -}); - -test('server exist', async () => { - const json = await (await fetch('http://localhost:3010')).json(); - expect(json.compatibility).toMatch(/[0-9]+\.[0-9]+\.[0-9]+(-[a-z]+)?/); -}); - -test('enable cloud success', async ({ page, context }) => { +test.beforeEach(async ({ page, context }) => { await loginUser(page, user, { beforeLogin: async () => { expect(await getLoginCookie(context)).toBeUndefined(); @@ -42,3 +32,41 @@ test('enable cloud success', async ({ page, context }) => { }, }); }); + +test.afterEach(async () => { + // if you want to keep the user in the database for debugging, + // comment this line + await deleteUser(user.email); +}); + +test.describe('basic', () => { + test('can see and change email and password in setting panel', async ({ + page, + }) => { + const newName = 'test name'; + { + await clickSideBarSettingButton(page); + const locator = page.getByTestId('user-info-card'); + expect(locator.getByText(user.email)).toBeTruthy(); + expect(locator.getByText(user.name)).toBeTruthy(); + await locator.click({ + delay: 50, + }); + const nameInput = page.getByPlaceholder('Input account name'); + await nameInput.clear(); + await nameInput.type(newName, { + delay: 50, + }); + await page.getByTestId('save-user-name').click({ + delay: 50, + }); + } + await page.reload(); + { + await clickSideBarSettingButton(page); + const locator = page.getByTestId('user-info-card'); + expect(locator.getByText(user.email)).toBeTruthy(); + expect(locator.getByText(newName)).toBeTruthy(); + } + }); +});