This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-1,10 +1,18 @@ | |
import { Module } from '@nestjs/common'; | |
import { AppController } from './app.controller'; | |
-import { AppService } from './app.service'; | |
+import { AddBookUseCase } from './add-book.usecase'; | |
+import { StubBookRepository } from './stub.book-repository'; | |
+import { BookRepository } from './book-repository.port'; | |
@Module({ | |
imports: [], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-1,5 +1,7 @@ | |
+import { Injectable } from '@nestjs/common'; | |
import { BookRepository } from './book-repository.port'; | |
+@Injectable() | |
export class AddBookUseCase { | |
constructor(private readonly bookRepository: BookRepository) {} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-1,3 +1,3 @@ | |
-export interface BookRepository { | |
- save(book: { title: string }): Promise<void>; | |
+export abstract class BookRepository { | |
+ abstract save(book: { title: string }): Promise<void>; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-1,9 +1,9 @@ | |
import { Controller, Get, Query } from '@nestjs/common'; | |
-import { AppService } from './app.service'; | |
+import { AddBookUseCase } from './add-book.usecase'; | |
@Controller() | |
export class AppController { | |
- constructor(private readonly appService: AppService) {} | |
+ constructor(private readonly addBookUseCase: AddBookUseCase) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-6,7 +6,7 @@ export class AppController { | |
constructor(private readonly appService: AppService) {} | |
@Get() | |
- getHello(): string { | |
+ getHello(@Query() query?: { title: string }): string { | |
return ` | |
// ... | |
<body> | |
<form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-11,11 +11,15 @@ export class AppController { | |
<!DOCTYPE html> | |
<html> | |
<head> | |
- <title>Crafty Reads</title> | |
+ <title>Crafty Reads</title> | |
</head> | |
<body> | |
- <p>Hello, World!</p> | |
-</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-0,0 +1,12 @@ | |
+import { test, expect } from '@playwright/test'; | |
+ | |
+test.describe('Feature: Adding a book', () => { | |
+ test('Example: User can add a book', async ({ page }) => { | |
+ await page.goto('http://localhost:3000'); | |
+ | |
+ await page.getByLabel(/title/i).fill('Clean Code'); | |
+ await page.getByText(/add book/i).click(); | |
+ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-11,7 +11,7 @@ export class AppController { | |
<!DOCTYPE html> | |
<html> | |
<head> | |
- <title>Page Title</title> | |
+ <title>Crafty Reads</title> | |
</head> | |
<body> | |
<p>Hello, World!</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-7,6 +7,15 @@ export class AppController { | |
@Get() | |
getHello(): string { | |
- return this.appService.getHello(); | |
+ return ` | |
+<!DOCTYPE html> | |
+<html> | |
+ <head> | |
+ <title>Page Title</title> // Je mets ici volontairement le mauvais titre ! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-0,0 +1,8 @@ | |
+import { test, expect } from '@playwright/test'; | |
+ | |
+test('has title', async ({ page }) => { | |
+ await page.goto('http://localhost:3000'); | |
+ | |
+ // Expect a title "to contain" a substring. | |
+ await expect(page).toHaveTitle(/Crafty Reads/); | |
+}); |
NewerOlder