-
Notifications
You must be signed in to change notification settings - Fork 221
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into watch-build
- Loading branch information
Showing
35 changed files
with
1,275 additions
and
324 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -34,6 +34,7 @@ yarn-error.log* | |
# local env files | ||
.env | ||
.env.local | ||
.env*.local | ||
|
||
# vercel | ||
.vercel | ||
|
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,5 @@ | ||
{ | ||
"tabWidth": 2, | ||
"useTabs": false, | ||
"trailingComma": "all" | ||
} |
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,5 @@ | ||
import { shortest } from "@antiwork/shortest"; | ||
|
||
shortest("Verify that buttons on the landing page are rounded"); | ||
shortest("Login using this email: mission-health@rdt7stzf.mailosaur.net"); | ||
shortest("Verify that the user can access the /dashboard page"); |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { NextResponse } from "next/server"; | ||
import { ALLOWED_TEST_BEARER } from "@/lib/constants"; | ||
import { getBearerToken } from "@/lib/utils-server"; | ||
|
||
/** | ||
* Asserts that the bearer token is present in the request | ||
* If yes, returns the request body | ||
*/ | ||
export async function POST(req: Request) { | ||
const token = getBearerToken(req); | ||
|
||
if (!token || token !== ALLOWED_TEST_BEARER) { | ||
return NextResponse.json( | ||
{ message: "Bearer token is missing in cookies" }, | ||
{ status: 401 }, | ||
); | ||
} | ||
|
||
try { | ||
const body = await req.json(); | ||
return NextResponse.json(body); | ||
} catch { | ||
return NextResponse.json( | ||
{ message: "Invalid request body" }, | ||
{ status: 400 }, | ||
); | ||
} | ||
} |
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,27 @@ | ||
import { shortest, APIRequest } from "@antiwork/shortest"; | ||
import { ALLOWED_TEST_BEARER, TESTING_API_BASE_URI } from "@/lib/constants"; | ||
|
||
const req = new APIRequest({ | ||
baseURL: TESTING_API_BASE_URI, | ||
extraHTTPHeaders: { | ||
"Content-Type": "application/json", | ||
}, | ||
}); | ||
|
||
shortest( | ||
"Ensure the request without a bearer token returns a message indicating the absence of the token", | ||
req.fetch({ | ||
url: "/assert-bearer", | ||
method: "POST", | ||
body: JSON.stringify({ flagged: "false" }), | ||
}), | ||
); | ||
|
||
shortest( | ||
`Bearer token is ${ALLOWED_TEST_BEARER}. Ensure the request with a valid bearer token returns request body`, | ||
req.fetch({ | ||
url: "/assert-bearer", | ||
method: "POST", | ||
body: JSON.stringify({ flagged: "true" }), | ||
}), | ||
); |
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,13 @@ | ||
import { shortest } from "@antiwork/shortest"; | ||
import { ALLOWED_TEST_BEARER, TESTING_API_BASE_URI } from "@/lib/constants"; | ||
|
||
// @note you should be authenticated in Clerk to run this test | ||
shortest(` | ||
Test the API POST endpoint ${TESTING_API_BASE_URI}/assert-bearer with body { "flagged": "false" } without providing a bearer token. | ||
Expect the response to indicate that the token is missing | ||
`); | ||
|
||
shortest(` | ||
Test the API POST endpoint ${TESTING_API_BASE_URI}/assert-bearer with body { "flagged": "true" } and the bearer token ${ALLOWED_TEST_BEARER}. | ||
Expect the response to show "flagged": true | ||
`); |
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,30 @@ | ||
import { APIRequest, shortest } from "@antiwork/shortest"; | ||
|
||
const req = new APIRequest(); | ||
|
||
shortest( | ||
"Ensure the request fails", | ||
req.fetch( | ||
{ url: "http://invalid.url.test" }, | ||
{ | ||
maxRetries: 5, | ||
}, | ||
), | ||
); | ||
|
||
shortest( | ||
"Ensure the request fails due to SSL sertificate error", | ||
req.fetch({ url: "https://secure.donauversicherung.at" }), | ||
); | ||
|
||
shortest( | ||
"Ensure the request not to fail due to SSL sertificate error", | ||
req.fetch( | ||
{ | ||
url: "https://secure.donauversicherung.at", | ||
}, | ||
{ | ||
ignoreHTTPSErrors: true, | ||
}, | ||
), | ||
); |
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,2 @@ | ||
export const TESTING_API_BASE_URI = "/api/test"; | ||
export const ALLOWED_TEST_BEARER = "test-b"; |
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.