Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADM-662: [frontend] add version in header #824

Merged
merged 21 commits into from
Dec 18, 2023
Merged

ADM-662: [frontend] add version in header #824

merged 21 commits into from
Dec 18, 2023

Conversation

neomgb
Copy link

@neomgb neomgb commented Dec 18, 2023

Summary

add version in header

Before

Description

Screenshots
If applicable, add screenshots to help explain behavior of your code.
image

After

Description

Screenshots
image

Note

Null

Copy link

codacy-production bot commented Dec 18, 2023

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+0.00% 100.00%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (8edc996) 4396 4396 100.00%
Head commit (ce88770) 4417 (+21) 4417 (+21) 100.00% (+0.00%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#824) 21 21 100.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

You may notice some variations in coverage metrics with the latest Coverage engine update. For more details, visit the documentation

Copy link

Hi @neomgb! 👋
Thank you for submitting a pull request! We appreciate your contribution and will review your changes as soon as possible.

@neomgb neomgb requested a review from Zxx-Ivy December 18, 2023 02:49
description: |
What version of our software are you running? There is two methods to get the current version:
1. you can see the version info at the top of the heartbeat pages
2. Add “api/v1/version”after the host address you visit the heartbeat
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use English quotation marks

@@ -15,6 +24,34 @@ describe('Header', () => {
expect(getByText(PROJECT_NAME)).toBeInTheDocument()
})

it('should show version info when request succeed', async () => {
headerClient.getVersion = jest.fn().mockResolvedValueOnce('1.11')
let component: any
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix issues of github actions


it('should show version info when request failed', async () => {
headerClient.getVersion = jest.fn().mockResolvedValueOnce('')
let component: any
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the same

let component: any
await act(async () => {
component = render(
<BrowserRouter>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can extract a function for those piece of lines

headerClient.getVersion = jest.fn().mockResolvedValueOnce('')
let component: any
await act(async () => {
component = render(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can extract a function for those piece of lines

@@ -11,6 +11,10 @@ class Home {
this.createANewProjectButton().click()
}

checkVersion = () => {
cy.get('span[title="Heartbeat"]').parent().next().should('exist')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please follow the POM pattern and avoid using assert at the page level

// fontSize: '0.88rem',
fontSize: '14px',
export const StyledTypography = styled('div')({
width: '10rem',
})
```
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can add a new one, e2e requires the use of POM's model

})

const setup = () =>
act(async () =>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to put "act" to assert block

@neomgb neomgb merged commit 3bf47ed into main Dec 18, 2023
41 checks passed
@neomgb neomgb deleted the ADM-662 branch December 18, 2023 06:36
Copy link
Collaborator

@guzhongren guzhongren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PLZ update commit with the comments

suggestion: PLZ refactor code after coding. Ref to red green blue of the refactor

expect(getByText(PROJECT_NAME)).toBeInTheDocument()
})

it('should show version info when request succeed', async () => {
headerClient.getVersion = jest.fn().mockResolvedValueOnce('1.11')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@neomgb using 1.11 from fixtures.ts

afterAll(() => server.close())

it('should get response when get header status 200', async () => {
const excepted = '1.11'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixturet.ts

headerClient.getVersion = jest.fn().mockResolvedValueOnce('1.11')
const { getByText } = await act(async () => setup())

expect(getByText(/v1.11/)).toBeInTheDocument()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixtures.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants