From 98d1b9b9bdce8b2dd21aea17da0d5f5d9976014d Mon Sep 17 00:00:00 2001 From: Shyam-Chen Date: Wed, 9 Oct 2024 11:53:20 +0800 Subject: [PATCH] 384th Commit --- .dockerignore | 1 + .gitignore | 1 + e2e/src/todos.test.ts | 17 +++++++++++++++++ 3 files changed, 19 insertions(+) diff --git a/.dockerignore b/.dockerignore index c98a889..e2e8ff3 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,4 +2,5 @@ **/node_modules **/dist **/coverage +**/test-results *.log diff --git a/.gitignore b/.gitignore index c98a889..e2e8ff3 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ **/node_modules **/dist **/coverage +**/test-results *.log diff --git a/e2e/src/todos.test.ts b/e2e/src/todos.test.ts index 06041b0..e90222f 100644 --- a/e2e/src/todos.test.ts +++ b/e2e/src/todos.test.ts @@ -1,7 +1,24 @@ import { expect, test } from '@playwright/test'; +test.describe.configure({ mode: 'serial' }); + test('POST /api/todos', async ({ request }) => { const response = await request.post('/api/todos', { data: {} }); const data = await response.json(); expect(data.total).toEqual(3); }); + +test('POST /api/todos/new', async ({ request }) => { + const response = await request.post('/api/todos/new', { + data: { title: 'foo' }, + }); + const data = await response.json(); + expect(data.message).toEqual('OK'); +}); + +test('POST /api/todos { "title": "foo" }', async ({ request }) => { + const response = await request.post('/api/todos', { data: { title: 'foo' } }); + const data = await response.json(); + expect(data.total).toEqual(1); + expect(data.result[0]).toEqual(expect.objectContaining({ title: 'foo', completed: false })); +});