richie-education 2.25.0-b2.dev62 → 2.25.0-b2.dev65

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -38,9 +38,11 @@ const JOANIE_DEV_DEMO_USER_JWT_TOKENS = {
38
38
  'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNzMzOTI4MjE0LCJpYXQiOjE3MDIzOTIyMTQsImp0aSI6ImNkZjAyMGM4ODdjOTQxYzU5ZmExN2FkZGExNjNjMDIzIiwiZW1haWwiOiJqZWFuLWJhcHRpc3RlLnBlbnJhdGgrc3R1ZGVudF91c2VyQGZ1bi1tb29jLmZyIiwibGFuZ3VhZ2UiOiJmci1mciIsInVzZXJuYW1lIjoic3R1ZGVudF91c2VyIiwiZnVsbF9uYW1lIjoiXHUwMGM5dHVkaWFudCJ9.JMdnC2VXwq2VbNPrIYxj8PEq0oJJ4LZZT_ywWyE1lBM',
39
39
  };
40
40
 
41
+ export type DevDemoUser = keyof typeof JOANIE_DEV_DEMO_USER_JWT_TOKENS;
42
+
41
43
  export const RICHIE_DUMMY_IS_LOGGED_IN = 'RICHIE_DUMMY_IS_LOGGED_IN';
42
44
 
43
- function getUserInfo(username: keyof typeof JOANIE_DEV_DEMO_USER_JWT_TOKENS): Maybe<User> {
45
+ function getUserInfo(username: DevDemoUser): Maybe<User> {
44
46
  const accessToken = JOANIE_DEV_DEMO_USER_JWT_TOKENS[username];
45
47
  const JWTPayload: JWTPayload = JSON.parse(base64Decode(accessToken.split('.')[1]));
46
48
 
@@ -1,12 +1,3 @@
1
- /**
2
- * Available users:
3
- * * admin
4
- * * user0
5
- * * user1
6
- * * user2
7
- * * user3
8
- * * user4
9
- * * organization_owner
10
- * * student_user
11
- */
12
- export const CURRENT_JOANIE_DEV_DEMO_USER = 'admin';
1
+ import { DevDemoUser } from 'api/lms/dummy';
2
+
3
+ export const CURRENT_JOANIE_DEV_DEMO_USER: DevDemoUser = 'admin';
@@ -27,9 +27,10 @@ describe('CreditCardHelper', () => {
27
27
  });
28
28
 
29
29
  it('is soon expired', () => {
30
- const expirationDate = faker.date.future({
31
- refDate: new Date(),
32
- years: 2.99 / 12,
30
+ const now = new Date();
31
+ const expirationDate = faker.date.between({
32
+ from: now,
33
+ to: new Date(now.getFullYear(), now.getMonth() + 4, 0, 23, 59, 59),
33
34
  });
34
35
 
35
36
  expect(
@@ -43,7 +44,10 @@ describe('CreditCardHelper', () => {
43
44
  });
44
45
 
45
46
  it('is expired', () => {
46
- const date = faker.date.past();
47
+ const now = new Date();
48
+ const date = faker.date.past({
49
+ refDate: new Date(now.getFullYear(), now.getMonth(), 0, 23, 59, 59),
50
+ });
47
51
  expect(
48
52
  CreditCardHelper.getExpirationState(
49
53
  CreditCardFactory({
@@ -15,16 +15,29 @@ export class CreditCardHelper {
15
15
  if (!creditCard.expiration_month || !creditCard.expiration_year) {
16
16
  return false;
17
17
  }
18
- const expirationDate = new Date(creditCard.expiration_year, creditCard.expiration_month - 1, 1);
19
- const limitDate = new Date();
20
- limitDate.setMonth(limitDate.getMonth() + 3);
21
- return limitDate.getTime() > expirationDate.getTime();
18
+ const expirationDate = new Date(
19
+ creditCard.expiration_year,
20
+ creditCard.expiration_month,
21
+ 0,
22
+ 23,
23
+ 59,
24
+ 59,
25
+ );
26
+ const limitDate = new Date(new Date().getFullYear(), new Date().getMonth() + 4, 0, 23, 59, 59);
27
+ return limitDate.getTime() >= expirationDate.getTime();
22
28
  }
23
29
 
24
30
  static isExpired(creditCard: CreditCard): boolean {
25
- const expirationDate = new Date(creditCard.expiration_year, creditCard.expiration_month - 1, 1);
31
+ const expirationDate = new Date(
32
+ creditCard.expiration_year,
33
+ creditCard.expiration_month,
34
+ 0,
35
+ 23,
36
+ 59,
37
+ 59,
38
+ );
26
39
  const now = new Date();
27
- return expirationDate.getTime() < now.getTime();
40
+ return expirationDate.getTime() <= now.getTime();
28
41
  }
29
42
 
30
43
  static getExpirationState(creditCard: CreditCard): CreditCardExpirationStatus {
@@ -141,7 +141,7 @@ export const TEACHER_DASHBOARD_ROUTE_LABELS = defineMessages<TeacherDashboardPat
141
141
  [TeacherDashboardPaths.ORGANIZATION_PRODUCT]: {
142
142
  id: 'components.TeacherDashboard.TeacherDashboardRoutes.organization.course.product.label',
143
143
  description: 'Label of the organization product view.',
144
- defaultMessage: 'Training',
144
+ defaultMessage: 'General information',
145
145
  },
146
146
  [TeacherDashboardPaths.COURSE]: {
147
147
  id: 'components.TeacherDashboard.TeacherDashboardRoutes.course.label',
@@ -156,7 +156,7 @@ export const TEACHER_DASHBOARD_ROUTE_LABELS = defineMessages<TeacherDashboardPat
156
156
  [TeacherDashboardPaths.COURSE_PRODUCT]: {
157
157
  id: 'components.TeacherDashboard.TeacherDashboardRoutes.course.product.label',
158
158
  description: 'Label of the product view.',
159
- defaultMessage: 'Training',
159
+ defaultMessage: 'General information',
160
160
  },
161
161
  [TeacherDashboardPaths.COURSE_CONTRACTS]: {
162
162
  id: 'components.TeacherDashboard.TeacherDashboardRoutes.course.contracts.label',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "richie-education",
3
- "version": "2.25.0-b2.dev62",
3
+ "version": "2.25.0-b2.dev65",
4
4
  "description": "A CMS to build learning portals for Open Education",
5
5
  "main": "sandbox/manage.py",
6
6
  "scripts": {