diff --git a/cypress/e2e/player/main.cy.ts b/cypress/e2e/player/main.cy.ts index d10ba59..94d428f 100644 --- a/cypress/e2e/player/main.cy.ts +++ b/cypress/e2e/player/main.cy.ts @@ -11,7 +11,7 @@ import { import { USER_ANSWER_CONTENT } from '../../fixtures/appData'; import { ANSWER_SETTING, QUESTION_SETTING } from '../../fixtures/appSettings'; -describe('player view as reader', () => { +describe('player view as anonymous', () => { beforeEach(() => { cy.setUpApi( { @@ -19,7 +19,7 @@ describe('player view as reader', () => { }, { context: Context.Player, - permission: PermissionLevel.Read, + memberId: undefined, }, ); cy.visit(`/`); @@ -51,7 +51,7 @@ describe('player view as reader', () => { }); }); -describe('player view as writer', () => { +describe('player view as reader', () => { beforeEach(() => { cy.setUpApi( { @@ -59,7 +59,7 @@ describe('player view as writer', () => { }, { context: Context.Player, - permission: PermissionLevel.Write, + permission: PermissionLevel.Read, }, ); cy.visit(`/`); diff --git a/src/modules/main/PlayerView.tsx b/src/modules/main/PlayerView.tsx index b17cd06..d6e5af5 100644 --- a/src/modules/main/PlayerView.tsx +++ b/src/modules/main/PlayerView.tsx @@ -11,7 +11,7 @@ import { } from '@mui/material'; import { useLocalContext } from '@graasp/apps-query-client'; -import { AppData, PermissionLevel } from '@graasp/sdk'; +import { AppData } from '@graasp/sdk'; import isEqual from 'lodash.isequal'; import sortBy from 'lodash.sortby'; @@ -29,7 +29,7 @@ function isAnswer(appData: AppData): boolean { const PlayerView = (): JSX.Element => { const { t } = useTranslation('translations', { keyPrefix: 'PLAYER' }); - const { permission } = useLocalContext(); + const { memberId } = useLocalContext(); const { question, // answer: answerSavedState, @@ -55,29 +55,21 @@ const PlayerView = (): JSX.Element => { const [answer, setAnswer] = useState(savedAnswer); const disableSave = useMemo(() => { - // disable if permission is read - if (permission === PermissionLevel.Read) { + // disable if there is no user (logged out or anonymous) + if (!memberId) { return true; } // disable if answer is equal - if (isEqual(savedAnswer, answer)) { - return true; - } - - // disable if minimum length is not achieved - if (answer.length < minChars) { - return true; - } - - return false; - }, [answer, savedAnswer, permission, minChars]); + return isEqual(savedAnswer, answer); + }, [answer, savedAnswer, memberId]); const disabledMessage = useMemo(() => { - if (permission === PermissionLevel.Read) { + // disable if there is no user (logged out or anonymous) + if (!memberId) { return t('SAVE_BUTTON'); } return t('SAVED_MESSAGE'); - }, [permission, t]); + }, [memberId, t]); const handleChangeAnswer = (event: ChangeEvent): void => { const { value } = event.target;