Skip to content

Commit

Permalink
Add admin metadata test, fix public metadata test
Browse files Browse the repository at this point in the history
  • Loading branch information
toonalbers committed Jan 5, 2024
1 parent 27aa392 commit 1c0ec79
Showing 1 changed file with 57 additions and 1 deletion.
58 changes: 57 additions & 1 deletion kratos-admin-ui/src/service/schema-service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ describe("test getSchemaFields", () => {
}
},
},
"required": ["emails"],
"required": ["email"],
"additionalProperties": false
},
"metadata_public": {
Expand Down Expand Up @@ -383,4 +383,60 @@ describe("test getSchemaFields", () => {
expect(fields[1].title).toBe("Groups");
expect(fields[1].fieldKind).toBe("metadata_public");
})

test("test admin metadata schema", () => {
const schema = {
"$id": "https://schemas.ory.sh/presets/kratos/identity.email.schema.json",
"title": "Person",
"type": "object",
"properties": {
"traits": {
"type": "object",
"properties": {
"email": {
"type": "string",
"format": "email",
"title": "E-Mail",
"minLength": 3,
"ory.sh/kratos": {
"credentials": {
"password": {
"identifier": true
}
},
"verification": {
"via": "email"
},
"recovery": {
"via": "email"
}
}
},
},
"required": ["email"],
"additionalProperties": false
},
"metadata_admin": {
"type": "object",
"properties": {
"notes": {
"title": "Notes",
"type": "string"
}
}
},
}
}

const fields: SchemaField[] = SchemaService.getSchemaFields(schema);

expect(fields.length).toBe(2);
expect(fields[0].type).toBe("string");
expect(fields[0].title).toBe("E-Mail");
expect(fields[0].fieldKind).toBe("trait");

expect(fields[1].type).toBe("string");
expect(fields[1].title).toBe("Notes");
expect(fields[1].fieldKind).toBe("metadata_admin");
})
})

0 comments on commit 1c0ec79

Please sign in to comment.