test(e2e): make sure they api requests actually complete

This commit is contained in:
MiniDigger | Martin 2024-04-21 10:21:12 +02:00
parent 06c71a9d70
commit 6ef34b40ed
3 changed files with 16 additions and 1 deletions

View File

@ -64,4 +64,5 @@ jobs:
BROWSERSTACK_DEBUG: ${{ github.event.inputs.debug || false }}
E2E_PASSWORD: ${{ secrets.E2E_PASSWORD }}
E2E_TOTP_SECRET: ${{ secrets.E2E_TOTP_SECRET }}
E2E_API_KEY: ${{ secrets.E2E_API_KEY }}
run: (cd e2e && pnpm run browserstack-multiple)

1
e2e/.gitignore vendored
View File

@ -4,3 +4,4 @@ package-lock.json
local.log
.env
output
test.http

View File

@ -1,6 +1,7 @@
const { I } = inject();
const { TOTP } = require("totp-generator");
const { jwtDecode } = require("jwt-decode");
const { expect } = require("chai");
module.exports = new (class {
url = process.env.BROWSERSTACK_LOCAL === "true" ? "http://localhost:3333" : "https://hangar.papermc.dev";
@ -40,6 +41,11 @@ module.exports = new (class {
method: "POST",
});
const json = await result.json();
if (result.status != 200) {
console.log(json);
}
expect(result.status, "JWT Authentication should return status 200").to.equal(200);
expect(json.token, "JWT Authentication should return a jwt").to.be.ok;
this.jwt = json.token;
return this.jwt;
}
@ -61,6 +67,10 @@ module.exports = new (class {
headers: { Authorization: "Bearer " + (await this.getJwt()), "Content-Type": "application/json" },
body: JSON.stringify({ content: "E2E" }),
});
if (result.status != 204) {
console.log(await result.text());
}
expect(result.status, "project deletion to return 200").to.equal(204);
}
public async deleteOrg(name: string) {
@ -69,6 +79,9 @@ module.exports = new (class {
headers: { Authorization: "Bearer " + (await this.getJwt()), "Content-Type": "application/json" },
body: JSON.stringify({ content: "E2E" }),
});
console.log(await result.text());
if (result.status != 200) {
console.log(await result.text());
}
expect(result.status, "org deletion to return 200").to.equal(200);
}
})();