diff --git a/public/assets/images/thumbnail.png b/public/assets/images/thumbnail.png
new file mode 100644
index 0000000..4501791
Binary files /dev/null and b/public/assets/images/thumbnail.png differ
diff --git a/start/routes.ts b/start/routes.ts
index e4e5f0a..b57aade 100644
--- a/start/routes.ts
+++ b/start/routes.ts
@@ -29,6 +29,11 @@ router
.group(() => {
router.on('/').renderInertia('home').as('home.show')
router.get('/feed', [FeedController, 'index']).as('feed.show')
+ router
+ .group(() => {
+ router.get(':id', [FeedController, 'show']).as('users.show')
+ })
+ .prefix('users')
})
.use(middleware.guest())
@@ -66,13 +71,13 @@ router
router
.group(() => {
router.get('/', [UsersController, 'index']).as('users.index')
- router.get(':id', [FeedController, 'show']).as('users.show') // TODO: Make public, and contextualize `ctx.auth.authenticate` via middleware.
- router.get(':id/settings', [UsersController, 'show']).as('settings.show')
router.patch(':id', [UsersController, 'update']).as('users.update')
router.delete(':id', [UsersController, 'destroy']).as('users.destroy')
})
.prefix('users')
+ router.get('settings', [UsersController, 'show']).as('settings.show')
+
router
.group(() => {
router.post('/', [PostsController, 'store']).as('posts.store')
diff --git a/tests/browser/admin_post_report.spec.ts b/tests/browser/admin_post_report.spec.ts
index eb5e6d8..859dc12 100644
--- a/tests/browser/admin_post_report.spec.ts
+++ b/tests/browser/admin_post_report.spec.ts
@@ -1,11 +1,11 @@
import { UserFactory } from '#database/factories/user_factory'
import { PostReportReason, PostReportStatus } from '#enums/post'
import testUtils from '@adonisjs/core/services/test_utils'
+import { route } from '@izzyjs/route/client'
import { test } from '@japa/runner'
test.group('Admin post report', (group) => {
- // FIX-ME: Izzy
- const url = '/admin/posts/reports'
+ const url = route('admin_posts_reports.index').path
group.each.setup(() => testUtils.db().truncate())
diff --git a/tests/browser/pages/feed.spec.ts b/tests/browser/pages/feed.spec.ts
index c574721..8ba4667 100644
--- a/tests/browser/pages/feed.spec.ts
+++ b/tests/browser/pages/feed.spec.ts
@@ -1,12 +1,13 @@
import { UserFactory } from '#database/factories/user_factory'
import testUtils from '@adonisjs/core/services/test_utils'
+import { route } from '@izzyjs/route/client'
import { test } from '@japa/runner'
test.group('Acessing feed', (group) => {
group.each.setup(() => testUtils.db().truncate())
test('Fails to access the feed without being authenticated', async ({ visit }) => {
- const page = await visit('/feed')
+ const page = await visit(route('feed.show').path)
await page.assertTextContains('body', 'Sign in')
})
@@ -14,7 +15,7 @@ test.group('Acessing feed', (group) => {
const user = await UserFactory.create()
const created = await UserFactory.with('posts', 8).create()
await browserContext.loginAs(user)
- const page = await visit('/feed')
+ const page = await visit(route('feed.show').path)
const locator = page.locator('.feed-list > article > .post-content')
await page.assertElementsText(
locator,
@@ -27,7 +28,7 @@ test.group('Acessing feed', (group) => {
await UserFactory.with('posts', 8).create()
await browserContext.loginAs(user)
- const page = await visit('/feed')
+ const page = await visit(route('feed.show').path)
await page.locator('button.create-post').click()
const postContent = 'Lets get dat bread! 🍞'
@@ -42,7 +43,13 @@ test.group('Acessing feed', (group) => {
await UserFactory.with('posts', 8).create()
await browserContext.loginAs(user)
- const page = await visit(`/posts/${user.posts[0].id}`)
+ const page = await visit(
+ route('posts.show', {
+ params: {
+ id: user.posts[0].id,
+ },
+ }).path
+ )
await page.locator('button.trigger-user-post-actions').click()
const updateButton = page.locator('button.update-post-trigger')
@@ -59,7 +66,13 @@ test.group('Acessing feed', (group) => {
await UserFactory.with('posts', 8).create()
await browserContext.loginAs(user)
- const page = await visit(`/posts/${user.posts[0].id}`)
+ const page = await visit(
+ route('posts.show', {
+ params: {
+ id: user.posts[0].id,
+ },
+ }).path
+ )
await page.locator('button.trigger-user-post-actions').click()
const deleteButton = page.locator('button.delete-post-trigger')
@@ -75,7 +88,13 @@ test.group('Acessing feed', (group) => {
const user = await UserFactory.with('posts', 1).create()
const otherUser = await UserFactory.with('posts', 8).create()
await browserContext.loginAs(user)
- const page = await visit(`/posts/${otherUser.posts[0].id}`)
+ const page = await visit(
+ route('posts.show', {
+ params: {
+ id: otherUser.posts[0].id,
+ },
+ }).path
+ )
await page.locator('button.trigger-user-post-actions').click()
const updateAction = page.locator('button.update-post-trigger')
const deleteAction = page.locator('button.delete-post-trigger')
@@ -88,7 +107,13 @@ test.group('Acessing feed', (group) => {
const otherUser = await UserFactory.with('posts', 8).create()
await browserContext.loginAs(user)
- const page = await visit(`/posts/${otherUser.posts[0].id}`)
+ const page = await visit(
+ route('posts.show', {
+ params: {
+ id: otherUser.posts[0].id,
+ },
+ }).path
+ )
const reactButton = page.locator('button.trigger-user-post-react')
await reactButton.hover()
diff --git a/tests/browser/pages/user_feed.spec.ts b/tests/browser/pages/user_feed.spec.ts
index ae891a2..9828eb7 100644
--- a/tests/browser/pages/user_feed.spec.ts
+++ b/tests/browser/pages/user_feed.spec.ts
@@ -1,5 +1,6 @@
import { UserFactory } from '#database/factories/user_factory'
import testUtils from '@adonisjs/core/services/test_utils'
+import { route } from '@izzyjs/route/client'
import { test } from '@japa/runner'
test.group('Acessing user profile feed', (group) => {
@@ -7,7 +8,13 @@ test.group('Acessing user profile feed', (group) => {
test('Fails to access the user profile feed without being authenticated', async ({ visit }) => {
const user = await UserFactory.create()
- const page = await visit(`/users/${user.id}`)
+ const page = await visit(
+ route('users.show', {
+ params: {
+ id: user.id,
+ },
+ }).path
+ )
await page.assertTextContains('body', 'Sign in')
})
@@ -17,7 +24,13 @@ test.group('Acessing user profile feed', (group) => {
}) => {
const user = await UserFactory.with('posts', 2).create()
await browserContext.withGuard('web').loginAs(user)
- const page = await visit(`/users/${user.id}`)
+ const page = await visit(
+ route('users.show', {
+ params: {
+ id: user.id,
+ },
+ }).path
+ )
const locator = page.getByText('Total posts').first()
await page.assertText(locator, `Total posts ${user.posts.length}`)
})
@@ -29,7 +42,13 @@ test.group('Acessing user profile feed', (group) => {
const user = await UserFactory.with('posts', 2).create()
const otherUser = await UserFactory.with('posts', 8).create()
await browserContext.loginAs(user)
- const page = await visit(`/users/${otherUser.id}`)
+ const page = await visit(
+ route('users.show', {
+ params: {
+ id: otherUser.id,
+ },
+ }).path
+ )
const locator = page.getByText('Total posts').first()
await page.assertText(locator, `Total posts ${otherUser.posts.length}`)
})
diff --git a/tests/browser/post_report.spec.ts b/tests/browser/post_report.spec.ts
index 27ddb5e..a6f663e 100644
--- a/tests/browser/post_report.spec.ts
+++ b/tests/browser/post_report.spec.ts
@@ -2,11 +2,11 @@ import { UserFactory } from '#database/factories/user_factory'
import User from '#models/user'
import testUtils from '@adonisjs/core/services/test_utils'
import { faker } from '@faker-js/faker'
+import { route } from '@izzyjs/route/client'
import { test } from '@japa/runner'
test.group('Post report', (group) => {
let user: User | null = null
- const postShow = '/posts/:id'
group.each.setup(async () => {
await testUtils.db().truncate()
@@ -16,10 +16,9 @@ test.group('Post report', (group) => {
test('Successfuly creates a post report', async ({ browserContext, visit }) => {
const authUser = user!
const otherUser = await UserFactory.with('posts', 1).create()
- const url = postShow.replace(':id', otherUser.posts[0].id)
await browserContext.loginAs(authUser)
- const page = await visit(url)
+ const page = await visit(route('posts.show', { params: { id: otherUser.posts[0].id } }).path)
await page.locator('button.trigger-user-post-actions').click()
await page.locator('button.report-post-trigger').click()
await page.locator('button.select-reason').click() // FIX-ME: Review these tag classes. Too cumbersome.
@@ -39,10 +38,11 @@ test.group('Post report', (group) => {
})
)
).create()
- const url = postShow.replace(':id', userPostReport.posts[0].id)
await browserContext.loginAs(authUser)
- const page = await visit(url)
+ const page = await visit(
+ route('posts.show', { params: { id: userPostReport.posts[0].id } }).path
+ )
await page.locator('button.trigger-user-post-actions').click()
await page.locator('button.report-post-trigger').click()
await page.assertSelectedOptions('select', [userPostReport.posts[0].reports[0].reason])
diff --git a/tests/browser/user/settings.spec.ts b/tests/browser/user/settings.spec.ts
index c5d4109..294dd09 100644
--- a/tests/browser/user/settings.spec.ts
+++ b/tests/browser/user/settings.spec.ts
@@ -4,16 +4,16 @@ import User from '#models/user'
import testUtils from '@adonisjs/core/services/test_utils'
import { InferPageProps, SharedProps } from '@adonisjs/inertia/types'
import { faker } from '@faker-js/faker'
+import { route } from '@izzyjs/route/client'
import { test } from '@japa/runner'
test.group('User settings', (group) => {
let user: User | null = null
- let url = '/users/:id/settings'
+ let url = route('settings.show').path
group.each.setup(async () => {
await testUtils.db().truncate()
user = await UserFactory.create()
- url = url.replace(':id', user.id)
})
test('Sucessfully updates profile', async ({ visit, browserContext, assert }) => {