Skip to content

Commit

Permalink
Merge pull request #246 from detached/feature/comments
Browse files Browse the repository at this point in the history
Implements comments for recipes
  • Loading branch information
detached authored Jun 2, 2024
2 parents 5ba0428 + b58f2d2 commit 7669233
Show file tree
Hide file tree
Showing 59 changed files with 12,008 additions and 21,043 deletions.
18 changes: 17 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ dependencies {
implementation("jakarta.transaction:jakarta.transaction-api")

implementation("io.micronaut.kotlin:micronaut-kotlin-runtime")
implementation("io.micronaut.kotlin:micronaut-kotlin-extension-functions")
implementation("io.micronaut.serde:micronaut-serde-jackson")
implementation("io.micronaut.security:micronaut-security")
implementation("io.micronaut.security:micronaut-security-jwt")
Expand All @@ -62,6 +63,7 @@ dependencies {
runtimeOnly("ch.qos.logback:logback-classic")
runtimeOnly("com.h2database:h2:$h2Version")
runtimeOnly("org.postgresql:postgresql:$postgresqlJdbcVersion")
testImplementation("io.micronaut:micronaut-http-client")
testImplementation("com.willowtreeapps.assertk:assertk:$assertKVersion")
testImplementation("org.mockito.kotlin:mockito-kotlin:$mockitoVersion")
}
Expand Down Expand Up @@ -138,7 +140,9 @@ jooq {
target.apply {
packageName = "de.w3is.recipes.infra.persistence.generated"
}
generate.withJpaAnnotations(true)
generate
.withJpaAnnotations(true)
.withDaos(true)
}
}
}
Expand All @@ -155,6 +159,18 @@ ktlint {
}
}

tasks.register<NpmTask>("testFrontend") {
dependsOn("npmInstall")
args.addAll("run", "test")
inputs.files("frontend/package.json", "frontend/package-lock.json")
inputs.dir("frontend/src")
inputs.dir(fileTree("frontend/node_modules").exclude(".cache"))
}

tasks.withType<Test> {
dependsOn("testFrontend")
}

tasks.register<NpmTask>("buildFrontend") {
dependsOn("npmInstall")
args.addAll("run", "build")
Expand Down
7 changes: 7 additions & 0 deletions frontend/mocks/handlers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { http } from 'msw'
import {getComments, postComment} from "./resolver/comments";

export const handlers = [
http.get('/api/comments/recipe/*', getComments),
http.post("/api/comments/recipe/*", postComment)
];
19 changes: 19 additions & 0 deletions frontend/mocks/node.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { setupServer } from 'msw/node'
import { handlers } from './handlers.js'

export const server = setupServer(...handlers);

server.events.on('response:mocked', ({ request, response }) => {
console.log(
'%s %s received %s %s',
request.method,
request.url,
response.status,
response.statusText
)
});

server.events.on('unhandledException', ({ request, error }) => {
console.log('%s %s errored! See details below.', request.method, request.url)
console.error(error)
})
43 changes: 43 additions & 0 deletions frontend/mocks/resolver/comments.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import {HttpResponse} from "msw";

export const getComments = () => {
return HttpResponse.json({
comments: [
{
id: 'commentId1',
author: {
id: 'authorId1',
name: 'Author 1'
},
comment: 'That is comment 1',
createdOn: '1970-01-01',
canDelete: true
},
{
id: 'commentId2',
author: {
id: 'authorId2',
name: 'Author 2'
},
comment: 'That is comment 2',
createdOn: '1970-01-02',
canDelete: false
}
]
});
}

export const postComment = () => {
return HttpResponse.json(
{
id: 'newCommentId',
author: {
id: 'authorId1',
name: 'Author 1'
},
comment: 'That is comment 1',
createdOn: '1970-01-01',
canDelete: true
}
)
}
Loading

0 comments on commit 7669233

Please sign in to comment.