Skip to content

Commit

Permalink
fix: allow legacy members to exist and don't show them the banner
Browse files Browse the repository at this point in the history
  • Loading branch information
spaenleh committed Jul 22, 2024
1 parent 7abd0e2 commit d0aa3ac
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
13 changes: 12 additions & 1 deletion cypress/e2e/banners.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import {
MEMBER_VALIDATION_BANNER_ID,
} from '@/config/selectors';

import { NOT_VALIDATED_MEMBER, VALIDATED_MEMBER } from '../fixtures/members';
import {
LEGACY_NOT_VALIDATED_MEMBER,
NOT_VALIDATED_MEMBER,
VALIDATED_MEMBER,
} from '../fixtures/members';

describe('Member validation banner', () => {
it('Shows banner when member is not validated', () => {
Expand All @@ -12,9 +16,16 @@ describe('Member validation banner', () => {
cy.get(`#${MEMBER_VALIDATION_BANNER_ID}`).should('be.visible');
cy.get(`#${MEMBER_VALIDATION_BANNER_CLOSE_BUTTON_ID}`).click();
});

it('Does not show banner when member is validated', () => {
cy.setUpApi({ currentMember: VALIDATED_MEMBER });
cy.visit('/');
cy.get(`#${MEMBER_VALIDATION_BANNER_ID}`).should('not.exist');
});

it('Does not show banner when member is legacy', () => {
cy.setUpApi({ currentMember: LEGACY_NOT_VALIDATED_MEMBER });
cy.visit('/');
cy.get(`#${MEMBER_VALIDATION_BANNER_ID}`).should('not.exist');
});
});
6 changes: 6 additions & 0 deletions cypress/fixtures/members.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ export const MEMBERS: Record<string, MemberForTest> = {
export const CURRENT_USER = MEMBERS.ANNA;
export const NOT_VALIDATED_MEMBER = MEMBERS.GARRY;
export const VALIDATED_MEMBER = MEMBERS.ANNA;
export const LEGACY_NOT_VALIDATED_MEMBER = {
...NOT_VALIDATED_MEMBER,
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
isValidated: undefined,
};

export const MOCK_SESSIONS = [
{ id: MEMBERS.BOB.id, token: 'bob-token', createdAt: Date.now() },
Expand Down
3 changes: 2 additions & 1 deletion src/components/alerts/MemberValidationBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ const MemberValidationBanner = (): JSX.Element | false => {
const { t, i18n } = useBuilderTranslation();
const { data: member } = hooks.useCurrentMember();

if (isOpen && !member?.isValidated) {
// banner should not be shown when the member does not have the property
if (isOpen && member && 'isValidated' in member && !member.isValidated) {
return (
<Alert
id={MEMBER_VALIDATION_BANNER_ID}
Expand Down

0 comments on commit d0aa3ac

Please sign in to comment.