diff --git a/.vscode/launch.json b/.vscode/launch.json index 09c8da3ad8..466e078425 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -37,6 +37,19 @@ "runtimeArgs": ["run", "test:client", "${relativeFile}"] } }, + { + "type": "node", + "request": "launch", + "name": "Debug E2E Tests", + "runtimeExecutable": "yarn", + "runtimeArgs": ["test:e2e", "${file}"], + "skipFiles": ["/**"], + "console": "integratedTerminal", + "internalConsoleOptions": "neverOpen", + "windows": { + "runtimeArgs": ["test:e2e", "${fileBasename}"] + } + }, { "type": "node", "request": "launch", diff --git a/packages/plugins/auth/src/client/__tests__/e2e/auth.e2e.ts b/packages/plugins/auth/src/client/__tests__/e2e/auth.e2e.ts new file mode 100644 index 0000000000..a6edeed2c3 --- /dev/null +++ b/packages/plugins/auth/src/client/__tests__/e2e/auth.e2e.ts @@ -0,0 +1,34 @@ +import { expect, test } from '@playwright/test'; + +test.describe('auth', () => { + // 重置登录状态 + test.use({ + storageState: { + cookies: [], + origins: [], + }, + }); + + test('register', async ({ page }) => { + await page.goto('/'); + await page.getByRole('link', { name: 'Create an account' }).click(); + await page.getByPlaceholder('Username').click(); + await page.getByPlaceholder('Username').fill('zidonghuaceshi'); + await page.getByPlaceholder('Password', { exact: true }).click(); + await page.getByPlaceholder('Password', { exact: true }).fill('zidonghuaceshi123'); + await page.getByPlaceholder('Confirm password').click(); + await page.getByPlaceholder('Confirm password').fill('zidonghuaceshi123'); + await page.getByRole('button', { name: 'Sign up' }).click(); + + await expect(page.getByText('Sign up successfully, and automatically jump to the sign in page')).toBeVisible(); + + // 用新账户登录 + await page.getByPlaceholder('Username/Email').click(); + await page.getByPlaceholder('Username/Email').fill('zidonghuaceshi'); + await page.getByPlaceholder('Password').click(); + await page.getByPlaceholder('Password').fill('zidonghuaceshi123'); + await page.getByRole('button', { name: 'Sign in' }).click(); + + await expect(page.getByText('zidonghuaceshi')).toBeVisible(); + }); +}); diff --git a/scripts/utils.ts b/scripts/utils.ts index 08d582a3ed..2e76d62777 100644 --- a/scripts/utils.ts +++ b/scripts/utils.ts @@ -9,7 +9,7 @@ export const commonConfig: any = { }; export const deleteNocoBase = () => { - execSync(`yarn pm2 delete 0`, commonConfig); + execSync(`yarn pm2 delete 0`); }; export const runNocoBase = () => {