Skip to content

Commit

Permalink
commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jarle committed Apr 19, 2024
1 parent d1856c2 commit d153f8b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
8 changes: 8 additions & 0 deletions packages/reference-app/resources/remix_app/routes/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ import { Form } from '@remix-run/react'
export const action = async ({ context }: ActionFunctionArgs) => {
const { http } = context

const { password } = http.request.only(['password'])
if (password !== '123') {
http.session.flash('message', 'Wrong password')
return new Response(null, {
status: 401,
})
}

http.session.put('login', 'true')
http.session.flash('status', 'success')

Expand Down
14 changes: 12 additions & 2 deletions packages/reference-app/tests/browser/session_handling.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,21 @@ test.group('Session handling', () => {
await page.waitForURL('/dashboard')

const session = await browserContext.getSession()
// const flash = await browserContext.getFlashMessages()

assert.equal(session['login'], 'true')
// assert.equal(flash['status'], 'success')

await page.screenshot({ path: 'tests/screenshots/dashboard.png' })
})
test('Read flash message', async ({ visit, browserContext, assert }) => {
const page = await visit('/login')

await page.fill('input[name="email"]', '[email protected]')
await page.fill('input[name="password"]', '4444')

await page.getByRole('button', { name: 'Login' }).click()

const flash = await browserContext.getFlashMessages()

assert.equal(flash['message'], 'Wrong password')
})
})

0 comments on commit d153f8b

Please sign in to comment.