From bde829513977682bd3d6997f5e5e5952619f9289 Mon Sep 17 00:00:00 2001 From: Geoffroy Begouaussel Date: Fri, 4 Oct 2024 11:31:20 +0200 Subject: [PATCH 1/3] feat(mon-pix): remove has-seen-level-seven-information banner --- mon-pix/app/adapters/user.js | 5 -- mon-pix/app/components/profile-content.hbs | 13 ----- mon-pix/app/components/profile-content.js | 32 ------------ mon-pix/app/models/user.js | 1 - mon-pix/app/services/url.js | 9 ---- mon-pix/mirage/factories/user.js | 12 ----- mon-pix/mirage/routes/users/index.js | 6 --- mon-pix/mirage/serializers/user.js | 1 - mon-pix/tests/acceptance/profile-test.js | 60 +--------------------- mon-pix/tests/unit/services/url-test.js | 32 ------------ mon-pix/translations/en.json | 3 +- mon-pix/translations/es.json | 3 +- mon-pix/translations/fr.json | 3 +- mon-pix/translations/nl.json | 3 +- 14 files changed, 5 insertions(+), 178 deletions(-) delete mode 100644 mon-pix/app/components/profile-content.js diff --git a/mon-pix/app/adapters/user.js b/mon-pix/app/adapters/user.js index d3099d6d853..078afc6ce10 100644 --- a/mon-pix/app/adapters/user.js +++ b/mon-pix/app/adapters/user.js @@ -50,11 +50,6 @@ export default class User extends ApplicationAdapter { return url + '/remember-user-has-seen-assessment-instructions'; } - if (adapterOptions && adapterOptions.rememberUserHasSeenLevelSevenBanner) { - delete adapterOptions.rememberUserHasSeenLevelSevenBanner; - return url + '/user-has-seen-level-seven-info'; - } - if (adapterOptions && adapterOptions.rememberUserHasSeenNewDashboardInfo) { delete adapterOptions.rememberUserHasSeenNewDashboardInfo; return url + '/has-seen-new-dashboard-info'; diff --git a/mon-pix/app/components/profile-content.hbs b/mon-pix/app/components/profile-content.hbs index e94ef732e1e..2233c6ae9d0 100644 --- a/mon-pix/app/components/profile-content.hbs +++ b/mon-pix/app/components/profile-content.hbs @@ -2,19 +2,6 @@
- {{#if this.displayLevelSevenBanner}} -
-
- -
-
- {{/if}}

{{t "pages.profile.accessibility.title"}}

diff --git a/mon-pix/app/components/profile-content.js b/mon-pix/app/components/profile-content.js deleted file mode 100644 index c60d846837a..00000000000 --- a/mon-pix/app/components/profile-content.js +++ /dev/null @@ -1,32 +0,0 @@ -import { action } from '@ember/object'; -import { service } from '@ember/service'; -import Component from '@glimmer/component'; - -const LEVEL_SEVEN = 7; - -export default class ProfileContent extends Component { - @service intl; - @service url; - - get lvlSevenInformation() { - return this.intl.t('common.new-information-banner.lvl-seven', { lvlSevenUrl: this.lvlSevenUrl }); - } - - get lvlSevenUrl() { - return this.url.levelSevenNewsUrl; - } - - get maxReachableLevel() { - return this.args.model.profile.get('maxReachableLevel'); - } - - get displayLevelSevenBanner() { - return this.maxReachableLevel === LEVEL_SEVEN && !this.args.model.hasSeenLevelSevenInfo; - } - - @action - async closeLevelSevenBanner(event) { - event.preventDefault(); - await this.args.model.save({ adapterOptions: { rememberUserHasSeenLevelSevenBanner: true } }); - } -} diff --git a/mon-pix/app/models/user.js b/mon-pix/app/models/user.js index 47cf110bb53..d7cd6b6cfd0 100644 --- a/mon-pix/app/models/user.js +++ b/mon-pix/app/models/user.js @@ -13,7 +13,6 @@ export default class User extends Model { @attr('boolean') hasSeenNewDashboardInfo; @attr('boolean') hasSeenFocusedChallengeTooltip; @attr('boolean') hasSeenOtherChallengesTooltip; - @attr('boolean') hasSeenLevelSevenInfo; @attr('boolean') hasAssessmentParticipations; @attr('boolean') hasRecommendedTrainings; @attr('string') codeForLastProfileToShare; diff --git a/mon-pix/app/services/url.js b/mon-pix/app/services/url.js index eb15fc2c932..5ff81cd3099 100644 --- a/mon-pix/app/services/url.js +++ b/mon-pix/app/services/url.js @@ -126,15 +126,6 @@ export default class Url extends Service { } } - get levelSevenNewsUrl() { - const currentLanguage = this.intl.primaryLocale; - - if (currentLanguage === ENGLISH_INTERNATIONAL_LOCALE) { - return 'https://pix.org/en/news/discover-level-7-on-pix'; - } - return 'https://pix.fr/actualites/decouvrez-le-niveau-7-des-maintenant-sur-pix'; - } - get serverStatusUrl() { const currentLanguage = this.intl.primaryLocale; return `https://status.pix.org/?locale=${currentLanguage}`; diff --git a/mon-pix/mirage/factories/user.js b/mon-pix/mirage/factories/user.js index dd32520bc93..abf2821875f 100644 --- a/mon-pix/mirage/factories/user.js +++ b/mon-pix/mirage/factories/user.js @@ -271,9 +271,6 @@ export default Factory.extend({ isAnonymous() { return false; }, - hasSeenLevelSevenInfo() { - return false; - }, shouldChangePassword: trait({ shouldChangePassword: true, }), @@ -298,15 +295,6 @@ export default Factory.extend({ hasSeenNewDashboardInfo: trait({ hasSeenNewDashboardInfo: true, }), - withMaxReachableLevelSeven: trait({ - afterCreate(user, server) { - user.update({ - profile: server.create('profile', { - maxReachableLevel: 7, - }), - }); - }, - }), withMaxReachableLevelSix: trait({ afterCreate(user, server) { user.update({ diff --git a/mon-pix/mirage/routes/users/index.js b/mon-pix/mirage/routes/users/index.js index 3bc1e92c2da..0fb4dd6a03f 100644 --- a/mon-pix/mirage/routes/users/index.js +++ b/mon-pix/mirage/routes/users/index.js @@ -64,12 +64,6 @@ export default function index(config) { return user; }); - config.patch('/users/:id/user-has-seen-level-seven-info', (schema, request) => { - const user = schema.users.find(request.params.id); - user.update({ hasSeenLevelSevenInfo: true }); - return user; - }); - config.patch('/users/:id/has-seen-challenge-tooltip/:challengeType', (schema, request) => { const user = schema.users.find(request.params.id); user.update({ tooltipChallengeType: request.params.challengeType }); diff --git a/mon-pix/mirage/serializers/user.js b/mon-pix/mirage/serializers/user.js index 498a6079eb5..cc884de0479 100644 --- a/mon-pix/mirage/serializers/user.js +++ b/mon-pix/mirage/serializers/user.js @@ -12,7 +12,6 @@ export default ApplicationSerializer.extend({ 'pixCertifTermsOfServiceAccepted', 'hasSeenAssessmentInstructions', 'hasSeenNewDashboardInfo', - 'hasSeenLevelSevenInfo', 'isAnonymous', 'hasRecommendedTrainings', ], diff --git a/mon-pix/tests/acceptance/profile-test.js b/mon-pix/tests/acceptance/profile-test.js index 36ee22f9bb5..e3222254cf6 100644 --- a/mon-pix/tests/acceptance/profile-test.js +++ b/mon-pix/tests/acceptance/profile-test.js @@ -1,4 +1,4 @@ -import { getByTextWithHtml, queryByTextWithHtml, visit } from '@1024pix/ember-testing-library'; +import { visit } from '@1024pix/ember-testing-library'; import { click, currentURL, fillIn } from '@ember/test-helpers'; import { setupMirage } from 'ember-cli-mirage/test-support'; import { t } from 'ember-intl/test-support'; @@ -66,64 +66,6 @@ module('Acceptance | Profile', function (hooks) { }); }); - module('Authenticated cases as a user with specific max reachable level', function () { - module('max reachable level is set to seven', function (hooks) { - hooks.beforeEach(async function () { - const userWithMaxReachableLevelSeven = server.create('user', 'withMaxReachableLevelSeven'); - await authenticate(userWithMaxReachableLevelSeven); - }); - module('user has never closed the banner', function () { - test('should display the level seven information banner', async function (assert) { - // when - await visit('/competences'); - - // then - assert.ok( - getByTextWithHtml( - t('common.new-information-banner.lvl-seven', { lvlSevenUrl: this.url.levelSevenNewsUrl }), - ), - ); - }); - }); - - module('user has closed the banner', function () { - test('should not display the level seven information banner', async function (assert) { - // given - const screen = await visit('/competences'); - - // when - await click(screen.getByRole('button', { name: t('common.new-information-banner.close-label') })); - - // then - assert.strictEqual( - queryByTextWithHtml( - t('common.new-information-banner.lvl-seven', { lvlSevenUrl: this.url.levelSevenNewsUrl }), - ), - null, - ); - }); - }); - }); - - module('max reachable level is not set to seven', function (hooks) { - hooks.beforeEach(async function () { - const userWithMaxReachableLevelSix = server.create('user', 'withMaxReachableLevelSix'); - await authenticate(userWithMaxReachableLevelSix); - }); - test('should not display the level seven information banner', async function (assert) { - // when - await visit('/competences'); - - assert.strictEqual( - queryByTextWithHtml( - t('common.new-information-banner.lvl-seven', { lvlSevenUrl: this.url.levelSevenNewsUrl }), - ), - null, - ); - }); - }); - }); - module('Not authenticated cases', function () { test('should redirect to home, when user is not authenticated', async function (assert) { // when diff --git a/mon-pix/tests/unit/services/url-test.js b/mon-pix/tests/unit/services/url-test.js index 955c83b013d..67571274844 100644 --- a/mon-pix/tests/unit/services/url-test.js +++ b/mon-pix/tests/unit/services/url-test.js @@ -424,38 +424,6 @@ module('Unit | Service | url', function (hooks) { }); }); - module('#levelSevenNewsUrl', function () { - test('returns the French URL page', function (assert) { - // given - const service = this.owner.lookup('service:url'); - service.currentDomain = { isFranceDomain: true }; - service.intl = { primaryLocale: FRENCH_INTERNATIONAL_LOCALE }; - const expectedLevelSevenNewsUrl = 'https://pix.fr/actualites/decouvrez-le-niveau-7-des-maintenant-sur-pix'; - - // when - const levelSevenNewsUrl = service.levelSevenNewsUrl; - - // then - assert.strictEqual(levelSevenNewsUrl, expectedLevelSevenNewsUrl); - }); - - module('when current language is "en"', function () { - test('returns the English URL page', function (assert) { - // given - const service = this.owner.lookup('service:url'); - service.currentDomain = { isFranceDomain: false }; - service.intl = { primaryLocale: ENGLISH_INTERNATIONAL_LOCALE }; - const expectedLevelSevenNewsUrl = 'https://pix.org/en/news/discover-level-7-on-pix'; - - // when - const levelSevenNewsUrl = service.levelSevenNewsUrl; - - // then - assert.strictEqual(levelSevenNewsUrl, expectedLevelSevenNewsUrl); - }); - }); - }); - module('#supportHomeUrl', function () { module('when website is pix.fr', function () { test('returns the French page URL', function (assert) { diff --git a/mon-pix/translations/en.json b/mon-pix/translations/en.json index b6f7cf91d9c..a48aa7a1110 100644 --- a/mon-pix/translations/en.json +++ b/mon-pix/translations/en.json @@ -98,8 +98,7 @@ "test": "Your test is loading" }, "new-information-banner": { - "close-label": "Close banner", - "lvl-seven": "Level 7 is now available! Learn more '<'a href=\"{lvlSevenUrl}\" class=\"link\" target=\"_blank\" rel=\"noopener noreferrer\"'>'here''." + "close-label": "Close banner" }, "or": "or", "pagination": { diff --git a/mon-pix/translations/es.json b/mon-pix/translations/es.json index 54088e01ea8..343c1f70f25 100644 --- a/mon-pix/translations/es.json +++ b/mon-pix/translations/es.json @@ -91,8 +91,7 @@ "test": "Tu prueba se está cargando" }, "new-information-banner": { - "close-label": "Cerrar el banner", - "lvl-seven": "¡Por fin está disponible el nivel 7! Puedes obtener más información en '<'a href=\"{lvlSevenUrl}\" class=\"link\" target=\"_blank\" rel=\"noopener noreferrer\"'>'esta noticia''." + "close-label": "Cerrar el banner" }, "or": "o", "pagination": { diff --git a/mon-pix/translations/fr.json b/mon-pix/translations/fr.json index eb3e50ce7dd..1b478b2468c 100644 --- a/mon-pix/translations/fr.json +++ b/mon-pix/translations/fr.json @@ -98,8 +98,7 @@ "test": "Votre test est en cours de chargement" }, "new-information-banner": { - "close-label": "Fermer la bannière", - "lvl-seven": "Le niveau 7 est enfin disponible ! Vous pouvez en apprendre plus via '<'a href=\"{lvlSevenUrl}\" class=\"link\" target=\"_blank\" rel=\"noopener noreferrer\"'>'cette actualité''." + "close-label": "Fermer la bannière" }, "or": "ou", "pagination": { diff --git a/mon-pix/translations/nl.json b/mon-pix/translations/nl.json index 5898234f6fc..a410e07caa5 100644 --- a/mon-pix/translations/nl.json +++ b/mon-pix/translations/nl.json @@ -91,8 +91,7 @@ "test": "Je test wordt geladen" }, "new-information-banner": { - "close-label": "Sluit de banner", - "lvl-seven": "Pix wordt geleidelijk aan vertaald naar het Nederlands! De vertaling van al onze vaardigheden zal binnenkort beschikbaar zijn. '<'a href=\"https://pix.org/nl-be/de-planning-voor-de-uitrol-van-pix-in-het-nederlan\" class=\"link\" target=\"_blank\" rel=\"noopener noreferrer\"'>'Meer informatie''" + "close-label": "Sluit de banner" }, "or": "of", "pagination": { From ea754147ebbf1bc266c4951afdffb80c1f7f6d19 Mon Sep 17 00:00:00 2001 From: Geoffroy Begouaussel Date: Fri, 4 Oct 2024 11:26:13 +0200 Subject: [PATCH 2/3] tech(api): add migration to delete user has-seen-level-seven-info column --- ...234_remove-has-seen-level-seven-info-column.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 api/db/migrations/20241004090234_remove-has-seen-level-seven-info-column.js diff --git a/api/db/migrations/20241004090234_remove-has-seen-level-seven-info-column.js b/api/db/migrations/20241004090234_remove-has-seen-level-seven-info-column.js new file mode 100644 index 00000000000..a342644900e --- /dev/null +++ b/api/db/migrations/20241004090234_remove-has-seen-level-seven-info-column.js @@ -0,0 +1,15 @@ +const TABLE_NAME = 'users'; +const COLUMN_NAME = 'hasSeenLevelSevenInfo'; + +const up = async function (knex) { + await knex.schema.table(TABLE_NAME, function (table) { + table.dropColumn(COLUMN_NAME); + }); +}; + +const down = async function (knex) { + await knex.schema.table(TABLE_NAME, function (table) { + table.boolean(COLUMN_NAME).defaultTo(false); + }); +}; +export { down, up }; From 23420d2ef1f7246faa17f444d6da0265a1731c34 Mon Sep 17 00:00:00 2001 From: Geoffroy Begouaussel Date: Wed, 9 Oct 2024 17:49:40 +0200 Subject: [PATCH 3/3] feat(api): remove has-seen-level-seven-info usage --- api/db/database-builder/factory/build-user.js | 3 - api/src/evaluation/application/users/index.js | 25 ------- .../application/users/user-controller.js | 9 +-- ...remember-user-has-seen-level-seven-info.js | 5 -- .../repositories/user-repository.js | 13 +--- .../application/api/users-api.js | 4 -- .../domain/models/User.js | 3 - ...as-seen-level-seven-information.usecase.js | 13 ---- .../repositories/user.repository.js | 12 ---- .../jsonapi/user-with-activity.serializer.js | 1 - .../serializers/jsonapi/user-serializer.js | 1 - .../application/users/user-controller_test.js | 71 ------------------- .../application/users/user-controller_test.js | 29 -------- ...ber-user-has-seen-level-seven-info_test.js | 20 ------ .../application/user/user.route.test.js | 1 - .../application/api/users-api_test.js | 14 ---- .../unit/domain/models/User.test.js | 1 - ...en-level-seven-information.usecase.test.js | 21 ------ .../user-with-activity.serializer.test.js | 2 - .../jsonapi/user-serializer_test.js | 2 - .../database-builder/database-helpers_test.js | 2 +- 21 files changed, 4 insertions(+), 248 deletions(-) delete mode 100644 api/src/evaluation/domain/usecases/remember-user-has-seen-level-seven-info.js delete mode 100644 api/src/identity-access-management/domain/usecases/remember-user-has-seen-level-seven-information.usecase.js delete mode 100644 api/tests/evaluation/acceptance/application/users/user-controller_test.js delete mode 100644 api/tests/evaluation/unit/domain/usecases/remember-user-has-seen-level-seven-info_test.js delete mode 100644 api/tests/identity-access-management/unit/domain/usecases/remember-user-has-seen-level-seven-information.usecase.test.js diff --git a/api/db/database-builder/factory/build-user.js b/api/db/database-builder/factory/build-user.js index 6a6c555e6dc..63bb529a44e 100644 --- a/api/db/database-builder/factory/build-user.js +++ b/api/db/database-builder/factory/build-user.js @@ -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 @@ -102,7 +101,6 @@ const buildUser = function buildUser({ pixCertifTermsOfServiceAccepted = false, hasSeenAssessmentInstructions = false, hasSeenNewDashboardInfo = false, - hasSeenLevelSevenInfo = false, hasSeenFocusedChallengeTooltip = false, hasSeenOtherChallengesTooltip = false, isAnonymous = false, @@ -132,7 +130,6 @@ const buildUser = function buildUser({ pixCertifTermsOfServiceAccepted, hasSeenAssessmentInstructions, hasSeenNewDashboardInfo, - hasSeenLevelSevenInfo, hasSeenFocusedChallengeTooltip, hasSeenOtherChallengesTooltip, isAnonymous, diff --git a/api/src/evaluation/application/users/index.js b/api/src/evaluation/application/users/index.js index 1f1710e43f4..4c1b6e31b6e 100644 --- a/api/src/evaluation/application/users/index.js +++ b/api/src/evaluation/application/users/index.js @@ -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', diff --git a/api/src/evaluation/application/users/user-controller.js b/api/src/evaluation/application/users/user-controller.js index 5d2b374906c..f0bb3bd8168 100644 --- a/api/src/evaluation/application/users/user-controller.js +++ b/api/src/evaluation/application/users/user-controller.js @@ -1,13 +1,6 @@ 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; @@ -15,6 +8,6 @@ const rememberUserHasSeenNewDashboardInfo = async function (request, h, dependen return dependencies.userSerializer.serialize(updatedUser); }; -const userController = { rememberUserHasSeenLevelSevenInfo, rememberUserHasSeenNewDashboardInfo }; +const userController = { rememberUserHasSeenNewDashboardInfo }; export { userController }; diff --git a/api/src/evaluation/domain/usecases/remember-user-has-seen-level-seven-info.js b/api/src/evaluation/domain/usecases/remember-user-has-seen-level-seven-info.js deleted file mode 100644 index d3d1f64c5bb..00000000000 --- a/api/src/evaluation/domain/usecases/remember-user-has-seen-level-seven-info.js +++ /dev/null @@ -1,5 +0,0 @@ -const rememberUserHasSeenLevelSevenInfo = function ({ userId, userRepository }) { - return userRepository.updateMarkLevelSevenInfoAsSeen({ userId }); -}; - -export { rememberUserHasSeenLevelSevenInfo }; diff --git a/api/src/evaluation/infrastructure/repositories/user-repository.js b/api/src/evaluation/infrastructure/repositories/user-repository.js index 06bd530c801..65815e9a4d7 100644 --- a/api/src/evaluation/infrastructure/repositories/user-repository.js +++ b/api/src/evaluation/infrastructure/repositories/user-repository.js @@ -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 @@ -21,4 +12,4 @@ const updateHasSeenNewDashboardInfo = async function ({ userId, userApi }) { return userApi.markNewDashboardInfoAsSeen({ userId }); }; -export { updateHasSeenNewDashboardInfo, updateMarkLevelSevenInfoAsSeen }; +export { updateHasSeenNewDashboardInfo }; diff --git a/api/src/identity-access-management/application/api/users-api.js b/api/src/identity-access-management/application/api/users-api.js index 69990d54c39..29b50386c2d 100644 --- a/api/src/identity-access-management/application/api/users-api.js +++ b/api/src/identity-access-management/application/api/users-api.js @@ -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 }); }; diff --git a/api/src/identity-access-management/domain/models/User.js b/api/src/identity-access-management/domain/models/User.js index f05b64cc746..a6b739a757d 100644 --- a/api/src/identity-access-management/domain/models/User.js +++ b/api/src/identity-access-management/domain/models/User.js @@ -29,7 +29,6 @@ class User { lastDataProtectionPolicySeenAt, hasSeenAssessmentInstructions, hasSeenNewDashboardInfo, - hasSeenLevelSevenInfo, hasSeenFocusedChallengeTooltip, hasSeenOtherChallengesTooltip, mustValidateTermsOfService, @@ -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; @@ -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, diff --git a/api/src/identity-access-management/domain/usecases/remember-user-has-seen-level-seven-information.usecase.js b/api/src/identity-access-management/domain/usecases/remember-user-has-seen-level-seven-information.usecase.js deleted file mode 100644 index fbf381e5840..00000000000 --- a/api/src/identity-access-management/domain/usecases/remember-user-has-seen-level-seven-information.usecase.js +++ /dev/null @@ -1,13 +0,0 @@ -/** - * @typedef {import ('../../domain/usecases/index.js').UserRepository} UserRepository - */ - -/** - * @param {Object} params - * @param {UserRepository} params.userRepository - */ -const rememberUserHasSeenLevelSevenInformation = function ({ userId, userRepository }) { - return userRepository.updateHasSeenLevelSevenInfoToTrue(userId); -}; - -export { rememberUserHasSeenLevelSevenInformation }; diff --git a/api/src/identity-access-management/infrastructure/repositories/user.repository.js b/api/src/identity-access-management/infrastructure/repositories/user.repository.js index d12cafd6ac3..1558f3e9907 100644 --- a/api/src/identity-access-management/infrastructure/repositories/user.repository.js +++ b/api/src/identity-access-management/infrastructure/repositories/user.repository.js @@ -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 }) @@ -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 @@ -480,7 +469,6 @@ export { updateEmail, updateHasSeenAssessmentInstructionsToTrue, updateHasSeenChallengeTooltip, - updateHasSeenLevelSevenInfoToTrue, updateHasSeenNewDashboardInfoToTrue, updateLastDataProtectionPolicySeenAt, updatePixCertifTermsOfServiceAcceptedToTrue, diff --git a/api/src/identity-access-management/infrastructure/serializers/jsonapi/user-with-activity.serializer.js b/api/src/identity-access-management/infrastructure/serializers/jsonapi/user-with-activity.serializer.js index a01d64770be..ebcb11e9746 100644 --- a/api/src/identity-access-management/infrastructure/serializers/jsonapi/user-with-activity.serializer.js +++ b/api/src/identity-access-management/infrastructure/serializers/jsonapi/user-with-activity.serializer.js @@ -22,7 +22,6 @@ const serialize = function (users, meta) { 'hasSeenAssessmentInstructions', 'isCertifiable', 'hasSeenNewDashboardInfo', - 'hasSeenLevelSevenInfo', 'hasSeenFocusedChallengeTooltip', 'hasSeenOtherChallengesTooltip', 'hasAssessmentParticipations', diff --git a/api/src/shared/infrastructure/serializers/jsonapi/user-serializer.js b/api/src/shared/infrastructure/serializers/jsonapi/user-serializer.js index 21721321e53..083f2e4f280 100644 --- a/api/src/shared/infrastructure/serializers/jsonapi/user-serializer.js +++ b/api/src/shared/infrastructure/serializers/jsonapi/user-serializer.js @@ -22,7 +22,6 @@ const serialize = function (users, meta) { 'profile', 'campaignParticipations', 'hasSeenAssessmentInstructions', - 'hasSeenLevelSevenInfo', 'isCertifiable', 'hasSeenNewDashboardInfo', 'hasSeenFocusedChallengeTooltip', diff --git a/api/tests/evaluation/acceptance/application/users/user-controller_test.js b/api/tests/evaluation/acceptance/application/users/user-controller_test.js deleted file mode 100644 index 7736dfc0a74..00000000000 --- a/api/tests/evaluation/acceptance/application/users/user-controller_test.js +++ /dev/null @@ -1,71 +0,0 @@ -import { - createServer, - databaseBuilder, - expect, - generateValidRequestAuthorizationHeader, -} from '../../../../test-helper.js'; - -describe('Acceptance | Route | Users ', function () { - let server; - let user; - let options; - - describe('PATCH /api/users/{id}/user-has-seen-level-seven-info', function () { - async function givenUserHasSeenLevelSevenInfo(hasSeenLevelSevenInfo) { - server = await createServer(); - - user = databaseBuilder.factory.buildUser({ hasSeenLevelSevenInfo }); - - options = { - method: 'PATCH', - url: `/api/users/${user.id}/user-has-seen-level-seven-info`, - headers: { authorization: generateValidRequestAuthorizationHeader(user.id) }, - }; - - await databaseBuilder.commit(); - } - - describe('Resource access management', function () { - beforeEach(async function () { - await givenUserHasSeenLevelSevenInfo(false); - }); - - it('should respond with a 401 - unauthorized access - if user is not authenticated', async function () { - options.headers.authorization = 'invalid.access.token'; - - const response = await server.inject(options); - - expect(response.statusCode).to.equal(401); - }); - - it('should respond with a 403 - forbidden access - if requested user is not the same as authenticated user', async function () { - const otherUserId = 9999; - options.headers.authorization = generateValidRequestAuthorizationHeader(otherUserId); - - const response = await server.inject(options); - - expect(response.statusCode).to.equal(403); - }); - }); - - describe('User has seen level seven info', function () { - it('should return the user with hasSeenLevelSevenInfo to true', async function () { - await givenUserHasSeenLevelSevenInfo(true); - - const response = await server.inject(options); - - expect(response.result.data.attributes['has-seen-level-seven-info']).to.be.true; - }); - }); - - describe('User has not seen level seven info', function () { - it('should return the user with hasSeenLevelSevenInfo to true', async function () { - await givenUserHasSeenLevelSevenInfo(false); - - const response = await server.inject(options); - - expect(response.result.data.attributes['has-seen-level-seven-info']).to.be.true; - }); - }); - }); -}); diff --git a/api/tests/evaluation/unit/application/users/user-controller_test.js b/api/tests/evaluation/unit/application/users/user-controller_test.js index e98d31e96ee..c36e8d906bf 100644 --- a/api/tests/evaluation/unit/application/users/user-controller_test.js +++ b/api/tests/evaluation/unit/application/users/user-controller_test.js @@ -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 diff --git a/api/tests/evaluation/unit/domain/usecases/remember-user-has-seen-level-seven-info_test.js b/api/tests/evaluation/unit/domain/usecases/remember-user-has-seen-level-seven-info_test.js deleted file mode 100644 index d40e213c1ea..00000000000 --- a/api/tests/evaluation/unit/domain/usecases/remember-user-has-seen-level-seven-info_test.js +++ /dev/null @@ -1,20 +0,0 @@ -import { rememberUserHasSeenLevelSevenInfo } from '../../../../../src/evaluation/domain/usecases/remember-user-has-seen-level-seven-info.js'; -import { expect, sinon } from '../../../../test-helper.js'; - -describe('Unit | UseCase | remember-user-has-seen-level-seven-info', function () { - it('should return user information', async function () { - // given - const userRepository = { updateMarkLevelSevenInfoAsSeen: sinon.stub() }; - const userId = 1; - userRepository.updateMarkLevelSevenInfoAsSeen.withArgs({ userId }).resolves(); - - // when - await rememberUserHasSeenLevelSevenInfo({ - userId, - userRepository, - }); - - // then - expect(userRepository.updateMarkLevelSevenInfoAsSeen).to.have.been.calledOnce; - }); -}); diff --git a/api/tests/identity-access-management/acceptance/application/user/user.route.test.js b/api/tests/identity-access-management/acceptance/application/user/user.route.test.js index b4fcbc4aeb7..a81b2fe5834 100644 --- a/api/tests/identity-access-management/acceptance/application/user/user.route.test.js +++ b/api/tests/identity-access-management/acceptance/application/user/user.route.test.js @@ -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, diff --git a/api/tests/identity-access-management/integration/application/api/users-api_test.js b/api/tests/identity-access-management/integration/application/api/users-api_test.js index ffb39c06bfa..bd657b227f6 100644 --- a/api/tests/identity-access-management/integration/application/api/users-api_test.js +++ b/api/tests/identity-access-management/integration/application/api/users-api_test.js @@ -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 diff --git a/api/tests/identity-access-management/unit/domain/models/User.test.js b/api/tests/identity-access-management/unit/domain/models/User.test.js index 198b845647f..0afd398fa1d 100644 --- a/api/tests/identity-access-management/unit/domain/models/User.test.js +++ b/api/tests/identity-access-management/unit/domain/models/User.test.js @@ -612,7 +612,6 @@ describe('Unit | Identity Access Management | Domain | Model | User', function ( 'hasSeenAssessmentInstructions', 'hasSeenOtherChallengesTooltip', 'hasSeenNewDashboardInfo', - 'hasSeenLevelSevenInfo', 'hasSeenFocusedChallengeTooltip', 'lang', 'locale', diff --git a/api/tests/identity-access-management/unit/domain/usecases/remember-user-has-seen-level-seven-information.usecase.test.js b/api/tests/identity-access-management/unit/domain/usecases/remember-user-has-seen-level-seven-information.usecase.test.js deleted file mode 100644 index b430a659df7..00000000000 --- a/api/tests/identity-access-management/unit/domain/usecases/remember-user-has-seen-level-seven-information.usecase.test.js +++ /dev/null @@ -1,21 +0,0 @@ -import { User } from '../../../../../src/identity-access-management/domain/models/User.js'; -import { rememberUserHasSeenLevelSevenInformation } from '../../../../../src/identity-access-management/domain/usecases/remember-user-has-seen-level-seven-information.usecase.js'; -import { expect, sinon } from '../../../../test-helper.js'; - -describe('Unit | Identity Access Management | Domain | UseCase | remember-user-has-seen-level-seven-information', function () { - it('updates the last data protection policy to now', async function () { - // given - const userRepository = { - updateHasSeenLevelSevenInfoToTrue: sinon.stub(), - }; - const userId = 1; - const user = new User({ id: userId, lastDataProtectionPolicySeenAt: null }); - userRepository.updateHasSeenLevelSevenInfoToTrue.resolves(user); - - // when - await rememberUserHasSeenLevelSevenInformation({ userId, userRepository }); - - // then - expect(userRepository.updateHasSeenLevelSevenInfoToTrue).to.have.been.calledWithExactly(userId); - }); -}); diff --git a/api/tests/identity-access-management/unit/infrastructure/serializers/jsonapi/user-with-activity.serializer.test.js b/api/tests/identity-access-management/unit/infrastructure/serializers/jsonapi/user-with-activity.serializer.test.js index 90e40475dbf..3484d496586 100644 --- a/api/tests/identity-access-management/unit/infrastructure/serializers/jsonapi/user-with-activity.serializer.test.js +++ b/api/tests/identity-access-management/unit/infrastructure/serializers/jsonapi/user-with-activity.serializer.test.js @@ -25,7 +25,6 @@ describe('Unit | Identity Access Management | Infrastructure | Serializer | JSON hasSeenFocusedChallengeTooltip: false, hasSeenOtherChallengesTooltip: false, hasSeenNewDashboardInfo: false, - hasSeenLevelSevenInfo: false, lastDataProtectionPolicySeenAt: '2022-05-04T13:00:00.000Z', }), hasAssessmentParticipations: false, @@ -56,7 +55,6 @@ describe('Unit | Identity Access Management | Infrastructure | Serializer | JSON 'pix-certif-terms-of-service-accepted': userModelObject.pixCertifTermsOfServiceAccepted, 'has-seen-assessment-instructions': userModelObject.hasSeenAssessmentInstructions, 'has-seen-new-dashboard-info': userModelObject.hasSeenNewDashboardInfo, - 'has-seen-level-seven-info': userModelObject.hasSeenLevelSevenInfo, 'has-seen-focused-challenge-tooltip': userModelObject.hasSeenFocusedChallengeTooltip, 'has-seen-other-challenges-tooltip': userModelObject.hasSeenOtherChallengesTooltip, 'last-data-protection-policy-seen-at': userModelObject.lastDataProtectionPolicySeenAt, diff --git a/api/tests/shared/unit/infrastructure/serializers/jsonapi/user-serializer_test.js b/api/tests/shared/unit/infrastructure/serializers/jsonapi/user-serializer_test.js index 39d5187b189..1dc712185aa 100644 --- a/api/tests/shared/unit/infrastructure/serializers/jsonapi/user-serializer_test.js +++ b/api/tests/shared/unit/infrastructure/serializers/jsonapi/user-serializer_test.js @@ -26,7 +26,6 @@ describe('Unit | Shared | Infrastructure | Serializer | JSONAPI | user-serialize hasSeenFocusedChallengeTooltip: false, hasSeenOtherChallengesTooltip: false, hasSeenNewDashboardInfo: false, - hasSeenLevelSevenInfo: false, lastDataProtectionPolicySeenAt: '2022-12-24T10:00:00.000Z', }); }); @@ -53,7 +52,6 @@ describe('Unit | Shared | Infrastructure | Serializer | JSONAPI | user-serialize 'pix-certif-terms-of-service-accepted': userModelObject.pixCertifTermsOfServiceAccepted, 'has-seen-assessment-instructions': userModelObject.hasSeenAssessmentInstructions, 'has-seen-new-dashboard-info': userModelObject.hasSeenNewDashboardInfo, - 'has-seen-level-seven-info': userModelObject.hasSeenLevelSevenInfo, 'has-seen-focused-challenge-tooltip': userModelObject.hasSeenFocusedChallengeTooltip, 'has-seen-other-challenges-tooltip': userModelObject.hasSeenOtherChallengesTooltip, 'last-data-protection-policy-seen-at': userModelObject.lastDataProtectionPolicySeenAt, diff --git a/api/tests/unit/tooling/database-builder/database-helpers_test.js b/api/tests/unit/tooling/database-builder/database-helpers_test.js index 220987e92d5..244f8f92056 100644 --- a/api/tests/unit/tooling/database-builder/database-helpers_test.js +++ b/api/tests/unit/tooling/database-builder/database-helpers_test.js @@ -10,7 +10,7 @@ describe('Unit | Tooling | DatabaseBuilder | database-helpers', function () { { expectedTableName: 'users', insertSqlQuery: - '/* path: */ insert into "users" ("cgu", "createdAt", "email", "emailConfirmedAt", "firstName", "hasBeenAnonymised", "hasBeenAnonymisedBy", "hasSeenAssessmentInstructions", "hasSeenFocusedChallengeTooltip", "hasSeenLevelSevenInfo", "hasSeenNewDashboardInfo", "hasSeenOtherChallengesTooltip", "id", "isAnonymous", "lang", "lastDataProtectionPolicySeenAt", "lastName", "lastPixCertifTermsOfServiceValidatedAt", "lastPixOrgaTermsOfServiceValidatedAt", "lastTermsOfServiceValidatedAt", "locale", "mustValidateTermsOfService", "pixCertifTermsOfServiceAccepted", "pixOrgaTermsOfServiceAccepted", "updatedAt", "username") values ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, DEFAULT, $21, $22, $23, $24, $25)', + '/* path: */ insert into "users" ("cgu", "createdAt", "email", "emailConfirmedAt", "firstName", "hasBeenAnonymised", "hasBeenAnonymisedBy", "hasSeenAssessmentInstructions", "hasSeenFocusedChallengeTooltip", "hasSeenNewDashboardInfo", "hasSeenOtherChallengesTooltip", "id", "isAnonymous", "lang", "lastDataProtectionPolicySeenAt", "lastName", "lastPixCertifTermsOfServiceValidatedAt", "lastPixOrgaTermsOfServiceValidatedAt", "lastTermsOfServiceValidatedAt", "locale", "mustValidateTermsOfService", "pixCertifTermsOfServiceAccepted", "pixOrgaTermsOfServiceAccepted", "updatedAt", "username") values ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, DEFAULT, $21, $22, $23, $24, $25)', }, { expectedTableName: 'pgboss.job',