diff --git a/Gemfile.lock b/Gemfile.lock
index 17444cba3..bcb2eefb7 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -17,17 +17,17 @@ GEM
artifactory (3.0.15)
atomos (0.1.3)
aws-eventstream (1.1.0)
- aws-partitions (1.417.0)
- aws-sdk-core (3.111.2)
+ aws-partitions (1.430.0)
+ aws-sdk-core (3.112.0)
aws-eventstream (~> 1, >= 1.0.2)
aws-partitions (~> 1, >= 1.239.0)
aws-sigv4 (~> 1.1)
jmespath (~> 1.0)
- aws-sdk-kms (1.41.0)
- aws-sdk-core (~> 3, >= 3.109.0)
+ aws-sdk-kms (1.42.0)
+ aws-sdk-core (~> 3, >= 3.112.0)
aws-sigv4 (~> 1.1)
- aws-sdk-s3 (1.87.0)
- aws-sdk-core (~> 3, >= 3.109.0)
+ aws-sdk-s3 (1.89.0)
+ aws-sdk-core (~> 3, >= 3.112.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.1)
aws-sigv4 (1.2.2)
@@ -86,9 +86,9 @@ GEM
domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0)
dotenv (2.7.6)
- emoji_regex (3.2.1)
+ emoji_regex (3.2.2)
escape (0.0.4)
- excon (0.78.1)
+ excon (0.79.0)
faraday (1.3.0)
faraday-net_http (~> 1.0)
multipart-post (>= 1.2, < 3)
@@ -99,8 +99,8 @@ GEM
faraday-net_http (1.0.1)
faraday_middleware (1.0.0)
faraday (~> 1.0)
- fastimage (2.2.1)
- fastlane (2.172.0)
+ fastimage (2.2.3)
+ fastlane (2.176.0)
CFPropertyList (>= 2.3, < 4.0.0)
addressable (>= 2.3, < 3.0.0)
artifactory (~> 3.0)
@@ -124,6 +124,7 @@ GEM
jwt (>= 2.1.0, < 3)
mini_magick (>= 4.9.4, < 5.0.0)
multipart-post (~> 2.0.0)
+ naturally (~> 2.2)
plist (>= 3.1.0, < 4.0.0)
rubyzip (>= 2.0.0, < 3.0.0)
security (= 0.1.3)
@@ -148,7 +149,7 @@ GEM
representable (~> 3.0)
retriable (>= 2.0, < 4.0)
signet (~> 0.12)
- google-apis-core (0.2.0)
+ google-apis-core (0.2.1)
addressable (~> 2.5, >= 2.5.1)
googleauth (~> 0.14)
httpclient (>= 2.8.1, < 3.0)
@@ -157,9 +158,10 @@ GEM
retriable (>= 2.0, < 4.0)
rexml
signet (~> 0.14)
+ webrick
google-apis-iamcredentials_v1 (0.1.0)
google-apis-core (~> 0.1)
- google-apis-storage_v1 (0.1.0)
+ google-apis-storage_v1 (0.2.0)
google-apis-core (~> 0.1)
google-cloud-core (1.5.0)
google-cloud-env (~> 1.0)
@@ -175,7 +177,7 @@ GEM
google-cloud-core (~> 1.2)
googleauth (~> 0.9)
mini_mime (~> 1.0)
- googleauth (0.14.0)
+ googleauth (0.15.1)
faraday (>= 0.17.3, < 2.0)
jwt (>= 1.4, < 3.0)
memoist (~> 0.16)
@@ -223,7 +225,7 @@ GEM
ruby2_keywords (0.0.4)
rubyzip (2.3.0)
security (0.1.3)
- signet (0.14.0)
+ signet (0.14.1)
addressable (~> 2.3)
faraday (>= 0.17.3, < 2.0)
jwt (>= 1.5, < 3.0)
@@ -250,6 +252,7 @@ GEM
unf_ext
unf_ext (0.0.7.7)
unicode-display_width (1.7.0)
+ webrick (1.7.0)
word_wrap (1.0.0)
xcodeproj (1.19.0)
CFPropertyList (>= 2.3.3, < 4.0)
diff --git a/Rakefile b/Rakefile
index 84ebbd45a..4e5a06a6e 100755
--- a/Rakefile
+++ b/Rakefile
@@ -103,7 +103,7 @@ namespace :cordova do
if platform == 'android'
sh %{ cordova plugin add phonegap-plugin-push@2.1.2 }
else
- sh %{ cordova plugin add phonegap-plugin-push@1.9.2 --variable SENDER_ID="XXXXXXX" }
+ sh %{ cordova plugin add phonegap-plugin-push@2.3.0 --variable SENDER_ID="XXXXXXX" }
end
build = (environment == "staging" && platform == 'android') ? "debug" : "release"
extra_params = (platform === "android") ? '' : ios_build_config
diff --git a/app/components/add-edit-message-overlay.js b/app/components/add-edit-message-overlay.js
new file mode 100644
index 000000000..4cc3754f3
--- /dev/null
+++ b/app/components/add-edit-message-overlay.js
@@ -0,0 +1,61 @@
+import Ember from "ember";
+import _ from "lodash";
+import AsyncTasksMixin, { ERROR_STRATEGIES } from "../mixins/async_tasks";
+
+export default Ember.Component.extend(AsyncTasksMixin, {
+ messageService: Ember.inject.service(),
+ store: Ember.inject.service(),
+
+ async didReceiveAttrs() {
+ const editMessage = this.get("messageService.editMessage");
+ const store = this.get("store");
+ const message =
+ store.peekRecord("canned_response", editMessage.messageId) ||
+ store.createRecord("canned-response");
+ this.set("message", message);
+ this.set("isEnglish", true);
+ },
+
+ disableCreateEdit: Ember.computed(
+ "message.nameEn",
+ "message.contentEn",
+ function() {
+ return !(this.get("message.nameEn") && this.get("message.contentEn"));
+ }
+ ),
+
+ actions: {
+ createCannedMessage() {
+ this.runTask(
+ this.get("message")
+ .save()
+ .then(() => this.set("messageService.isAddMessageVisible", false))
+ );
+ },
+
+ closeOverlay() {
+ this.set("messageService.isAddMessageVisible", false);
+ this.set("messageService.editMessage.language", "en");
+ this.set("messageService.editMessage.messageId", "");
+ },
+
+ setLanguage(lang = "en") {
+ this.set("isEnglish", lang == "en");
+ },
+
+ deleteMessage() {
+ const store = this.get("store");
+ const message = store.peekRecord(
+ "canned_response",
+ this.get("message").id
+ );
+ this.runTask(
+ message.destroyRecord().then(() => {
+ store.unloadRecord(message);
+ this.set("messageService.isAddMessageVisible", false);
+ }),
+ ERROR_STRATEGIES
+ );
+ }
+ }
+});
diff --git a/app/components/canned-messages-overlay.js b/app/components/canned-messages-overlay.js
index 304d58c8e..bf0ac95d4 100644
--- a/app/components/canned-messages-overlay.js
+++ b/app/components/canned-messages-overlay.js
@@ -18,12 +18,25 @@ export default Ember.Component.extend({
return this.get("searchText") && this.get("searchText").trim().length;
}),
+ refreshDisplayResult: Ember.observer(
+ "messageService.isAddMessageVisible",
+ function() {
+ if (!this.get("messageService.isAddMessageVisible")) {
+ this.reloadResults();
+ }
+ }
+ ),
+
actions: {
loadMoreCannedMessages() {
const params = { searchText: this.get("searchText") };
return this.get("store").query("canned_response", params);
},
+ openProFormaOverlay() {
+ this.set("messageService.isProFormaMessageVisible", true);
+ },
+
setCannedResponse(text) {
if (!text) return;
const onSelect = this.getWithDefault("onSelect", _.noop);
diff --git a/app/components/let-alias.js b/app/components/let-alias.js
new file mode 100644
index 000000000..56268b039
--- /dev/null
+++ b/app/components/let-alias.js
@@ -0,0 +1,20 @@
+import Ember from "ember";
+
+/**
+ * @module Components/let-alias
+ * @description Small helper component allowing to rename variables within the .hbs file
+ * @example
+ *
+ * {{#let-alias model.someReallyLongPropertyName as |short| }}
+ *
This is {{short}}
+ * I can use {{short}} many times {{short}}
+ * because it's very {{short}}
this.set("displayResults", true), 500);
+ },
+
+ hasSearchText: Ember.computed("searchText", function() {
+ return this.get("searchText") && this.get("searchText").trim().length;
+ }),
+
+ actions: {
+ loadMoreCannedMessages() {
+ const params = {
+ searchText: this.get("searchText")
+ };
+ return this.get("store").query("canned_response", params);
+ },
+
+ addMessage() {
+ this.set("messageService.isAddMessageVisible", true);
+ },
+
+ closeOverlay() {
+ this.set("messageService.isProFormaMessageVisible", false);
+ },
+
+ editMessage(message, lang) {
+ this.set("messageService.editMessage.messageId", message.id);
+ this.set("messageService.editMessage.language", lang);
+ this.send("addMessage");
+ },
+
+ cancel() {
+ this.set("open", false);
+ }
+ }
+});
diff --git a/app/components/receive-menu.js b/app/components/receive-menu.js
index 15c96d95f..700c7773c 100644
--- a/app/components/receive-menu.js
+++ b/app/components/receive-menu.js
@@ -15,6 +15,14 @@ export default Ember.Component.extend(AsyncTasksMixin, {
isReceived: Ember.computed.equal("package.state", "received"),
isMissing: Ember.computed.equal("package.state", "missing"),
+ isReceivedWithoutInventory: Ember.computed(
+ "package",
+ "isReceived",
+ function() {
+ return this.get("isReceived") && !this.get("package.inventoryNumber");
+ }
+ ),
+
allowLabelPrint: Ember.computed(
"isReceived",
"package.inventoryNumber",
@@ -157,6 +165,18 @@ export default Ember.Component.extend(AsyncTasksMixin, {
}
},
+ inventorizeReceivedItem() {
+ this.get("messageBox").confirm(
+ this.get("i18n").t("receive.inventorize_warning"),
+ () => {
+ this.get("router").transitionTo(
+ "receive_package",
+ this.get("packageId")
+ );
+ }
+ );
+ },
+
applyReceiving(event, allow_event = true) {
if (!this.get("isFirstReceivingPackage") && allow_event) {
return this.send(event);
diff --git a/app/controllers/application.js b/app/controllers/application.js
new file mode 100644
index 000000000..3a58115ec
--- /dev/null
+++ b/app/controllers/application.js
@@ -0,0 +1,59 @@
+import config from "../config/environment";
+
+export default Ember.Controller.extend({
+ cordova: Ember.inject.service(),
+ subscriptions: Ember.inject.controller(),
+ messageService: Ember.inject.service(),
+ isMobileApp: config.cordova.enabled,
+ config,
+
+ app_id: config.APP.ANDROID_APP_ID,
+ ios_app_id: config.APP.IOS_APP_ID,
+ appTitle: config.APP.TITLE,
+ bannerImage: config.APP.BANNER_IMAGE,
+
+ initSubscriptions: Ember.on("init", function() {
+ if (this.session.get("isLoggedIn")) {
+ this.send("setSubscriptions");
+ }
+ }),
+
+ supportGCLink: Ember.computed("session.language", function() {
+ return this.get("session.language") === "zh-tw"
+ ? "https://www.crossroads.org.hk/zh-hant/home/donate-funds/"
+ : "https://www.crossroads.org.hk/home/donate-funds/";
+ }),
+
+ appVersion: Ember.computed(function() {
+ return config.cordova.enabled ? config.APP.VERSION : null;
+ }),
+
+ actions: {
+ logMeOut() {
+ this.session.clear(); // this should be first since it updates isLoggedIn status
+ this.get("subscriptions").send("unwire");
+ this.get("subscriptions").send("unloadNotifications");
+ this.store.unloadAll();
+ var _this = this;
+ config.APP.PRELOAD_TYPES.forEach(function(type) {
+ _this.store.findAll(type);
+ });
+ this.transitionToRoute("login");
+ },
+
+ logMeIn() {
+ this.send("setSubscriptions");
+ },
+
+ setSubscriptions() {
+ this.get("subscriptions").send("wire");
+ },
+
+ rateApp() {
+ if (this.get("cordova").isIOS()) {
+ this.set("app_id", this.get("ios_app_id"));
+ }
+ LaunchReview.launch(this.get("app_id"));
+ }
+ }
+});
diff --git a/app/controllers/message_base_controller.js b/app/controllers/message_base_controller.js
index bfc6a550d..2e2ae162d 100644
--- a/app/controllers/message_base_controller.js
+++ b/app/controllers/message_base_controller.js
@@ -59,14 +59,13 @@ export default Ember.Controller.extend({
this.get("recipientId") ||
(this.get("isPrivate") ? null : this.get("offer.createdById"));
- if (recipientId) {
- messages = messages.filter(m => {
- return (
- m.get("recipientId") === recipientId ||
- m.get("senderId") === recipientId
- );
- });
- }
+ messages = messages.filter(m => {
+ return (
+ recipientId &&
+ (m.get("recipientId") === recipientId ||
+ m.get("senderId") === recipientId)
+ );
+ });
return messages.filter(m => {
return Boolean(m.get("isPrivate")) === this.get("isPrivate");
diff --git a/app/controllers/my_notifications.js b/app/controllers/my_notifications.js
index aa5646bb8..d082d5bbe 100644
--- a/app/controllers/my_notifications.js
+++ b/app/controllers/my_notifications.js
@@ -183,8 +183,9 @@ export default Ember.Controller.extend({
const donorId = message.get("offer.createdById");
return (
- message.get("senderId") !== donorId &&
- message.get("recipientId") !== donorId
+ !donorId ||
+ (message.get("senderId") !== donorId &&
+ message.get("recipientId") !== donorId)
);
},
@@ -235,6 +236,9 @@ export default Ember.Controller.extend({
const messageId = notification.get("id");
var message = this.store.peekRecord("message", messageId);
var route = this.get("messagesUtil").getRoute(message);
+ if (message.get("messageableType") === "Item") {
+ route[1] = message.get("item.offer.id");
+ }
this.transitionToRoute.apply(this, route);
}
},
diff --git a/app/controllers/receive_package.js b/app/controllers/receive_package.js
index e1ec937a4..022c15882 100644
--- a/app/controllers/receive_package.js
+++ b/app/controllers/receive_package.js
@@ -398,22 +398,11 @@ export default Ember.Controller.extend(AsyncTasksMixin, {
pkgUpdateError(pkg) {
const errorMessage =
pkg.get("errors.firstObject.message") ||
- pkg.get("adapterError.errors.firstObject.title");
- if (
- errorMessage === "Adapter Error" ||
- errorMessage.indexOf("Connection error") >= 0
- ) {
- this.get("messageBox").alert(
- "could not contact Stockit, try again later.",
- () => pkg.rollbackAttributes()
- );
- } else {
- this.get("messageBox").alert(
- pkg
- .get("errors")
- .getEach("message")
- .join("\n")
- );
+ pkg.get("adapterError.errors.firstObject.detail.errors.firstObject");
+
+ if (errorMessage) {
+ pkg.rollbackAttributes();
+ this.get("messageBox").alert(errorMessage);
}
}
}
diff --git a/app/controllers/review_offer.js b/app/controllers/review_offer.js
index 5cace66ef..e6ec32d0f 100644
--- a/app/controllers/review_offer.js
+++ b/app/controllers/review_offer.js
@@ -97,6 +97,17 @@ export default Ember.Controller.extend(AsyncTasksMixin, {
}
}),
+ deleteOffer(offer, path = this.get("backLinkPath")) {
+ this.set("cancelByMe", true);
+ this.runTask(offer.destroyRecord())
+ .then(() => this.transitionToRoute(path))
+ .catch(error => {
+ offer.rollbackAttributes();
+ throw error;
+ })
+ .finally(() => this.set("cancelByMe", false));
+ },
+
actions: {
toggleOfferOptions() {
this.toggleProperty("displayOfferOptions");
@@ -133,25 +144,36 @@ export default Ember.Controller.extend(AsyncTasksMixin, {
deleteOffer() {
this.send("toggleOfferOptions");
- var offer = this.get("model");
+ const offer = this.get("model");
this.get("messageBox").custom(
this.get("i18n").t("delete_confirm"),
this.get("i18n").t("review_offer.options.yes"),
() => {
- this.set("cancelByMe", true);
- this.runTask(offer.destroyRecord())
- .then(() => this.transitionToRoute(this.get("backLinkPath")))
- .catch(error => {
- offer.rollbackAttributes();
- throw error;
- })
- .finally(() => this.set("cancelByMe", false));
+ this.deleteOffer(offer);
},
this.get("i18n").t("review_item.not_now"),
null
);
},
+ transitionTo(path) {
+ const offer = this.get("model");
+ const items = offer.get("items");
+ if (!items.length) {
+ this.get("messageBox").custom(
+ this.get("i18n").t("review_offer.empty_offer_message"),
+ this.get("i18n").t("review_offer.options.yes"),
+ () => {
+ this.deleteOffer(offer, path);
+ },
+ this.get("i18n").t("review_item.not_now"),
+ null
+ );
+ } else {
+ this.transitionToRoute(path);
+ }
+ },
+
reopenOffer() {
this.runTask(async () => {
await this.get("offerService").reopenOffer(this.get("model"));
diff --git a/app/controllers/review_offer/share/index.js b/app/controllers/review_offer/share/index.js
index 0d9163222..644d32158 100644
--- a/app/controllers/review_offer/share/index.js
+++ b/app/controllers/review_offer/share/index.js
@@ -23,7 +23,6 @@ export default Ember.Controller.extend(AsyncTasksMixin, {
"allMessages.length",
"allMessages.@each.{senderId,recipientId}",
function() {
- const donorId = this.get("offer.createdById");
return this.get("allMessages")
.filterBy("offerId", this.get("offer.id"))
.filter(m =>
@@ -141,7 +140,7 @@ export default Ember.Controller.extend(AsyncTasksMixin, {
const t = k => this.get("i18n").t(k);
const district = this.getWithDefault(
"offer.createdBy.address.district.name",
- "N/A"
+ "Hong Kong"
);
const lines = [
`${t("review_offer.donor.district")}: ${district}`,
diff --git a/app/controllers/search.js b/app/controllers/search.js
index e81797393..b43d8ec16 100644
--- a/app/controllers/search.js
+++ b/app/controllers/search.js
@@ -76,15 +76,18 @@ export default Ember.Controller.extend(backNavigator, {
getFilterQuery() {
const filterService = this.get("filterService");
const isPriority = filterService.isPriority();
+ const isPublished = filterService.isPublished();
const { after, before } = filterService.get("offerTimeRange");
let stateFilters = _.without(
filterService.get("offerStateFilters"),
- "showPriority"
+ "priorityOffers",
+ "publishedOffers"
);
return {
state: utilityMethods.stringifyArray(stateFilters),
priority: isPriority,
+ shareable: isPublished,
after: after && after.getTime(),
before: before && before.getTime()
};
diff --git a/app/helpers/state-filter-icon.js b/app/helpers/state-filter-icon.js
index a29938402..83bc7d5b8 100644
--- a/app/helpers/state-filter-icon.js
+++ b/app/helpers/state-filter-icon.js
@@ -3,6 +3,7 @@ import { STATE_FILTERS } from "../services/filter-service";
const {
PRIORITY,
+ PUBLISHED,
NEW,
REVIEWING,
REVIEWED,
@@ -22,7 +23,8 @@ const STATE_ICONS = {
[RECEIVED]: "thumbs-up",
[CANCELLED]: "thumbs-down",
[INACTIVE]: "bed",
- [PRIORITY]: "warning"
+ [PRIORITY]: "warning",
+ [PUBLISHED]: "eye"
};
export default Ember.Helper.helper(function(state) {
diff --git a/app/locales/en/translations.coffee b/app/locales/en/translations.coffee
index 3411052d5..81ce409e2 100644
--- a/app/locales/en/translations.coffee
+++ b/app/locales/en/translations.coffee
@@ -91,7 +91,7 @@ I18nTranslationsEn =
month: "This month",
next_month: "Next month"
- show_priority_offers: "Only Show Priority Offers"
+ show_priority_offers: "Only Show ..."
offer_statuses: "Offer Statuses"
on_or_after: "On or after"
on_or_before: "On or before"
@@ -103,8 +103,10 @@ I18nTranslationsEn =
time_filter_title: "Offer Due Date"
button_state: "State"
button_due: "Due"
- showPriority: "Show Priority"
- showPriority_info: "Have remained in a state too long. Need attention."
+ priorityOffers: "Priority Offers"
+ priorityOffers_info: "Have remained in a state too long. Need attention."
+ publishedOffers: "Published Offers"
+ publishedOffers_info: "Shared on charity site"
submitted: "New"
submitted_info: "Offers that have yet to be reviewed."
under_review: "Reviewing"
@@ -250,6 +252,7 @@ I18nTranslationsEn =
"close_offer_summary": "This will close the offer."
"add_note": "Tap to add/edit sticky note"
"tap_to_save": "tap to save"
+ "empty_offer_message": "This offer is empty. Do you want to delete it?"
"donor":
"offer_id": "Offer ID"
@@ -318,6 +321,7 @@ I18nTranslationsEn =
"assign": "Assign"
"select_package_image": "Choose the favourite image for this package:"
+
"reject":
"select_type": "Please choose Item Type first!"
"option_error": "Please choose a reason."
@@ -353,6 +357,8 @@ I18nTranslationsEn =
"not_now": "Not Now"
"begin_receiving": "Begin Receiving"
+ "inventorize_warning": "Are you sure you want to inventorize?"
+
"finished":
"title": "Finished"
"received": "Received"
@@ -471,5 +477,9 @@ I18nTranslationsEn =
"canned_response":
"title": "Manage pro-forma messages"
-
+ "en_content": "English content cannot be blank"
+ "en_label": "English label be blank"
+ "delete_message": "Delete Message"
+ "label": "Label"
+ "message": "Message"
`export default I18nTranslationsEn`
diff --git a/app/locales/zh-tw/translations.coffee b/app/locales/zh-tw/translations.coffee
index 807a92f15..9df74c124 100644
--- a/app/locales/zh-tw/translations.coffee
+++ b/app/locales/zh-tw/translations.coffee
@@ -91,7 +91,7 @@ I18nTranslationsZhTw =
month: "This month",
next_month: "Next month"
- show_priority_offers: "Only Show Priority Offers"
+ show_priority_offers: "Only Show ..."
offer_statuses: "Offer Statuses"
on_or_after: "On or after"
on_or_before: "On or before"
@@ -102,8 +102,10 @@ I18nTranslationsZhTw =
all_review: "All"
time_filter_title: "Offer Due Date"
button_state: "State"
- showPriority: "Show Priority"
- showPriority_info: "Have remained in a state too long. Need attention."
+ priorityOffers: "Priority Offers"
+ priorityOffers_info: "Have remained in a state too long. Need attention."
+ publishedOffers: "Published Offers"
+ publishedOffers_info: "Shared on charity site"
submitted: "New"
submitted_info: "Offers that have yet to be reviewed."
under_review: "Reviewing"
@@ -248,6 +250,7 @@ I18nTranslationsZhTw =
"close_offer_summary": "這項捐贈項目將列為完成。"
"add_note": "按下以增加/修改記事板"
"tap_to_save": "按下以儲存"
+ "empty_offer_message": "這個捐贈沒有任何相關物資。你是否需要刪除"
"donor":
"offer_id": "捐贈項目號碼"
@@ -349,7 +352,8 @@ I18nTranslationsZhTw =
"header": "開始接收捐贈項目"
"cant_modify_note": "提示:一旦捐贈項目狀態改成「正在接收」,將無法還原,捐贈人士亦無法更改物資資料。"
"not_now": "現在無法進行"
- "begin_receiving": "開始接收"
+ "begin_receiving": "開始接收",
+ "inventorize_warning": "Are you sure you want to inventorize?"
"finished":
@@ -470,5 +474,10 @@ I18nTranslationsZhTw =
"canned_response":
"title": "Manage pro-forma messages"
+ "en_content": "English content cannot be blank"
+ "en_label": "English label be blank"
+ "delete_message": "Delete Message"
+ "label": "Label"
+ "message": "Message"
`export default I18nTranslationsZhTw`
diff --git a/app/models/canned_response.js b/app/models/canned_response.js
index cb32207a2..554720ee5 100644
--- a/app/models/canned_response.js
+++ b/app/models/canned_response.js
@@ -4,6 +4,7 @@ import attr from "ember-data/attr";
export default Model.extend({
name: attr("string"),
nameEn: attr("string"),
+ nameZhTw: attr("string"),
content: attr("string"),
contentEn: attr("string"),
contentZhTw: attr("string")
diff --git a/app/models/message.js b/app/models/message.js
index 262a07704..11b7b94ce 100644
--- a/app/models/message.js
+++ b/app/models/message.js
@@ -69,6 +69,10 @@ export default DS.Model.extend({
const donorId = this.get("offer.createdById");
+ if (!donorId) {
+ return !this.get("isPrivate");
+ }
+
// It's a chat with an external user (a charity) if:
// - It's public
// - It does not involve the donor
diff --git a/app/routes/receive_package.js b/app/routes/receive_package.js
index c5ab5bfc1..e1be58afa 100644
--- a/app/routes/receive_package.js
+++ b/app/routes/receive_package.js
@@ -36,7 +36,7 @@ export default AuthorizeRoute.extend({
model.get("inventoryNumber");
this.setupPrinterId(controller);
- if (model.get("isReceived")) {
+ if (model.get("isReceived") && model.get("inventoryNumber")) {
return controller.redirectToReceiveOffer();
}
if (!model.get("inventoryNumber")) {
diff --git a/app/routes/review_item.js b/app/routes/review_item.js
index 837f42929..c76a117eb 100644
--- a/app/routes/review_item.js
+++ b/app/routes/review_item.js
@@ -1,26 +1,32 @@
-import AuthorizeRoute from './authorize';
+import AuthorizeRoute from "./authorize";
export default AuthorizeRoute.extend({
-
editItemRequest: "",
- beforeModel(){
+ beforeModel() {
var previousRoutes = this.router.router.currentHandlerInfos;
var previousRoute = previousRoutes && previousRoutes.pop();
- if(previousRoute){
- var editItemRequest = ["review_offer.items", "review_offer.receive"].indexOf(previousRoute.name) >= 0;
+ if (previousRoute) {
+ var editItemRequest =
+ ["review_offer.items", "review_offer.receive"].indexOf(
+ previousRoute.name
+ ) >= 0;
this.set("editItemRequest", editItemRequest);
}
},
model(params) {
- return this.store.findRecord('item', params.item_id);
+ return this.store.findRecord("item", params.item_id);
},
setupController(controller, model) {
this._super(controller, model);
+ this.set(
+ "existingPackageType",
+ model.get("packageType") && model.get("packageType").id
+ );
- if((this.get("editItemRequest"))){
+ if (this.get("editItemRequest")) {
var itemDetails = {
donorConditionId: model.get("donorConditionId"),
donorDescription: model.get("donorDescription")
diff --git a/app/services/filter-service.js b/app/services/filter-service.js
index 8f1e766bd..73d38850e 100644
--- a/app/services/filter-service.js
+++ b/app/services/filter-service.js
@@ -24,7 +24,8 @@ const PERSISTENT_VAR = function(propName, defaultValue, deserializeMap = {}) {
};
export const STATE_FILTERS = {
- PRIORITY: "showPriority",
+ PRIORITY: "priorityOffers",
+ PUBLISHED: "publishedOffers",
NEW: "submitted",
REVIEWING: "under_review",
REVIEWED: "reviewed",
@@ -48,6 +49,11 @@ export default Ember.Service.extend(Ember.Evented, {
return filters && filters.indexOf(STATE_FILTERS.PRIORITY) >= 0;
},
+ isPublished() {
+ const filters = this.get("offerStateFilters");
+ return _.includes(filters, STATE_FILTERS.PUBLISHED);
+ },
+
clearOfferStateFilters() {
this.set("offerStateFilters", []);
},
diff --git a/app/services/message-service.js b/app/services/message-service.js
index 40c13ab3f..ceb29978a 100644
--- a/app/services/message-service.js
+++ b/app/services/message-service.js
@@ -5,10 +5,16 @@ import ApiBaseService from "./api-base-service";
export default ApiBaseService.extend({
store: Ember.inject.service(),
+ editMessage: {
+ language: "en",
+ messageId: ""
+ },
init() {
this._super(...arguments);
this.set("isCannedMessagesVisible", false);
+ this.set("isProFormaMessageVisible", false);
+ this.set("isAddMessageVisible", false);
},
toggle() {
diff --git a/app/styles/_filters.scss b/app/styles/_filters.scss
index 1c5aa5242..976f59441 100644
--- a/app/styles/_filters.scss
+++ b/app/styles/_filters.scss
@@ -86,7 +86,7 @@
font-size: 1.2rem;
float: right;
@media #{$small-only} {
- margin-right: 8.5rem !important;
+ margin-right: 7.5rem !important;
}
@media #{$medium-only} {
margin-right: 22.2rem;
diff --git a/app/styles/templates/_dashboard.scss b/app/styles/templates/_dashboard.scss
index 98c6952b5..9523cdf61 100644
--- a/app/styles/templates/_dashboard.scss
+++ b/app/styles/templates/_dashboard.scss
@@ -78,7 +78,7 @@
justify-content: center;
img {
- height: -webkit-fill-available;
+ height: 89px;
@media #{$small-only} {
margin-left: -5%;
diff --git a/app/styles/templates/components/_canned-messages-overlay.scss b/app/styles/templates/components/_canned-messages-overlay.scss
index b6b0f68a8..388b45154 100644
--- a/app/styles/templates/components/_canned-messages-overlay.scss
+++ b/app/styles/templates/components/_canned-messages-overlay.scss
@@ -16,6 +16,19 @@
margin-left: 0%;
}
+ .tabs {
+ width: 50%;
+ padding-left: 15%;
+ margin-left: -10%;
+ float: left;
+ padding-top: 2%;
+ padding-bottom: 2%;
+ cursor: pointer;
+ }
+
+ .selected {
+ border-bottom: 2px solid #ddd;
+ }
.search-field {
flex: 0.8;
}
@@ -43,6 +56,80 @@
flex-direction: column;
margin-top: 1.5rem;
+ i.edit-pointer {
+ font-size: 200%;
+ }
+
+ .message-textarea {
+ background: #1A3A64;
+ border: 1px solid #002352;
+ color: #8496AE;
+ width: 98%;
+ font-size: 100%;
+ }
+
+ .edit-message {
+ display: flex;
+
+
+ .disabled {
+ color: #bab3b3;
+ cursor: default;
+ }
+
+ .input-error {
+ background: #f46769;
+ color: #fff;
+ padding: .2rem;
+ width: 98%;
+ margin-top: -5%;
+ margin-bottom: 5%;
+ }
+ }
+
+ .create-btn{
+ width: 50%;
+ margin-left: 30%;
+ }
+
+ span.label {
+ flex: 1;
+ text-align: center;
+ }
+
+ span.content {
+ flex: 5;
+ }
+
+ .light-button {
+ border: 1px solid #fff;
+ max-width: 16rem;
+ height: 2rem;
+ text-align: center;
+ cursor: pointer;
+ color: #fff;
+ background: #002352;
+ float: right;
+ font-size: 100%;
+ padding-bottom: 2.5%;
+ padding-top: 1%;
+ padding-left: 5%;
+ padding-right: 5%;
+ margin-right: 25%;
+
+
+ @media #{$small-only} {
+ line-height: 2rem;
+ font-size: 120%;
+ padding-bottom: 7.5%;
+ padding-top: 0.5%;
+ padding-left: 7%;
+ padding-right: 7%;
+ position: relative;
+ margin-right: 5%;
+ }
+ }
+
li {
margin-bottom: clamp(1rem, 5vw, 4rem);
diff --git a/app/templates/_global_components.hbs b/app/templates/_global_components.hbs
new file mode 100644
index 000000000..bc54c8e9e
--- /dev/null
+++ b/app/templates/_global_components.hbs
@@ -0,0 +1,10 @@
+{{#let-alias messageService as |s|}}
+ {{pro-forma-message-overlay
+ open=s.isProFormaMessageVisible
+ }}
+
+ {{add-edit-message-overlay
+ open=s.isAddMessageVisible
+ cannedMessageId=s.cannedMessageId
+ }}
+{{/let-alias}}
\ No newline at end of file
diff --git a/app/templates/_state_filters.hbs b/app/templates/_state_filters.hbs
index ee0f84422..e85f96d77 100644
--- a/app/templates/_state_filters.hbs
+++ b/app/templates/_state_filters.hbs
@@ -7,7 +7,12 @@
- {{offer-filter-checkbox name="showPriority"}}
+ {{offer-filter-checkbox name="priorityOffers"}}
+
+
+
+
+ {{offer-filter-checkbox name="publishedOffers"}}
diff --git a/app/templates/components/add-edit-message-overlay.hbs b/app/templates/components/add-edit-message-overlay.hbs
new file mode 100644
index 000000000..fcd5c7bda
--- /dev/null
+++ b/app/templates/components/add-edit-message-overlay.hbs
@@ -0,0 +1,64 @@
+
+ {{#popup-overlay open=open}}
+
+
+
+ {{if message.id "Edit" "Create"}} Message
+
+
+
+ {{#if message.id}}
+
+ {{t 'canned_response.delete_message'}}
+
+ {{/if}}
+
+
+ {{t 'canned_response.label'}}*
+
+ EN | 中文
+
+
+
+ {{#if isEnglish}}
+ {{textarea type='textarea' value=message.nameEn classNames="message-textarea" rows="5"}}
+ {{else}}
+ {{textarea type='textarea' value=message.nameZhTw classNames="message-textarea" rows="5"}}
+ {{/if}}
+ {{#unless message.nameEn}}
+ {{t 'canned_response.en_label'}}
+ {{/unless}}
+
+
+
+
+
+ {{t 'canned_response.message'}}*
+
+ EN | 中文
+
+
+
+ {{#if isEnglish}}
+ {{textarea type='textarea' value=message.contentEn classNames="message-textarea" rows="10"}}
+ {{else}}
+ {{textarea type='textarea' value=message.contentZhTw classNames="message-textarea" rows="10"}}
+ {{/if}}
+ {{#unless message.contentEn}}
+ {{t 'canned_response.en_content'}}
+ {{/unless}}
+
+
+
+
Done
+
+
+
+
+ {{/popup-overlay}}
+
\ No newline at end of file
diff --git a/app/templates/components/canned-messages-overlay.hbs b/app/templates/components/canned-messages-overlay.hbs
index 80758df66..4501e85b5 100644
--- a/app/templates/components/canned-messages-overlay.hbs
+++ b/app/templates/components/canned-messages-overlay.hbs
@@ -19,9 +19,10 @@
-
+ {{else if isReceivedWithoutInventory}}
+
+
+ {{t "receive.inventory"}}
+
{{else}}
-
-
- {{t "receive.inventory"}}
-
+
+
+ {{t "receive.inventory"}}
+
{{/if}}
diff --git a/app/templates/review_offer.hbs b/app/templates/review_offer.hbs
index 31328034d..584e5fc4c 100644
--- a/app/templates/review_offer.hbs
+++ b/app/templates/review_offer.hbs
@@ -1,6 +1,6 @@
- {{#link-to backLinkPath classNames="back"}}{{t "back"}}{{/link-to}}
+ {{t "back"}}
diff --git a/package.json b/package.json
index 012de71b2..e378474fd 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "goodcity",
- "version": "0.18.0",
+ "version": "0.18.1",
"description": "The GoodCity Admin app enables administrators to process donated goods.",
"private": true,
"directories": {
@@ -9,6 +9,7 @@
},
"scripts": {
"start": "EMBER_CLI_CORDOVA=0 ENVIRONMENT=development ember serve --port 4201 --live-reload-port 35730",
+ "start:staging": "EMBER_CLI_CORDOVA=0 ENVIRONMENT=staging ember serve --port 4201 --live-reload-port 35730",
"test": "EMBER_CLI_CORDOVA=0 ENVIRONMENT=test ember test --server --test-port 7358",
"test:ci": "EMBER_CLI_CORDOVA=0 ENVIRONMENT=test ember-pretty-test",
"build:web:development": "EMBER_CLI_CORDOVA=0 ENVIRONMENT=development ember build",
diff --git a/tests/acceptance/accept-test.js b/tests/acceptance/accept-test.js
index 32ccb9a39..f28137c0e 100644
--- a/tests/acceptance/accept-test.js
+++ b/tests/acceptance/accept-test.js
@@ -43,6 +43,14 @@ module("Reviewer: Accept Item Tab", {
roles: [role.toJSON({ includeId: true })]
}
});
+ $.mockjax({
+ url: "/api/v1/canned*",
+ type: "GET",
+ status: 200,
+ responseText: {
+ canned_responses: []
+ }
+ });
$.mockjax({
url: "/api/v1/donor_condition*",
diff --git a/tests/acceptance/app-menu-test.js b/tests/acceptance/app-menu-test.js
index bb7c5cdee..8e4d26261 100644
--- a/tests/acceptance/app-menu-test.js
+++ b/tests/acceptance/app-menu-test.js
@@ -37,6 +37,14 @@ module("App Menu", {
responseText: {
roles: [role.toJSON({ includeId: true })]
}
+ }),
+ $.mockjax({
+ url: "/api/v1/canned*",
+ type: "GET",
+ status: 200,
+ responseText: {
+ canned_responses: []
+ }
})
);
diff --git a/tests/acceptance/authorization-test.js b/tests/acceptance/authorization-test.js
index 967b3f78f..7b7ed99b5 100644
--- a/tests/acceptance/authorization-test.js
+++ b/tests/acceptance/authorization-test.js
@@ -18,6 +18,14 @@ module("Authorization", {
roles: [role.toJSON({ includeId: true })]
}
});
+ $.mockjax({
+ url: "/api/v1/canned*",
+ type: "GET",
+ status: 200,
+ responseText: {
+ canned_responses: []
+ }
+ });
},
afterEach: function() {
Ember.run(App, "destroy");
diff --git a/tests/acceptance/closed-offers-test.js b/tests/acceptance/closed-offers-test.js
index 7c750aa4c..89513b6f6 100644
--- a/tests/acceptance/closed-offers-test.js
+++ b/tests/acceptance/closed-offers-test.js
@@ -1,29 +1,43 @@
-import Ember from 'ember';
-import { module, test } from 'qunit';
-import startApp from '../helpers/start-app';
-import '../factories/offer';
-import '../factories/item';
-import FactoryGuy from 'ember-data-factory-guy';
-import '../factories/role';
-import TestHelper from 'ember-data-factory-guy/factory-guy-test-helper';
+import Ember from "ember";
+import { module, test } from "qunit";
+import startApp from "../helpers/start-app";
+import "../factories/offer";
+import "../factories/item";
+import FactoryGuy from "ember-data-factory-guy";
+import "../factories/role";
+import TestHelper from "ember-data-factory-guy/factory-guy-test-helper";
var App, offer, item, role;
-module('Closed Offer', {
+module("Closed Offer", {
beforeEach: function() {
App = startApp({}, 2);
TestHelper.setup();
offer = FactoryGuy.make("offer", { state: "closed" });
item = FactoryGuy.make("item", { state: "rejected", offer: offer });
role = FactoryGuy.make("role");
- $.mockjax({url: '/api/v1/role*', type: 'GET', status: 200,responseText: {
- roles: [role.toJSON({includeId: true})]
+ $.mockjax({
+ url: "/api/v1/role*",
+ type: "GET",
+ status: 200,
+ responseText: {
+ roles: [role.toJSON({ includeId: true })]
+ }
+ });
+ $.mockjax({
+ url: "/api/v1/canned*",
+ type: "GET",
+ status: 200,
+ responseText: {
+ canned_responses: []
}
});
},
afterEach: function() {
- Em.run(function() { TestHelper.teardown(); });
- Ember.run(App, 'destroy');
+ Em.run(function() {
+ TestHelper.teardown();
+ });
+ Ember.run(App, "destroy");
}
});
@@ -31,7 +45,7 @@ test("display closed offer with rejected items", function(assert) {
assert.expect(2);
visit("/offers/" + offer.id + "/review_offer/items");
- andThen(function(){
+ andThen(function() {
assert.equal(currentURL(), "/offers/" + offer.id + "/review_offer/items");
assert.equal(find(".reject_badge").length, 1);
});
@@ -41,10 +55,20 @@ test("display logistics tab of closed offer", function(assert) {
assert.expect(2);
visit("/offers/" + offer.id + "/review_offer/logistics");
- andThen(function(){
- assert.equal(currentURL(), "/offers/" + offer.id + "/review_offer/logistics");
+ andThen(function() {
+ assert.equal(
+ currentURL(),
+ "/offers/" + offer.id + "/review_offer/logistics"
+ );
- var logistics_text = $.trim($('.noTransportItems').text().replace(/\s+/g, " "));
- assert.equal(logistics_text, "No items to transport. This offer is closed now.");
+ var logistics_text = $.trim(
+ $(".noTransportItems")
+ .text()
+ .replace(/\s+/g, " ")
+ );
+ assert.equal(
+ logistics_text,
+ "No items to transport. This offer is closed now."
+ );
});
});
diff --git a/tests/acceptance/complete_review_offer_test.js b/tests/acceptance/complete_review_offer_test.js
index 2b5aa5c51..669a4a435 100644
--- a/tests/acceptance/complete_review_offer_test.js
+++ b/tests/acceptance/complete_review_offer_test.js
@@ -33,6 +33,15 @@ module("In Review Offers", {
}
});
+ $.mockjax({
+ url: "/api/v1/canned*",
+ type: "GET",
+ status: 200,
+ responseText: {
+ canned_responses: []
+ }
+ });
+
$.mockjax({
url: "/api/v1/canned_respons*",
type: "GET",
diff --git a/tests/acceptance/index-test.js b/tests/acceptance/index-test.js
index 4ff42eb6e..e1daae83f 100644
--- a/tests/acceptance/index-test.js
+++ b/tests/acceptance/index-test.js
@@ -29,6 +29,14 @@ module("Home Page", {
roles: [role.toJSON({ includeId: true })]
}
});
+ $.mockjax({
+ url: "/api/v1/canned*",
+ type: "GET",
+ status: 200,
+ responseText: {
+ canned_responses: []
+ }
+ });
item = FactoryGuy.make("item", { state: "submitted", offer: offer1 });
message2 = FactoryGuy.make("message", {
diff --git a/tests/acceptance/login-test.js b/tests/acceptance/login-test.js
index 414cb81fa..0d3981f1f 100644
--- a/tests/acceptance/login-test.js
+++ b/tests/acceptance/login-test.js
@@ -22,6 +22,14 @@ module("Acceptance: Login", {
roles: [role.toJSON({ includeId: true })]
}
});
+ $.mockjax({
+ url: "/api/v1/canned*",
+ type: "GET",
+ status: 200,
+ responseText: {
+ canned_responses: []
+ }
+ });
reviewer1 = FactoryGuy.make("user", { isReviwer: true });
offer1 = FactoryGuy.make("offer", { state: "receiving" });
offer2 = FactoryGuy.make("offer", { state: "submitted" });
diff --git a/tests/acceptance/logistic-tab-test.js b/tests/acceptance/logistic-tab-test.js
index c75498181..6d34d5686 100644
--- a/tests/acceptance/logistic-tab-test.js
+++ b/tests/acceptance/logistic-tab-test.js
@@ -47,6 +47,14 @@ module("Review Offer Logistics", {
roles: [role.toJSON({ includeId: true })]
}
});
+ $.mockjax({
+ url: "/api/v1/canned*",
+ type: "GET",
+ status: 200,
+ responseText: {
+ canned_responses: []
+ }
+ });
reviewer = FactoryGuy.make("user");
offer = FactoryGuy.make("offer", {
diff --git a/tests/acceptance/my-notifications-test.js b/tests/acceptance/my-notifications-test.js
index f63ba8a34..06ab288d6 100644
--- a/tests/acceptance/my-notifications-test.js
+++ b/tests/acceptance/my-notifications-test.js
@@ -91,6 +91,14 @@ module("Reviewer: Notifications", {
roles: [role.toJSON({ includeId: true })]
}
}),
+ $.mockjax({
+ url: "/api/v1/canned*",
+ type: "GET",
+ status: 200,
+ responseText: {
+ canned_responses: []
+ }
+ }),
$.mockjax({
url: "/api/v1/message*",
type: "GET",
diff --git a/tests/acceptance/not-found-test.js b/tests/acceptance/not-found-test.js
index d37e7c5ae..0902ac0f2 100644
--- a/tests/acceptance/not-found-test.js
+++ b/tests/acceptance/not-found-test.js
@@ -1,29 +1,42 @@
-import Ember from 'ember';
-import { module, test } from 'qunit';
-import '../factories/offer';
-import startApp from '../helpers/start-app';
-import testSkip from '../helpers/test-skip';
-import FactoryGuy from 'ember-data-factory-guy';
-import '../factories/role';
+import Ember from "ember";
+import { module, test } from "qunit";
+import "../factories/offer";
+import startApp from "../helpers/start-app";
+import testSkip from "../helpers/test-skip";
+import FactoryGuy from "ember-data-factory-guy";
+import "../factories/role";
var App, offer, t, role;
-module('Display not found error', {
+module("Display not found error", {
beforeEach: function() {
App = startApp();
Ember.run.later = () => true;
offer = FactoryGuy.make("offer");
- var i18n = App.__container__.lookup('service:i18n');
+ var i18n = App.__container__.lookup("service:i18n");
t = i18n.t.bind(i18n);
role = FactoryGuy.make("role");
- $.mockjax({url: '/api/v1/role*', type: 'GET', status: 200,responseText: {
- roles: [role.toJSON({includeId: true})]
+ $.mockjax({
+ url: "/api/v1/role*",
+ type: "GET",
+ status: 200,
+ responseText: {
+ roles: [role.toJSON({ includeId: true })]
+ }
+ });
+
+ $.mockjax({
+ url: "/api/v1/canned*",
+ type: "GET",
+ status: 200,
+ responseText: {
+ canned_responses: []
}
});
App.__container__.lookup("service:logger").error = () => {};
},
afterEach: function() {
- Ember.run(App, 'destroy');
+ Ember.run(App, "destroy");
}
});
@@ -32,33 +45,39 @@ module('Display not found error', {
testSkip("Display error popup for invalid offer", function(assert) {
assert.expect(1);
- $('.reveal-modal').remove();
+ $(".reveal-modal").remove();
visit("/offers/invalid/review_offer/items");
- andThen(function(){
+ andThen(function() {
assert.equal(Ember.$("#messageBoxText").text(), t("404_error").toString());
- Ember.$('#errorModal').foundation('reveal', 'close');
+ Ember.$("#errorModal").foundation("reveal", "close");
});
});
testSkip("Display error popup for invalid item", function(assert) {
assert.expect(1);
- $('.reveal-modal').remove();
+ $(".reveal-modal").remove();
visit("/offers/" + offer.id + "/review_item/invalid/accept");
- $.mockjax({url:"/api/v1/items/*",status:404});
+ $.mockjax({ url: "/api/v1/items/*", status: 404 });
- andThen(function(){
+ andThen(function() {
assert.equal(Ember.$("#messageBoxText").text(), t("404_error").toString());
- Ember.$('#errorModal').foundation('reveal', 'close');
+ Ember.$("#errorModal").foundation("reveal", "close");
});
});
test("Display not-found page for invalid url", function(assert) {
assert.expect(2);
- $('.reveal-modal').remove();
+ $(".reveal-modal").remove();
visit("/invalid_url");
- andThen(function(){
+ andThen(function() {
assert.equal(currentURL(), "/invalid_url");
- assert.notEqual(Ember.$(".xy-center").text().indexOf(t("not_found")), -1, "not found message found");
+ assert.notEqual(
+ Ember.$(".xy-center")
+ .text()
+ .indexOf(t("not_found")),
+ -1,
+ "not found message found"
+ );
});
});
diff --git a/tests/acceptance/receive-tab-close-options-test.js b/tests/acceptance/receive-tab-close-options-test.js
index 3ed2ba985..a0ae16623 100644
--- a/tests/acceptance/receive-tab-close-options-test.js
+++ b/tests/acceptance/receive-tab-close-options-test.js
@@ -1,81 +1,126 @@
-import Ember from 'ember';
-import startApp from '../helpers/start-app';
-import '../factories/orders_package';
-import '../factories/packages_location';
-import { module, test } from 'qunit';
-import '../factories/offer';
-import FactoryGuy from 'ember-data-factory-guy';
-import TestHelper from 'ember-data-factory-guy/factory-guy-test-helper';
-import '../factories/role';
+import Ember from "ember";
+import startApp from "../helpers/start-app";
+import "../factories/orders_package";
+import "../factories/packages_location";
+import { module, test } from "qunit";
+import "../factories/offer";
+import FactoryGuy from "ember-data-factory-guy";
+import TestHelper from "ember-data-factory-guy/factory-guy-test-helper";
+import "../factories/role";
var App, ofr1, item, pkg1, pkg2, pkg3, order_pkg, packages_location, role;
-module('Received Tab close options', {
+module("Received Tab close options", {
beforeEach: function() {
App = startApp({}, 2);
TestHelper.setup();
- item = FactoryGuy.make("item", {state: "accepted"});
+ item = FactoryGuy.make("item", { state: "accepted" });
ofr1 = FactoryGuy.make("offer", { state: "received", items: [item] });
packages_location = FactoryGuy.make("packages_location");
role = FactoryGuy.make("role");
- $.mockjax({url: '/api/v1/role*', type: 'GET', status: 200,responseText: {
- roles: [role.toJSON({includeId: true})]
+ $.mockjax({
+ url: "/api/v1/role*",
+ type: "GET",
+ status: 200,
+ responseText: {
+ roles: [role.toJSON({ includeId: true })]
}
});
- order_pkg = FactoryGuy.make("orders_package", { id: 500, state: "designated", quantity: 6});
- pkg1 = FactoryGuy.make("package", { offerId: parseInt(ofr1.id), state: "expecting", item: item});
- pkg2 = FactoryGuy.make("package", { offerId: parseInt(ofr1.id), state: "expecting", item: item});
- pkg3 = FactoryGuy.make("package", { offerId: parseInt(ofr1.id), state: "expecting", item: item});
-
+ $.mockjax({
+ url: "/api/v1/canned*",
+ type: "GET",
+ status: 200,
+ responseText: {
+ canned_responses: []
+ }
+ });
+ order_pkg = FactoryGuy.make("orders_package", {
+ id: 500,
+ state: "designated",
+ quantity: 6
+ });
+ pkg1 = FactoryGuy.make("package", {
+ offerId: parseInt(ofr1.id),
+ state: "expecting",
+ item: item
+ });
+ pkg2 = FactoryGuy.make("package", {
+ offerId: parseInt(ofr1.id),
+ state: "expecting",
+ item: item
+ });
+ pkg3 = FactoryGuy.make("package", {
+ offerId: parseInt(ofr1.id),
+ state: "expecting",
+ item: item
+ });
},
afterEach: function() {
- Em.run(function() { TestHelper.teardown(); });
- Ember.run(App, 'destroy');
+ Em.run(function() {
+ TestHelper.teardown();
+ });
+ Ember.run(App, "destroy");
}
});
test("Clicking on receive item options closes other receive-options if already open", function(assert) {
assert.expect(2);
- visit("/offers/"+ofr1.id+"/review_offer/receive");
- $.mockjax({url: '/api/v1/packages_location*', type: 'GET', status: 200,responseText: {
- packages_locations: [packages_location.toJSON({includeId: true})]
+ visit("/offers/" + ofr1.id + "/review_offer/receive");
+ $.mockjax({
+ url: "/api/v1/packages_location*",
+ type: "GET",
+ status: 200,
+ responseText: {
+ packages_locations: [packages_location.toJSON({ includeId: true })]
}
});
- $.mockjax({url: '/api/v1/orders_package*', type: 'GET', status: 200,responseText: {
- orders_packages: [order_pkg.toJSON({includeId: true})]
+ $.mockjax({
+ url: "/api/v1/orders_package*",
+ type: "GET",
+ status: 200,
+ responseText: {
+ orders_packages: [order_pkg.toJSON({ includeId: true })]
}
});
- andThen(function(){
+ andThen(function() {
//clicking on item options of first package
- Ember.$('.options-link-open.' + pkg1.id).click();
- assert.equal($('.receive-options').not('.hidden').length, 1);
+ Ember.$(".options-link-open." + pkg1.id).click();
+ assert.equal($(".receive-options").not(".hidden").length, 1);
//clicking on item optins of second package
- Ember.$('.options-link-open.' + pkg2.id).click();
+ Ember.$(".options-link-open." + pkg2.id).click();
//checking if item option is closed for first package
- assert.equal($('.receive-options .hidden').length, 0);
+ assert.equal($(".receive-options .hidden").length, 0);
});
});
test("Clicking on other item detail closes item options", function(assert) {
assert.expect(2);
- visit("/offers/"+ofr1.id+"/review_offer/receive");
- $.mockjax({url: '/api/v1/packages_location*', type: 'GET', status: 200,responseText: {
- packages_locations: [packages_location.toJSON({includeId: true})]
+ visit("/offers/" + ofr1.id + "/review_offer/receive");
+ $.mockjax({
+ url: "/api/v1/packages_location*",
+ type: "GET",
+ status: 200,
+ responseText: {
+ packages_locations: [packages_location.toJSON({ includeId: true })]
}
});
- $.mockjax({url: '/api/v1/orders_package*', type: 'GET', status: 200,responseText: {
- orders_packages: [order_pkg.toJSON({includeId: true})]
+ $.mockjax({
+ url: "/api/v1/orders_package*",
+ type: "GET",
+ status: 200,
+ responseText: {
+ orders_packages: [order_pkg.toJSON({ includeId: true })]
}
});
- andThen(function(){
+ andThen(function() {
//clicking on item options of first package
- Ember.$('.options-link-open.' + pkg1.id).click();
- assert.equal($('.receive-options').not('.hidden').length, 1);
+ Ember.$(".options-link-open." + pkg1.id).click();
+ assert.equal($(".receive-options").not(".hidden").length, 1);
//clicking on item status of second package
- Ember.$('.package-expecting:first div div').click();
+ Ember.$(".package-expecting:first div div").click();
//checking if item option is closed for first package
- assert.equal(Ember.$('.receive-options').not('.hidden').length, 0);
+ assert.equal(Ember.$(".receive-options").not(".hidden").length, 0);
});
});
diff --git a/tests/acceptance/receive_package_test.js b/tests/acceptance/receive_package_test.js
index cea379c3d..439243655 100644
--- a/tests/acceptance/receive_package_test.js
+++ b/tests/acceptance/receive_package_test.js
@@ -51,6 +51,14 @@ module("Receive package", {
roles: [role.toJSON({ includeId: true })]
}
});
+ $.mockjax({
+ url: "/api/v1/canned*",
+ type: "GET",
+ status: 200,
+ responseText: {
+ canned_responses: []
+ }
+ });
$.mockjax({
url: "/api/v1/offer*",
diff --git a/tests/acceptance/received-test.js b/tests/acceptance/received-test.js
index 1f4a6ac37..b669f1b19 100644
--- a/tests/acceptance/received-test.js
+++ b/tests/acceptance/received-test.js
@@ -1,60 +1,120 @@
-import Ember from 'ember';
-import startApp from '../helpers/start-app';
-import '../factories/orders_package';
-import '../factories/packages_location';
-import { module, test } from 'qunit';
-import '../factories/offer';
-import '../factories/role';
-import FactoryGuy from 'ember-data-factory-guy';
-import TestHelper from 'ember-data-factory-guy/factory-guy-test-helper';
+import Ember from "ember";
+import startApp from "../helpers/start-app";
+import "../factories/orders_package";
+import "../factories/packages_location";
+import { module, test } from "qunit";
+import "../factories/offer";
+import "../factories/role";
+import FactoryGuy from "ember-data-factory-guy";
+import TestHelper from "ember-data-factory-guy/factory-guy-test-helper";
-var App, offer1, item1, package1, package2, package3, orders_pkg1, packages_location, role;
+var App,
+ offer1,
+ item1,
+ package1,
+ package2,
+ package3,
+ orders_pkg1,
+ packages_location,
+ role;
-module('Received Offers', {
+module("Received Offers", {
beforeEach: function() {
App = startApp({}, 2);
TestHelper.setup();
role = FactoryGuy.make("role");
- $.mockjax({url: '/api/v1/role*', type: 'GET', status: 200,responseText: {
- roles: [role.toJSON({includeId: true})]
+ $.mockjax({
+ url: "/api/v1/role*",
+ type: "GET",
+ status: 200,
+ responseText: {
+ roles: [role.toJSON({ includeId: true })]
}
});
- item1 = FactoryGuy.make("item", {state: "accepted"});
+ $.mockjax({
+ url: "/api/v1/canned*",
+ type: "GET",
+ status: 200,
+ responseText: {
+ canned_responses: []
+ }
+ });
+ item1 = FactoryGuy.make("item", { state: "accepted" });
offer1 = FactoryGuy.make("offer", { state: "received", items: [item1] });
packages_location = FactoryGuy.make("packages_location");
- orders_pkg1 = FactoryGuy.make("orders_package", { id: 500, state: "designated", quantity: 6});
- package1 = FactoryGuy.make("package", { offerId: parseInt(offer1.id), state: "received", item: item1});
- package2 = FactoryGuy.make("package", { offerId: parseInt(offer1.id), state: "expecting", item: item1});
- package3 = FactoryGuy.make("package", { offerId: parseInt(offer1.id), state: "missing", item: item1});
-
+ orders_pkg1 = FactoryGuy.make("orders_package", {
+ id: 500,
+ state: "designated",
+ quantity: 6
+ });
+ package1 = FactoryGuy.make("package", {
+ offerId: parseInt(offer1.id),
+ state: "received",
+ item: item1
+ });
+ package2 = FactoryGuy.make("package", {
+ offerId: parseInt(offer1.id),
+ state: "expecting",
+ item: item1
+ });
+ package3 = FactoryGuy.make("package", {
+ offerId: parseInt(offer1.id),
+ state: "missing",
+ item: item1
+ });
},
afterEach: function() {
- Em.run(function() { TestHelper.teardown(); });
- Ember.run(App, 'destroy');
+ Em.run(function() {
+ TestHelper.teardown();
+ });
+ Ember.run(App, "destroy");
}
});
test("expecting, received and missing count", function(assert) {
assert.expect(3);
- visit("/offers/"+offer1.id+"/review_offer/receive");
- $.mockjax({url: '/api/v1/packages_location*', type: 'GET', status: 200,responseText: {
- packages_locations: [packages_location.toJSON({includeId: true})]
+ visit("/offers/" + offer1.id + "/review_offer/receive");
+ $.mockjax({
+ url: "/api/v1/packages_location*",
+ type: "GET",
+ status: 200,
+ responseText: {
+ packages_locations: [packages_location.toJSON({ includeId: true })]
}
});
- $.mockjax({url: '/api/v1/orders_package*', type: 'GET', status: 200,responseText: {
- orders_packages: [orders_pkg1.toJSON({includeId: true})]
+ $.mockjax({
+ url: "/api/v1/orders_package*",
+ type: "GET",
+ status: 200,
+ responseText: {
+ orders_packages: [orders_pkg1.toJSON({ includeId: true })]
}
});
- andThen(function(){
+ andThen(function() {
//expecting
- var href = "/offers/"+offer1.id+"/review_offer/receive";
- assert.equal($('a[href="'+href+'"]:last').text().trim(), "Expecting(1)");
+ var href = "/offers/" + offer1.id + "/review_offer/receive";
+ assert.equal(
+ $('a[href="' + href + '"]:last')
+ .text()
+ .trim(),
+ "Expecting(1)"
+ );
//received
- var href1 = href +"?state=received";
- assert.equal($('a[href="'+href1+'"]:last').text().trim(), "Received(1)");
+ var href1 = href + "?state=received";
+ assert.equal(
+ $('a[href="' + href1 + '"]:last')
+ .text()
+ .trim(),
+ "Received(1)"
+ );
//missing
- href1 = href +"?state=missing";
- assert.equal($('a[href="'+href1+'"]').text().trim(), "Missing(1)");
+ href1 = href + "?state=missing";
+ assert.equal(
+ $('a[href="' + href1 + '"]')
+ .text()
+ .trim(),
+ "Missing(1)"
+ );
});
});
diff --git a/tests/acceptance/reject-test.js b/tests/acceptance/reject-test.js
index 708cd78c8..7316326b8 100644
--- a/tests/acceptance/reject-test.js
+++ b/tests/acceptance/reject-test.js
@@ -41,6 +41,15 @@ module("Reviewer: Reject Item Tab", {
}
});
+ $.mockjax({
+ url: "/api/v1/canned*",
+ type: "GET",
+ status: 200,
+ responseText: {
+ canned_responses: []
+ }
+ });
+
offer = FactoryGuy.make("offer", {
state: "under_review"
});
diff --git a/tests/acceptance/review-item-test.js b/tests/acceptance/review-item-test.js
index 173aaf4c5..3bc1d04f0 100644
--- a/tests/acceptance/review-item-test.js
+++ b/tests/acceptance/review-item-test.js
@@ -49,6 +49,14 @@ module("Display review Item", {
roles: [role.toJSON({ includeId: true })]
}
});
+ $.mockjax({
+ url: "/api/v1/canned*",
+ type: "GET",
+ status: 200,
+ responseText: {
+ canned_responses: []
+ }
+ });
$.mockjax({
url: "/api/v1/packages_location*",
type: "GET",
diff --git a/tests/acceptance/reviewer-item-messages-test.js b/tests/acceptance/reviewer-item-messages-test.js
index 06b284204..5cddb2de7 100644
--- a/tests/acceptance/reviewer-item-messages-test.js
+++ b/tests/acceptance/reviewer-item-messages-test.js
@@ -8,7 +8,7 @@ import "../factories/offer";
import "../factories/item";
import "../factories/role";
-var App, offer, item, message1, message2, message3, role;
+var App, offer, item, message1, message2, message3, role, donor;
module("Reviewer: Display Item Messages", {
beforeEach: function() {
@@ -23,20 +23,35 @@ module("Reviewer: Display Item Messages", {
roles: [role.toJSON({ includeId: true })]
}
});
- offer = { id: "300", state: "under_review" };
+
+ $.mockjax({
+ url: "/api/v1/canned*",
+ type: "GET",
+ status: 200,
+ responseText: {
+ canned_responses: []
+ }
+ });
+
+ donor = { id: "1000", first_name: "jane", last_name: "doe" };
+ offer = { id: "300", state: "under_review", created_by_id: 1000 };
item = { id: "110", state: "submitted", offer_id: offer.id };
message1 = {
id: "44",
offer_id: offer.id,
item_id: item.id,
- created_at: new Date("2015/1/1").toString()
+ created_at: new Date("2015/1/1").toString(),
+ is_private: false,
+ sender_id: donor.id
};
message2 = {
id: "45",
offer_id: offer.id,
item_id: item.id,
body: "Message from Donor",
- created_at: new Date("2015/1/2").toString()
+ created_at: new Date("2015/1/2").toString(),
+ is_private: false,
+ sender_id: donor.id
};
message3 = {
id: "46",
@@ -51,7 +66,8 @@ module("Reviewer: Display Item Messages", {
type: "GET",
status: 200,
responseText: {
- messages: [message1, message2, message3]
+ messages: [message1, message2, message3],
+ users: [donor]
}
});
@@ -62,7 +78,8 @@ module("Reviewer: Display Item Messages", {
responseText: {
items: [item],
offers: [offer],
- messages: [message1, message2, message3]
+ messages: [message1, message2, message3],
+ users: [donor]
}
});
diff --git a/tests/acceptance/reviewer-item-status-message-test.js b/tests/acceptance/reviewer-item-status-message-test.js
index d4f5a4568..7ca962ac5 100644
--- a/tests/acceptance/reviewer-item-status-message-test.js
+++ b/tests/acceptance/reviewer-item-status-message-test.js
@@ -1,92 +1,146 @@
-import Ember from 'ember';
-import startApp from '../helpers/start-app';
-import FactoryGuy from 'ember-data-factory-guy';
-import TestHelper from 'ember-data-factory-guy/factory-guy-test-helper';
-import { module, test } from 'qunit';
-import '../factories/offer';
-import '../factories/item';
-import '../factories/role';
-
-var App, offer1, offer2, item2, item1, item3, item4,
- offer3, item5, role;
-
-module('Reviewer: Display Item Status', {
+import Ember from "ember";
+import startApp from "../helpers/start-app";
+import FactoryGuy from "ember-data-factory-guy";
+import TestHelper from "ember-data-factory-guy/factory-guy-test-helper";
+import { module, test } from "qunit";
+import "../factories/offer";
+import "../factories/item";
+import "../factories/role";
+
+var App, offer1, offer2, item2, item1, item3, item4, offer3, item5, role;
+
+module("Reviewer: Display Item Status", {
beforeEach: function() {
App = startApp({}, 2);
TestHelper.setup();
role = FactoryGuy.make("role");
- $.mockjax({url: '/api/v1/role*', type: 'GET', status: 200,responseText: {
- roles: [role.toJSON({includeId: true})]
+ $.mockjax({
+ url: "/api/v1/role*",
+ type: "GET",
+ status: 200,
+ responseText: {
+ roles: [role.toJSON({ includeId: true })]
}
});
- offer1 = FactoryGuy.make("offer", {state:"submitted"});
- item1 = FactoryGuy.make("item", {offer: offer1, state:"submitted"});
+ $.mockjax({
+ url: "/api/v1/canned*",
+ type: "GET",
+ status: 200,
+ responseText: {
+ canned_responses: []
+ }
+ });
+
+ offer1 = FactoryGuy.make("offer", { state: "submitted" });
+ item1 = FactoryGuy.make("item", { offer: offer1, state: "submitted" });
- offer2 = FactoryGuy.make("offer", {state:"under_review"});
- item2 = FactoryGuy.make("item", {offer: offer2, state:"submitted"});
- item3 = FactoryGuy.make("item", {offer: offer2, state:"accepted"});
- item4 = FactoryGuy.make("item", {offer: offer2, state:"rejected"});
+ offer2 = FactoryGuy.make("offer", { state: "under_review" });
+ item2 = FactoryGuy.make("item", { offer: offer2, state: "submitted" });
+ item3 = FactoryGuy.make("item", { offer: offer2, state: "accepted" });
+ item4 = FactoryGuy.make("item", { offer: offer2, state: "rejected" });
- offer3 = FactoryGuy.make("offer", {state:"cancelled"});
- item5 = FactoryGuy.make("item", {offer: offer3, state:"accepted"});
+ offer3 = FactoryGuy.make("offer", { state: "cancelled" });
+ item5 = FactoryGuy.make("item", { offer: offer3, state: "accepted" });
},
afterEach: function() {
- Em.run(function() { TestHelper.teardown(); });
- Ember.run(App, 'destroy');
+ Em.run(function() {
+ TestHelper.teardown();
+ });
+ Ember.run(App, "destroy");
}
});
test("Display item status for submitted item", function(assert) {
assert.expect(2);
- visit('/offers/' + offer1.id + "/review_item/"+ item1.id +"/accept");
+ visit("/offers/" + offer1.id + "/review_item/" + item1.id + "/accept");
andThen(function() {
- assert.equal(currentURL(), '/offers/' + offer1.id + "/review_item/"+ item1.id +"/accept");
- assert.equal($.trim(find('.status-message').text()), "This item is awaiting review.");
+ assert.equal(
+ currentURL(),
+ "/offers/" + offer1.id + "/review_item/" + item1.id + "/accept"
+ );
+ assert.equal(
+ $.trim(find(".status-message").text()),
+ "This item is awaiting review."
+ );
});
});
test("Display item status for under review item", function(assert) {
assert.expect(2);
- visit('/offers/' + offer2.id + "/review_item/"+ item2.id +"/accept");
+ visit("/offers/" + offer2.id + "/review_item/" + item2.id + "/accept");
andThen(function() {
- assert.equal(currentURL(), '/offers/' + offer2.id + "/review_item/"+ item2.id +"/accept");
- assert.equal($.trim(find('.status-message').text()), "This item is being reviewed.");
+ assert.equal(
+ currentURL(),
+ "/offers/" + offer2.id + "/review_item/" + item2.id + "/accept"
+ );
+ assert.equal(
+ $.trim(find(".status-message").text()),
+ "This item is being reviewed."
+ );
});
});
test("Display item status for accepted item", function(assert) {
assert.expect(2);
- visit('/offers/' + offer2.id + "/review_item/"+ item3.id +"/accept");
+ visit("/offers/" + offer2.id + "/review_item/" + item3.id + "/accept");
andThen(function() {
- assert.equal(currentURL(), '/offers/' + offer2.id + "/review_item/"+ item3.id +"/accept");
- assert.equal($.trim(find('.status-message').text()), "This item has been accepted.");
+ assert.equal(
+ currentURL(),
+ "/offers/" + offer2.id + "/review_item/" + item3.id + "/accept"
+ );
+ assert.equal(
+ $.trim(find(".status-message").text()),
+ "This item has been accepted."
+ );
});
});
test("Display offer status for reviewed offer", function(assert) {
assert.expect(2);
- visit('/offers/' + offer2.id + "/review_item/"+ item4.id +"/reject");
+ visit("/offers/" + offer2.id + "/review_item/" + item4.id + "/reject");
andThen(function() {
- assert.equal(currentURL(), '/offers/' + offer2.id + "/review_item/"+ item4.id +"/reject");
- assert.equal($.trim(find('.status-message').text()), "This item has been rejected.");
+ assert.equal(
+ currentURL(),
+ "/offers/" + offer2.id + "/review_item/" + item4.id + "/reject"
+ );
+ assert.equal(
+ $.trim(find(".status-message").text()),
+ "This item has been rejected."
+ );
});
});
test("Display offer status for reviewed offer", function(assert) {
assert.expect(2);
- visit('/offers/' + offer3.id + "/review_item/"+ item5.id +"/accept");
+ visit("/offers/" + offer3.id + "/review_item/" + item5.id + "/accept");
andThen(function() {
- assert.equal(currentURL(), '/offers/' + offer3.id + "/review_item/"+ item5.id +"/accept");
-
- var donor_name = offer3.get("createdBy.firstName") + " " + offer3.get("createdBy.lastName");
-
- assert.equal($('.status-message').text().trim().indexOf("The offer this item belongs to has been cancelled by " + donor_name + " on") >= 0, true);
+ assert.equal(
+ currentURL(),
+ "/offers/" + offer3.id + "/review_item/" + item5.id + "/accept"
+ );
+
+ var donor_name =
+ offer3.get("createdBy.firstName") +
+ " " +
+ offer3.get("createdBy.lastName");
+
+ assert.equal(
+ $(".status-message")
+ .text()
+ .trim()
+ .indexOf(
+ "The offer this item belongs to has been cancelled by " +
+ donor_name +
+ " on"
+ ) >= 0,
+ true
+ );
});
});
diff --git a/tests/acceptance/reviewer-offer-messages-test.js b/tests/acceptance/reviewer-offer-messages-test.js
index 8e9f08bc1..06615d005 100644
--- a/tests/acceptance/reviewer-offer-messages-test.js
+++ b/tests/acceptance/reviewer-offer-messages-test.js
@@ -18,7 +18,7 @@ var App,
message5,
user1,
user2,
- offer1,
+ offer2,
role;
module("Reviewer: Display Offer Messages", {
@@ -34,31 +34,41 @@ module("Reviewer: Display Offer Messages", {
roles: [role.toJSON({ includeId: true })]
}
});
+
+ $.mockjax({
+ url: "/api/v1/canned*",
+ type: "GET",
+ status: 200,
+ responseText: {
+ canned_responses: []
+ }
+ });
user1 = FactoryGuy.make("user");
user2 = FactoryGuy.make("user_with_image");
- offer = { id: 33, state: "under_review" };
- offer1 = { id: 34, createdBy: user1, state: "under_review" };
+ offer = { id: 33, created_by_id: user1.get("id"), state: "under_review" };
+ offer2 = { id: 34, created_by_id: user2.get("id"), state: "under_review" };
message4 = {
id: 81,
- offer_id: offer1.id,
- sender: user2.get("id"),
- item_id: null,
- body: "Message from donor1",
- created_at: new Date("2015/1/1").toString()
- };
- message5 = {
- id: 82,
- offer_id: offer1.id,
+ offer_id: offer.id,
sender_id: user1.get("id"),
item_id: null,
- body: "Message from donor2",
- created_at: new Date("2015/1/2").toString()
+ body: "Message from donor 1",
+ created_at: new Date("2015/1/1").toString()
};
message1 = {
id: 83,
+ offer_id: offer2.id,
+ item: null,
+ created_at: new Date("2015/1/3").toString(),
+ sender_id: user2.get("id")
+ };
+ message2 = {
+ id: 85,
offer_id: offer.id,
item: null,
- created_at: new Date("2015/1/3").toString()
+ body: "Message from Donor",
+ created_at: new Date("2015/1/4").toString(),
+ sender_id: user1.get("id")
};
message3 = {
id: 84,
@@ -67,22 +77,19 @@ module("Reviewer: Display Offer Messages", {
body: "Message from Supervisor",
is_private: true
};
- message2 = {
- id: 85,
- offer_id: offer.id,
- item: null,
- body: "Message from Donor",
- created_at: new Date("2015/1/4").toString()
- };
- let messages = [message1, message2, message3, message4, message5];
- let offers = [offer, offer1];
+ let messages = [message1, message2, message3, message4];
+ let offers = [offer, offer2];
+ let users = [
+ user1.toJSON({ includeId: true }),
+ user2.toJSON({ includeId: true })
+ ];
$.mockjax({
url: "/api/v1/message*",
type: "GET",
status: 200,
- responseText: { messages }
+ responseText: { messages, users, offers }
});
$.mockjax({
@@ -98,7 +105,7 @@ module("Reviewer: Display Offer Messages", {
url: "/api/v1/offer*",
type: "GET",
status: 200,
- responseText: { offers, messages }
+ responseText: { offers, messages, users }
});
},
@@ -183,7 +190,7 @@ test("offer-messages from staff should add unread bubble in supervisor message t
testSkip("offer-message with image", function(assert) {
assert.expect(1);
- visit("/offers/" + offer1.id + "/donor_messages");
+ visit("/offers/" + offer2.id + "/donor_messages");
andThen(function() {
var src = $(".received_message#" + message4.id + " img").attr("src");
assert.equal(src.indexOf("cloudinary") > 0, true);
diff --git a/tests/acceptance/reviewer-offer-status-messages-test.js b/tests/acceptance/reviewer-offer-status-messages-test.js
index c7ddc7a80..8379cfce2 100644
--- a/tests/acceptance/reviewer-offer-status-messages-test.js
+++ b/tests/acceptance/reviewer-offer-status-messages-test.js
@@ -1,100 +1,165 @@
-import Ember from 'ember';
-import startApp from '../helpers/start-app';
-import FactoryGuy from 'ember-data-factory-guy';
-import TestHelper from 'ember-data-factory-guy/factory-guy-test-helper';
-import { module, test } from 'qunit';
-import '../factories/user';
-import '../factories/offer';
-import '../factories/item';
-import '../factories/schedule';
-import '../factories/gogovan_order';
-import '../factories/delivery';
-import '../factories/role';
-
-var App, offer1, offer2, reviewer, reviewerName,
- offer7, offer3, offer4, delivery1, delivery2, offer5, delivery3, offer6,
- offer8, item8, offer9, item9, offer10, schedule, ggv_order11, delivery11,
- offer11, offer12, role;
-
-module('Reviewer: Display Offer Status', {
+import Ember from "ember";
+import startApp from "../helpers/start-app";
+import FactoryGuy from "ember-data-factory-guy";
+import TestHelper from "ember-data-factory-guy/factory-guy-test-helper";
+import { module, test } from "qunit";
+import "../factories/user";
+import "../factories/offer";
+import "../factories/item";
+import "../factories/schedule";
+import "../factories/gogovan_order";
+import "../factories/delivery";
+import "../factories/role";
+
+var App,
+ offer1,
+ offer2,
+ reviewer,
+ reviewerName,
+ offer7,
+ offer3,
+ offer4,
+ delivery1,
+ delivery2,
+ offer5,
+ delivery3,
+ offer6,
+ offer8,
+ item8,
+ offer9,
+ item9,
+ offer10,
+ schedule,
+ ggv_order11,
+ delivery11,
+ offer11,
+ offer12,
+ role;
+
+module("Reviewer: Display Offer Status", {
beforeEach: function() {
App = startApp({}, 2);
TestHelper.setup();
role = FactoryGuy.make("role");
- $.mockjax({url: '/api/v1/role*', type: 'GET', status: 200,responseText: {
- roles: [role.toJSON({includeId: true})]
+ $.mockjax({
+ url: "/api/v1/role*",
+ type: "GET",
+ status: 200,
+ responseText: {
+ roles: [role.toJSON({ includeId: true })]
+ }
+ });
+
+ $.mockjax({
+ url: "/api/v1/canned*",
+ type: "GET",
+ status: 200,
+ responseText: {
+ canned_responses: []
}
});
reviewer = FactoryGuy.make("user");
- offer1 = FactoryGuy.make("offer_with_items", {state:"submitted"});
+ offer1 = FactoryGuy.make("offer_with_items", { state: "submitted" });
- offer2 = FactoryGuy.make("offer_with_items", {state:"under_review", reviewedBy: reviewer});
+ offer2 = FactoryGuy.make("offer_with_items", {
+ state: "under_review",
+ reviewedBy: reviewer
+ });
reviewerName = reviewer.get("firstName") + " " + reviewer.get("lastName");
- offer3 = FactoryGuy.make("offer_with_items", {state:"reviewed"});
+ offer3 = FactoryGuy.make("offer_with_items", { state: "reviewed" });
- schedule = FactoryGuy.make('schedule', {scheduledAt: '12/01/2014'});
- delivery1 = FactoryGuy.make('delivery', {deliveryType: "Alternate", schedule: schedule});
- offer4 = FactoryGuy.make("offer_with_items", {state:"scheduled", delivery: delivery1});
+ schedule = FactoryGuy.make("schedule", { scheduledAt: "12/01/2014" });
+ delivery1 = FactoryGuy.make("delivery", {
+ deliveryType: "Alternate",
+ schedule: schedule
+ });
+ offer4 = FactoryGuy.make("offer_with_items", {
+ state: "scheduled",
+ delivery: delivery1
+ });
- delivery2 = FactoryGuy.make('delivery', {deliveryType: "Gogovan", schedule: schedule});
- offer5 = FactoryGuy.make("offer_with_items", {state:"scheduled", delivery: delivery2});
+ delivery2 = FactoryGuy.make("delivery", {
+ deliveryType: "Gogovan",
+ schedule: schedule
+ });
+ offer5 = FactoryGuy.make("offer_with_items", {
+ state: "scheduled",
+ delivery: delivery2
+ });
- delivery3 = FactoryGuy.make('delivery', {deliveryType: "Drop Off", schedule: schedule});
- offer6 = FactoryGuy.make("offer_with_items", {state:"scheduled", delivery: delivery3});
+ delivery3 = FactoryGuy.make("delivery", {
+ deliveryType: "Drop Off",
+ schedule: schedule
+ });
+ offer6 = FactoryGuy.make("offer_with_items", {
+ state: "scheduled",
+ delivery: delivery3
+ });
- offer7 = FactoryGuy.make("offer_with_items", { state:"closed", reviewedBy: reviewer });
+ offer7 = FactoryGuy.make("offer_with_items", {
+ state: "closed",
+ reviewedBy: reviewer
+ });
- offer8 = FactoryGuy.make("offer", { state:"under_review" });
+ offer8 = FactoryGuy.make("offer", { state: "under_review" });
item8 = FactoryGuy.make("item", { state: "rejected", offer: offer8 });
- offer9 = FactoryGuy.make("offer", { state:"under_review" });
+ offer9 = FactoryGuy.make("offer", { state: "under_review" });
item9 = FactoryGuy.make("item", { state: "accepted", offer: offer9 });
- offer10 = FactoryGuy.make("offer_with_items", { state:"received" });
+ offer10 = FactoryGuy.make("offer_with_items", { state: "received" });
ggv_order11 = FactoryGuy.make("gogovan_active_order");
- delivery11 = FactoryGuy.make("delivery", { deliveryType: "Gogovan", gogovanOrder: ggv_order11 });
- offer11 = FactoryGuy.make("offer_with_items", {state:"scheduled", delivery: delivery11});
- offer12 = FactoryGuy.make("offer_with_items", {state:"cancelled"});
+ delivery11 = FactoryGuy.make("delivery", {
+ deliveryType: "Gogovan",
+ gogovanOrder: ggv_order11
+ });
+ offer11 = FactoryGuy.make("offer_with_items", {
+ state: "scheduled",
+ delivery: delivery11
+ });
+ offer12 = FactoryGuy.make("offer_with_items", { state: "cancelled" });
},
afterEach: function() {
- Em.run(function() { TestHelper.teardown(); });
- Ember.run(App, 'destroy');
+ Em.run(function() {
+ TestHelper.teardown();
+ });
+ Ember.run(App, "destroy");
}
});
test("Display offer status for submitted offer", function(assert) {
assert.expect(2);
- visit('/offers/' + offer1.id + "/review_offer/items");
+ visit("/offers/" + offer1.id + "/review_offer/items");
andThen(function() {
assert.equal(currentURL(), "/offers/" + offer1.id + "/review_offer/items");
- assert.equal($.trim(find('.status-message').text()), "Start Review");
+ assert.equal($.trim(find(".status-message").text()), "Start Review");
});
});
// display initial char with message
test("Display offer status for offer under review", function(assert) {
assert.expect(3);
- visit('/offers/' + offer2.id + "/review_offer/items");
+ visit("/offers/" + offer2.id + "/review_offer/items");
andThen(function() {
assert.equal(currentURL(), "/offers/" + offer2.id + "/review_offer/items");
// message detail
- var status = $.trim(find('.status-message').text());
- assert.equal(status.indexOf("Started by "+ reviewerName) >= 0, true);
- assert.equal(status.indexOf(reviewer.get('nameInitial')) >= 0, true);
+ var status = $.trim(find(".status-message").text());
+ assert.equal(status.indexOf("Started by " + reviewerName) >= 0, true);
+ assert.equal(status.indexOf(reviewer.get("nameInitial")) >= 0, true);
});
});
test("Display offer status for reviewed offer", function(assert) {
assert.expect(1);
- visit('/offers/' + offer3.id + "/review_offer/items");
+ visit("/offers/" + offer3.id + "/review_offer/items");
andThen(function() {
assert.equal(currentURL(), "/offers/" + offer3.id + "/review_offer/items");
@@ -106,48 +171,73 @@ test("Display offer status for reviewed offer", function(assert) {
test("Display offer status for scheduled offer: Collection", function(assert) {
assert.expect(2);
- visit('/offers/' + offer4.id + "/review_offer/items");
+ visit("/offers/" + offer4.id + "/review_offer/items");
andThen(function() {
assert.equal(currentURL(), "/offers/" + offer4.id + "/review_offer/items");
- assert.equal($.trim(find('.status-message').text().replace(/\s{2,}/g, ' ')), "Collection Mon 1st Dec Afternoon");
+ assert.equal(
+ $.trim(
+ find(".status-message")
+ .text()
+ .replace(/\s{2,}/g, " ")
+ ),
+ "Collection Mon 1st Dec Afternoon"
+ );
});
});
test("Display offer status for scheduled offer: Gogovan pending", function(assert) {
assert.expect(2);
- visit('/offers/' + offer5.id + "/review_offer/items");
+ visit("/offers/" + offer5.id + "/review_offer/items");
andThen(function() {
assert.equal(currentURL(), "/offers/" + offer5.id + "/review_offer/items");
- assert.equal($.trim(find('.status-message').text().replace(/\s{2,}/g, ' ')), "Van ordered Afternoon, 2pm-4pm Mon 1st Dec");
+ assert.equal(
+ $.trim(
+ find(".status-message")
+ .text()
+ .replace(/\s{2,}/g, " ")
+ ),
+ "Van ordered Afternoon, 2pm-4pm Mon 1st Dec"
+ );
});
});
test("Display offer status for scheduled offer: Gogovan active", function(assert) {
assert.expect(2);
- visit('/offers/' + offer11.id + "/review_offer/items");
+ visit("/offers/" + offer11.id + "/review_offer/items");
andThen(function() {
assert.equal(currentURL(), "/offers/" + offer11.id + "/review_offer/items");
- var status = $.trim(find('.status-message').text().replace(/\s{2,}/g, ' '));
+ var status = $.trim(
+ find(".status-message")
+ .text()
+ .replace(/\s{2,}/g, " ")
+ );
assert.equal(status.indexOf("Van confirmed Afternoon, 2pm-4pm") >= 0, true);
});
});
test("Display offer status for scheduled offer: Drop Off", function(assert) {
assert.expect(2);
- visit('/offers/' + offer6.id + "/review_offer/items");
+ visit("/offers/" + offer6.id + "/review_offer/items");
andThen(function() {
assert.equal(currentURL(), "/offers/" + offer6.id + "/review_offer/items");
- assert.equal($.trim(find('.status-message').text().replace(/\s{2,}/g, ' ')), "Drop-off Mon 1st Dec Afternoon");
+ assert.equal(
+ $.trim(
+ find(".status-message")
+ .text()
+ .replace(/\s{2,}/g, " ")
+ ),
+ "Drop-off Mon 1st Dec Afternoon"
+ );
});
});
test("Display offer status for closed offer", function(assert) {
assert.expect(1);
- visit('/offers/' + offer7.id + "/review_offer/items");
+ visit("/offers/" + offer7.id + "/review_offer/items");
andThen(function() {
assert.equal(currentURL(), "/offers/" + offer7.id + "/review_offer/items");
@@ -157,42 +247,69 @@ test("Display offer status for closed offer", function(assert) {
test("Display offer status for all rejected items", function(assert) {
assert.expect(2);
- visit('/offers/' + offer8.id + "/review_offer/items");
+ visit("/offers/" + offer8.id + "/review_offer/items");
andThen(function() {
assert.equal(currentURL(), "/offers/" + offer8.id + "/review_offer/items");
- assert.equal($.trim(find('.status-message').text()).indexOf("No items needed") >= 0, true);
+ assert.equal(
+ $.trim(find(".status-message").text()).indexOf("No items needed") >= 0,
+ true
+ );
});
});
test("Display offer status for all reviewed items", function(assert) {
assert.expect(2);
- visit('/offers/' + offer9.id + "/review_offer/items");
+ visit("/offers/" + offer9.id + "/review_offer/items");
andThen(function() {
assert.equal(currentURL(), "/offers/" + offer9.id + "/review_offer/items");
- assert.equal(find('.status-message').text().replace(/ /g,' ').indexOf("All items reviewed") >= 0, true);
+ assert.equal(
+ find(".status-message")
+ .text()
+ .replace(/ /g, " ")
+ .indexOf("All items reviewed") >= 0,
+ true
+ );
});
});
test("Display offer status for received offer-items", function(assert) {
assert.expect(2);
- visit('/offers/' + offer10.id + "/review_offer/items");
+ visit("/offers/" + offer10.id + "/review_offer/items");
andThen(function() {
assert.equal(currentURL(), "/offers/" + offer10.id + "/review_offer/items");
- var donor_name = offer10.get("createdBy.firstName") + " " + offer10.get("createdBy.lastName");
- assert.equal($('.status-message').text().trim().indexOf("Goods donated by " + donor_name + " received") >= 0, true);
+ var donor_name =
+ offer10.get("createdBy.firstName") +
+ " " +
+ offer10.get("createdBy.lastName");
+ assert.equal(
+ $(".status-message")
+ .text()
+ .trim()
+ .indexOf("Goods donated by " + donor_name + " received") >= 0,
+ true
+ );
});
});
test("Display offer status for cancelled offer", function(assert) {
assert.expect(2);
- visit('/offers/' + offer12.id + "/review_offer/items");
+ visit("/offers/" + offer12.id + "/review_offer/items");
andThen(function() {
assert.equal(currentURL(), "/offers/" + offer12.id + "/review_offer/items");
- var donor_name = offer12.get("closedBy.firstName") + " " + offer12.get("closedBy.lastName");
- assert.equal($('.status-message').text().trim().indexOf("Cancelled by " + donor_name) >= 0, true);
+ var donor_name =
+ offer12.get("closedBy.firstName") +
+ " " +
+ offer12.get("closedBy.lastName");
+ assert.equal(
+ $(".status-message")
+ .text()
+ .trim()
+ .indexOf("Cancelled by " + donor_name) >= 0,
+ true
+ );
});
});
diff --git a/tests/acceptance/reviewer-reject-item-test.js b/tests/acceptance/reviewer-reject-item-test.js
index f4d99bbcd..44a053043 100644
--- a/tests/acceptance/reviewer-reject-item-test.js
+++ b/tests/acceptance/reviewer-reject-item-test.js
@@ -1,33 +1,48 @@
-import Ember from 'ember';
-import startApp from '../helpers/start-app';
-import FactoryGuy from 'ember-data-factory-guy';
-import TestHelper from 'ember-data-factory-guy/factory-guy-test-helper';
-import testSkip from '../helpers/test-skip';
-import { module, test } from 'qunit';
-import '../factories/offer';
-import '../factories/role';
+import Ember from "ember";
+import startApp from "../helpers/start-app";
+import FactoryGuy from "ember-data-factory-guy";
+import TestHelper from "ember-data-factory-guy/factory-guy-test-helper";
+import testSkip from "../helpers/test-skip";
+import { module, test } from "qunit";
+import "../factories/offer";
+import "../factories/role";
var App, offer, item1, item2, role;
-module('Reviewer: Rejct Item Tab', {
+module("Reviewer: Rejct Item Tab", {
beforeEach: function() {
App = startApp({}, 2);
TestHelper.setup();
role = FactoryGuy.make("role");
- $.mockjax({url: '/api/v1/role*', type: 'GET', status: 200,responseText: {
- roles: [role.toJSON({includeId: true})]
+ $.mockjax({
+ url: "/api/v1/role*",
+ type: "GET",
+ status: 200,
+ responseText: {
+ roles: [role.toJSON({ includeId: true })]
}
});
- offer = FactoryGuy.make("offer", { state:"under_review"});
- item1 = FactoryGuy.make("item_with_type", { offer: offer});
- item2 = FactoryGuy.make("item", { offer: offer});
+ $.mockjax({
+ url: "/api/v1/canned*",
+ type: "GET",
+ status: 200,
+ responseText: {
+ canned_responses: []
+ }
+ });
+
+ offer = FactoryGuy.make("offer", { state: "under_review" });
+ item1 = FactoryGuy.make("item_with_type", { offer: offer });
+ item2 = FactoryGuy.make("item", { offer: offer });
},
afterEach: function() {
- Em.run(function() { TestHelper.teardown(); });
- Ember.run(App, 'destroy');
+ Em.run(function() {
+ TestHelper.teardown();
+ });
+ Ember.run(App, "destroy");
}
});
@@ -35,9 +50,12 @@ test("visit rejected item without item_type", function(assert) {
assert.expect(3);
visit("/offers/" + offer.id + "/review_item/" + item2.id + "/reject");
andThen(function() {
- assert.equal(currentURL(), "/offers/" + offer.id + "/review_item/" + item2.id + "/reject");
- assert.equal($('.item_lable_input input').val(), "");
- assert.equal($('p.no-items').text(), "Please choose Item Type first!");
+ assert.equal(
+ currentURL(),
+ "/offers/" + offer.id + "/review_item/" + item2.id + "/reject"
+ );
+ assert.equal($(".item_lable_input input").val(), "");
+ assert.equal($("p.no-items").text(), "Please choose Item Type first!");
});
});
@@ -45,12 +63,21 @@ testSkip("visit rejected item with item_type", function(assert) {
assert.expect(4);
visit("/offers/" + offer.id + "/review_item/" + item1.id + "/reject");
andThen(function() {
- assert.equal(currentURL(), "/offers/" + offer.id + "/review_item/" + item1.id + "/reject");
- assert.equal($('.item_lable_input input').val(), item1.get('packageType.name'));
+ assert.equal(
+ currentURL(),
+ "/offers/" + offer.id + "/review_item/" + item1.id + "/reject"
+ );
+ assert.equal(
+ $(".item_lable_input input").val(),
+ item1.get("packageType.name")
+ );
assert.equal($(".reject-offer ul li").length, 4);
//placeholder message in recjectio comments textarea
- assert.equal($('textarea').attr('placeholder'), "Message to donor about the rejection of this item");
+ assert.equal(
+ $("textarea").attr("placeholder"),
+ "Message to donor about the rejection of this item"
+ );
});
});
@@ -58,9 +85,12 @@ test("validate at least one option selected", function(assert) {
assert.expect(2);
visit("/offers/" + offer.id + "/review_item/" + item1.id + "/reject");
andThen(function() {
- assert.equal(currentURL(), "/offers/" + offer.id + "/review_item/" + item1.id + "/reject");
- click('.rejectOffer');
- andThen(function(){
+ assert.equal(
+ currentURL(),
+ "/offers/" + offer.id + "/review_item/" + item1.id + "/reject"
+ );
+ click(".rejectOffer");
+ andThen(function() {
assert.equal($.trim($(".error-box").text()), "Please choose a reason.");
});
});
@@ -70,16 +100,22 @@ testSkip("display message for quality option", function(assert) {
assert.expect(3);
visit("/offers/" + offer.id + "/review_item/" + item1.id + "/reject");
andThen(function() {
- assert.equal(currentURL(), "/offers/" + offer.id + "/review_item/" + item1.id + "/reject");
- click($('input[type=radio]:eq(0)'));
- andThen(function(){
+ assert.equal(
+ currentURL(),
+ "/offers/" + offer.id + "/review_item/" + item1.id + "/reject"
+ );
+ click($("input[type=radio]:eq(0)"));
+ andThen(function() {
// set textarea conent on click of radio option
- assert.equal($('textarea').val(), "Unfortunately we cannot receive this item. Some categories of items are very difficult for us to distribute unless they are in excellent condition.");
+ assert.equal(
+ $("textarea").val(),
+ "Unfortunately we cannot receive this item. Some categories of items are very difficult for us to distribute unless they are in excellent condition."
+ );
// clear message conent on click of x-icon
- click($('.remove-text'));
- andThen(function(){
- assert.equal($('textarea').val(), "");
+ click($(".remove-text"));
+ andThen(function() {
+ assert.equal($("textarea").val(), "");
});
});
});
diff --git a/tests/acceptance/scheduled-test.js b/tests/acceptance/scheduled-test.js
index 04b5a47d6..f25294e2e 100644
--- a/tests/acceptance/scheduled-test.js
+++ b/tests/acceptance/scheduled-test.js
@@ -1,49 +1,91 @@
-import Ember from 'ember';
-import startApp from '../helpers/start-app';
-import FactoryGuy from 'ember-data-factory-guy';
-import TestHelper from 'ember-data-factory-guy/factory-guy-test-helper';
-import testSkip from '../helpers/test-skip';
-import { module } from 'qunit';
-import '../factories/user';
-import '../factories/offer';
-import '../factories/item';
-import '../factories/schedule';
-import '../factories/gogovan_order';
-import '../factories/delivery';
-import '../factories/role';
-
-var App, offer1, delivery1, offer2, delivery2, offer3,
- delivery3, schedule4, offer4, delivery4, ggv_order, role;
-
-module('Scheduled Offers', {
+import Ember from "ember";
+import startApp from "../helpers/start-app";
+import FactoryGuy from "ember-data-factory-guy";
+import TestHelper from "ember-data-factory-guy/factory-guy-test-helper";
+import testSkip from "../helpers/test-skip";
+import { module } from "qunit";
+import "../factories/user";
+import "../factories/offer";
+import "../factories/item";
+import "../factories/schedule";
+import "../factories/gogovan_order";
+import "../factories/delivery";
+import "../factories/role";
+
+var App,
+ offer1,
+ delivery1,
+ offer2,
+ delivery2,
+ offer3,
+ delivery3,
+ schedule4,
+ offer4,
+ delivery4,
+ ggv_order,
+ role;
+
+module("Scheduled Offers", {
beforeEach: function() {
App = startApp({}, 2);
TestHelper.setup();
role = FactoryGuy.make("role");
- $.mockjax({url: '/api/v1/role*', type: 'GET', status: 200,responseText: {
- roles: [role.toJSON({includeId: true})]
+ $.mockjax({
+ url: "/api/v1/role*",
+ type: "GET",
+ status: 200,
+ responseText: {
+ roles: [role.toJSON({ includeId: true })]
}
});
- delivery1 = FactoryGuy.make('delivery', {deliveryType: "Gogovan"});
- offer1 = FactoryGuy.make("offer_with_items", { state: "scheduled", delivery: delivery1 });
+ $.mockjax({
+ url: "/api/v1/canned*",
+ type: "GET",
+ status: 200,
+ responseText: {
+ canned_responses: []
+ }
+ });
- ggv_order = FactoryGuy.make("gogovan_order", {status: "pending"});
- schedule4 = FactoryGuy.make('schedule', {
- scheduledAt: (new Date(new Date().setDate(new Date().getDate()+30)))});
- delivery4 = FactoryGuy.make('delivery', {deliveryType: "Gogovan", schedule: schedule4, gogovanOrder: ggv_order });
- offer4 = FactoryGuy.make("offer_with_items", { state: "scheduled", delivery: delivery4 });
+ delivery1 = FactoryGuy.make("delivery", { deliveryType: "Gogovan" });
+ offer1 = FactoryGuy.make("offer_with_items", {
+ state: "scheduled",
+ delivery: delivery1
+ });
- delivery2 = FactoryGuy.make('delivery', {deliveryType: "Alternate"});
- offer2 = FactoryGuy.make("offer_with_items", { state: "scheduled", delivery: delivery2 });
+ ggv_order = FactoryGuy.make("gogovan_order", { status: "pending" });
+ schedule4 = FactoryGuy.make("schedule", {
+ scheduledAt: new Date(new Date().setDate(new Date().getDate() + 30))
+ });
+ delivery4 = FactoryGuy.make("delivery", {
+ deliveryType: "Gogovan",
+ schedule: schedule4,
+ gogovanOrder: ggv_order
+ });
+ offer4 = FactoryGuy.make("offer_with_items", {
+ state: "scheduled",
+ delivery: delivery4
+ });
- delivery3 = FactoryGuy.make('delivery', {deliveryType: "Drop Off"});
- offer3 = FactoryGuy.make("offer_with_items", { state: "scheduled", delivery: delivery3 });
+ delivery2 = FactoryGuy.make("delivery", { deliveryType: "Alternate" });
+ offer2 = FactoryGuy.make("offer_with_items", {
+ state: "scheduled",
+ delivery: delivery2
+ });
+
+ delivery3 = FactoryGuy.make("delivery", { deliveryType: "Drop Off" });
+ offer3 = FactoryGuy.make("offer_with_items", {
+ state: "scheduled",
+ delivery: delivery3
+ });
},
afterEach: function() {
- Em.run(function() { TestHelper.teardown(); });
- Ember.run(App, 'destroy');
+ Em.run(function() {
+ TestHelper.teardown();
+ });
+ Ember.run(App, "destroy");
}
});
@@ -51,12 +93,24 @@ testSkip("viewing collection schedule", function(assert) {
assert.expect(5);
visit("/offers/scheduled");
- andThen(function(){
+ andThen(function() {
assert.equal(currentURL(), "/offers/scheduled/collection");
assert.equal(find("ul.list li").length, 1);
assert.equal(find("ul.list img").length, 1);
- assert.equal($('.time_indicator').text().indexOf('Collection') > 0, true);
- assert.equal($.trim(find('.dynamic_filter select option').first().text()), "All offers (1)");
+ assert.equal(
+ $(".time_indicator")
+ .text()
+ .indexOf("Collection") > 0,
+ true
+ );
+ assert.equal(
+ $.trim(
+ find(".dynamic_filter select option")
+ .first()
+ .text()
+ ),
+ "All offers (1)"
+ );
});
});
@@ -64,11 +118,16 @@ testSkip("viewing gogovan delivery schedule", function(assert) {
assert.expect(4);
visit("/offers/scheduled/gogovan");
- andThen(function(){
+ andThen(function() {
assert.equal(currentURL(), "/offers/scheduled/gogovan");
assert.equal(find("ul.list li").length, 2);
assert.equal(find("ul.list img").length, 2);
- assert.equal($('.time_indicator').text().indexOf('Van ordered') > 0, true);
+ assert.equal(
+ $(".time_indicator")
+ .text()
+ .indexOf("Van ordered") > 0,
+ true
+ );
});
});
@@ -76,17 +135,29 @@ testSkip("filtering gogovan delivery schedule", function(assert) {
assert.expect(5);
visit("/offers/scheduled/gogovan");
- andThen(function(){
+ andThen(function() {
assert.equal(currentURL(), "/offers/scheduled/gogovan");
- var option = find('.dynamic_filter select option:contains("After next week (1)")').val();
- $('.dynamic_filter select').val(option).change();
-
- andThen(function(){
- assert.equal($.trim(find('.dynamic_filter select :selected').text()), "After next week (1)");
+ var option = find(
+ '.dynamic_filter select option:contains("After next week (1)")'
+ ).val();
+ $(".dynamic_filter select")
+ .val(option)
+ .change();
+
+ andThen(function() {
+ assert.equal(
+ $.trim(find(".dynamic_filter select :selected").text()),
+ "After next week (1)"
+ );
assert.equal(find("ul.list li").length, 1);
assert.equal(find("ul.list img").length, 1);
- assert.equal($('.time_indicator').text().indexOf('Van ordered') > 0, true);
+ assert.equal(
+ $(".time_indicator")
+ .text()
+ .indexOf("Van ordered") > 0,
+ true
+ );
});
});
});
@@ -95,10 +166,15 @@ testSkip("viewing other delivery schedule", function(assert) {
assert.expect(4);
visit("/offers/scheduled/other_delivery");
- andThen(function(){
+ andThen(function() {
assert.equal(currentURL(), "/offers/scheduled/other_delivery");
assert.equal(find("ul.list li").length, 1);
assert.equal(find("ul.list img").length, 1);
- assert.equal($('.time_indicator').text().indexOf('Drop-off') > 0, true);
+ assert.equal(
+ $(".time_indicator")
+ .text()
+ .indexOf("Drop-off") > 0,
+ true
+ );
});
});
diff --git a/tests/acceptance/search-test.js b/tests/acceptance/search-test.js
index 533389f66..20d829e3f 100644
--- a/tests/acceptance/search-test.js
+++ b/tests/acceptance/search-test.js
@@ -31,6 +31,15 @@ module("Search Offers", {
}
});
+ $.mockjax({
+ url: "/api/v1/canned*",
+ type: "GET",
+ status: 200,
+ responseText: {
+ canned_responses: []
+ }
+ });
+
user = FactoryGuy.make("user", { firstName: "Johnny", mobile: "99999999" });
offer = FactoryGuy.make("offer_with_items", {
state: "scheduled",
@@ -173,7 +182,7 @@ test("Checking multiple states checkboxes in State filter page applies number of
assert.equal(currentURL(), "/offers_filters?applyStateFilter=true");
click("#submitted");
noOfSelectedStates += 1;
- click("#showPriority");
+ click("#priorityOffers");
noOfSelectedStates += 1;
});
diff --git a/tests/acceptance/selecting-package-type-test.js b/tests/acceptance/selecting-package-type-test.js
index b8ccd6894..a2817626f 100644
--- a/tests/acceptance/selecting-package-type-test.js
+++ b/tests/acceptance/selecting-package-type-test.js
@@ -40,6 +40,15 @@ module("Reviewer: Select package type", {
}
});
+ $.mockjax({
+ url: "/api/v1/canned*",
+ type: "GET",
+ status: 200,
+ responseText: {
+ canned_responses: []
+ }
+ });
+
$.mockjax({
url: "/api/v1/package_types",
type: "GET",
diff --git a/yarn.lock b/yarn.lock
index 6e0b071e1..7625ef940 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -7795,11 +7795,16 @@ got@^8.0.1:
url-parse-lax "^3.0.0"
url-to-options "^1.0.1"
-graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.3, graceful-fs@^4.1.4, graceful-fs@^4.1.6, graceful-fs@^4.1.9, graceful-fs@^4.2.0:
+graceful-fs@^4.1.11, graceful-fs@^4.1.3, graceful-fs@^4.1.9, graceful-fs@^4.2.0:
version "4.2.4"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.4.tgz#2256bde14d3632958c465ebc96dc467ca07a29fb"
integrity sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw==
+graceful-fs@^4.1.2, graceful-fs@^4.1.4, graceful-fs@^4.1.6:
+ version "4.2.6"
+ resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.6.tgz#ff040b2b0853b23c3d31027523706f1885d76bee"
+ integrity sha512-nTnJ528pbqxYanhpDYsi4Rd8MAeaBA67+RZ10CM1m3bTAVFEDcd5AuA4a6W5YkGZ1iNXHzZz8T6TBKLeBuNriQ==
+
graceful-fs@~4.1.2, graceful-fs@~4.1.6, graceful-fs@~4.1.9:
version "4.1.15"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.15.tgz#ffb703e1066e8a0eeaa4c8b80ba9253eeefbfb00"
@@ -8572,7 +8577,7 @@ is-ci@^2.0.0:
dependencies:
ci-info "^2.0.0"
-is-core-module@^2.1.0:
+is-core-module@^2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.2.0.tgz#97037ef3d52224d85163f5597b2b63d9afed981a"
integrity sha512-XRAfAdyyY5F5cOXn7hYQDqh2Xmii+DEfIcQGxK/uNwMHhIkPWO0g8msXcbzLe+MpGoR951MlqM/2iIlU4vKDdQ==
@@ -9827,11 +9832,16 @@ lodash@^3.10.0, lodash@^3.10.1, lodash@^3.3.1, lodash@^3.5.0, lodash@^3.9.3:
resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6"
integrity sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y=
-lodash@^4.0.0, lodash@^4.17.11, lodash@^4.17.12, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.4, lodash@^4.3.0, lodash@^4.5.1, lodash@^4.6.1, lodash@~4.17.10:
+lodash@^4.0.0, lodash@^4.17.11, lodash@^4.17.12, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.4, lodash@^4.3.0, lodash@^4.5.1, lodash@^4.6.1, lodash@~4.17.10:
version "4.17.20"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52"
integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==
+lodash@^4.17.14:
+ version "4.17.21"
+ resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
+ integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
+
lodash@~2.4.1:
version "2.4.2"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-2.4.2.tgz#fadd834b9683073da179b3eae6d9c0d15053f73e"
@@ -12836,11 +12846,11 @@ resolve@^0.6.3:
integrity sha1-3ZV5gufnNt699TtYpN2RdUV13UY=
resolve@^1.1.2, resolve@^1.1.6, resolve@^1.10.0:
- version "1.19.0"
- resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.19.0.tgz#1af5bf630409734a067cae29318aac7fa29a267c"
- integrity sha512-rArEXAgsBG4UgRGcynxWIWKFvh/XZCcS8UJdHhwy91zwAvCZIbcs+vAbflgBnNjYMs/i/i+/Ux6IZhML1yPvxg==
+ version "1.20.0"
+ resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.20.0.tgz#629a013fb3f70755d6f0b7935cc1c2c5378b1975"
+ integrity sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A==
dependencies:
- is-core-module "^2.1.0"
+ is-core-module "^2.2.0"
path-parse "^1.0.6"
resolve@^1.1.3, resolve@^1.1.4, resolve@^1.11.1, resolve@^1.13.1, resolve@^1.17.0, resolve@^1.3.0, resolve@^1.3.2, resolve@^1.3.3, resolve@^1.4.0, resolve@^1.5.0, resolve@^1.8.1:
@@ -13259,7 +13269,7 @@ sha@~2.0.1:
"shared-goodcity@git://github.com/crossroads/shared.goodcity.git#master":
version "0.0.0"
- resolved "git://github.com/crossroads/shared.goodcity.git#a676df6f453bb8f390d8f90037c614c6d5bd45c5"
+ resolved "git://github.com/crossroads/shared.goodcity.git#006c006783ac6a87ff2d26bcf4df3a81482f1508"
dependencies:
cryptiles "^4.1.2"
ember-cli-babel "^5.1.6"
@@ -15340,7 +15350,12 @@ xtend@^4.0.0, xtend@^4.0.1, xtend@^4.0.2, xtend@~4.0.1:
resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54"
integrity sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==
-y18n@^3.2.0, y18n@^3.2.1:
+y18n@^3.2.0:
+ version "3.2.2"
+ resolved "https://registry.yarnpkg.com/y18n/-/y18n-3.2.2.tgz#85c901bd6470ce71fc4bb723ad209b70f7f28696"
+ integrity sha512-uGZHXkHnhF0XeeAPgnKfPv1bgKAYyVvmNL1xlKsPYZPaIHxGti2hHqvOCQv71XMsLxu1QjergkqogUnms5D3YQ==
+
+y18n@^3.2.1:
version "3.2.1"
resolved "https://registry.yarnpkg.com/y18n/-/y18n-3.2.1.tgz#6d15fba884c08679c0d77e88e7759e811e07fa41"
integrity sha1-bRX7qITAhnnA136I53WegR4H+kE=