test: add a test of rigster

This commit is contained in:
Rain 2023-09-09 11:05:06 +08:00
parent cee91490c6
commit 7d58699846
3 changed files with 48 additions and 1 deletions

13
.vscode/launch.json vendored
View File

@ -37,6 +37,19 @@
"runtimeArgs": ["run", "test:client", "${relativeFile}"]
}
},
{
"type": "node",
"request": "launch",
"name": "Debug E2E Tests",
"runtimeExecutable": "yarn",
"runtimeArgs": ["test:e2e", "${file}"],
"skipFiles": ["<node_internals>/**"],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"windows": {
"runtimeArgs": ["test:e2e", "${fileBasename}"]
}
},
{
"type": "node",
"request": "launch",

View File

@ -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();
});
});

View File

@ -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 = () => {