-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4402 from cloud-gov/4379-explain-that-build-logs-…
…are-gone-after-180-days fix: Add message explaining that build logs are deleted after 180 days.
- Loading branch information
Showing
7 changed files
with
147 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './useBuildDetails'; | ||
export * from './useBuildLogs'; | ||
export * from './useSiteBranchConfigs'; | ||
export * from './useSiteDomains'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* eslint-disable import/prefer-default-export */ | ||
import { useEffect, useState } from 'react'; | ||
import api from '../util/federalistApi'; | ||
|
||
const initResultsState = { | ||
buildDetails: null, | ||
isLoading: true, | ||
}; | ||
|
||
export const useBuildDetails = (id) => { | ||
const [results, setResults] = useState(initResultsState); | ||
|
||
useEffect(() => { | ||
if (!results.buildDetails) { | ||
api.fetchBuild(id).then(data => setResults({ | ||
isLoading: false, | ||
buildDetails: data, | ||
})); | ||
} | ||
}, [results]); | ||
|
||
return results; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,58 @@ | ||
import React from 'react'; | ||
import { expect, assert } from 'chai'; | ||
import proxyquire from 'proxyquire'; | ||
import sinon from 'sinon'; | ||
import { mount } from 'enzyme'; | ||
|
||
import api from '../../../../frontend/util/federalistApi'; | ||
import LoadingIndicator from '../../../../frontend/components/LoadingIndicator'; | ||
|
||
proxyquire.noCallThru(); | ||
|
||
const fetchBuildMock = sinon.stub(); | ||
const buildActions = { | ||
fetchBuild: fetchBuildMock, | ||
}; | ||
const CommitSummary = proxyquire( | ||
'../../../../frontend/components/site/CommitSummary', | ||
{ | ||
'../icons': { | ||
IconBranch: () => <span />, | ||
}, | ||
'../../actions/buildActions': buildActions, | ||
} | ||
).default; | ||
|
||
const defaultProps = { | ||
buildId: 1, | ||
buildDetails: { | ||
site: { | ||
owner: 'user', | ||
repository: 'repo', | ||
}, | ||
branch: 'branch', | ||
username: 'username', | ||
clonedCommitSha: 'sha4567890abcdef', | ||
createdAt: new Date(), | ||
} | ||
}; | ||
|
||
describe('<CommitSummary />', () => { | ||
afterEach(() => { | ||
sinon.restore(); | ||
}); | ||
|
||
it('should exist', () => { | ||
assert.isDefined(CommitSummary); | ||
}); | ||
|
||
it('renders a loading state whie loading', () => { | ||
const stub = sinon.stub(api, 'fetchBuild'); | ||
stub.resolves([]); | ||
|
||
const wrapper = mount(<CommitSummary {...defaultProps} />); | ||
it('renders a loading state while loading', () => { | ||
const wrapper = mount(<CommitSummary { ...{ buildDetails: null } } />); | ||
expect(wrapper.find(LoadingIndicator)).to.have.length(1); | ||
}); | ||
|
||
// no useEffect in tests | ||
// it('requests build information once on load', () => { | ||
// const wrapper = mountStore(<CommitSummary {...defaultProps} />, defaultState); | ||
// const buildId = 1; | ||
// expect(fetchBuildMock.callCount).to.be.greaterThanOrEqual(1); | ||
// fetchBuildMock.resetHistory(); | ||
// sinon.restore(); | ||
// }); | ||
|
||
// describe('after load', () => { | ||
// let wrapper; | ||
// let loadedState = lodashClonedeep(defaultState); | ||
// loadedState.build = { | ||
// isLoading: false, | ||
// data: { ...defaultBuildData } | ||
// }; | ||
|
||
// it('renders the branch and github user name for the commit', () => { | ||
// wrapper = mountStore(<CommitSummary {...defaultProps} />, loadedState); | ||
// expect(wrapper.find('.commit-branch')).to.have.length(1); | ||
// expect(wrapper.find('.commit-branch').text()).to.contain(defaultBuildData.branch); | ||
// expect(wrapper.find('.commit-username')).to.have.length(1); | ||
// expect(wrapper.find('.commit-username').text()).to.equal(defaultBuildData.username); | ||
// }); | ||
|
||
// it('formats a sha link correctly and limits to first 7 chars', () => { | ||
// wrapper = mountStore(<CommitSummary {...defaultProps} />, loadedState); | ||
// expect(wrapper.find('.sha-link')).to.have.length(1); | ||
// expect(defaultBuildData.clonedCommitSha).to.contain(wrapper.find('.sha-link').text()); | ||
// expect(wrapper.find('.sha-link').text()).to.have.length(7); | ||
// }); | ||
// }); | ||
describe('after load', () => { | ||
const build = defaultProps.buildDetails; | ||
|
||
it('renders the branch and github user name for the commit', () => { | ||
const wrapper = mount(<CommitSummary {...defaultProps} />); | ||
expect(wrapper.find('.commit-branch')).to.have.length(1); | ||
expect(wrapper.find('.commit-branch').text()).to.contain(build.branch); | ||
expect(wrapper.find('.commit-username')).to.have.length(1); | ||
expect(wrapper.find('.commit-username').text()).to.equal(build.username); | ||
}); | ||
|
||
it('formats a sha link correctly and limits to first 7 chars', () => { | ||
const wrapper = mount(<CommitSummary {...defaultProps} />); | ||
expect(wrapper.find('.sha-link')).to.have.length(1); | ||
expect(build.clonedCommitSha).to.contain(wrapper.find('.sha-link').text()); | ||
expect(wrapper.find('.sha-link').text()).to.have.length(7); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters