diff --git a/src/components/auth/login/LoginForm.tsx b/src/components/auth/login/LoginForm.tsx index bbd6b45..7715c3e 100644 --- a/src/components/auth/login/LoginForm.tsx +++ b/src/components/auth/login/LoginForm.tsx @@ -75,7 +75,7 @@ export const LoginForm = () => { return ( <> {state.isError && ( - + )}
@@ -94,6 +94,7 @@ export const LoginForm = () => { placeholder="Email" {...field} className="py-3 px-6 text-xl rounded-s-md text-gray-400 placeholder:text-gray-400 focus-visible:ring-0 focus-visible:ring-offset-0 focus:border-blue-custom" + data-testid="email-input" /> @@ -112,6 +113,7 @@ export const LoginForm = () => { placeholder="Password" {...field} className="py-3 px-6 text-xl rounded-s-md text-gray-400 placeholder:text-gray-400 focus-visible:ring-0 focus-visible:ring-offset-0 focus:border-blue-custom" + data-testid="password-input" /> @@ -123,6 +125,7 @@ export const LoginForm = () => { type="submit" disabled={state.loading} className="bg-green-custom opacity-65 py-3 px-5 rounded-md text-xl hover:bg-green-custom hover:opacity-100" + data-testid="signin-btn" > Sign in diff --git a/src/components/error/FormattedErrors.tsx b/src/components/error/FormattedErrors.tsx index 34f44c1..d9ea5ef 100644 --- a/src/components/error/FormattedErrors.tsx +++ b/src/components/error/FormattedErrors.tsx @@ -16,7 +16,7 @@ export const FormattedErrors: React.FC = ({
    {keys.map((ele) => data[ele].map((error, index) => ( -
  • {ele + " " + error}
  • +
  • {ele + " " + error}
  • )) )}
diff --git a/src/components/profiles/ProfileHeader.tsx b/src/components/profiles/ProfileHeader.tsx index 0c94eea..e8fefe6 100644 --- a/src/components/profiles/ProfileHeader.tsx +++ b/src/components/profiles/ProfileHeader.tsx @@ -44,6 +44,7 @@ const ProfileHeader: React.FC = ({ profile, session }) => { Edit Profile Settings diff --git a/src/components/profiles/avatar/UserAvatar.tsx b/src/components/profiles/avatar/UserAvatar.tsx index d88cb4a..77ef7b9 100644 --- a/src/components/profiles/avatar/UserAvatar.tsx +++ b/src/components/profiles/avatar/UserAvatar.tsx @@ -31,7 +31,7 @@ const UserAvatar: React.FC = ({ className )} > - {username} + {username}

{date}

diff --git a/tests/login.spec.ts b/tests/login.spec.ts new file mode 100644 index 0000000..3fc503d --- /dev/null +++ b/tests/login.spec.ts @@ -0,0 +1,33 @@ +import { test, expect } from '@playwright/test'; +const URL = "http://localhost:3000/"; + + +test.describe.only('Given conduit login page is loaded', ()=> { + test.beforeEach(async ({ page }) =>{ + await page.goto(`${URL}login`); + }) + + test('When entering valid credentials', async ({ page }) => { + const email = 'jose.carrera@conduit.com'; + const password = "123456" + + await page.getByTestId('email-input').fill(email); + await page.getByTestId('password-input').fill(password); + await page.getByTestId('signin-btn').click({force:true}); + + await expect(page.locator('a[href="/profile/jose.carrera"]')).toBeVisible(); + }); + + test.describe('When entering invalid credentials', () =>{ + test('Then login is not successful', async ({ page }) => { + const email = 'invalid@conduit.com'; + const password = "123456" + + await page.getByTestId('email-input').fill(email); + await page.getByTestId('password-input').fill(password); + await page.getByTestId('signin-btn').click({force:true}); + + await expect(page.getByTestId('error-msg')).toContainText('Internal server error'); + }); + }); +}); diff --git a/tests/view-articles.spec.ts b/tests/view-articles.spec.ts index 5ff40ab..e75ceb8 100644 --- a/tests/view-articles.spec.ts +++ b/tests/view-articles.spec.ts @@ -2,7 +2,7 @@ import { test, expect } from '@playwright/test'; const URL = "http://localhost:3000/"; -test.describe.only('Given conduit home page is loaded', ()=> { +test.describe('Given conduit home page is loaded', ()=> { test.beforeEach(async ({ page }) =>{ await page.goto(URL); }) @@ -11,7 +11,7 @@ test.describe.only('Given conduit home page is loaded', ()=> { await expect(page.getByTestId('article-title')).toHaveCount(2); }); - test.describe('When clicking the first article', () =>{ + test.describe('When clicking the first article', () => { test('Then article page loads', async ({ page }) => { await page.getByTestId('article-title').nth(1).click();