Skip to content

Commit ef975ce

Browse files
committed
test: update test to work with student as default user mode
1 parent 76eaa8d commit ef975ce

22 files changed

+349
-272
lines changed

public/app/config/config.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ const PRODUCT_NAME = 'Graasp';
4343
const TMP_FOLDER = 'tmp';
4444
const DEFAULT_LANG = 'en';
4545
const DEFAULT_DEVELOPER_MODE = false;
46-
const TEACHER_USER_MODE = 'student';
47-
const DEFAULT_USER_MODE = TEACHER_USER_MODE;
46+
const STUDENT_USER_MODE = 'student';
47+
const DEFAULT_USER_MODE = STUDENT_USER_MODE;
4848
const DEFAULT_GEOLOCATION_ENABLED = false;
4949
const VISUAL_SYNC_MODE = 'visual';
5050
const DEFAULT_SYNC_MODE = VISUAL_SYNC_MODE;

src/components/common/DrawerHeader.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
USER_MODES,
1919
THEME_COLORS,
2020
} from '../../config/constants';
21+
import { DRAWER_HEADER_TEACHER_ICON_ID } from '../../config/selectors';
2122

2223
const styles = () => ({
2324
drawerHeader: {
@@ -50,7 +51,10 @@ const DrawerHeader = ({
5051
>
5152
<ListItemIcon>
5253
{isTeacher ? (
53-
<TeacherIcon className={classes.teacherColor} />
54+
<TeacherIcon
55+
className={classes.teacherColor}
56+
id={DRAWER_HEADER_TEACHER_ICON_ID}
57+
/>
5458
) : (
5559
<PersonIcon />
5660
)}

src/components/common/MainMenu.js

+5
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ export class MainMenu extends Component {
9393
authenticated,
9494
t,
9595
match: { path },
96+
history: { push },
9697
} = this.props;
9798

9899
if (authenticated) {
@@ -101,6 +102,10 @@ export class MainMenu extends Component {
101102
id={SIGN_OUT_MENU_ITEM_ID}
102103
onClick={() => {
103104
this.handleSignOut();
105+
106+
// manual redirect for pages (settings) which are
107+
// also available when disconnected
108+
push(SIGN_IN_PATH);
104109
}}
105110
selected={path === SIGN_IN_PATH}
106111
button

src/config/selectors.js

+2
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,5 @@ export const EDIT_USER_IN_CLASSROOM_DELETE_DATA_BUTTON_CLASS =
143143
export const EDIT_CLASSROOM_DELETE_DATA_BUTTON_CLASS =
144144
'editClassroomDeleteDataButton';
145145
export const buildTableCellSpaceId = id => `tableCellSpace-${id}`;
146+
147+
export const DRAWER_HEADER_TEACHER_ICON_ID = 'drawerHeaderTeacherIcon';

test/classrooms.test.js

+8-10
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ import {
1010
expectElementToExist,
1111
toggleStudentMode,
1212
clearInput,
13+
menuGoToSettings,
14+
menuGoToClassrooms,
15+
menuGoToSignOut,
16+
userSignIn,
17+
openDrawer,
1318
} from './utils';
1419
import { createApplication, closeApplication } from './application';
1520
import {
@@ -63,14 +68,7 @@ import {
6368
SELECT_OPEN_PAUSE,
6469
OPEN_IMPORT_DATA_IN_CLASSROOM_PAUSE,
6570
} from './constants';
66-
import {
67-
openDrawer,
68-
menuGoToSettings,
69-
menuGoToClassrooms,
70-
menuGoToSignOut,
71-
} from './menu.test';
72-
import { userSignIn } from './userSignIn.test';
73-
import { USER_GRAASP, USER_ALICE, USER_BOB } from './fixtures/users';
71+
import { USER_GRAASP, USER_ALICE } from './fixtures/users';
7472
import {
7573
checkLoadSelectionLayout,
7674
setCheckboxesTo,
@@ -449,8 +447,8 @@ describe('Classrooms Scenarios', function() {
449447

450448
await menuGoToSignOut(client);
451449

452-
// add classroom as bob
453-
await userSignIn(client, USER_BOB);
450+
// add classroom as graasp
451+
await userSignIn(client, USER_GRAASP);
454452

455453
await menuGoToClassrooms(client);
456454

test/fixtures/settings.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
SYNC_MODES,
66
DEFAULT_SYNC_MODE,
77
} from '../../src/config/constants';
8-
import { USER_ALICE, USER_GRAASP, USER_BOB } from './users';
8+
import { USER_ALICE, USER_GRAASP, USER_CEDRIC } from './users';
99

1010
/* eslint-disable-next-line import/prefer-default-export */
1111
export const settingsPerUser = {
@@ -21,7 +21,7 @@ export const settingsPerUser = {
2121
geolocationEnabled: true,
2222
syncMode: SYNC_MODES.ADVANCED,
2323
},
24-
[USER_BOB.name]: {
24+
[USER_CEDRIC.name]: {
2525
lang: 'ja',
2626
developerMode: true,
2727
geolocationEnabled: DEFAULT_GEOLOCATION_ENABLED,

test/fixtures/users.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
1-
/* eslint-disable-next-line import/prefer-default-export */
1+
import { USER_MODES } from '../../src/config/constants';
2+
23
export const USER_GRAASP = {
34
name: 'graasp',
45
id: 'graasp-id',
6+
mode: USER_MODES.TEACHER,
57
};
68

79
export const USER_ALICE = {
810
name: 'alice',
911
id: 'alice-id',
12+
mode: USER_MODES.TEACHER,
1013
};
1114

1215
export const USER_BOB = {
1316
name: 'bob',
1417
id: 'bob-id',
18+
mode: USER_MODES.STUDENT,
19+
};
20+
21+
export const USER_CEDRIC = {
22+
name: 'cedric',
23+
id: 'cedric-id',
24+
mode: USER_MODES.TEACHER,
1525
};

test/menu.test.js

+11-97
Original file line numberDiff line numberDiff line change
@@ -1,105 +1,19 @@
1-
/* eslint-disable no-unused-expressions */
21
/* eslint-disable no-await-in-loop */
32
/* eslint-disable no-restricted-syntax */
4-
import { expect } from 'chai';
5-
import { mochaAsync } from './utils';
6-
import { createApplication, closeApplication } from './application';
7-
import {
8-
DRAWER_BUTTON_ID,
9-
LOAD_MAIN_ID,
10-
LOAD_MENU_ITEM_ID,
11-
VISIT_MAIN_ID,
12-
VISIT_MENU_ITEM_ID,
13-
SETTINGS_MAIN_ID,
14-
SETTINGS_MENU_ITEM_ID,
15-
SPACES_NEARBY_MENU_ITEM_ID,
16-
SPACES_NEARBY_MAIN_ID,
17-
HOME_MENU_ITEM_ID,
18-
HOME_MAIN_ID,
19-
DASHBOARD_MAIN_ID,
20-
DASHBOARD_MENU_ITEM_ID,
21-
DEVELOPER_MENU_ITEM_ID,
22-
DEVELOPER_MAIN_ID,
23-
SIGN_OUT_MENU_ITEM_ID,
24-
PHASE_MENU_LIST_ID,
25-
buildPhaseMenuItemId,
26-
SAVED_SPACES_MENU_ITEM_ID,
27-
SAVED_SPACES_MAIN_ID,
28-
CLASSROOMS_MAIN_ID,
29-
CLASSROOMS_MENU_ITEM_ID,
30-
} from '../src/config/selectors';
313
import {
32-
LOAD_TAB_PAUSE,
33-
DEFAULT_GLOBAL_TIMEOUT,
34-
OPEN_DRAWER_PAUSE,
35-
LOAD_PHASE_PAUSE,
36-
} from './constants';
37-
import { userSignIn } from './userSignIn.test';
4+
mochaAsync,
5+
userSignIn,
6+
menuGoToSpacesNearby,
7+
menuGoToVisitSpace,
8+
menuGoToLoadSpace,
9+
menuGoToSettings,
10+
menuGoToDashboard,
11+
menuGoToSavedSpaces,
12+
} from './utils';
13+
import { createApplication, closeApplication } from './application';
14+
import { DEFAULT_GLOBAL_TIMEOUT } from './constants';
3815
import { USER_GRAASP } from './fixtures/users';
3916

40-
export const openDrawer = async client => {
41-
if (await client.isVisible(`#${DRAWER_BUTTON_ID}`)) {
42-
await client.click(`#${DRAWER_BUTTON_ID}`);
43-
}
44-
await client.pause(OPEN_DRAWER_PAUSE);
45-
};
46-
47-
const menuGoTo = async (client, menuItemId, elementToExpectId = null) => {
48-
// open menu if it is closed
49-
await openDrawer(client);
50-
await client.click(`#${menuItemId}`);
51-
if (elementToExpectId) {
52-
expect(await client.isExisting(`#${elementToExpectId}`)).to.be.true;
53-
}
54-
await client.pause(LOAD_TAB_PAUSE);
55-
};
56-
57-
export const menuGoToPhase = async (client, nb) => {
58-
await openDrawer(client);
59-
await client.click(`#${PHASE_MENU_LIST_ID} li#${buildPhaseMenuItemId(nb)}`);
60-
await client.pause(LOAD_PHASE_PAUSE);
61-
};
62-
63-
export const menuGoToSettings = async client => {
64-
await menuGoTo(client, SETTINGS_MENU_ITEM_ID, SETTINGS_MAIN_ID);
65-
};
66-
67-
export const menuGoToDeveloper = async client => {
68-
await menuGoTo(client, DEVELOPER_MENU_ITEM_ID, DEVELOPER_MAIN_ID);
69-
};
70-
71-
export const menuGoToSpacesNearby = async client => {
72-
await menuGoTo(client, SPACES_NEARBY_MENU_ITEM_ID, SPACES_NEARBY_MAIN_ID);
73-
};
74-
75-
export const menuGoToVisitSpace = async client => {
76-
await menuGoTo(client, VISIT_MENU_ITEM_ID, VISIT_MAIN_ID);
77-
};
78-
79-
export const menuGoToLoadSpace = async client => {
80-
await menuGoTo(client, LOAD_MENU_ITEM_ID, LOAD_MAIN_ID);
81-
};
82-
83-
export const menuGoToDashboard = async client => {
84-
await menuGoTo(client, DASHBOARD_MENU_ITEM_ID, DASHBOARD_MAIN_ID);
85-
};
86-
87-
export const menuGoToSignOut = async client => {
88-
await menuGoTo(client, SIGN_OUT_MENU_ITEM_ID);
89-
};
90-
91-
export const menuGoToHome = async client => {
92-
await menuGoTo(client, HOME_MENU_ITEM_ID, HOME_MAIN_ID);
93-
};
94-
95-
export const menuGoToSavedSpaces = async client => {
96-
await menuGoTo(client, SAVED_SPACES_MENU_ITEM_ID, SAVED_SPACES_MAIN_ID);
97-
};
98-
99-
export const menuGoToClassrooms = async client => {
100-
await menuGoTo(client, CLASSROOMS_MENU_ITEM_ID, CLASSROOMS_MAIN_ID);
101-
};
102-
10317
describe('Menu Scenarios', function() {
10418
this.timeout(DEFAULT_GLOBAL_TIMEOUT);
10519
let app;

test/settings.test.js

+9-11
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ import {
1212
toggleGeolocationEnabled,
1313
toggleSyncAdvancedMode,
1414
changeLanguage,
15+
openDrawer,
16+
menuGoToSettings,
17+
menuGoToSavedSpaces,
18+
menuGoToDeveloper,
19+
menuGoToSpacesNearby,
20+
menuGoToSignOut,
21+
userSignIn,
1522
} from './utils';
1623
import { createApplication, closeApplication } from './application';
1724
import {
@@ -35,23 +42,14 @@ import {
3542
LOAD_TAB_PAUSE,
3643
SYNC_OPEN_SCREEN_PAUSE,
3744
} from './constants';
38-
import {
39-
openDrawer,
40-
menuGoToSettings,
41-
menuGoToSavedSpaces,
42-
menuGoToDeveloper,
43-
menuGoToSpacesNearby,
44-
menuGoToSignOut,
45-
} from './menu.test';
4645
import {
4746
DEFAULT_LANGUAGE,
4847
DEFAULT_GEOLOCATION_ENABLED,
4948
DEFAULT_DEVELOPER_MODE,
5049
DEFAULT_SYNC_MODE,
5150
SYNC_MODES,
5251
} from '../src/config/constants';
53-
import { userSignIn } from './userSignIn.test';
54-
import { USER_GRAASP, USER_ALICE, USER_BOB } from './fixtures/users';
52+
import { USER_GRAASP, USER_ALICE, USER_CEDRIC } from './fixtures/users';
5553
import { settingsPerUser } from './fixtures/settings';
5654
import { loadSpaceById } from './spaces/loadSpace.test';
5755
import {
@@ -271,7 +269,7 @@ describe('Settings Scenarios', function() {
271269
'Settings are saved for each user',
272270
mochaAsync(async () => {
273271
const { client } = app;
274-
const users = [USER_GRAASP, USER_ALICE, USER_BOB];
272+
const users = [USER_GRAASP, USER_ALICE, USER_CEDRIC];
275273
for (const user of users) {
276274
const {
277275
lang,

test/spaceSearch.test.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/* eslint-disable no-await-in-loop */
33
/* eslint-disable no-restricted-syntax */
44
import { expect } from 'chai';
5-
import { mochaAsync } from './utils';
5+
import { mochaAsync, userSignIn } from './utils';
66
import { createApplication, closeApplication } from './application';
77
import {
88
SPACE_SEARCH_INPUT_ID,
@@ -13,7 +13,6 @@ import {
1313
SPACE_SEARCH_PAUSE,
1414
TOOLTIP_FADE_OUT_PAUSE,
1515
} from './constants';
16-
import { userSignIn } from './userSignIn.test';
1716
import { USER_GRAASP } from './fixtures/users';
1817
import { loadSpaceById } from './spaces/loadSpace.test';
1918
import { searchSpacesFixtures } from './fixtures/searchSpaces';

test/spaces/clearUserInput.test.js

+5-10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
/* eslint-disable no-unused-expressions */
22
/* eslint-disable no-await-in-loop */
33
/* eslint-disable no-restricted-syntax */
4-
import { mochaAsync } from '../utils';
5-
import { createApplication, closeApplication } from '../application';
64
import {
5+
mochaAsync,
6+
userSignIn,
77
menuGoToSavedSpaces,
88
menuGoToPhase,
99
menuGoToSignOut,
10-
} from '../menu.test';
10+
} from '../utils';
11+
import { createApplication, closeApplication } from '../application';
1112
import {
1213
buildSpaceCardId,
1314
SPACE_CLEAR_BUTTON_CLASS,
@@ -23,7 +24,6 @@ import {
2324
TOOLTIP_FADE_OUT_PAUSE,
2425
OPEN_SAVED_SPACE_PAUSE,
2526
} from '../constants';
26-
import { userSignIn } from '../userSignIn.test';
2727
import { USER_GRAASP, USER_BOB, USER_ALICE } from '../fixtures/users';
2828
import {
2929
typeInTextInputApp,
@@ -156,12 +156,7 @@ describe('Clear User Input in a space', function() {
156156
const text1 = 'some user input conceptualisation';
157157

158158
// load space with user input
159-
await loadSpaceById(
160-
client,
161-
162-
SPACE_ATOMIC_STRUCTURE_PATH,
163-
spaceId
164-
);
159+
await loadSpaceById(client, SPACE_ATOMIC_STRUCTURE_PATH, spaceId);
165160

166161
// add user input
167162
await menuGoToPhase(client, 0);

test/spaces/deleteSpace.test.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,15 @@
22
/* eslint-disable no-await-in-loop */
33
/* eslint-disable no-restricted-syntax */
44
import { expect } from 'chai';
5-
import { mochaAsync } from '../utils';
5+
import { mochaAsync, userSignIn, menuGoToSavedSpaces } from '../utils';
66
import { createApplication, closeApplication } from '../application';
7-
import { menuGoToSavedSpaces } from '../menu.test';
87
import {
98
buildSpaceCardId,
109
SPACE_DELETE_BUTTON_CLASS,
1110
} from '../../src/config/selectors';
1211
import { SPACE_ATOMIC_STRUCTURE } from '../fixtures/spaces';
1312
import { visitAndSaveSpaceById } from './visitSpace.test';
1413
import { DELETE_SPACE_PAUSE, DEFAULT_GLOBAL_TIMEOUT } from '../constants';
15-
import { userSignIn } from '../userSignIn.test';
1614
import { USER_GRAASP } from '../fixtures/users';
1715

1816
describe('Delete a space', function() {

0 commit comments

Comments
 (0)