Skip to content

Instantly share code, notes, and snippets.

View PCreations's full-sized avatar

Pierre Criulanscy PCreations

View GitHub Profile
@PCreations
PCreations / c0a2e3b039d9.diff
Created May 31, 2024 17:00
c0a2e3b039d9.diff
-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: [],
@PCreations
PCreations / 7dbd6ee4b353.diff
Created May 31, 2024 17:00
7dbd6ee4b353.diff
-1,5 +1,7 @@
+import { Injectable } from '@nestjs/common';
import { BookRepository } from './book-repository.port';
+@Injectable()
export class AddBookUseCase {
constructor(private readonly bookRepository: BookRepository) {}
@PCreations
PCreations / b91fc4f5db9a.diff
Created May 31, 2024 17:00
b91fc4f5db9a.diff
-1,3 +1,3 @@
-export interface BookRepository {
- save(book: { title: string }): Promise<void>;
+export abstract class BookRepository {
+ abstract save(book: { title: string }): Promise<void>;
}
@PCreations
PCreations / c378cecd9a41.diff
Created May 31, 2024 17:00
c378cecd9a41.diff
-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) {}
@PCreations
PCreations / 614fd33f99f0.diff
Created May 31, 2024 17:00
614fd33f99f0.diff
-6,7 +6,7 @@ export class AppController {
constructor(private readonly appService: AppService) {}
@Get()
- getHello(): string {
+ getHello(@Query() query?: { title: string }): string {
return `
// ...
<body>
<form>
@PCreations
PCreations / 8ef2017007b7.diff
Created May 31, 2024 16:17
8ef2017007b7.diff
-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>
@PCreations
PCreations / 49d6bdf9bf78.diff
Created May 31, 2024 16:17
49d6bdf9bf78.diff
-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();
+
@PCreations
PCreations / ec843a9e9db0.diff
Created May 31, 2024 16:17
ec843a9e9db0.diff
-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>
@PCreations
PCreations / fdc3d4f7b2b67aa7fad593fb21cbba8283fb935fcf7230942e0bfd993226394f.diff
Created May 28, 2024 19:24
fdc3d4f7b2b67aa7fad593fb21cbba8283fb935fcf7230942e0bfd993226394f.diff
-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 !
@PCreations
PCreations / 393eb230988e1f4e9204c6ad52b278b0f225936be746c47dd44dd6a25f6af197.diff
Created May 28, 2024 19:24
393eb230988e1f4e9204c6ad52b278b0f225936be746c47dd44dd6a25f6af197.diff
-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/);
+});