Skip to content
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

Stage main2 #1367

Merged
merged 44 commits into from
Jan 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
047e67f
upgrade react-formal, which gets rid of browser-console warnings rela…
lperson Jul 27, 2019
efad50f
use Fragment to replace <divs> used only to group multiple children
lperson Jul 27, 2019
964aafc
do the render in 2 parts
lperson Jul 27, 2019
f268672
updated yarn.lock
lperson Jul 27, 2019
e50d518
fixes problem with script edit on safari
lperson Jul 27, 2019
9c5ce1f
got rid of react-dot-fragment because it degraded performance; added …
lperson Jul 28, 2019
7720fcc
functions for analyzing brightness of background in AssignmentSummary
SAnschutz Nov 9, 2019
b857690
dynamically set contrasting text color
SAnschutz Nov 9, 2019
3d1576a
import theme for colors
SAnschutz Nov 10, 2019
98d3f86
extract color contrast function into separate file, add test
SAnschutz Nov 18, 2019
6e2dd2c
rename test file
SAnschutz Nov 18, 2019
f5afa90
refactor to use tinycolor2
SAnschutz Nov 23, 2019
b50333f
ran prettier to see if it helps with merge conflicts
lperson Nov 25, 2019
b96c45e
Merge remote-tracking branch 'moveon/main' into lp_moveon_optimize_in…
lperson Nov 25, 2019
bb3f35c
Add basic tests for CampaignInteractionStepsForm
lperson Nov 28, 2019
812a5a5
got rid of a hack!
lperson Nov 29, 2019
b60186e
Allow alternate schema for postgres db
jeffm2001 Dec 16, 2019
f06d081
avoid unicode in files as it breaks some text editors
schuyler1d Dec 17, 2019
32c0b07
move code from using message.assignment_id => message.campaign_contac…
schuyler1d Dec 18, 2019
b484937
comment out log.info logs on message sending
schuyler1d Dec 19, 2019
00b0e18
data migration and message index changes for message.assignment_id =>…
schuyler1d Dec 19, 2019
63d02c0
Merge remote-tracking branch 'origin/main' into db-messagecontactid
schuyler1d Dec 24, 2019
25ac5a1
Delete a bad test.
lperson Dec 20, 2019
6fc298b
simplify migration -- concurrent will have to be manual
schuyler1d Dec 24, 2019
4b11729
remove unused var
schuyler1d Dec 24, 2019
f6e189d
also drop assignment_id
schuyler1d Dec 24, 2019
9ffd11c
only query first message -- not all of them!
schuyler1d Dec 24, 2019
5fc0f5b
Don't refereence userData if it is null.
lperson Dec 29, 2019
2f928ef
merge load-messages branch which fixes a performance issue on production
schuyler1d Jan 2, 2020
fd50e33
import-script debugging/tweaks
schuyler1d Jan 3, 2020
0078d6b
Merge remote-tracking branch 'origin/main' into db-messagecontactid
schuyler1d Jan 3, 2020
c5bfb6c
fixes to message.messageservice_sid saving and test for handleIncomin…
schuyler1d Jan 6, 2020
17bcb3c
ability to load config files from a deployed file instead of just env…
schuyler1d Jan 6, 2020
a59e301
add documentation, remove console.logs
schuyler1d Jan 7, 2020
64953a4
Merge branch 'pr/1351' into stage-main2
schuyler1d Jan 13, 2020
47fbba5
Merge branch 'pr/1309' into stage-main2
schuyler1d Jan 13, 2020
695aa9a
Merge branch 'pr/1311' into stage-main2
schuyler1d Jan 13, 2020
ebc0d5b
Merge branch 'pr/1277' into stage-main2
schuyler1d Jan 13, 2020
303a82a
Merge branch 'pr/1344' into stage-main2
schuyler1d Jan 13, 2020
83f8697
Merge branch 'pr/1179' into stage-main2
schuyler1d Jan 13, 2020
ce485c2
Merge branch 'pr/1178' into stage-main2
schuyler1d Jan 13, 2020
41e29cb
merge pr/1306 into stage-main
schuyler1d Jan 13, 2020
bd03a35
fix accurate sent/received counts on dashboard after message.campaign…
schuyler1d Jan 13, 2020
e312b23
Merge remote-tracking branch 'origin/db-messagecontactid' into stage-…
schuyler1d Jan 13, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ coverage/
*.vscode
*.rdb
package-lock.json
CONFIG_FILE.json
90 changes: 89 additions & 1 deletion __test__/backend.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,20 @@ import {
UserOrganization
} from "../src/server/models/";
import { resolvers as campaignResolvers } from "../src/server/api/campaign";
import { getContext, setupTest, cleanupTest } from "./test_helpers";
import {
setupTest,
cleanupTest,
getContext,
createUser as helperCreateUser,
createTexter as helperCreateTexter,
createOrganization as helperCreateOrganization,
createInvite as helperCreateInvite,
runGql
} from "./test_helpers";
import { makeExecutableSchema } from "graphql-tools";

import { editUserMutation } from "../src/containers/UserEdit.jsx";

const mySchema = makeExecutableSchema({
typeDefs: schema,
resolvers,
Expand Down Expand Up @@ -697,3 +708,80 @@ describe("Campaign", () => {
});
});
});

describe.only("editUser mutation", () => {
let testAdminUser;
let testTexter;
let testOrganization;
let organizationId;
let variables;

beforeEach(async () => {
await setupTest();
testAdminUser = await helperCreateUser();
testOrganization = await helperCreateOrganization(
testAdminUser,
await helperCreateInvite()
);
organizationId = testOrganization.data.createOrganization.id;
testTexter = await helperCreateTexter(testOrganization);

variables = {
organizationId,
userId: testTexter.id,
userData: null
};
}, global.DATABASE_SETUP_TEARDOWN_TIMEOUT);

afterEach(async () => {
await cleanupTest();
if (r.redis) r.redis.flushdb();
}, global.DATABASE_SETUP_TEARDOWN_TIMEOUT);

it("returns the user if it is called with a userId by no userData", async () => {
const result = await runGql(editUserMutation, variables, testAdminUser);
expect(result).toEqual({
data: {
editUser: {
id: "2",
firstName: "TestTexterFirst",
lastName: "TestTexterLast",
cell: "555-555-6666",
email: "testtexter@example.com"
}
}
});
});

it("updates the user if it is called with a userId and userData", async () => {
const userData = {
firstName: "Jerry",
lastName: "Garcia",
email: "jerry@heaven.org",
cell: "4151111111"
};

variables.userData = userData;

// the mutation returns the right thing
const result = await runGql(editUserMutation, variables, testAdminUser);
expect(result).toEqual({
data: {
editUser: {
...userData,
id: testTexter.id.toString()
}
}
});

// it gets updated in the database
const updatedUser = await r.knex("user").where("id", testTexter.id);
expect(updatedUser[0]).toMatchObject({
first_name: userData.firstName,
last_name: userData.lastName,
email: userData.email,
cell: userData.cell,
id: testTexter.id
});
});
});
86 changes: 86 additions & 0 deletions __test__/components/CampaignInteractionStepsForm.test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions __test__/lib.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { resolvers } from "../src/server/api/schema";
import { schema } from "../src/api/schema";
import twilio from "../src/server/api/lib/twilio";
import { getConfig, hasConfig } from "../src/server/api/lib/config";
import { makeExecutableSchema } from "graphql-tools";

const mySchema = makeExecutableSchema({
Expand Down Expand Up @@ -35,3 +36,27 @@ it("should parse a message with a media url", () => {

expect(twilio.parseMessageText({ text: undefined }).body).toBe("");
});

describe("getConfig/hasConfig", () => {
// note this is only testing global.* for set vars
// but implicitly it's testing CONFIG_FILE.json for unset vars, at least
it("should return getConfig for set var", () => {
expect(getConfig("TEST_ENVIRONMENT")).toBe("1");
});

it("should return getConfig for unset var", () => {
expect(getConfig("XXXTEST_ENVIRONMENT")).toBe(undefined);
});

it("should return false for hasConfig for unset var", () => {
expect(hasConfig("XXXTEST_ENVIRONMENT")).toBe(false);
});

it("should return false for hasConfig for blank set var", () => {
expect(hasConfig("TWILIO_API_KEY")).toBe(false);
});

it("should return true for hasConfig for set var", () => {
expect(hasConfig("TEST_ENVIRONMENT")).toBe(true);
});
});
23 changes: 23 additions & 0 deletions __test__/lib/color-contrast-helper.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { setContrastingColor } from "../../src/lib/color-contrast-helper";

import theme from "../../src/styles/theme";

describe("test setContrastingColor", () => {
it("returns darkGray when a light color is passed in", () => {
expect(setContrastingColor("#fff")).toEqual(theme.colors.darkGray);
});

it("returns white when a dark color is passed in", () => {
expect(setContrastingColor("#000")).toEqual(theme.colors.white);
});

it("returns darkGray when a color is passed in with an opacity of less than .4", () => {
expect(setContrastingColor("rgba(0, 0, 0, .39)")).toEqual(
theme.colors.darkGray
);
});

it("returns darkGray when an invalid color is passed in", () => {
expect(setContrastingColor("incorrect")).toEqual(theme.colors.darkGray);
});
});
1 change: 0 additions & 1 deletion __test__/server/api/campaign.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,6 @@ describe("Bulk Send", async () => {

// send some texts
const bulkSendResult = await bulkSendMessages(assignmentId, testTexterUser);
console.log(bulkSendResult);
resultTestFunction(bulkSendResult);

// TEXTER 1 (95 needsMessage, 5 needsResponse)
Expand Down
39 changes: 39 additions & 0 deletions __test__/server/api/lib/twilio.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/* eslint-disable no-unused-expressions, consistent-return */
import { r, Message } from "../../../../src/server/models/";
import { postMessageSend } from "../../../../src/server/api/lib/twilio";
import twilio from "../../../../src/server/api/lib/twilio";
import { getLastMessage } from "../../../../src/server/api/lib/message-sending";

import {
setupTest,
Expand Down Expand Up @@ -154,6 +156,43 @@ it("postMessageSend error from twilio response should fail immediately", async (
}
});

it("handleIncomingMessage should save message and update contact state", async () => {
const message = await Message.save({
assignment_id: assignmentId,
campaign_contact_id: dbCampaignContact.id,
contact_number: dbCampaignContact.cell,
messageservice_sid: "fakeSid_MK123",
is_from_contact: false,
send_status: "SENT",
service: "twilio",
text: "some message",
user_id: testTexterUser.id,
service_id: "123123123"
});
const lastMessage = await getLastMessage({
contactNumber: dbCampaignContact.cell,
service: "twilio",
messageServiceSid: "fakeSid_MK123"
});

expect(lastMessage.campaign_contact_id).toEqual(dbCampaignContact.id);
await twilio.handleIncomingMessage({
From: dbCampaignContact.cell,
To: "+16465559999",
MessageSid: "TestMessageId",
Body: "Fake reply",
MessagingServiceSid: "fakeSid_MK123"
});
const [reply] = await r.knex("message").where("service_id", "TestMessageId");
dbCampaignContact = await getCampaignContact(dbCampaignContact.id);
expect(reply.send_status).toEqual("DELIVERED");
expect(reply.campaign_contact_id).toEqual(dbCampaignContact.id);
expect(reply.contact_number).toEqual(dbCampaignContact.cell);
expect(reply.user_number).toEqual("+16465559999");
expect(reply.messageservice_sid).toEqual("fakeSid_MK123");
expect(dbCampaignContact.message_status).toEqual("needsResponse");
});

// FUTURE
// * handleDeliveryReport (error and non-error)
// * parseMessageText
Expand Down
68 changes: 0 additions & 68 deletions __test__/server/texter.test/correctOptOut.test.js

This file was deleted.

Loading