Skip to content

Commit

Permalink
fix: make integration work and fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
spaenleh committed Nov 26, 2024
1 parent 16d0981 commit 6569ca1
Show file tree
Hide file tree
Showing 171 changed files with 4,347 additions and 3,715 deletions.
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
[![gitlocalized-it](https://gitlocalize.com/repo/8978/it/badge.svg)](https://gitlocalize.com/repo/8978/it?utm_source=badge)
[![gitlocalized-ar](https://gitlocalize.com/repo/8978/ar/badge.svg)](https://gitlocalize.com/repo/8978/ar?utm_source=badge)

## Environement variables
## Environment variables

```sh
# .env.development
Expand All @@ -28,4 +28,18 @@ VITE_SENTRY_ENV= # some value
VITE_SENTRY_DSN= # some value

VITE_RECAPTCHA_SITE_KEY= # some value

VITE_GRAASP_H5P_INTEGRATION_URL= # the origin for the h5p integration
```

## Test setup

```sh
# .env.test
VITE_VERSION=local
VITE_PORT=3333
VITE_GRAASP_API_HOST=http://localhost:3636
VITE_SHOW_NOTIFICATIONS=true
VITE_GRAASP_ANALYZER_HOST=http://localhost:3005

```
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { HttpMethod } from '@graasp/sdk';
import { formatDistanceToNow } from 'date-fns';
import { StatusCodes } from 'http-status-codes';

import { getLocalForDateFns } from '../../src/components/langs';
import { ACCOUNT_HOME_PATH } from '../../src/config/paths';
import { getLocalForDateFns } from '../../../src/components/langs';
import { ACCOUNT_HOME_PATH } from '../../../src/config/paths';
import {
AVATAR_UPLOAD_ICON_ID,
AVATAR_UPLOAD_INPUT_ID,
Expand All @@ -14,16 +14,16 @@ import {
MEMBER_AVATAR_IMAGE_ID,
MEMBER_CREATED_AT_ID,
MEMBER_USERNAME_DISPLAY_ID,
} from '../../src/config/selectors';
import { BOB, MEMBER_WITH_AVATAR } from '../fixtures/members';
} from '../../../src/config/selectors';
import { MEMBERS, MEMBER_WITH_AVATAR } from '../../fixtures/members';
import {
AVATAR_LINK,
THUMBNAIL_MEDIUM_PATH,
} from '../fixtures/thumbnails/links';
import { ID_FORMAT, MemberForTest } from '../support/utils';
} from '../../fixtures/thumbnails/links';
import { API_HOST } from '../../support/env';
import { ID_FORMAT, MemberForTest } from '../../support/utils';

const { buildGetCurrentMemberRoute, buildUploadAvatarRoute } = API_ROUTES;
const API_HOST = Cypress.env('VITE_GRAASP_API_HOST');

type TestHelperInput = { currentMember: MemberForTest };
class TestHelper {
Expand Down Expand Up @@ -75,7 +75,7 @@ class TestHelper {
describe('Upload Avatar', () => {
let helpers: TestHelper;
beforeEach(() => {
helpers = new TestHelper({ currentMember: BOB });
helpers = new TestHelper({ currentMember: MEMBERS.BOB });
helpers.setupServer();
cy.visit(ACCOUNT_HOME_PATH);
});
Expand All @@ -102,7 +102,7 @@ describe('Upload Avatar', () => {

describe('Image is not set', () => {
beforeEach(() => {
cy.setUpApi({ currentMember: BOB });
cy.setUpApi({ currentMember: MEMBERS.BOB });
cy.visit(ACCOUNT_HOME_PATH);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import {
GO_TO_LANDING_ID,
NOT_FOUND_MESSAGE_ID,
NOT_FOUND_TEXT_ID,
} from '../../src/config/selectors';
import { BOB } from '../fixtures/members';
} from '../../../src/config/selectors';
import { MEMBERS } from '../../fixtures/members';

describe('404 Page Test', () => {
beforeEach(() => {
cy.setUpApi({ currentMember: BOB });
cy.setUpApi({ currentMember: MEMBERS.BOB });
cy.visit('/non-existing-page');
});
it('should display 404 page for non-existing routes', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ACCOUNT_HOME_PATH, LOG_IN_PAGE_PATH } from '../../src/config/paths';
import { ACCOUNT_HOME_PATH, LOG_IN_PAGE_PATH } from '../../../src/config/paths';

describe('Redirections', () => {
it('redirects to the login page when not logged in', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { ACCOUNT_SETTINGS_PATH } from '../../../src/config/paths';
import { ACCOUNT_SETTINGS_PATH } from '../../../../src/config/paths';
import {
DELETE_MEMBER_BUTTON_ID,
DELETE_MEMBER_DIALOG_CONFIRMATION_BUTTON_ID,
DELETE_MEMBER_DIALOG_CONFIRMATION_FIELD_ID,
DELETE_MEMBER_DIALOG_TITLE_ID,
DELETE_MEMBER_SECTION_ID,
MAGIC_LINK_EMAIL_FIELD_ID,
} from '../../../src/config/selectors';
import { CURRENT_MEMBER } from '../../fixtures/members';
} from '../../../../src/config/selectors';
import { CURRENT_MEMBER } from '../../../fixtures/members';

describe('Current Member', () => {
it('Delete account', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ACCOUNT_SETTINGS_PATH } from '../../../src/config/paths';
import { EXPORT_DATA_BUTTON_ID } from '../../../src/config/selectors';
import { CURRENT_MEMBER } from '../../fixtures/members';
import { ACCOUNT_SETTINGS_PATH } from '../../../../src/config/paths';
import { EXPORT_DATA_BUTTON_ID } from '../../../../src/config/selectors';
import { CURRENT_MEMBER } from '../../../fixtures/members';

describe('Check exporting data', () => {
beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ACCOUNT_SETTINGS_PATH } from '../../../src/config/paths';
import { ACCOUNT_SETTINGS_PATH } from '../../../../src/config/paths';
import {
PASSWORD_CREATE_CONTAINER_ID,
PASSWORD_DISPLAY_CONTAINER_ID,
Expand All @@ -8,8 +8,8 @@ import {
PASSWORD_INPUT_CURRENT_PASSWORD_ID,
PASSWORD_INPUT_NEW_PASSWORD_ID,
PASSWORD_SAVE_BUTTON_ID,
} from '../../../src/config/selectors';
import { BOB } from '../../fixtures/members';
} from '../../../../src/config/selectors';
import { MEMBERS } from '../../../fixtures/members';

const MOCK_CURRENT_PASSWORD = 'qwertzuiop1!D';
const WEAK_PASSWORD = 'weakPassword';
Expand Down Expand Up @@ -42,7 +42,7 @@ const openPasswordEdition = () => {
describe('Create new password', () => {
beforeEach(() => {
cy.setUpApi({
currentMember: BOB,
currentMember: MEMBERS.BOB,
hasPassword: false,
});
cy.visit(ACCOUNT_SETTINGS_PATH);
Expand Down Expand Up @@ -126,7 +126,7 @@ describe('Create new password', () => {
describe('Create new password - network error', () => {
it('Show error network message', () => {
cy.setUpApi({
currentMember: BOB,
currentMember: MEMBERS.BOB,
hasPassword: false,
createPasswordError: true,
});
Expand All @@ -152,7 +152,7 @@ describe('Create new password - network error', () => {
describe('Update password', () => {
beforeEach(() => {
cy.setUpApi({
currentMember: BOB,
currentMember: MEMBERS.BOB,
hasPassword: true,
});
cy.visit(ACCOUNT_SETTINGS_PATH);
Expand Down Expand Up @@ -263,7 +263,7 @@ describe('Update password', () => {
describe('Update password - network error', () => {
it('Show error network message', () => {
cy.setUpApi({
currentMember: BOB,
currentMember: MEMBERS.BOB,
hasPassword: true,
updatePasswordError: true,
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ACCOUNT_SETTINGS_PATH } from '../../../src/config/paths';
import { ACCOUNT_SETTINGS_PATH } from '../../../../src/config/paths';
import {
PERSONAL_INFO_CANCEL_BUTTON_ID,
PERSONAL_INFO_DISPLAY_CONTAINER_ID,
Expand All @@ -8,8 +8,8 @@ import {
PERSONAL_INFO_INPUT_EMAIL_ID,
PERSONAL_INFO_SAVE_BUTTON_ID,
PERSONAL_INFO_USERNAME_DISPLAY_ID,
} from '../../../src/config/selectors';
import { BOB } from '../../fixtures/members';
} from '../../../../src/config/selectors';
import { MEMBERS } from '../../../fixtures/members';

const changeUsername = (newUserName: string) => {
cy.get('input[name=username]').clear();
Expand All @@ -20,7 +20,7 @@ const changeUsername = (newUserName: string) => {
describe('Display personal information', () => {
beforeEach(() => {
cy.setUpApi({
currentMember: BOB,
currentMember: MEMBERS.BOB,
});
cy.visit(ACCOUNT_SETTINGS_PATH);
cy.wait('@getCurrentMember');
Expand All @@ -31,17 +31,20 @@ describe('Display personal information', () => {
// displays the correct member name
cy.get(`#${PERSONAL_INFO_USERNAME_DISPLAY_ID}`).should(
'have.text',
BOB.name,
MEMBERS.BOB.name,
);
// displays the correct member email
cy.get(`#${PERSONAL_INFO_EMAIL_DISPLAY_ID}`).should('have.text', BOB.email);
cy.get(`#${PERSONAL_INFO_EMAIL_DISPLAY_ID}`).should(
'have.text',
MEMBERS.BOB.email,
);
});
});

describe('Edit personal information', () => {
describe('Username', () => {
beforeEach(() => {
cy.setUpApi({ currentMember: BOB });
cy.setUpApi({ currentMember: MEMBERS.BOB });
cy.visit(ACCOUNT_SETTINGS_PATH);
cy.get(`#${PERSONAL_INFO_EDIT_BUTTON_ID}`).click();
});
Expand Down Expand Up @@ -93,7 +96,9 @@ describe('Edit personal information', () => {
it('Should not update the user name if canceling edit', () => {
changeUsername('validUsername');
cy.get(`#${PERSONAL_INFO_CANCEL_BUTTON_ID}`).click();
cy.get(`#${PERSONAL_INFO_USERNAME_DISPLAY_ID}`).contains(BOB.name);
cy.get(`#${PERSONAL_INFO_USERNAME_DISPLAY_ID}`).contains(
MEMBERS.BOB.name,
);
});

it('Saves username after trimming trailing space', () => {
Expand All @@ -108,7 +113,7 @@ describe('Edit personal information', () => {

describe('Email', () => {
beforeEach(() => {
cy.setUpApi({ currentMember: BOB });
cy.setUpApi({ currentMember: MEMBERS.BOB });
cy.visit(ACCOUNT_SETTINGS_PATH);
cy.get(`#${PERSONAL_INFO_EDIT_BUTTON_ID}`).click();
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { EmailFrequency } from '@graasp/sdk';
import { langs } from '@graasp/translations';

import { ACCOUNT_SETTINGS_PATH } from '../../../src/config/paths';
import { ACCOUNT_SETTINGS_PATH } from '../../../../src/config/paths';
import {
PREFERENCES_ANALYTICS_SWITCH_ID,
PREFERENCES_CANCEL_BUTTON_ID,
Expand All @@ -11,8 +11,8 @@ import {
PREFERENCES_LANGUAGE_DISPLAY_ID,
PREFERENCES_LANGUAGE_SWITCH_ID,
PREFERENCES_SAVE_BUTTON_ID,
} from '../../../src/config/selectors';
import { BOB, CURRENT_MEMBER } from '../../fixtures/members';
} from '../../../../src/config/selectors';
import { BOB, CURRENT_MEMBER } from '../../../fixtures/members';

describe('Display preferences', () => {
describe('Language', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { ACCOUNT_SETTINGS_PATH } from '../../../src/config/paths';
import { ACCOUNT_SETTINGS_PATH } from '../../../../src/config/paths';
import {
PUBLIC_PROFILE_BIO_ID,
PUBLIC_PROFILE_EDIT_BUTTON_ID,
PUBLIC_PROFILE_FACEBOOK_ID,
PUBLIC_PROFILE_LINKEDIN_ID,
PUBLIC_PROFILE_SAVE_BUTTON_ID,
PUBLIC_PROFILE_TWITTER_ID,
} from '../../../src/config/selectors';
} from '../../../../src/config/selectors';
import {
BOB,
MEMBER_EMPTY_PUBLIC_PROFILE,
MEMBER_PUBLIC_PROFILE,
} from '../../fixtures/members';
} from '../../../fixtures/members';

const SocialProfile = {
Linkedin: 'linkedinID',
Expand Down
10 changes: 4 additions & 6 deletions cypress/e2e/storage.cy.ts → cypress/e2e/account/storage.cy.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import { formatDate, formatFileSize } from '@graasp/sdk';

import { ACCOUNT_STORAGE_PATH } from '../../src/config/paths';
import { ACCOUNT_STORAGE_PATH } from '../../../src/config/paths';
import {
MEMBER_STORAGE_FILE_NAME_ID,
MEMBER_STORAGE_FILE_SIZE_ID,
MEMBER_STORAGE_FILE_UPDATED_AT_ID,
MEMBER_STORAGE_PARENT_FOLDER_ID,
STORAGE_BAR_LABEL_ID,
getCellId,
} from '../../src/config/selectors';
import {
CURRENT_MEMBER,
MEMBER_STORAGE_ITEM_RESPONSE,
} from '../fixtures/members';
} from '../../../src/config/selectors';
import { CURRENT_MEMBER } from '../../fixtures/members';
import { MEMBER_STORAGE_ITEM_RESPONSE } from '../../fixtures/storage';

describe('Storage', () => {
it('Display storage interface', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@ import { HttpMethod } from '@graasp/sdk';

import { StatusCodes } from 'http-status-codes';

import { EMAIL_CHANGE_VALIDATION_PATH } from '../../src/config/paths';
import { EMAIL_CHANGE_VALIDATION_PATH } from '../../../src/config/paths';
import {
EMAIL_VALIDATION_BUTTON_ID,
EMAIL_VALIDATION_CONFLICT_MESSAGE_ID,
EMAIL_VALIDATION_SUCCESS_MESSAGE_ID,
EMAIL_VALIDATION_UNAUTHORIZED_MESSAGE_ID,
} from '../../src/config/selectors';
import { CURRENT_MEMBER } from '../fixtures/members';

const API_HOST = Cypress.env('VITE_GRAASP_API_HOST');
} from '../../../src/config/selectors';
import { CURRENT_MEMBER } from '../../fixtures/members';
import { API_HOST } from '../../support/env';

describe('Validate Email Update', () => {
it('No token', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import 'cypress-iframe';

import { buildContentPagePath } from '@/config/paths';

import {
APP_USING_CONTEXT_ITEM,
PUBLIC_APP_USING_CONTEXT_ITEM,
} from '../fixtures/apps';
} from '../../fixtures/apps';
import { buildContentPagePath } from './utils';

const clickElementInIframe = (
iframeSelector: string,
Expand Down Expand Up @@ -62,6 +61,7 @@ describe('Apps', () => {
checkContentInElementInIframe(iframeSelector, 'ul', 'patch app data');
});
});

describe('Public Apps', () => {
const { id, name } = PUBLIC_APP_USING_CONTEXT_ITEM;
beforeEach(() => {
Expand Down
Loading

0 comments on commit 6569ca1

Please sign in to comment.