T2951
Summary: Ref T2951 Test Plan: npm run test Reviewers: #testers, FilipI Reviewed By: FilipI Subscribers: FilipI, jenkins-user Maniphest Tasks: T2951 Differential Revision: https://hub.sealcode.org/D1526
This commit is contained in:
parent
3f09f26a31
commit
7488669b39
@ -86,7 +86,7 @@ describe("password-reset-intents", function () {
|
||||
(message) => message.recipients[0] == "<user@example.com>"
|
||||
);
|
||||
assert.equal(messages.length, 1);
|
||||
assert.equal(messages[0].recipients.length, 1);
|
||||
assert.equal(messages[0].recipients[0], "<user@example.com>");
|
||||
assert.equal(messages[0]?.recipients.length, 1);
|
||||
assert.equal(messages[0]?.recipients[0], "<user@example.com>");
|
||||
}));
|
||||
});
|
||||
|
@ -23,6 +23,9 @@ export default class UserRoles extends Collection {
|
||||
await super.init(app, collection_name);
|
||||
app.on("started", async () => {
|
||||
const roles = app.collections["user-roles"];
|
||||
if (!roles) {
|
||||
throw new Error("roles undefined");
|
||||
}
|
||||
for (const action of <const>["create", "delete"]) {
|
||||
const policy = roles.getPolicy(action);
|
||||
if (policy instanceof Policies.Public) {
|
||||
|
@ -42,6 +42,9 @@ export default class Users extends Collections.users {
|
||||
}
|
||||
|
||||
public static async getRoles(ctx: Context) {
|
||||
if (!ctx.app.collections["user-roles"]) {
|
||||
throw new Error("user-roles undefined");
|
||||
}
|
||||
const rolesEntries = await ctx.app.collections["user-roles"]
|
||||
.list(ctx)
|
||||
.filter({ user: ctx.user_id || "" })
|
||||
|
@ -13,7 +13,9 @@ export default async function PasswordResetTemplate(
|
||||
if (!matching_users.items.length) {
|
||||
throw new Errors.NotFound("No user with that email");
|
||||
}
|
||||
|
||||
if (!matching_users.items[0]) {
|
||||
throw new Error("matching_users.items[0] undefined");
|
||||
}
|
||||
const username = matching_users.items[0].get("username");
|
||||
|
||||
return EmailTemplates.Simple(app, {
|
||||
|
@ -12,6 +12,9 @@ export class Roles extends Policy {
|
||||
async countMatchingRoles(context: Context) {
|
||||
const user_id = context.user_id;
|
||||
context.app.Logger.debug2("ROLES", "Checking the roles for user", user_id);
|
||||
if (!context.app.collections["user-roles"]) {
|
||||
throw new Error(`context.app.collections["user-roles"] undefined`);
|
||||
}
|
||||
const user_roles = await context.app.collections["user-roles"]
|
||||
.list(context)
|
||||
.filter({ user: user_id })
|
||||
|
@ -10,6 +10,10 @@ import { makeJDDContext } from "../../jdd-context.js";
|
||||
|
||||
function moveElement<T>(array: Array<T>, fromIndex: number, toIndex: number): Array<T> {
|
||||
const element = array.splice(fromIndex, 1)[0];
|
||||
if (!element) {
|
||||
console.error("element is undefined");
|
||||
return array;
|
||||
}
|
||||
array.splice(toIndex, 0, element);
|
||||
return array;
|
||||
}
|
||||
|
@ -15,6 +15,9 @@ export const actionName = "Components";
|
||||
export default new (class JddcomponentDebuggerPage extends JDDPage {
|
||||
renderParameterButtons(state: JDDPageState): Stringifiable {
|
||||
const all_components = super.getRegistryComponents();
|
||||
if (!state.components[0]) {
|
||||
console.error("No components are present in state.components");
|
||||
}
|
||||
return (
|
||||
<div>
|
||||
<input type="submit" value="Preview" />
|
||||
@ -26,7 +29,11 @@ export default new (class JddcomponentDebuggerPage extends JDDPage {
|
||||
{Object.entries(all_components).map(([name]) => (
|
||||
<option
|
||||
value={name}
|
||||
selected={name == state.components[0].component_name}
|
||||
selected={
|
||||
state.components[0]
|
||||
? name == state.components[0].component_name
|
||||
: false
|
||||
}
|
||||
>
|
||||
{name}
|
||||
</option>
|
||||
@ -40,7 +47,11 @@ export default new (class JddcomponentDebuggerPage extends JDDPage {
|
||||
actions = ComponentPreviewActions;
|
||||
|
||||
async getInitialState(ctx: BaseContext) {
|
||||
const [component_name, component] = Object.entries(registry.getAll())[0];
|
||||
const component_constants = Object.entries(registry.getAll())[0];
|
||||
if (!component_constants) {
|
||||
throw new Error("Constant component_name or component is udefined");
|
||||
}
|
||||
const [component_name, component] = component_constants;
|
||||
const initial_state = {
|
||||
components: [
|
||||
{
|
||||
|
@ -32,10 +32,12 @@ export function shuffle<T>(array: T[]): T[] {
|
||||
currentIndex--;
|
||||
|
||||
// And swap it with the current element.
|
||||
[array_copy[currentIndex], array_copy[randomIndex]] = [
|
||||
array_copy[randomIndex],
|
||||
array_copy[currentIndex],
|
||||
];
|
||||
const new_value = [array_copy[randomIndex], array_copy[currentIndex]];
|
||||
if (new_value[0] && new_value[1]) {
|
||||
[array_copy[currentIndex], array_copy[randomIndex]] = new_value;
|
||||
} else {
|
||||
console.error("One of array_copy's values is undefined");
|
||||
}
|
||||
}
|
||||
return array_copy;
|
||||
}
|
||||
|
@ -6,7 +6,6 @@
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"target": "ES2019",
|
||||
"esModuleInterop": true,
|
||||
"lib": ["es2021"],
|
||||
"outDir": "./dist/back",
|
||||
"keyofStringsOnly": true,
|
||||
@ -18,7 +17,8 @@
|
||||
"resolveJsonModule": true,
|
||||
"sourceMap": true,
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": true
|
||||
"esModuleInterop": true,
|
||||
"noUncheckedIndexedAccess": true
|
||||
},
|
||||
"include": ["./src/back/*", "./src/back/**/*", "./src/back/routes/common/navbar.ts"],
|
||||
"exclude": ["./src/front", "./src/**/*.stimulus.ts"],
|
||||
|
@ -4,7 +4,8 @@
|
||||
"target": "ES6",
|
||||
"lib": ["dom", "es2021"],
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": true
|
||||
"esModuleInterop": true,
|
||||
"noUncheckedIndexedAccess": true
|
||||
},
|
||||
"include": ["./src/front", "./src/**/*.stimulus.ts"]
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user