Add a volunteer demo user, document demo users
This commit is contained in:
3 files changed
+34
No files matched your search
@@ -38,6 +38,21 @@ server and open the app on your device or simulator:
|
||||
|
||||
npm run start
|
||||
|
||||
### Demo users
|
||||
|
||||
Dev builds accept three fake users (defined in `src/api.ts`) so you can preview the
|
||||
membership screens without a real account. They are valid with any password:
|
||||
|
||||
| Username | State |
|
||||
| ----------- | ------------------------------------------------------- |
|
||||
| `nonmember` | Not a member, no membership history |
|
||||
| `member` | Valid standard membership, expires 2099-08-01 |
|
||||
| `volunteer` | Same membership as `member`, but flagged as a volunteer |
|
||||
|
||||
They only work via `npm run start`/`android`/`ios`, not in EAS `preview` or
|
||||
`production` builds. Only login and fetching user data are faked, so
|
||||
buying a membership or deleting the account will fail against the real API.
|
||||
|
||||
### Android
|
||||
|
||||
`mise install` provides the Android SDK (the `android` CLI
|
||||
|
||||
@@ -99,6 +99,13 @@ describe('fetchUserData', () => {
|
||||
expect(fetchMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('resolves the dev fake volunteer as a member with the volunteer flag', async () => {
|
||||
const user = await fetchUserData('dev-fake-token:volunteer');
|
||||
|
||||
expect(user).toMatchObject({ is_member: true, is_volunteer: true });
|
||||
expect(fetchMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('throws an ApiError with the status, so a 401 is recognizable', async () => {
|
||||
mockResponseOnce({ detail: 'Ugyldig token.' }, false, 401);
|
||||
|
||||
|
||||
+12
@@ -30,6 +30,18 @@ const DEV_FAKE_USERS: Record<string, UserType> = {
|
||||
end_date: '2099-08-01',
|
||||
},
|
||||
},
|
||||
volunteer: {
|
||||
username: 'volunteer',
|
||||
email: 'volunteer@example.test',
|
||||
first_name: 'Aktiv',
|
||||
last_name: 'Frivillig',
|
||||
is_member: true,
|
||||
is_volunteer: true,
|
||||
last_membership: {
|
||||
membership_type: 'standard',
|
||||
end_date: '2099-08-01',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const JSON_HEADERS = {
|
||||
|
||||
Reference in new issue
Block a user