Add customer contract clearance console
This commit is contained in:
@@ -23,23 +23,36 @@ function expectOk(result, label) {
|
||||
return result.payload;
|
||||
}
|
||||
|
||||
function sleep(ms) {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
async function login(email, label) {
|
||||
let lastResult = null;
|
||||
for (let attempt = 1; attempt <= 3; attempt += 1) {
|
||||
const result = await request("/api/auth/login", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ email, password: "Demo@123456" })
|
||||
});
|
||||
if (result.response.status !== 429) return expectOk(result, label);
|
||||
lastResult = result;
|
||||
const retryAfter = Number(result.response.headers.get("retry-after") || result.payload.retryAfter || 1);
|
||||
await sleep(Math.min(65, Math.max(1, retryAfter)) * 1000);
|
||||
}
|
||||
return expectOk(lastResult, label);
|
||||
}
|
||||
|
||||
let created = false;
|
||||
let jobId = "";
|
||||
try {
|
||||
const login = expectOk(await request("/api/auth/login", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ email: "producer@local.test", password: "Demo@123456" })
|
||||
}), "owner login");
|
||||
const ownerLogin = await login("producer@local.test", "owner login");
|
||||
const headers = {
|
||||
authorization: `Bearer ${login.session.token}`,
|
||||
authorization: `Bearer ${ownerLogin.session.token}`,
|
||||
"x-organization-id": organizationId,
|
||||
"x-workspace-id": workspaceId,
|
||||
"x-project-id": "thunder-mouth"
|
||||
};
|
||||
const writerLogin = expectOk(await request("/api/auth/login", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ email: "writer@local.test", password: "Demo@123456" })
|
||||
}), "writer login");
|
||||
const writerLogin = await login("writer@local.test", "writer login");
|
||||
|
||||
const creation = expectOk(await request("/api/projects", {
|
||||
method: "POST",
|
||||
|
||||
Reference in New Issue
Block a user