Skip to content

Commit

Permalink
feat(api): remove has-seen-level-seven-info usage
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeyffrey committed Oct 9, 2024
1 parent ea75414 commit 23420d2
Show file tree
Hide file tree
Showing 21 changed files with 4 additions and 248 deletions.
3 changes: 0 additions & 3 deletions api/db/database-builder/factory/build-user.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ function _generateEmailIfUndefined(email, id, lastName, firstName) {
* @property {boolean} pixCertifTermsOfServiceAccepted
* @property {boolean} hasSeenAssessmentInstructions
* @property {boolean} hasSeenNewDashboardInfo
* @property {boolean} hasSeenLevelSevenInfo
* @property {boolean} hasSeenFocusedChallengeTooltip
* @property {boolean} hasSeenOtherChallengesTooltip
* @property {boolean} isAnonymous
Expand Down Expand Up @@ -102,7 +101,6 @@ const buildUser = function buildUser({
pixCertifTermsOfServiceAccepted = false,
hasSeenAssessmentInstructions = false,
hasSeenNewDashboardInfo = false,
hasSeenLevelSevenInfo = false,
hasSeenFocusedChallengeTooltip = false,
hasSeenOtherChallengesTooltip = false,
isAnonymous = false,
Expand Down Expand Up @@ -132,7 +130,6 @@ const buildUser = function buildUser({
pixCertifTermsOfServiceAccepted,
hasSeenAssessmentInstructions,
hasSeenNewDashboardInfo,
hasSeenLevelSevenInfo,
hasSeenFocusedChallengeTooltip,
hasSeenOtherChallengesTooltip,
isAnonymous,
Expand Down
25 changes: 0 additions & 25 deletions api/src/evaluation/application/users/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,6 @@ import { userController } from './user-controller.js';

const register = async function (server) {
server.route([
{
method: 'PATCH',
path: '/api/users/{id}/user-has-seen-level-seven-info',
config: {
pre: [
{
method: securityPreHandlers.checkRequestedUserIsAuthenticatedUser,
assign: 'requestedUserIsAuthenticatedUser',
},
],
validate: {
params: Joi.object({
id: identifiersType.userId,
}),
},
handler: userController.rememberUserHasSeenLevelSevenInfo,
notes: [
'- **Cette route est restreinte aux utilisateurs authentifiés**\n' +
"- Sauvegarde le fait que l'utilisateur ait vu le message d'information d'ouverture du niveau 7" +
'- L’id demandé doit correspondre à celui de l’utilisateur authentifié',
"- Le contenu de la requête n'est pas pris en compte.",
],
tags: ['api', 'user'],
},
},
{
method: 'PATCH',
path: '/api/users/{id}/has-seen-new-dashboard-info',
Expand Down
9 changes: 1 addition & 8 deletions api/src/evaluation/application/users/user-controller.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
import * as userSerializer from '../../../shared/infrastructure/serializers/jsonapi/user-serializer.js';
import { evaluationUsecases as usecases } from '../../domain/usecases/index.js';

const rememberUserHasSeenLevelSevenInfo = async function (request, h, dependencies = { userSerializer }) {
const authenticatedUserId = request.auth.credentials.userId;

const updatedUser = await usecases.rememberUserHasSeenLevelSevenInfo({ userId: authenticatedUserId });
return dependencies.userSerializer.serialize(updatedUser);
};

const rememberUserHasSeenNewDashboardInfo = async function (request, h, dependencies = { userSerializer }) {
const authenticatedUserId = request.auth.credentials.userId;

const updatedUser = await usecases.rememberUserHasSeenNewDashboardInfo({ userId: authenticatedUserId });
return dependencies.userSerializer.serialize(updatedUser);
};

const userController = { rememberUserHasSeenLevelSevenInfo, rememberUserHasSeenNewDashboardInfo };
const userController = { rememberUserHasSeenNewDashboardInfo };

export { userController };

This file was deleted.

13 changes: 2 additions & 11 deletions api/src/evaluation/infrastructure/repositories/user-repository.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
/**
* @typedef {import ('./index.js').UserApi} UserApi
* @typedef {import ("./index.js").UserApi} UserApi
*/

/**
* @function
* @param {Object} params
* @param {UserApi} params.userApi
*/
const updateMarkLevelSevenInfoAsSeen = async function ({ userId, userApi }) {
return userApi.markLevelSevenInfoAsSeen({ userId });
};

/**
* @function
* @param {Object} params
Expand All @@ -21,4 +12,4 @@ const updateHasSeenNewDashboardInfo = async function ({ userId, userApi }) {
return userApi.markNewDashboardInfoAsSeen({ userId });
};

export { updateHasSeenNewDashboardInfo, updateMarkLevelSevenInfoAsSeen };
export { updateHasSeenNewDashboardInfo };
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ import { UserDTO } from './models/UserDTO.js';
* @module UserApi
*/

export const markLevelSevenInfoAsSeen = async ({ userId }) => {
return usecases.rememberUserHasSeenLevelSevenInformation({ userId });
};

export const markNewDashboardInfoAsSeen = async ({ userId }) => {
return usecases.markUserHasSeenNewDashboardInfo({ userId });
};
Expand Down
3 changes: 0 additions & 3 deletions api/src/identity-access-management/domain/models/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class User {
lastDataProtectionPolicySeenAt,
hasSeenAssessmentInstructions,
hasSeenNewDashboardInfo,
hasSeenLevelSevenInfo,
hasSeenFocusedChallengeTooltip,
hasSeenOtherChallengesTooltip,
mustValidateTermsOfService,
Expand Down Expand Up @@ -73,7 +72,6 @@ class User {
this.hasSeenAssessmentInstructions = hasSeenAssessmentInstructions;
this.hasSeenOtherChallengesTooltip = hasSeenOtherChallengesTooltip;
this.hasSeenNewDashboardInfo = hasSeenNewDashboardInfo;
this.hasSeenLevelSevenInfo = hasSeenLevelSevenInfo;
this.hasSeenFocusedChallengeTooltip = hasSeenFocusedChallengeTooltip;
this.knowledgeElements = knowledgeElements;
this.lang = lang ?? dependencies.languageService.LANGUAGES_CODE.FRENCH;
Expand Down Expand Up @@ -189,7 +187,6 @@ class User {
hasSeenAssessmentInstructions: this.hasSeenAssessmentInstructions,
hasSeenOtherChallengesTooltip: this.hasSeenOtherChallengesTooltip,
hasSeenNewDashboardInfo: this.hasSeenNewDashboardInfo,
hasSeenLevelSevenInfo: this.hasSeenLevelSevenInfo,
hasSeenFocusedChallengeTooltip: this.hasSeenFocusedChallengeTooltip,
lang: this.lang,
locale: this.locale,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -296,16 +296,6 @@ const updateHasSeenAssessmentInstructionsToTrue = async function (id) {
return new User(user);
};

const updateHasSeenLevelSevenInfoToTrue = async function (id) {
const now = new Date();
const [user] = await knex('users')
.where({ id })
.update({ hasSeenLevelSevenInfo: true, updatedAt: now })
.returning('*');

return new User(user);
};

const updateHasSeenNewDashboardInfoToTrue = async function (id) {
const [user] = await knex('users')
.where({ id })
Expand Down Expand Up @@ -447,7 +437,6 @@ const updateLastDataProtectionPolicySeenAt = async function ({ userId }) {
* @property {function} updateEmail
* @property {function} updateHasSeenAssessmentInstructionsToTrue
* @property {function} updateHasSeenChallengeTooltip
* @property {function} updateHasSeenLevelSevenInfoToTrue
* @property {function} updateHasSeenNewDashboardInfoToTrue
* @property {function} updateLastDataProtectionPolicySeenAt
* @property {function} updatePixCertifTermsOfServiceAcceptedToTrue
Expand Down Expand Up @@ -480,7 +469,6 @@ export {
updateEmail,
updateHasSeenAssessmentInstructionsToTrue,
updateHasSeenChallengeTooltip,
updateHasSeenLevelSevenInfoToTrue,
updateHasSeenNewDashboardInfoToTrue,
updateLastDataProtectionPolicySeenAt,
updatePixCertifTermsOfServiceAcceptedToTrue,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const serialize = function (users, meta) {
'hasSeenAssessmentInstructions',
'isCertifiable',
'hasSeenNewDashboardInfo',
'hasSeenLevelSevenInfo',
'hasSeenFocusedChallengeTooltip',
'hasSeenOtherChallengesTooltip',
'hasAssessmentParticipations',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const serialize = function (users, meta) {
'profile',
'campaignParticipations',
'hasSeenAssessmentInstructions',
'hasSeenLevelSevenInfo',
'isCertifiable',
'hasSeenNewDashboardInfo',
'hasSeenFocusedChallengeTooltip',
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,6 @@ import { evaluationUsecases } from '../../../../../src/evaluation/domain/usecase
import { expect, hFake, sinon } from '../../../../test-helper.js';

describe('Unit | Controller | user-controller', function () {
describe('#rememberUserHasSeenLevelSevenInfo', function () {
it('should remember user has seen level seven info', async function () {
// given
const userId = 1;
const userInformation = Symbol('userInformation');
const userInformationSerialized = Symbol('userInformationSerialized');
const userSerializer = {
serialize: sinon.stub(),
};

sinon.stub(evaluationUsecases, 'rememberUserHasSeenLevelSevenInfo');
evaluationUsecases.rememberUserHasSeenLevelSevenInfo.withArgs({ userId }).resolves(userInformation);
userSerializer.serialize.withArgs(userInformation).returns(userInformationSerialized);

// when
const response = await userController.rememberUserHasSeenLevelSevenInfo(
{
auth: { credentials: { userId } },
params: { id: userId },
},
hFake,
{ userSerializer },
);

// then
expect(response).to.be.equal(userInformationSerialized);
});
});

describe('#rememberUserHasSeenNewDashboardInfo', function () {
it('should remember user has seen new dashboard info', async function () {
// given
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ describe('Acceptance | Identity Access Management | Application | Route | User',
'has-seen-new-dashboard-info': user.hasSeenNewDashboardInfo,
'has-seen-focused-challenge-tooltip': user.hasSeenFocusedChallengeTooltip,
'has-seen-other-challenges-tooltip': user.hasSeenOtherChallengesTooltip,
'has-seen-level-seven-info': false,
'has-assessment-participations': true,
'code-for-last-profile-to-share': expectedCode,
'has-recommended-trainings': true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,6 @@ import * as userApi from '../../../../../src/identity-access-management/applicat
import { databaseBuilder, expect } from '../../../../test-helper.js';

describe('Integration | Application | users-api', function () {
describe('#markLevelSevenInfoAsSeen', function () {
it('should return user information', async function () {
// given
const userId = databaseBuilder.factory.buildUser({ hasSeenLevelSevenInfo: false }).id;
await databaseBuilder.commit();

// when
const actualUser = await userApi.markLevelSevenInfoAsSeen({ userId });

// then
expect(actualUser.hasSeenLevelSevenInfo).to.be.true;
});
});

describe('#markNewDashboardInfoAsSeen', function () {
it('should return user information', async function () {
// given
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,6 @@ describe('Unit | Identity Access Management | Domain | Model | User', function (
'hasSeenAssessmentInstructions',
'hasSeenOtherChallengesTooltip',
'hasSeenNewDashboardInfo',
'hasSeenLevelSevenInfo',
'hasSeenFocusedChallengeTooltip',
'lang',
'locale',
Expand Down

This file was deleted.

Loading

0 comments on commit 23420d2

Please sign in to comment.