Skip to content

Commit

Permalink
Update Seeds and Readme (#282)
Browse files Browse the repository at this point in the history
  • Loading branch information
steets250 authored Feb 7, 2022
1 parent 0802548 commit 9310daf
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 3 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,20 @@ CLIENT=localhost:8000

Take a look at [`package.json`](https://github.com/acmucsd/membership-portal/blob/master/package.json) for the actual commands.

### Testing Information
After having executed `npm run db:seed`, `tests/Seeds.ts` will have been used to generate sample data. For all testing accounts, the password is `password`. To test basic features of the portal, `[email protected]` can be used for the demo admin account, and any seed email (e.g. `[email protected]`) can be used for a demo member account.

For testing out the different portal roles, use the email `acm_[role]@ucsd.edu`, such that `[role]` is replaced with any of the following terms:
* `restricted` - User has been blocked from appearing on the leaderboard, although their account is still valid.
* `standard` - The default user role for all member accounts.
* `staff` - User is able to check in to events as a staff member.
* `admin` - User has full permissions to administrate the portal and store.
* `marketing` - User is able to create and edit events.
* `store_manager` - User is able to administrate store, including modifying collections, items, options, stock, and pricing.
* `store_distributor` - User is able to execute store distributions, including viewing and fulfilling orders for each pickup event.

For testing out the store, use the email `[email protected]`, as the majority of demo orders will be placed with this account.

### Upgrading to Latest Version
The first iteration of the membership portal is a JavaScript app written in 2019. The second and latest iteration, written 2020, is a TypeScript app built with better reliability and error handling, stronger concurrency guarantees, and a smoother development experience in mind, and includes a number of breaking changes at the API and database levels. For a more concrete list of improvements, see [acmucsd/membership-portal#115](https://github.com/acmucsd/membership-portal/pull/115).

Expand Down
56 changes: 53 additions & 3 deletions tests/Seeds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,42 @@ async function seed(): Promise<void> {
graduationYear: getGraduationYear(0),
});

// Used for testing out user view of the merch store
const USER_STORE = UserFactory.fake({
email: '[email protected]',
points: 500,
});

// Used for testing out user access types
const USER_RESTRICTED = UserFactory.fake({
email: '[email protected]',
accessType: UserAccessType.RESTRICTED,
});
const USER_STANDARD = UserFactory.fake({
email: '[email protected]',
accessType: UserAccessType.STANDARD,
});
const USER_STAFF = UserFactory.fake({
email: '[email protected]',
accessType: UserAccessType.STAFF,
});
const USER_ADMIN = UserFactory.fake({
email: '[email protected]',
accessType: UserAccessType.ADMIN,
});
const USER_MARKETING = UserFactory.fake({
email: '[email protected]',
accessType: UserAccessType.MARKETING,
});
const USER_MERCH_STORE_MANAGER = UserFactory.fake({
email: '[email protected]',
accessType: UserAccessType.MERCH_STORE_MANAGER,
});
const USER_MERCH_STORE_DISTRIBUTOR = UserFactory.fake({
email: '[email protected]',
accessType: UserAccessType.MERCH_STORE_DISTRIBUTOR,
});

// create members in bulk for testing things like sliding leaderboard in a realistic manner
const otherMembers = UserFactory.create(200);
const highAttendanceMembers = otherMembers.slice(0, 50);
Expand Down Expand Up @@ -494,6 +530,14 @@ async function seed(): Promise<void> {
MEMBER_SOPHOMORE,
MEMBER_JUNIOR,
MEMBER_SENIOR,
USER_STORE,
USER_RESTRICTED,
USER_STANDARD,
USER_STAFF,
USER_ADMIN,
USER_MARKETING,
USER_MERCH_STORE_MANAGER,
USER_MERCH_STORE_DISTRIBUTOR,
...otherMembers,
)
.createEvents(
Expand Down Expand Up @@ -577,9 +621,15 @@ async function seed(): Promise<void> {
MERCH_COLLECTION_2,
)
.createOrderPickupEvents(PAST_ORDER_PICKUP_EVENT, ONGOING_ORDER_PICKUP_EVENT, FUTURE_ORDER_PICKUP_EVENT)
.orderMerch(MEMBER_SOPHOMORE, [{ option: MERCH_ITEM_1_OPTION_M, quantity: 1 }], PAST_ORDER_PICKUP_EVENT)
.orderMerch(MEMBER_SOPHOMORE, [{ option: MERCH_ITEM_1_OPTION_M, quantity: 1 }], PAST_ORDER_PICKUP_EVENT)
.orderMerch(MEMBER_SOPHOMORE, [{ option: MERCH_ITEM_1_OPTION_M, quantity: 1 }], ONGOING_ORDER_PICKUP_EVENT)
.orderMerch(USER_STORE, [{ option: MERCH_ITEM_1_OPTION_M, quantity: 1 }], PAST_ORDER_PICKUP_EVENT)
.orderMerch(USER_STORE, [{ option: MERCH_ITEM_1_OPTION_L, quantity: 1 }], PAST_ORDER_PICKUP_EVENT)
.orderMerch(MEMBER_JUNIOR, [{ option: MERCH_ITEM_2_OPTION_4X4, quantity: 2 }], PAST_ORDER_PICKUP_EVENT)
.orderMerch(USER_STORE, [{ option: MERCH_ITEM_2_OPTION_3X3, quantity: 1 }], ONGOING_ORDER_PICKUP_EVENT)
.orderMerch(MEMBER_FRESHMAN, [{ option: MERCH_ITEM_2_OPTION_3X3, quantity: 1 }], ONGOING_ORDER_PICKUP_EVENT)
.orderMerch(MEMBER_SOPHOMORE, [{ option: MERCH_ITEM_2_OPTION_2X2, quantity: 1 }], ONGOING_ORDER_PICKUP_EVENT)
.orderMerch(MEMBER_SOPHOMORE, [{ option: MERCH_ITEM_2_OPTION_2X2, quantity: 1 }], ONGOING_ORDER_PICKUP_EVENT)
.orderMerch(MEMBER_JUNIOR, [{ option: MERCH_ITEM_2_OPTION_4X4, quantity: 2 }], ONGOING_ORDER_PICKUP_EVENT)
.orderMerch(MEMBER_SENIOR, [{ option: MERCH_ITEM_2_OPTION_3X3, quantity: 1 }], ONGOING_ORDER_PICKUP_EVENT)
.write();
}

Expand Down

0 comments on commit 9310daf

Please sign in to comment.