diff --git a/cypress/e2e/participant/default-tests/playOptionalGames.cy.js b/cypress/e2e/participant/default-tests/playOptionalGames.cy.js index 99604d04d..b0ffa347c 100644 --- a/cypress/e2e/participant/default-tests/playOptionalGames.cy.js +++ b/cypress/e2e/participant/default-tests/playOptionalGames.cy.js @@ -3,9 +3,10 @@ import { isCurrentVersion } from '../../../support/utils'; const administration = Cypress.env('testOptionalRoarAppsAdministration'); const language = 'en'; +const optional = true; function playOptionalGame(game, administration, language, optional) { - game.testSpec(administration, language, optional); + game.testSpec({ administration: administration, language: language, optional: optional }); } describe('Play Optional Games', () => { @@ -16,7 +17,7 @@ describe('Play Optional Games', () => { cy.log(`Did not detect a new version of ${game.app}, skipping test.`); } else { cy.log(`Detected a new version of ${game.app}, running test.`); - playOptionalGame(game, administration, language, game.optional); + playOptionalGame(game, administration, language, optional); } }); }); diff --git a/cypress/support/commands.js b/cypress/support/commands.js index e211ace81..8b6ceeab7 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -149,7 +149,16 @@ Cypress.Commands.add('getAdministrationCard', (testAdministration) => { Cypress.Commands.add('switchToOptionalAssessments', () => { cy.wait(0.2 * Cypress.env('timeout')); - cy.get("[data-cy='switch-show-optional-assessments']").click(); + cy.get("[data-cy='switch-show-optional-assessments']") + .invoke('attr', 'class') + .then((classes) => { + if (classes.includes('p-inputswitch-checked')) { + cy.log('Optional assessments already selected.'); + } else { + cy.get("[data-cy='switch-show-optional-assessments']").click(); + cy.log('Optional assessments selected.'); + } + }); }); Cypress.Commands.add( diff --git a/src/pages/HomeParticipant.vue b/src/pages/HomeParticipant.vue index 7a0a6e131..397311a2d 100644 --- a/src/pages/HomeParticipant.vue +++ b/src/pages/HomeParticipant.vue @@ -122,8 +122,15 @@ const init = () => { const queryClient = useQueryClient(); const authStore = useAuthStore(); -const { roarfirekit, roarUid, uid, consentSpinner, userQueryKeyIndex, assignmentQueryKeyIndex } = - storeToRefs(authStore); +const { + roarfirekit, + roarUid, + uid, + consentSpinner, + showOptionalAssessments, + userQueryKeyIndex, + assignmentQueryKeyIndex, +} = storeToRefs(authStore); unsubscribe = authStore.$subscribe(async (mutation, state) => { if (state.roarfirekit.restConfig) init(); @@ -323,7 +330,6 @@ const noGamesAvailable = computed(() => { return assessments.value.length === 0; }); -const showOptionalAssessments = ref(null); const toggleShowOptionalAssessments = async () => { await checkConsent(); showOptionalAssessments.value = null; diff --git a/src/store/auth.js b/src/store/auth.js index bf6aed51d..1aabf560b 100644 --- a/src/store/auth.js +++ b/src/store/auth.js @@ -31,6 +31,7 @@ export const useAuthStore = () => { assignmentQueryKeyIndex: 0, administrationQueryKeyIndex: 0, tasksDictionary: {}, + showOptionalAssessments: false, }; }, getters: {