From 98718e76af646daa2dd08c24d03b609b6f6211b3 Mon Sep 17 00:00:00 2001 From: hschallh Date: Fri, 7 Dec 2018 11:38:02 -0500 Subject: [PATCH 01/17] Re-add Reader document list VBMS/VVA timestamps * Remove shortcut to return null on nil manifest timestamp values that kept error messages from displaying * Add check for nil VBMS manifest timestamp References #6049 --- client/app/reader/LastRetrievalInfo.jsx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/client/app/reader/LastRetrievalInfo.jsx b/client/app/reader/LastRetrievalInfo.jsx index c3926f24e1e..25b9dc15814 100644 --- a/client/app/reader/LastRetrievalInfo.jsx +++ b/client/app/reader/LastRetrievalInfo.jsx @@ -4,12 +4,10 @@ import { connect } from 'react-redux'; class UnconnectedLastRetrievalInfo extends React.PureComponent { render() { - if (!this.props.manifestVbmsFetchedAt) { - return null; - } - return [ -
Last VBMS retrieval: {this.props.manifestVbmsFetchedAt}
, + this.props.manifestVbmsFetchedAt ? +
Last VBMS retrieval: {this.props.manifestVbmsFetchedAt}
: +
Unable to display VBMS documents at this time
, this.props.manifestVvaFetchedAt ?
Last VVA retrieval: {this.props.manifestVvaFetchedAt}
:
Unable to display VVA documents at this time
From 48a4dd6242f3f3e8a8c19d7b24f6265a6bcf6d6a Mon Sep 17 00:00:00 2001 From: hschallh Date: Fri, 7 Dec 2018 11:39:55 -0500 Subject: [PATCH 02/17] Add alert for documents not fetched from VBMS/VVA References #6049 --- client/app/reader/PdfListView.jsx | 6 ++++++ client/app/styles/reader/_document_list.scss | 4 ++++ spec/feature/reader/reader_spec.rb | 6 ++++-- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/client/app/reader/PdfListView.jsx b/client/app/reader/PdfListView.jsx index d1e5cd47e60..7c624b9aa3f 100644 --- a/client/app/reader/PdfListView.jsx +++ b/client/app/reader/PdfListView.jsx @@ -16,6 +16,7 @@ import NoSearchResults from './NoSearchResults'; import { fetchAppealDetails, onReceiveAppealDetails } from '../reader/PdfViewer/PdfViewerActions'; import { shouldFetchAppeal } from '../reader/utils'; import { DOCUMENTS_OR_COMMENTS_ENUM } from './DocumentList/actionTypes'; +import Alert from '../components/Alert'; export class PdfListView extends React.Component { componentDidMount() { @@ -67,6 +68,11 @@ export class PdfListView extends React.Component {
+ { (!this.props.manifestVbmsFetchedAt || !this.props.manifestVvaFetchedAt) && + + Some documents could not be loaded at this time + + } Date: Wed, 12 Dec 2018 11:00:51 -0500 Subject: [PATCH 03/17] Break alert out into its own component * Add check for stale manifests * Add warning alert for stale manifests --- client/app/reader/DocumentRetrevalAlert.jsx | 25 +++++++++++++++++++++ client/app/reader/PdfListView.jsx | 7 ++---- 2 files changed, 27 insertions(+), 5 deletions(-) create mode 100644 client/app/reader/DocumentRetrevalAlert.jsx diff --git a/client/app/reader/DocumentRetrevalAlert.jsx b/client/app/reader/DocumentRetrevalAlert.jsx new file mode 100644 index 00000000000..b10ad6ecf2a --- /dev/null +++ b/client/app/reader/DocumentRetrevalAlert.jsx @@ -0,0 +1,25 @@ +import React, { PureComponent } from 'react'; +import Alert from '../components/Alert'; + +export default class DocumentRetrevalAlert extends PureComponent { + render() { + if (!this.props.manifestVbmsFetchedAt || !this.props.manifestVvaFetchedAt) { + return + Some documents could not be loaded at this time + ; + } + + let cacheTimeoutHours = 3, + timeoutTimestamp = new Date(); + timeoutTimestamp.setHours(timeoutTimestamp.getHours() - cacheTimeoutHours); + + if (this.props.manifestVbmsFetchedAt < timeoutTimestamp.getTime() || + this.props.manifestVvaFetchedAt < timeoutTimestamp.getTime()) { + return + The document list may be stale + ; + } + + return null; + } +} diff --git a/client/app/reader/PdfListView.jsx b/client/app/reader/PdfListView.jsx index 7c624b9aa3f..25d472dc8de 100644 --- a/client/app/reader/PdfListView.jsx +++ b/client/app/reader/PdfListView.jsx @@ -5,6 +5,7 @@ import { connect } from 'react-redux'; import _ from 'lodash'; import BackToQueueLink from './BackToQueueLink'; +import DocumentRetrievalAlert from './DocumentRetrevalAlert'; import LastRetrievalInfo from './LastRetrievalInfo'; import AppSegment from '@department-of-veterans-affairs/caseflow-frontend-toolkit/components/AppSegment'; import DocumentListHeader from './DocumentListHeader'; @@ -68,11 +69,7 @@ export class PdfListView extends React.Component {
- { (!this.props.manifestVbmsFetchedAt || !this.props.manifestVvaFetchedAt) && - - Some documents could not be loaded at this time - - } + Date: Wed, 12 Dec 2018 11:03:32 -0500 Subject: [PATCH 04/17] Add testing for stale manifest warning --- spec/feature/reader/reader_spec.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/spec/feature/reader/reader_spec.rb b/spec/feature/reader/reader_spec.rb index 4f9bf591d7e..5fb3b45262c 100644 --- a/spec/feature/reader/reader_spec.rb +++ b/spec/feature/reader/reader_spec.rb @@ -243,6 +243,16 @@ def add_comment(text) end end + context "When VVA manifest retrieval time is older than the eFolder cache limit" do + let(:vva_fetched_ts) { Time.zone.now - 4.hours } + scenario "Both times display on the page and a warning alert is shown" do + visit "/reader/appeal/#{appeal.vacols_id}/documents" + expect(find("#vbms-manifest-retrieved-at").text).to have_content(vbms_ts_string) + expect(find("#vva-manifest-retrieved-at").text).to have_content(vva_ts_string) + expect(find(".section--document-list .usa-alert-warning").text).to have_content("The document list may be stale") + end + end + context "When VVA manifest retrieval time is nil" do let(:vva_fetched_ts) { nil } scenario "Only VBMS time displays on the page and error alert is shown" do From b08f8042453473347c027cca66683c0afec4bf33 Mon Sep 17 00:00:00 2001 From: hschallhorn Date: Wed, 12 Dec 2018 15:34:41 -0500 Subject: [PATCH 05/17] Finish logic for warning alert on stale manifests * Rename alert component * Correctly parse manifest time strings * Add test for _not quite_ so old manifest retrieval time Still needs copy from design on verbiage References #6049 --- client/app/reader/DocumentRetrevalAlert.jsx | 25 ---------- client/app/reader/LastRetrievalAlert.jsx | 55 +++++++++++++++++++++ client/app/reader/PdfListView.jsx | 5 +- spec/feature/reader/reader_spec.rb | 12 ++++- 4 files changed, 68 insertions(+), 29 deletions(-) delete mode 100644 client/app/reader/DocumentRetrevalAlert.jsx create mode 100644 client/app/reader/LastRetrievalAlert.jsx diff --git a/client/app/reader/DocumentRetrevalAlert.jsx b/client/app/reader/DocumentRetrevalAlert.jsx deleted file mode 100644 index b10ad6ecf2a..00000000000 --- a/client/app/reader/DocumentRetrevalAlert.jsx +++ /dev/null @@ -1,25 +0,0 @@ -import React, { PureComponent } from 'react'; -import Alert from '../components/Alert'; - -export default class DocumentRetrevalAlert extends PureComponent { - render() { - if (!this.props.manifestVbmsFetchedAt || !this.props.manifestVvaFetchedAt) { - return - Some documents could not be loaded at this time - ; - } - - let cacheTimeoutHours = 3, - timeoutTimestamp = new Date(); - timeoutTimestamp.setHours(timeoutTimestamp.getHours() - cacheTimeoutHours); - - if (this.props.manifestVbmsFetchedAt < timeoutTimestamp.getTime() || - this.props.manifestVvaFetchedAt < timeoutTimestamp.getTime()) { - return - The document list may be stale - ; - } - - return null; - } -} diff --git a/client/app/reader/LastRetrievalAlert.jsx b/client/app/reader/LastRetrievalAlert.jsx new file mode 100644 index 00000000000..dc294113d8f --- /dev/null +++ b/client/app/reader/LastRetrievalAlert.jsx @@ -0,0 +1,55 @@ +import _ from 'lodash'; +import moment from 'moment'; +import React from 'react'; +import { connect } from 'react-redux'; +import Alert from '../components/Alert'; + +const CACHE_TIMEOUT_HOURS = 3; +const TIMEZONES = { + ' GMT': ' +0000', + ' EDT': ' -0400', + ' EST': ' -0500', + ' CDT': ' -0500', + ' CST': ' -0600', + ' MDT': ' -0600', + ' MST': ' -0700', + ' PDT': ' -0700', + ' PST': ' -0800' +}; + +class LastRetrievalAlert extends React.PureComponent { + + render() { + + // Check that document manifests have been recieved from VVA and VBMS + if (!this.props.manifestVbmsFetchedAt || !this.props.manifestVvaFetchedAt) { + return + Some documents could not be loaded at this time... + ; + } + + let staleCacheTime = new Date(); + staleCacheTime.setHours(staleCacheTime.getHours() - CACHE_TIMEOUT_HOURS); + + let vvaManifestTimeString = this.props.manifestVvaFetchedAt, + vbmsManifestTimeString = this.props.manifestVbmsFetchedAt, + parsableVvaManifestTimeString = vvaManifestTimeString.slice(0, -4) + TIMEZONES[vvaManifestTimeString.slice(-4)], + parsableVbmsManifestTimeString = vbmsManifestTimeString.slice(0, -4) + TIMEZONES[vbmsManifestTimeString.slice(-4)], + vvaManifestTimestamp = moment(parsableVvaManifestTimeString, 'MM/DD/YY HH:mma Z').unix(), + vbmsManifestTimestamp = moment(parsableVbmsManifestTimeString, 'MM/DD/YY HH:mma Z').unix(), + staleCacheTimestamp = staleCacheTime.getTime() / 1000; + + // Check that manifest results are fresh + if (vbmsManifestTimestamp < staleCacheTimestamp || vvaManifestTimestamp < staleCacheTimestamp) { + return + The document list may be stale + ; + } + + return null; + } +} + +export default connect( + (state) => _.pick(state.documentList, ['manifestVvaFetchedAt', 'manifestVbmsFetchedAt']) +)(LastRetrievalAlert); diff --git a/client/app/reader/PdfListView.jsx b/client/app/reader/PdfListView.jsx index 25d472dc8de..f8af3ef7cbf 100644 --- a/client/app/reader/PdfListView.jsx +++ b/client/app/reader/PdfListView.jsx @@ -5,7 +5,7 @@ import { connect } from 'react-redux'; import _ from 'lodash'; import BackToQueueLink from './BackToQueueLink'; -import DocumentRetrievalAlert from './DocumentRetrevalAlert'; +import LastRetrievalAlert from './LastRetrievalAlert'; import LastRetrievalInfo from './LastRetrievalInfo'; import AppSegment from '@department-of-veterans-affairs/caseflow-frontend-toolkit/components/AppSegment'; import DocumentListHeader from './DocumentListHeader'; @@ -17,7 +17,6 @@ import NoSearchResults from './NoSearchResults'; import { fetchAppealDetails, onReceiveAppealDetails } from '../reader/PdfViewer/PdfViewerActions'; import { shouldFetchAppeal } from '../reader/utils'; import { DOCUMENTS_OR_COMMENTS_ENUM } from './DocumentList/actionTypes'; -import Alert from '../components/Alert'; export class PdfListView extends React.Component { componentDidMount() { @@ -69,7 +68,7 @@ export class PdfListView extends React.Component {
- + Date: Thu, 13 Dec 2018 12:52:47 -0500 Subject: [PATCH 06/17] Linting --- client/app/reader/LastRetrievalAlert.jsx | 14 +++++++++----- spec/feature/reader/reader_spec.rb | 4 ++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/client/app/reader/LastRetrievalAlert.jsx b/client/app/reader/LastRetrievalAlert.jsx index dc294113d8f..fcf7f5bc0ee 100644 --- a/client/app/reader/LastRetrievalAlert.jsx +++ b/client/app/reader/LastRetrievalAlert.jsx @@ -29,15 +29,19 @@ class LastRetrievalAlert extends React.PureComponent { } let staleCacheTime = new Date(); + staleCacheTime.setHours(staleCacheTime.getHours() - CACHE_TIMEOUT_HOURS); - let vvaManifestTimeString = this.props.manifestVvaFetchedAt, + let staleCacheTimestamp = staleCacheTime.getTime() / 1000, vbmsManifestTimeString = this.props.manifestVbmsFetchedAt, - parsableVvaManifestTimeString = vvaManifestTimeString.slice(0, -4) + TIMEZONES[vvaManifestTimeString.slice(-4)], - parsableVbmsManifestTimeString = vbmsManifestTimeString.slice(0, -4) + TIMEZONES[vbmsManifestTimeString.slice(-4)], - vvaManifestTimestamp = moment(parsableVvaManifestTimeString, 'MM/DD/YY HH:mma Z').unix(), + vvaManifestTimeString = this.props.manifestVvaFetchedAt; + + let parsableVbmsManifestTimeString = vbmsManifestTimeString.slice(0, -4) + + TIMEZONES[vbmsManifestTimeString.slice(-4)], + parsableVvaManifestTimeString = vvaManifestTimeString.slice(0, -4) + + TIMEZONES[vvaManifestTimeString.slice(-4)], vbmsManifestTimestamp = moment(parsableVbmsManifestTimeString, 'MM/DD/YY HH:mma Z').unix(), - staleCacheTimestamp = staleCacheTime.getTime() / 1000; + vvaManifestTimestamp = moment(parsableVvaManifestTimeString, 'MM/DD/YY HH:mma Z').unix(); // Check that manifest results are fresh if (vbmsManifestTimestamp < staleCacheTimestamp || vvaManifestTimestamp < staleCacheTimestamp) { diff --git a/spec/feature/reader/reader_spec.rb b/spec/feature/reader/reader_spec.rb index 63814d682b1..8136a76fd24 100644 --- a/spec/feature/reader/reader_spec.rb +++ b/spec/feature/reader/reader_spec.rb @@ -259,7 +259,7 @@ def add_comment(text) visit "/reader/appeal/#{appeal.vacols_id}/documents" expect(find("#vbms-manifest-retrieved-at").text).to have_content(vbms_ts_string) expect(find("#vva-manifest-retrieved-at").text).to have_content(vva_ts_string) - expect(find(".section--document-list .usa-alert-warning").text).to have_content("The document list may be stale") + expect(page).to have_css(".section--document-list .usa-alert-warning") end end @@ -269,7 +269,7 @@ def add_comment(text) visit "/reader/appeal/#{appeal.vacols_id}/documents" expect(find("#vbms-manifest-retrieved-at").text).to have_content(vbms_ts_string) expect(page).to_not have_css("#vva-manifest-retrieved-at") - expect(find(".section--document-list .usa-alert-error").text).to have_content("Some documents could not be loaded at this time") + expect(page).to have_css(".section--document-list .usa-alert-error") end end From 7dacc0af856fe1d999bb6f87b46f92e5f724d217 Mon Sep 17 00:00:00 2001 From: hschallhorn Date: Thu, 13 Dec 2018 14:44:56 -0500 Subject: [PATCH 07/17] Add verbiage from design to errors --- client/app/reader/LastRetrievalAlert.jsx | 14 ++++++++++++-- client/app/reader/PdfListView.jsx | 9 +++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/client/app/reader/LastRetrievalAlert.jsx b/client/app/reader/LastRetrievalAlert.jsx index fcf7f5bc0ee..e8d142d1fe4 100644 --- a/client/app/reader/LastRetrievalAlert.jsx +++ b/client/app/reader/LastRetrievalAlert.jsx @@ -24,7 +24,12 @@ class LastRetrievalAlert extends React.PureComponent { // Check that document manifests have been recieved from VVA and VBMS if (!this.props.manifestVbmsFetchedAt || !this.props.manifestVvaFetchedAt) { return - Some documents could not be loaded at this time... + Some of {this.props.appeal.veteran_full_name}'s documents are not available at the moment due to + a loading error from VBMS or VVA. As a result, you may be viewing a partial list of claims folder documents. +
+
+ Please refresh your browser at a later point to view a complete list of documents in the claims + folder.
; } @@ -46,7 +51,12 @@ class LastRetrievalAlert extends React.PureComponent { // Check that manifest results are fresh if (vbmsManifestTimestamp < staleCacheTimestamp || vvaManifestTimestamp < staleCacheTimestamp) { return - The document list may be stale + Some of {this.props.appeal.veteran_full_name}'s documents may not be available at the moment due to + a loading error from VBMS or VVA. As a result, you may be viewing a partial list of claims folder documents. +
+
+ Please refresh your browser at a later point to view a complete list of documents in the claims + folder.
; } diff --git a/client/app/reader/PdfListView.jsx b/client/app/reader/PdfListView.jsx index f8af3ef7cbf..8ac596eba42 100644 --- a/client/app/reader/PdfListView.jsx +++ b/client/app/reader/PdfListView.jsx @@ -60,15 +60,15 @@ export class PdfListView extends React.Component { } return
- { this.props.queueRedirectUrl && } + vbmsId={this.props.appeal.vbms_id} />}
- + { - return { documents: getFilteredDocuments(state), + return { + documents: getFilteredDocuments(state), ..._.pick(state.documentList, 'docFilterCriteria', 'viewingDocumentsOrComments'), appeal: _.find(state.caseSelect.assignments, { vacols_id: props.match.params.vacolsId }) || state.pdfViewer.loadedAppeal, From f12105021f7f7905b443e1e6b9dfd204184f0d92 Mon Sep 17 00:00:00 2001 From: hschallhorn Date: Mon, 17 Dec 2018 11:00:11 -0500 Subject: [PATCH 08/17] Update the message displayed in the stale retreival warning. --- client/app/reader/LastRetrievalAlert.jsx | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/client/app/reader/LastRetrievalAlert.jsx b/client/app/reader/LastRetrievalAlert.jsx index e8d142d1fe4..3b8b3241cc8 100644 --- a/client/app/reader/LastRetrievalAlert.jsx +++ b/client/app/reader/LastRetrievalAlert.jsx @@ -51,12 +51,8 @@ class LastRetrievalAlert extends React.PureComponent { // Check that manifest results are fresh if (vbmsManifestTimestamp < staleCacheTimestamp || vvaManifestTimestamp < staleCacheTimestamp) { return - Some of {this.props.appeal.veteran_full_name}'s documents may not be available at the moment due to - a loading error from VBMS or VVA. As a result, you may be viewing a partial list of claims folder documents. -
-
- Please refresh your browser at a later point to view a complete list of documents in the claims - folder. + You may be viewing an outdated list of claims folder documents. Please refresh the page to load + the most up to date documents.
; } From 4def5e21f4fe35d8076a227318944e01609fa6c1 Mon Sep 17 00:00:00 2001 From: hschallhorn Date: Mon, 17 Dec 2018 12:32:51 -0500 Subject: [PATCH 09/17] const over let --- client/app/reader/LastRetrievalAlert.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/app/reader/LastRetrievalAlert.jsx b/client/app/reader/LastRetrievalAlert.jsx index 3b8b3241cc8..5f4ee7208a7 100644 --- a/client/app/reader/LastRetrievalAlert.jsx +++ b/client/app/reader/LastRetrievalAlert.jsx @@ -37,11 +37,11 @@ class LastRetrievalAlert extends React.PureComponent { staleCacheTime.setHours(staleCacheTime.getHours() - CACHE_TIMEOUT_HOURS); - let staleCacheTimestamp = staleCacheTime.getTime() / 1000, + const staleCacheTimestamp = staleCacheTime.getTime() / 1000, vbmsManifestTimeString = this.props.manifestVbmsFetchedAt, vvaManifestTimeString = this.props.manifestVvaFetchedAt; - let parsableVbmsManifestTimeString = vbmsManifestTimeString.slice(0, -4) + + const parsableVbmsManifestTimeString = vbmsManifestTimeString.slice(0, -4) + TIMEZONES[vbmsManifestTimeString.slice(-4)], parsableVvaManifestTimeString = vvaManifestTimeString.slice(0, -4) + TIMEZONES[vvaManifestTimeString.slice(-4)], From cfdd81968c802d6f9ea25e977df4e5045bb40303 Mon Sep 17 00:00:00 2001 From: hschallhorn Date: Mon, 17 Dec 2018 12:50:06 -0500 Subject: [PATCH 10/17] Alert styling with glamour --- client/app/reader/LastRetrievalAlert.jsx | 9 +++++++-- client/app/styles/reader/_document_list.scss | 4 ---- spec/feature/reader/reader_spec.rb | 6 ++++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/client/app/reader/LastRetrievalAlert.jsx b/client/app/reader/LastRetrievalAlert.jsx index 5f4ee7208a7..617adc806ed 100644 --- a/client/app/reader/LastRetrievalAlert.jsx +++ b/client/app/reader/LastRetrievalAlert.jsx @@ -3,6 +3,7 @@ import moment from 'moment'; import React from 'react'; import { connect } from 'react-redux'; import Alert from '../components/Alert'; +import { css } from '../../node_modules/glamor'; const CACHE_TIMEOUT_HOURS = 3; const TIMEZONES = { @@ -17,13 +18,17 @@ const TIMEZONES = { ' PST': ' -0800' }; +const alertStyling = css({ + marginBottom: '20px' +}); + class LastRetrievalAlert extends React.PureComponent { render() { // Check that document manifests have been recieved from VVA and VBMS if (!this.props.manifestVbmsFetchedAt || !this.props.manifestVvaFetchedAt) { - return + return Some of {this.props.appeal.veteran_full_name}'s documents are not available at the moment due to a loading error from VBMS or VVA. As a result, you may be viewing a partial list of claims folder documents.
@@ -50,7 +55,7 @@ class LastRetrievalAlert extends React.PureComponent { // Check that manifest results are fresh if (vbmsManifestTimestamp < staleCacheTimestamp || vvaManifestTimestamp < staleCacheTimestamp) { - return + return You may be viewing an outdated list of claims folder documents. Please refresh the page to load the most up to date documents. ; diff --git a/client/app/styles/reader/_document_list.scss b/client/app/styles/reader/_document_list.scss index 56c8da85d5f..ae102601108 100644 --- a/client/app/styles/reader/_document_list.scss +++ b/client/app/styles/reader/_document_list.scss @@ -242,10 +242,6 @@ background: inherit; } } - - .usa-alert { - margin-bottom: 20px; - } } .document-list-filter-message { diff --git a/spec/feature/reader/reader_spec.rb b/spec/feature/reader/reader_spec.rb index 8136a76fd24..19e22585ee5 100644 --- a/spec/feature/reader/reader_spec.rb +++ b/spec/feature/reader/reader_spec.rb @@ -255,8 +255,9 @@ def add_comment(text) context "When VVA manifest retrieval time is olde and outside of the eFolder cache limit" do let(:vva_fetched_ts) { Time.zone.now - 4.hours } - scenario "Both times display on the page and a warning alert is shown" do + scenario "Both times display on the page and a warning alert is shown", focus: true do visit "/reader/appeal/#{appeal.vacols_id}/documents" + binding.pry expect(find("#vbms-manifest-retrieved-at").text).to have_content(vbms_ts_string) expect(find("#vva-manifest-retrieved-at").text).to have_content(vva_ts_string) expect(page).to have_css(".section--document-list .usa-alert-warning") @@ -265,8 +266,9 @@ def add_comment(text) context "When VVA manifest retrieval time is nil" do let(:vva_fetched_ts) { nil } - scenario "Only VBMS time displays on the page and error alert is shown" do + scenario "Only VBMS time displays on the page and error alert is shown", focus: true do visit "/reader/appeal/#{appeal.vacols_id}/documents" + binding.pry expect(find("#vbms-manifest-retrieved-at").text).to have_content(vbms_ts_string) expect(page).to_not have_css("#vva-manifest-retrieved-at") expect(page).to have_css(".section--document-list .usa-alert-error") From befa07e6cefd5cb6193bb53c821772e82b0afb86 Mon Sep 17 00:00:00 2001 From: hschallhorn Date: Mon, 17 Dec 2018 14:01:31 -0500 Subject: [PATCH 11/17] Use moment for all dates and comparisons --- client/app/reader/LastRetrievalAlert.jsx | 42 ++++++++++++------------ 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/client/app/reader/LastRetrievalAlert.jsx b/client/app/reader/LastRetrievalAlert.jsx index 617adc806ed..b101c794a92 100644 --- a/client/app/reader/LastRetrievalAlert.jsx +++ b/client/app/reader/LastRetrievalAlert.jsx @@ -3,7 +3,7 @@ import moment from 'moment'; import React from 'react'; import { connect } from 'react-redux'; import Alert from '../components/Alert'; -import { css } from '../../node_modules/glamor'; +import { css } from 'glamor'; const CACHE_TIMEOUT_HOURS = 3; const TIMEZONES = { @@ -28,21 +28,19 @@ class LastRetrievalAlert extends React.PureComponent { // Check that document manifests have been recieved from VVA and VBMS if (!this.props.manifestVbmsFetchedAt || !this.props.manifestVvaFetchedAt) { - return - Some of {this.props.appeal.veteran_full_name}'s documents are not available at the moment due to - a loading error from VBMS or VVA. As a result, you may be viewing a partial list of claims folder documents. -
-
- Please refresh your browser at a later point to view a complete list of documents in the claims - folder. -
; + return
+ + Some of {this.props.appeal.veteran_full_name}'s documents are not available at the moment due to + a loading error from VBMS or VVA. As a result, you may be viewing a partial list of claims folder documents. +
+
+ Please refresh your browser at a later point to view a complete list of documents in the claims + folder. +
+
; } - let staleCacheTime = new Date(); - - staleCacheTime.setHours(staleCacheTime.getHours() - CACHE_TIMEOUT_HOURS); - - const staleCacheTimestamp = staleCacheTime.getTime() / 1000, + const staleCacheTime = moment().subtract(CACHE_TIMEOUT_HOURS, 'h'), vbmsManifestTimeString = this.props.manifestVbmsFetchedAt, vvaManifestTimeString = this.props.manifestVvaFetchedAt; @@ -50,15 +48,17 @@ class LastRetrievalAlert extends React.PureComponent { TIMEZONES[vbmsManifestTimeString.slice(-4)], parsableVvaManifestTimeString = vvaManifestTimeString.slice(0, -4) + TIMEZONES[vvaManifestTimeString.slice(-4)], - vbmsManifestTimestamp = moment(parsableVbmsManifestTimeString, 'MM/DD/YY HH:mma Z').unix(), - vvaManifestTimestamp = moment(parsableVvaManifestTimeString, 'MM/DD/YY HH:mma Z').unix(); + vbmsManifestTimestamp = moment(parsableVbmsManifestTimeString, 'MM/DD/YY HH:mma Z'), + vvaManifestTimestamp = moment(parsableVvaManifestTimeString, 'MM/DD/YY HH:mma Z'); // Check that manifest results are fresh - if (vbmsManifestTimestamp < staleCacheTimestamp || vvaManifestTimestamp < staleCacheTimestamp) { - return - You may be viewing an outdated list of claims folder documents. Please refresh the page to load - the most up to date documents. - ; + if (vbmsManifestTimestamp.isBefore(staleCacheTime) || vvaManifestTimestamp.isBefore(staleCacheTime)) { + return
+ + You may be viewing an outdated list of claims folder documents. Please refresh the page to load + the most up to date documents. + +
; } return null; From e26b8a48bea25fcbb7104a935ca6b8f1b01b25e8 Mon Sep 17 00:00:00 2001 From: hschallhorn Date: Mon, 17 Dec 2018 14:02:21 -0500 Subject: [PATCH 12/17] Remove testing focus: trues --- spec/feature/reader/reader_spec.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/spec/feature/reader/reader_spec.rb b/spec/feature/reader/reader_spec.rb index 19e22585ee5..8136a76fd24 100644 --- a/spec/feature/reader/reader_spec.rb +++ b/spec/feature/reader/reader_spec.rb @@ -255,9 +255,8 @@ def add_comment(text) context "When VVA manifest retrieval time is olde and outside of the eFolder cache limit" do let(:vva_fetched_ts) { Time.zone.now - 4.hours } - scenario "Both times display on the page and a warning alert is shown", focus: true do + scenario "Both times display on the page and a warning alert is shown" do visit "/reader/appeal/#{appeal.vacols_id}/documents" - binding.pry expect(find("#vbms-manifest-retrieved-at").text).to have_content(vbms_ts_string) expect(find("#vva-manifest-retrieved-at").text).to have_content(vva_ts_string) expect(page).to have_css(".section--document-list .usa-alert-warning") @@ -266,9 +265,8 @@ def add_comment(text) context "When VVA manifest retrieval time is nil" do let(:vva_fetched_ts) { nil } - scenario "Only VBMS time displays on the page and error alert is shown", focus: true do + scenario "Only VBMS time displays on the page and error alert is shown" do visit "/reader/appeal/#{appeal.vacols_id}/documents" - binding.pry expect(find("#vbms-manifest-retrieved-at").text).to have_content(vbms_ts_string) expect(page).to_not have_css("#vva-manifest-retrieved-at") expect(page).to have_css(".section--document-list .usa-alert-error") From 6fed358de0f2e8a7d1338e361611a943aae69231 Mon Sep 17 00:00:00 2001 From: hschallhorn Date: Thu, 20 Dec 2018 13:36:31 -0500 Subject: [PATCH 13/17] Initialize manifest timestamps in dev env. --- config/initializers/vbms.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/config/initializers/vbms.rb b/config/initializers/vbms.rb index 73d0551d43c..aa3cf63293d 100644 --- a/config/initializers/vbms.rb +++ b/config/initializers/vbms.rb @@ -1 +1,6 @@ VBMSService = (!ApplicationController.dependencies_faked? ? ExternalApi::VBMSService : Fakes::VBMSService) + +if ApplicationController.dependencies_faked? + VBMSService.manifest_vbms_fetched_at = Time.zone.now + VBMSService.manifest_vva_fetched_at = Time.zone.now +end \ No newline at end of file From 501d36e6f59130d38276871d9f452022234ccc55 Mon Sep 17 00:00:00 2001 From: hschallhorn Date: Thu, 20 Dec 2018 13:42:14 -0500 Subject: [PATCH 14/17] Format timestamps to be parsable by moment * Update the format of manifest retrieval timestamp timezones to offests rather than abbreviations so they can be parsed by moment on the front end --- app/services/document_fetcher.rb | 2 +- client/app/reader/LastRetrievalAlert.jsx | 22 ++----------------- spec/feature/reader/reader_spec.rb | 2 +- spec/services/document_fetcher_spec.rb | 2 +- .../external_api/efolder_service_spec.rb | 5 +++-- 5 files changed, 8 insertions(+), 25 deletions(-) diff --git a/app/services/document_fetcher.rb b/app/services/document_fetcher.rb index b5ad8068aed..9740262eecb 100644 --- a/app/services/document_fetcher.rb +++ b/app/services/document_fetcher.rb @@ -42,7 +42,7 @@ def manifest_vva_fetched_at=(fetched_at) end def fetched_at_format - "%D %l:%M%P %Z" + "%D %l:%M%P %z" end def save! diff --git a/client/app/reader/LastRetrievalAlert.jsx b/client/app/reader/LastRetrievalAlert.jsx index b101c794a92..be406963e30 100644 --- a/client/app/reader/LastRetrievalAlert.jsx +++ b/client/app/reader/LastRetrievalAlert.jsx @@ -6,17 +6,6 @@ import Alert from '../components/Alert'; import { css } from 'glamor'; const CACHE_TIMEOUT_HOURS = 3; -const TIMEZONES = { - ' GMT': ' +0000', - ' EDT': ' -0400', - ' EST': ' -0500', - ' CDT': ' -0500', - ' CST': ' -0600', - ' MDT': ' -0600', - ' MST': ' -0700', - ' PDT': ' -0700', - ' PST': ' -0800' -}; const alertStyling = css({ marginBottom: '20px' @@ -41,15 +30,8 @@ class LastRetrievalAlert extends React.PureComponent { } const staleCacheTime = moment().subtract(CACHE_TIMEOUT_HOURS, 'h'), - vbmsManifestTimeString = this.props.manifestVbmsFetchedAt, - vvaManifestTimeString = this.props.manifestVvaFetchedAt; - - const parsableVbmsManifestTimeString = vbmsManifestTimeString.slice(0, -4) + - TIMEZONES[vbmsManifestTimeString.slice(-4)], - parsableVvaManifestTimeString = vvaManifestTimeString.slice(0, -4) + - TIMEZONES[vvaManifestTimeString.slice(-4)], - vbmsManifestTimestamp = moment(parsableVbmsManifestTimeString, 'MM/DD/YY HH:mma Z'), - vvaManifestTimestamp = moment(parsableVvaManifestTimeString, 'MM/DD/YY HH:mma Z'); + vbmsManifestTimestamp = moment(this.props.manifestVbmsFetchedAt, 'MM/DD/YY HH:mma Z'), + vvaManifestTimestamp = moment(this.props.manifestVvaFetchedAt, 'MM/DD/YY HH:mma Z'); // Check that manifest results are fresh if (vbmsManifestTimestamp.isBefore(staleCacheTime) || vvaManifestTimestamp.isBefore(staleCacheTime)) { diff --git a/spec/feature/reader/reader_spec.rb b/spec/feature/reader/reader_spec.rb index 8136a76fd24..c87d6ca259e 100644 --- a/spec/feature/reader/reader_spec.rb +++ b/spec/feature/reader/reader_spec.rb @@ -212,7 +212,7 @@ def add_comment(text) end context "Appeals without any issues" do - let(:fetched_at_format) { "%D %l:%M%P %Z" } + let(:fetched_at_format) { "%D %l:%M%P %z" } let(:vbms_fetched_ts) { Time.zone.now } let(:vva_fetched_ts) { Time.zone.now } diff --git a/spec/services/document_fetcher_spec.rb b/spec/services/document_fetcher_spec.rb index 12fcd8beb9e..737d08b0875 100644 --- a/spec/services/document_fetcher_spec.rb +++ b/spec/services/document_fetcher_spec.rb @@ -13,7 +13,7 @@ let(:service_manifest_vbms_fetched_at) { Time.zone.local(1989, "nov", 23, 8, 2, 55) } let(:service_manifest_vva_fetched_at) { Time.zone.local(1989, "dec", 13, 20, 15, 1) } - let(:fetched_at_format) { "%D %l:%M%P %Z" } + let(:fetched_at_format) { "%D %l:%M%P %z" } let!(:efolder_fetched_at_format) { "%FT%T.%LZ" } let(:doc_struct) do { diff --git a/spec/services/external_api/efolder_service_spec.rb b/spec/services/external_api/efolder_service_spec.rb index 70470dc891e..303d52a5a13 100644 --- a/spec/services/external_api/efolder_service_spec.rb +++ b/spec/services/external_api/efolder_service_spec.rb @@ -36,8 +36,9 @@ let(:user) { Generators::User.create } let(:appeal) { Generators::LegacyAppeal.build } let(:vbms_id) { appeal.sanitized_vbms_id.to_s } - let(:manifest_vbms_fetched_at) { Time.zone.now.strftime("%D %l:%M%P %Z") } - let(:manifest_vva_fetched_at) { Time.zone.now.strftime("%D %l:%M%P %Z") } + let(:fetched_at_format) { "%D %l:%M%P %z" } + let(:manifest_vbms_fetched_at) { Time.zone.now.strftime(fetched_at_format) } + let(:manifest_vva_fetched_at) { Time.zone.now.strftime(fetched_at_format) } let(:expected_response) { construct_response(records, sources) } subject { ExternalApi::EfolderService.generate_efolder_request(vbms_id, user) } From f5444542b02bf9a662c1617cd2118c44b2046a2a Mon Sep 17 00:00:00 2001 From: hschallhorn Date: Thu, 20 Dec 2018 14:14:51 -0500 Subject: [PATCH 15/17] Reintroduce readable zone for displayed timestamps --- app/services/document_fetcher.rb | 2 +- client/app/reader/LastRetrievalInfo.jsx | 7 +++++-- spec/feature/reader/reader_spec.rb | 2 +- spec/services/document_fetcher_spec.rb | 2 +- spec/services/external_api/efolder_service_spec.rb | 2 +- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/services/document_fetcher.rb b/app/services/document_fetcher.rb index 9740262eecb..83c6eb67e7c 100644 --- a/app/services/document_fetcher.rb +++ b/app/services/document_fetcher.rb @@ -42,7 +42,7 @@ def manifest_vva_fetched_at=(fetched_at) end def fetched_at_format - "%D %l:%M%P %z" + "%D %l:%M%P %Z %z" end def save! diff --git a/client/app/reader/LastRetrievalInfo.jsx b/client/app/reader/LastRetrievalInfo.jsx index 25b9dc15814..ab0013dedf6 100644 --- a/client/app/reader/LastRetrievalInfo.jsx +++ b/client/app/reader/LastRetrievalInfo.jsx @@ -4,12 +4,15 @@ import { connect } from 'react-redux'; class UnconnectedLastRetrievalInfo extends React.PureComponent { render() { + const vbmsManifestTimestamp = this.props.manifestVbmsFetchedAt.slice(0, -5), + vvaManifestTimestamp = this.props.manifestVvaFetchedAt.slice(0, -5); + return [ this.props.manifestVbmsFetchedAt ? -
Last VBMS retrieval: {this.props.manifestVbmsFetchedAt}
: +
Last VBMS retrieval: {vbmsManifestTimestamp}
:
Unable to display VBMS documents at this time
, this.props.manifestVvaFetchedAt ? -
Last VVA retrieval: {this.props.manifestVvaFetchedAt}
: +
Last VVA retrieval: {vvaManifestTimestamp}
:
Unable to display VVA documents at this time
]; } diff --git a/spec/feature/reader/reader_spec.rb b/spec/feature/reader/reader_spec.rb index c87d6ca259e..8136a76fd24 100644 --- a/spec/feature/reader/reader_spec.rb +++ b/spec/feature/reader/reader_spec.rb @@ -212,7 +212,7 @@ def add_comment(text) end context "Appeals without any issues" do - let(:fetched_at_format) { "%D %l:%M%P %z" } + let(:fetched_at_format) { "%D %l:%M%P %Z" } let(:vbms_fetched_ts) { Time.zone.now } let(:vva_fetched_ts) { Time.zone.now } diff --git a/spec/services/document_fetcher_spec.rb b/spec/services/document_fetcher_spec.rb index 737d08b0875..4fa01de6090 100644 --- a/spec/services/document_fetcher_spec.rb +++ b/spec/services/document_fetcher_spec.rb @@ -13,7 +13,7 @@ let(:service_manifest_vbms_fetched_at) { Time.zone.local(1989, "nov", 23, 8, 2, 55) } let(:service_manifest_vva_fetched_at) { Time.zone.local(1989, "dec", 13, 20, 15, 1) } - let(:fetched_at_format) { "%D %l:%M%P %z" } + let(:fetched_at_format) { "%D %l:%M%P %Z %z" } let!(:efolder_fetched_at_format) { "%FT%T.%LZ" } let(:doc_struct) do { diff --git a/spec/services/external_api/efolder_service_spec.rb b/spec/services/external_api/efolder_service_spec.rb index 303d52a5a13..74aedb7cfa4 100644 --- a/spec/services/external_api/efolder_service_spec.rb +++ b/spec/services/external_api/efolder_service_spec.rb @@ -36,7 +36,7 @@ let(:user) { Generators::User.create } let(:appeal) { Generators::LegacyAppeal.build } let(:vbms_id) { appeal.sanitized_vbms_id.to_s } - let(:fetched_at_format) { "%D %l:%M%P %z" } + let(:fetched_at_format) { "%D %l:%M%P %Z %z" } let(:manifest_vbms_fetched_at) { Time.zone.now.strftime(fetched_at_format) } let(:manifest_vva_fetched_at) { Time.zone.now.strftime(fetched_at_format) } let(:expected_response) { construct_response(records, sources) } From 64533dfbc894f3ab611826b9489eccf788c7c09f Mon Sep 17 00:00:00 2001 From: hschallhorn Date: Thu, 20 Dec 2018 14:39:41 -0500 Subject: [PATCH 16/17] Fix error on null retrieval times --- client/app/reader/LastRetrievalInfo.jsx | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/client/app/reader/LastRetrievalInfo.jsx b/client/app/reader/LastRetrievalInfo.jsx index ab0013dedf6..01e43efda38 100644 --- a/client/app/reader/LastRetrievalInfo.jsx +++ b/client/app/reader/LastRetrievalInfo.jsx @@ -4,16 +4,21 @@ import { connect } from 'react-redux'; class UnconnectedLastRetrievalInfo extends React.PureComponent { render() { - const vbmsManifestTimestamp = this.props.manifestVbmsFetchedAt.slice(0, -5), - vvaManifestTimestamp = this.props.manifestVvaFetchedAt.slice(0, -5); - return [ this.props.manifestVbmsFetchedAt ? -
Last VBMS retrieval: {vbmsManifestTimestamp}
: -
Unable to display VBMS documents at this time
, +
+ Last VBMS retrieval: {this.props.manifestVbmsFetchedAt.slice(0, -5)} +
: +
+ Unable to display VBMS documents at this time +
, this.props.manifestVvaFetchedAt ? -
Last VVA retrieval: {vvaManifestTimestamp}
: -
Unable to display VVA documents at this time
+
+ Last VVA retrieval: {this.props.manifestVvaFetchedAt.slice(0, -5)} +
: +
+ Unable to display VVA documents at this time +
]; } } From c9c03535b22942d4bb721bc23562b639b7730804 Mon Sep 17 00:00:00 2001 From: hschallhorn Date: Fri, 21 Dec 2018 13:34:45 -0500 Subject: [PATCH 17/17] Update to less ominous version of warning text * Add 'last retrieved' time to warning as well --- client/app/reader/LastRetrievalAlert.jsx | 8 ++++++-- spec/feature/reader/reader_spec.rb | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/client/app/reader/LastRetrievalAlert.jsx b/client/app/reader/LastRetrievalAlert.jsx index be406963e30..880296536b5 100644 --- a/client/app/reader/LastRetrievalAlert.jsx +++ b/client/app/reader/LastRetrievalAlert.jsx @@ -35,10 +35,14 @@ class LastRetrievalAlert extends React.PureComponent { // Check that manifest results are fresh if (vbmsManifestTimestamp.isBefore(staleCacheTime) || vvaManifestTimestamp.isBefore(staleCacheTime)) { + const now = moment(), + vbmsDiff = now.diff(vbmsManifestTimestamp, 'hours'), + vvaDiff = now.diff(vvaManifestTimestamp, 'hours'); + return
- You may be viewing an outdated list of claims folder documents. Please refresh the page to load - the most up to date documents. + We last synced with VBMS and VVA {Math.max(vbmsDiff, vvaDiff)} hours ago. If you'd like to check for new + documents, refresh the page.
; } diff --git a/spec/feature/reader/reader_spec.rb b/spec/feature/reader/reader_spec.rb index 8136a76fd24..e4c04cd7475 100644 --- a/spec/feature/reader/reader_spec.rb +++ b/spec/feature/reader/reader_spec.rb @@ -259,7 +259,7 @@ def add_comment(text) visit "/reader/appeal/#{appeal.vacols_id}/documents" expect(find("#vbms-manifest-retrieved-at").text).to have_content(vbms_ts_string) expect(find("#vva-manifest-retrieved-at").text).to have_content(vva_ts_string) - expect(page).to have_css(".section--document-list .usa-alert-warning") + expect(find(".section--document-list .usa-alert-warning").text).to have_content("4 hours ago") end end