test: add open login modal test

This commit is contained in:
tzhangchi
2022-12-23 18:08:30 +08:00
parent 490dbb4a60
commit 2d52e49b3a
4 changed files with 24 additions and 4 deletions
@@ -11,7 +11,7 @@ interface LoginModalProps {
export const LoginModal = ({ open, onClose }: LoginModalProps) => {
return (
<Modal open={open} onClose={onClose}>
<Modal open={open} onClose={onClose} data-testid="login-modal">
<ModalWrapper width={620} height={334}>
<Header>
<ModalCloseButton
@@ -9,7 +9,10 @@ import {
export const LoginItem = () => {
const { triggerLoginModal } = useModal();
return (
<LoginItemWrapper onClick={() => triggerLoginModal()}>
<LoginItemWrapper
onClick={() => triggerLoginModal()}
data-testid="open-login-modal"
>
<WorkspaceItemAvatar alt="AFFiNE" src={''}>
A
</WorkspaceItemAvatar>
+2 -2
View File
@@ -5,10 +5,10 @@ loadPage();
test.describe('Open contact us', () => {
test('Click about us', async ({ page }) => {
page.waitForTimeout(1000);
// page.waitForTimeout(1000);
const currentWorkspace = page.getByTestId('current-workspace');
await currentWorkspace.click();
page.waitForTimeout(1000);
await page
.getByRole('tooltip', {
name: 'A AFFiNE Log in to sync with affine About AFFiNE',
+17
View File
@@ -0,0 +1,17 @@
import { test, expect, type Page } from '@playwright/test';
import { loadPage } from './libs/load-page';
loadPage();
test.describe('Login Flow', () => {
test('Open Login Modal', async ({ page }) => {
await page.getByTestId('current-workspace').click();
await page.waitForTimeout(800);
// why don't we use waitForSelector, It seems that waitForSelector not stable?
await page.getByTestId('open-login-modal').click();
await page.waitForTimeout(800);
await page
.getByRole('heading', { name: 'Currently not logged in' })
.click();
});
});