MCPcopy
hub / github.com/realworld-apps/realworld / login

Function login

specs/e2e/helpers/auth.ts:25–44  ·  view source on GitHub ↗
(page: Page, email: string, password: string)

Source from the content-addressed store, hash-verified

23}
24
25export async function login(page: Page, email: string, password: string) {
26 await page.goto('/login', { waitUntil: 'load' });
27 await page.fill('input[name="email"]', email);
28 await page.fill('input[name="password"]', password);
29
30 // Wait for navigation to complete or error to appear
31 try {
32 await Promise.all([page.waitForURL('/'), page.click('button[type="submit"]')]);
33 } catch (error) {
34 // If navigation fails, check for errors
35 const errorMsg = await page
36 .locator('.error-messages')
37 .textContent()
38 .catch(() => '');
39 if (errorMsg) {
40 throw new Error(`Login failed: ${errorMsg}`);
41 }
42 throw error;
43 }
44}
45
46export async function logout(page: Page) {
47 await page.click('a[href="/settings"]');

Callers 4

auth.spec.tsFile · 0.90
navigation.spec.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected