-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Dependency updates * Update playwright base url default to sandbox * Add put recipe w/o validation * Reorganize playwright tests * Fix issue where body of put response was old * Add validation tests to playwright * Clipp and formatting * More formatting
- Loading branch information
Showing
15 changed files
with
465 additions
and
268 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export const NIL_UUID = '00000000-0000-0000-0000-000000000000'; | ||
|
||
export const createData = { | ||
name: 'Playwright Recipe', | ||
}; | ||
|
||
export const updateData = { | ||
name: 'Updated Playwright Recipe', | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { test, expect } from '@playwright/test'; | ||
import { NIL_UUID, updateData } from './recipeConstants'; | ||
|
||
test('Create Invalid Recipe', async ({ request }) => { | ||
const response = await request.put(`./recipes`, { | ||
data: { | ||
id: 'this-is-not-a-uuid', | ||
name: '', | ||
}, | ||
}); | ||
|
||
expect(response.status()).toEqual(422); | ||
}); | ||
|
||
test('Create Recipe w/ Null Name', async ({ request }) => { | ||
const response = await request.put(`./recipes`, { | ||
data: { | ||
id: NIL_UUID, | ||
}, | ||
}); | ||
|
||
expect(response.status()).toEqual(422); | ||
}); | ||
|
||
test('Read Non-existent Recipe', async ({ request }) => { | ||
const response = await request.get(`./recipes/${NIL_UUID}`); | ||
|
||
expect(response.status()).toEqual(404); | ||
}); | ||
|
||
test('Update Non-existent Recipe', async ({ request }) => { | ||
const response = await request.patch(`./recipes/${NIL_UUID}`, { data: updateData }); | ||
|
||
expect(response.status()).toEqual(404); | ||
}); | ||
|
||
test('Delete Non-existent Recipe', async ({ request }) => { | ||
const response = await request.delete(`./recipes/${NIL_UUID}`); | ||
|
||
expect(response.status()).toEqual(404); | ||
}); |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import { test, expect } from '@playwright/test'; | ||
import { createData, updateData } from './recipeConstants'; | ||
|
||
let recipeUuid: string = '01010101-0101-0101-0101-010101010101'; | ||
|
||
test('pingable', async ({ request }) => { | ||
const response = await request.get('./recipes/ping'); | ||
|
||
expect(response.ok()).toBeTruthy(); | ||
expect(await response.json()).toEqual({ msg: 'Pong' }); | ||
}); | ||
|
||
test.describe('Happy Path', () => { | ||
test.describe.configure({ mode: 'serial' }); | ||
|
||
test('Put Recipe to create', async ({ request }) => { | ||
const response = await request.put('./recipes', { data: { id: recipeUuid, ...createData } }); | ||
|
||
expect(response.status()).toBe(201); | ||
|
||
const responseBody = await response.json(); | ||
expect(responseBody).toEqual({ | ||
id: recipeUuid, | ||
...createData, | ||
}); | ||
}); | ||
|
||
test('Read Recipe', async ({ request }) => { | ||
const response = await request.get(`./recipes/${recipeUuid}`); | ||
|
||
expect(response.ok()).toBeTruthy(); | ||
expect(await response.json()).toEqual({ | ||
id: recipeUuid, | ||
...createData, | ||
}); | ||
}); | ||
|
||
test('List Recipes', async ({ request }) => { | ||
const response = await request.get('./recipes'); | ||
|
||
expect(response.ok()).toBeTruthy(); | ||
const json = await response.json(); | ||
expect(json).toContainEqual({ | ||
id: recipeUuid, | ||
...createData, | ||
}); | ||
}); | ||
|
||
test('Put Recipe update', async ({ request }) => { | ||
const response = await request.put('./recipes', { | ||
data: { | ||
id: recipeUuid, | ||
name: 'PUT Update', | ||
}, | ||
}); | ||
|
||
expect(response.status()).toBe(200); | ||
|
||
const responseBody = await response.json(); | ||
expect(responseBody).toEqual({ | ||
id: recipeUuid, | ||
name: 'PUT Update', | ||
}); | ||
recipeUuid = responseBody.id; | ||
}); | ||
|
||
test('Update Recipe', async ({ request }) => { | ||
const response = await request.patch(`./recipes/${recipeUuid}`, { data: updateData }); | ||
|
||
expect(response.ok()).toBeTruthy(); | ||
expect(await response.json()).toEqual({ | ||
id: recipeUuid, | ||
...updateData, | ||
}); | ||
}); | ||
|
||
test('Read Updated Recipe', async ({ request }) => { | ||
const response = await request.get(`./recipes/${recipeUuid}`); | ||
|
||
expect(response.ok()).toBeTruthy(); | ||
expect(await response.json()).toEqual({ | ||
id: recipeUuid, | ||
...updateData, | ||
}); | ||
}); | ||
|
||
test.afterAll('Delete Recipe', async ({ request }) => { | ||
const response = await request.delete(`./recipes/${recipeUuid}`); | ||
|
||
expect(response.status()).toEqual(204); | ||
}); | ||
}); |
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
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
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
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
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
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
Oops, something went wrong.