Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
b7b2c285
Commit
b7b2c285
authored
May 13, 2021
by
Zack Cuddy
Committed by
Phil Hughes
May 13, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Geo 2.0 Regression - Timezone Issues
parent
6b58586e
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
71 additions
and
28 deletions
+71
-28
app/assets/javascripts/vue_shared/components/time_ago_tooltip.vue
...ts/javascripts/vue_shared/components/time_ago_tooltip.vue
+1
-1
ee/app/assets/javascripts/geo_nodes_beta/components/details/secondary_node/geo_node_secondary_other_info.vue
.../details/secondary_node/geo_node_secondary_other_info.vue
+4
-4
ee/app/assets/javascripts/geo_nodes_beta/components/header/geo_node_header.vue
...ipts/geo_nodes_beta/components/header/geo_node_header.vue
+1
-1
ee/app/assets/javascripts/geo_nodes_beta/components/header/geo_node_last_updated.vue
...eo_nodes_beta/components/header/geo_node_last_updated.vue
+2
-6
ee/spec/frontend/geo_nodes_beta/components/header/geo_node_last_updated_spec.js
...odes_beta/components/header/geo_node_last_updated_spec.js
+2
-6
spec/frontend/vue_shared/components/time_ago_tooltip_spec.js
spec/frontend/vue_shared/components/time_ago_tooltip_spec.js
+61
-10
No files found.
app/assets/javascripts/vue_shared/components/time_ago_tooltip.vue
View file @
b7b2c285
...
...
@@ -15,7 +15,7 @@ export default {
mixins
:
[
timeagoMixin
],
props
:
{
time
:
{
type
:
String
,
type
:
[
String
,
Number
]
,
required
:
true
,
},
tooltipPlacement
:
{
...
...
ee/app/assets/javascripts/geo_nodes_beta/components/details/secondary_node/geo_node_secondary_other_info.vue
View file @
b7b2c285
...
...
@@ -51,12 +51,12 @@ export default {
return
this
.
$options
.
i18n
.
unknown
;
},
lastEventTimestamp
()
{
const
time
=
this
.
node
.
lastEventTimestamp
*
1000
;
return
new
Date
(
time
).
toString
()
;
// Converting timestamp to ms
return
this
.
node
.
lastEventTimestamp
*
1000
;
},
lastCursorEventTimestamp
()
{
const
time
=
this
.
node
.
cursorLastEventTimestamp
*
1000
;
return
new
Date
(
time
).
toString
()
;
// Converting timestamp to ms
return
this
.
node
.
cursorLastEventTimestamp
*
1000
;
},
},
};
...
...
ee/app/assets/javascripts/geo_nodes_beta/components/header/geo_node_header.vue
View file @
b7b2c285
...
...
@@ -39,7 +39,7 @@ export default {
},
statusCheckTimestamp
()
{
return
this
.
node
.
lastSuccessfulStatusCheckTimestamp
?
this
.
node
.
lastSuccessfulStatusCheckTimestamp
*
1000
?
this
.
node
.
lastSuccessfulStatusCheckTimestamp
*
1000
// Converting timestamp to ms
:
null
;
},
},
...
...
ee/app/assets/javascripts/geo_nodes_beta/components/header/geo_node_last_updated.vue
View file @
b7b2c285
...
...
@@ -47,10 +47,6 @@ export default {
link
:
HELP_NODE_HEALTH_URL
,
};
},
timeAgo
()
{
const
time
=
this
.
statusCheckTimestamp
;
return
new
Date
(
time
).
toString
();
},
},
};
</
script
>
...
...
@@ -60,7 +56,7 @@ export default {
<span
class=
"gl-text-gray-500"
data-testid=
"last-updated-main-text"
>
<gl-sprintf
:message=
"$options.i18n.timeAgoMainText"
>
<template
#timeAgo
>
<time-ago
:time=
"
timeAgo
"
/>
<time-ago
:time=
"
statusCheckTimestamp
"
/>
</
template
>
</gl-sprintf>
</span>
...
...
@@ -74,7 +70,7 @@ export default {
<p
class=
"gl-font-base"
>
<gl-sprintf
:message=
"$options.i18n.timeAgoPopoverText"
>
<
template
#timeAgo
>
<time-ago
:time=
"
timeAgo
"
/>
<time-ago
:time=
"
statusCheckTimestamp
"
/>
</
template
>
</gl-sprintf>
</p>
...
...
ee/spec/frontend/geo_nodes_beta/components/header/geo_node_last_updated_spec.js
View file @
b7b2c285
...
...
@@ -51,9 +51,7 @@ describe('GeoNodeLastUpdated', () => {
it
(
'
renders main text correctly
'
,
()
=>
{
expect
(
findMainText
().
exists
()).
toBe
(
true
);
expect
(
findMainText
().
find
(
TimeAgo
).
props
(
'
time
'
)).
toBe
(
new
Date
(
staleStatusTime
).
toString
(),
);
expect
(
findMainText
().
find
(
TimeAgo
).
props
(
'
time
'
)).
toBe
(
staleStatusTime
);
});
it
(
'
renders the question icon correctly
'
,
()
=>
{
...
...
@@ -67,9 +65,7 @@ describe('GeoNodeLastUpdated', () => {
it
(
'
renders the popover text correctly
'
,
()
=>
{
expect
(
findPopoverText
().
exists
()).
toBe
(
true
);
expect
(
findPopoverText
().
find
(
TimeAgo
).
props
(
'
time
'
)).
toBe
(
new
Date
(
staleStatusTime
).
toString
(),
);
expect
(
findPopoverText
().
find
(
TimeAgo
).
props
(
'
time
'
)).
toBe
(
staleStatusTime
);
});
it
(
'
renders the popover link always
'
,
()
=>
{
...
...
spec/frontend/vue_shared/components/time_ago_tooltip_spec.js
View file @
b7b2c285
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
timezoneMock
from
'
timezone-mock
'
;
import
{
formatDate
,
getTimeago
}
from
'
~/lib/utils/datetime_utility
'
;
import
TimeAgoTooltip
from
'
~/vue_shared/components/time_ago_tooltip.vue
'
;
describe
(
'
Time ago with tooltip component
'
,
()
=>
{
let
vm
;
const
buildVm
=
(
propsData
=
{},
scopedSlots
=
{})
=>
{
const
timestamp
=
'
2017-05-08T14:57:39.781Z
'
;
const
timeAgoTimestamp
=
getTimeago
().
format
(
timestamp
);
const
defaultProps
=
{
time
:
timestamp
,
};
const
buildVm
=
(
props
=
{},
scopedSlots
=
{})
=>
{
vm
=
shallowMount
(
TimeAgoTooltip
,
{
propsData
,
propsData
:
{
...
defaultProps
,
...
props
,
},
scopedSlots
,
});
};
const
timestamp
=
'
2017-05-08T14:57:39.781Z
'
;
const
timeAgoTimestamp
=
getTimeago
().
format
(
timestamp
);
afterEach
(()
=>
{
vm
.
destroy
();
timezoneMock
.
unregister
();
});
it
(
'
should render timeago with a bootstrap tooltip
'
,
()
=>
{
buildVm
({
time
:
timestamp
,
});
buildVm
();
expect
(
vm
.
attributes
(
'
title
'
)).
toEqual
(
formatDate
(
timestamp
));
expect
(
vm
.
text
()).
toEqual
(
timeAgoTimestamp
);
...
...
@@ -30,7 +38,6 @@ describe('Time ago with tooltip component', () => {
it
(
'
should render provided html class
'
,
()
=>
{
buildVm
({
time
:
timestamp
,
cssClass
:
'
foo
'
,
});
...
...
@@ -38,14 +45,58 @@ describe('Time ago with tooltip component', () => {
});
it
(
'
should render with the datetime attribute
'
,
()
=>
{
buildVm
(
{
time
:
timestamp
}
);
buildVm
();
expect
(
vm
.
attributes
(
'
datetime
'
)).
toEqual
(
timestamp
);
});
it
(
'
should render provided scope content with the correct timeAgo string
'
,
()
=>
{
buildVm
(
{
time
:
timestamp
}
,
{
default
:
`<span>The time is {{ props.timeAgo }}</span>`
});
buildVm
(
null
,
{
default
:
`<span>The time is {{ props.timeAgo }}</span>`
});
expect
(
vm
.
text
()).
toEqual
(
`The time is
${
timeAgoTimestamp
}
`
);
});
describe
(
'
number based timestamps
'
,
()
=>
{
// Store a date object before we mock the TZ
const
date
=
new
Date
();
describe
(
'
with default TZ
'
,
()
=>
{
beforeEach
(()
=>
{
buildVm
({
time
:
date
.
getTime
()
});
});
it
(
'
handled correctly
'
,
()
=>
{
expect
(
vm
.
text
()).
toEqual
(
getTimeago
().
format
(
date
.
getTime
()));
});
});
describe
.
each
`
timezone | offset
${
'
US/Pacific
'
}
|
${
420
}
${
'
US/Eastern
'
}
|
${
240
}
${
'
Brazil/East
'
}
|
${
180
}
${
'
UTC
'
}
|
${
-
0
}
${
'
Europe/London
'
}
|
${
-
60
}
`
(
'
with different client vs server TZ
'
,
({
timezone
,
offset
})
=>
{
let
tzDate
;
beforeEach
(()
=>
{
timezoneMock
.
register
(
timezone
);
// Date object with mocked TZ
tzDate
=
new
Date
();
buildVm
({
time
:
date
.
getTime
()
});
});
it
(
'
the date object should have correct timezones
'
,
()
=>
{
expect
(
tzDate
.
getTimezoneOffset
()).
toBe
(
offset
);
});
it
(
'
timeago should handled the date correctly
'
,
()
=>
{
// getTime() should always handle the TZ, which allows for us to validate the date objects represent
// the same date and time regardless of the TZ.
expect
(
vm
.
text
()).
toEqual
(
getTimeago
().
format
(
date
.
getTime
()));
expect
(
vm
.
text
()).
toEqual
(
getTimeago
().
format
(
tzDate
.
getTime
()));
});
});
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment