Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
amundsen_dev
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Surendar Reddy Mangannagari
amundsen_dev
Commits
8b9ce930
Unverified
Commit
8b9ce930
authored
Aug 26, 2020
by
Marcos Iglesias
Committed by
GitHub
Aug 26, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes ordering issue on announcements on homepage (#619)
Signed-off-by:
Marcos Iglesias Valle
<
golodhros@gmail.com
>
parent
ebdcc0ac
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
15 deletions
+35
-15
index.spec.tsx
...nts/common/Announcements/AnnouncementsList/index.spec.tsx
+34
-14
index.tsx
...mponents/common/Announcements/AnnouncementsList/index.tsx
+1
-1
No files found.
amundsen_application/static/js/components/common/Announcements/AnnouncementsList/index.spec.tsx
View file @
8b9ce930
import
*
as
React
from
'react'
;
import
*
as
React
from
'react'
;
import
{
Link
,
BrowserRouter
}
from
'react-router-dom'
;
import
{
Link
,
BrowserRouter
}
from
'react-router-dom'
;
import
SanitizedHTML
from
'react-sanitized-html'
;
import
{
mount
}
from
'enzyme'
;
import
{
mount
}
from
'enzyme'
;
import
Card
from
'../../Card'
;
import
Card
from
'../../Card'
;
...
@@ -8,27 +7,22 @@ import Card from '../../Card';
...
@@ -8,27 +7,22 @@ import Card from '../../Card';
import
AnnouncementsList
,
{
AnnouncementsListProps
}
from
'.'
;
import
AnnouncementsList
,
{
AnnouncementsListProps
}
from
'.'
;
const
TWO_FAKE_ANNOUNCEMENTS
=
[
const
TWO_FAKE_ANNOUNCEMENTS
=
[
{
date
:
'12/31/1999'
,
title
:
'Y2K'
,
html_content
:
'<div>The end of the world</div>'
,
},
{
{
date
:
'01/01/2000'
,
date
:
'01/01/2000'
,
title
:
'False Alarm'
,
title
:
'False Alarm'
,
html_content
:
'<div>Just kidding</div>'
,
html_content
:
'<div>Just kidding</div>'
,
},
},
];
const
FOUR_FAKE_ANNOUNCEMENTS
=
[
{
{
date
:
'12/31/1999'
,
date
:
'12/31/1999'
,
title
:
'Y2K'
,
title
:
'Y2K'
,
html_content
:
'<div>The end of the world</div>'
,
html_content
:
'<div>The end of the world</div>'
,
},
},
];
const
FOUR_FAKE_ANNOUNCEMENTS
=
[
{
{
date
:
'01/01/20
0
0'
,
date
:
'01/01/20
2
0'
,
title
:
'
False Alarm
'
,
title
:
'
New Test
'
,
html_content
:
'<div>
Just kidding
</div>'
,
html_content
:
'<div>
New test
</div>'
,
},
},
{
{
date
:
'12/31/2009'
,
date
:
'12/31/2009'
,
...
@@ -36,9 +30,14 @@ const FOUR_FAKE_ANNOUNCEMENTS = [
...
@@ -36,9 +30,14 @@ const FOUR_FAKE_ANNOUNCEMENTS = [
html_content
:
'<div>Old test</div>'
,
html_content
:
'<div>Old test</div>'
,
},
},
{
{
date
:
'01/01/2020'
,
date
:
'01/01/2000'
,
title
:
'New Test'
,
title
:
'False Alarm'
,
html_content
:
'<div>New test</div>'
,
html_content
:
'<div>Just kidding</div>'
,
},
{
date
:
'12/31/1999'
,
title
:
'Y2K'
,
html_content
:
'<div>The end of the world</div>'
,
},
},
];
];
const
EMPTY_ANNOUNCEMENTS
=
[];
const
EMPTY_ANNOUNCEMENTS
=
[];
...
@@ -171,6 +170,27 @@ describe('AnnouncementsList', () => {
...
@@ -171,6 +170,27 @@ describe('AnnouncementsList', () => {
const
expected
=
3
;
const
expected
=
3
;
const
actual
=
wrapper
.
find
(
Card
).
length
;
const
actual
=
wrapper
.
find
(
Card
).
length
;
expect
(
actual
).
toEqual
(
expected
);
wrapper
.
unmount
();
});
it
(
'should render them starting on the latest announcement'
,
()
=>
{
const
{
wrapper
}
=
setup
({
announcements
:
FOUR_FAKE_ANNOUNCEMENTS
,
});
const
firstCardDate
=
wrapper
.
find
(
Card
)
.
at
(
0
)
.
find
(
'.card-subtitle'
)
.
text
();
const
lastCardDate
=
wrapper
.
find
(
Card
)
.
at
(
1
)
.
find
(
'.card-subtitle'
)
.
text
();
const
actual
=
new
Date
(
firstCardDate
)
>=
new
Date
(
lastCardDate
);
const
expected
=
true
;
expect
(
actual
).
toEqual
(
expected
);
expect
(
actual
).
toEqual
(
expected
);
});
});
});
});
...
...
amundsen_application/static/js/components/common/Announcements/AnnouncementsList/index.tsx
View file @
8b9ce930
...
@@ -27,7 +27,7 @@ export interface AnnouncementsListProps {
...
@@ -27,7 +27,7 @@ export interface AnnouncementsListProps {
const
getLatestsAnnouncements
=
(
announcements
:
AnnouncementPost
[])
=>
const
getLatestsAnnouncements
=
(
announcements
:
AnnouncementPost
[])
=>
announcements
.
length
>
ANNOUNCEMENT_LIST_THRESHOLD
announcements
.
length
>
ANNOUNCEMENT_LIST_THRESHOLD
?
announcements
.
s
plice
(
announcements
.
length
-
ANNOUNCEMENT_LIST_THRESHOLD
)
?
announcements
.
s
lice
(
0
,
ANNOUNCEMENT_LIST_THRESHOLD
)
:
announcements
;
:
announcements
;
const
times
=
(
numItems
:
number
)
=>
new
Array
(
numItems
).
fill
(
0
);
const
times
=
(
numItems
:
number
)
=>
new
Array
(
numItems
).
fill
(
0
);
...
...
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