-
Notifications
You must be signed in to change notification settings - Fork 406
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Paginated, searchable people page with other enhancements #1345
Merged
ibrand
merged 11 commits into
StateVoicesNational:main
from
lperson:lp_1326_paginated_people_page
May 28, 2020
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
edc9f92
Manual merge of WFP PR 101
lperson 558116a
Manual merge WFP PR 105
lperson a471413
Manual merge WFP PR 110
lperson 5fc0f5b
Don't refereence userData if it is null.
lperson ad009e0
Merge branch 'lp_1343_fix_user_edit' into lp_1326_paginated_people_page
lperson 80f98c7
Manual merge WFP PR 137
lperson 845a890
Manual merge of WFP PR 140
lperson 33b28a8
tests pass again
lperson 5a63628
working on tests
lperson eab707e
Finished tests
lperson 94e5d27
Get rid of a variable introduced in a bad merge
lperson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,193 @@ | ||
/* eslint-disable no-unused-expressions, consistent-return */ | ||
import { r } from "../../../src/server/models/"; | ||
import { getCampaignsQuery } from "../../../src/containers/CampaignList"; | ||
import { GraphQLError } from "graphql/error"; | ||
|
||
import { | ||
setupTest, | ||
cleanupTest, | ||
createUser, | ||
createInvite, | ||
createOrganization, | ||
createCampaign, | ||
createTexter, | ||
runGql | ||
} from "../../test_helpers"; | ||
|
||
describe("organization", async () => { | ||
let testTexterUser; | ||
let testAdminUser; | ||
let testInvite; | ||
let testOrganization; | ||
let testCampaign; | ||
let organizationId; | ||
|
||
beforeEach(async () => { | ||
// Set up an entire working campaign | ||
await setupTest(); | ||
testAdminUser = await createUser(); | ||
testInvite = await createInvite(); | ||
testOrganization = await createOrganization(testAdminUser, testInvite); | ||
organizationId = testOrganization.data.createOrganization.id; | ||
testCampaign = await createCampaign( | ||
testAdminUser, | ||
testOrganization, | ||
"Apples", | ||
{ dueBy: new Date(2019, 11, 31) } | ||
); | ||
testTexterUser = await createTexter(testOrganization); | ||
}, global.DATABASE_SETUP_TEARDOWN_TIMEOUT); | ||
|
||
afterEach(async () => { | ||
await cleanupTest(); | ||
if (r.redis) r.redis.flushdb(); | ||
}, global.DATABASE_SETUP_TEARDOWN_TIMEOUT); | ||
|
||
describe("organization.campaigns", async () => { | ||
let testCampaign2; | ||
let testCampaign3; | ||
let testCampaign4; | ||
let variables; | ||
let cursor; | ||
|
||
beforeEach(async () => { | ||
testCampaign2 = await createCampaign( | ||
testAdminUser, | ||
testOrganization, | ||
"Oranges", | ||
{ dueBy: new Date(2019, 11, 30) } | ||
); | ||
testCampaign3 = await createCampaign( | ||
testAdminUser, | ||
testOrganization, | ||
"Apples and Oranges", | ||
{ dueBy: new Date(2019, 11, 29) } | ||
); | ||
testCampaign4 = await createCampaign( | ||
testAdminUser, | ||
testOrganization, | ||
"Banana", | ||
{ dueBy: new Date(2019, 11, 28) } | ||
); | ||
|
||
cursor = { | ||
offset: 0, | ||
limit: 1000 | ||
}; | ||
|
||
variables = { | ||
cursor, | ||
organizationId | ||
}; | ||
}); | ||
|
||
it("filters by a single campaign id", async () => { | ||
const campaignsFilter = { | ||
campaignId: testCampaign.id | ||
}; | ||
variables.campaignsFilter = campaignsFilter; | ||
|
||
const result = await runGql(getCampaignsQuery, variables, testAdminUser); | ||
expect(result.data.organization.campaigns.campaigns.length).toEqual(1); | ||
expect(result.data.organization.campaigns.campaigns[0].id).toEqual( | ||
testCampaign.id | ||
); | ||
}); | ||
|
||
it("filter by more than one campaign id", async () => { | ||
const campaignsFilter = { | ||
campaignIds: [testCampaign.id, testCampaign2.id] | ||
}; | ||
variables.campaignsFilter = campaignsFilter; | ||
|
||
const result = await runGql(getCampaignsQuery, variables, testAdminUser); | ||
expect(result.data.organization.campaigns.campaigns.length).toEqual(2); | ||
|
||
const returnedIds = result.data.organization.campaigns.campaigns.map( | ||
campaign => campaign.id | ||
); | ||
expect(returnedIds).toContain(testCampaign.id); | ||
expect(returnedIds).toContain(testCampaign2.id); | ||
}); | ||
|
||
it("filters by search string", async () => { | ||
const campaignsFilter = { | ||
searchString: "oranges" | ||
}; | ||
variables.campaignsFilter = campaignsFilter; | ||
|
||
const result = await runGql(getCampaignsQuery, variables, testAdminUser); | ||
expect(result.data.organization.campaigns.campaigns.length).toEqual(2); | ||
|
||
const returnedIds = result.data.organization.campaigns.campaigns.map( | ||
campaign => campaign.id | ||
); | ||
expect(returnedIds).toContain(testCampaign2.id); | ||
expect(returnedIds).toContain(testCampaign3.id); | ||
}); | ||
|
||
it("regular texters don't have permission", async () => { | ||
const result = await runGql(getCampaignsQuery, variables, testTexterUser); | ||
expect(result.errors).toEqual([ | ||
new GraphQLError("You are not authorized to access that resource.") | ||
]); | ||
}); | ||
|
||
describe("sorts", async () => { | ||
const runTest = async (sortBy, expectedOrderedIds) => { | ||
variables.sortBy = sortBy; | ||
const result = await runGql( | ||
getCampaignsQuery, | ||
variables, | ||
testAdminUser | ||
); | ||
expect(result.data.organization.campaigns.campaigns.length).toEqual(4); | ||
const returnedIds = result.data.organization.campaigns.campaigns.map( | ||
campaign => campaign.id | ||
); | ||
expect(returnedIds).toEqual(expectedOrderedIds); | ||
}; | ||
|
||
it("sorts by due date ascending", async () => { | ||
await runTest("DUE_DATE_ASC", [ | ||
testCampaign4.id, | ||
testCampaign3.id, | ||
testCampaign2.id, | ||
testCampaign.id | ||
]); | ||
}); | ||
it("sorts by due date descending", async () => { | ||
await runTest("DUE_DATE_DESC", [ | ||
testCampaign.id, | ||
testCampaign2.id, | ||
testCampaign3.id, | ||
testCampaign4.id | ||
]); | ||
}); | ||
it("sorts by id ascending", async () => { | ||
await runTest("ID_ASC", [ | ||
testCampaign.id, | ||
testCampaign2.id, | ||
testCampaign3.id, | ||
testCampaign4.id | ||
]); | ||
}); | ||
it("sorts by id desc", async () => { | ||
await runTest("ID_DESC", [ | ||
testCampaign4.id, | ||
testCampaign3.id, | ||
testCampaign2.id, | ||
testCampaign.id | ||
]); | ||
}); | ||
it("sorts by title", async () => { | ||
await runTest("TITLE", [ | ||
testCampaign.id, | ||
testCampaign3.id, | ||
testCampaign4.id, | ||
testCampaign2.id | ||
]); | ||
}); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amusing test user :)