1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-07-26 13:48:33 +02:00

update user schema

This commit is contained in:
Tymoteusz Czech 2024-10-29 09:03:26 +01:00
parent dcca4f8e15
commit 2f6e67a2bd
No known key found for this signature in database
GPG Key ID: 133555230D88D75F
3 changed files with 24 additions and 19 deletions

View File

@ -68,7 +68,6 @@ export default class UserSettingsController extends Controller {
} }
async getUserSettings(req, res) { async getUserSettings(req, res) {
console.log({ req, flag: this.flagResolver.isEnabled('userSettings') });
if (!this.flagResolver.isEnabled('userSettings')) { if (!this.flagResolver.isEnabled('userSettings')) {
throw new ForbiddenError('User settings feature is not enabled'); throw new ForbiddenError('User settings feature is not enabled');
} }

View File

@ -21,7 +21,6 @@ const loginUser = (email: string) => {
beforeAll(async () => { beforeAll(async () => {
db = await dbInit('user_settings', getLogger); db = await dbInit('user_settings', getLogger);
userStore = db.stores.userStore;
app = await setupAppWithAuth( app = await setupAppWithAuth(
db.stores, db.stores,
{ {
@ -33,6 +32,7 @@ beforeAll(async () => {
}, },
db.rawDatabase, db.rawDatabase,
); );
userStore = db.stores.userStore;
}); });
afterAll(async () => { afterAll(async () => {
@ -41,12 +41,10 @@ afterAll(async () => {
await db.destroy(); await db.destroy();
}); });
// beforeEach(async () => { beforeEach(async () => {
// await db.stores.featureToggleStore.deleteAll(); await db.stores.userStore.deleteAll();
// await db.stores.userStore.deleteAll(); await db.stores.eventStore.deleteAll();
// await db.stores.eventStore.deleteAll(); });
// await db.stores.userStore.deleteAll();
// });
describe('UserSettingsController', () => { describe('UserSettingsController', () => {
test('should return user settings', async () => { test('should return user settings', async () => {
@ -55,19 +53,17 @@ describe('UserSettingsController', () => {
// await db.stores.userStore.setSettings(1, { // await db.stores.userStore.setSettings(1, {
// 'productivity-insights-email': 'true', // 'productivity-insights-email': 'true',
// }); // });
const { body } = await app.request // const { body } = await app.request
.put(`/api/admin/user/settings`) // .put(`/api/admin/user/settings`)
.send({ // .send({
key: 'productivity-insights-email', // key: 'productivity-insights-email',
value: 'new_value', // value: 'new_value',
}) // })
.expect(204); // .expect(204);
const res = await app.request const res = await app.request.get('/api/admin/user').expect(200);
.get('/api/admin/user/settings')
.expect(200);
expect(res.body).toEqual({ 'productivity-insights-email': 'true' }); // expect(res.body).toEqual({ 'productivity-insights-email': 'true' });
}); });
// test('should return empty object if no settings are available', async () => { // test('should return empty object if no settings are available', async () => {

View File

@ -99,6 +99,16 @@ export const userSchema = {
nullable: true, nullable: true,
example: '01HTMEXAMPLESCIMID7SWWGHN6', example: '01HTMEXAMPLESCIMID7SWWGHN6',
}, },
settings: {
description: 'User settings',
type: 'object',
additionalProperties: {
type: 'string',
},
example: {
'productivity-insights-email': 'true',
},
},
}, },
components: {}, components: {},
} as const; } as const;