Skip to content

Commit

Permalink
Merge branch 'main' into ADM-678
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrea2000728 authored Dec 20, 2023
2 parents d73a9be + d3c2a42 commit b9eb21b
Show file tree
Hide file tree
Showing 17 changed files with 267 additions and 43 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/BuildAndDeploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ jobs:
uses: gradle/gradle-build-action@v2.10.0
- name: License check
run: ./gradlew clean checkLicense
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
if: ${{ failure() }}
with:
name: backend-license-report
Expand Down Expand Up @@ -484,7 +484,7 @@ jobs:
env:
APP_ORIGIN: ${{ vars.APP_HTTP_SCHEDULE }}://${{ secrets.AWS_EC2_IP_E2E }}:${{ secrets.AWS_EC2_IP_E2E_FRONTEND_PORT }}
run: pnpm run e2e
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
if: always()
with:
name: cypress-videos
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/Release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
uses: gradle/gradle-build-action@v2.10.0
- name: Build
run: ./gradlew clean build
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: backend-app
path: backend/build/libs/heartbeat-backend-0.0.1-SNAPSHOT.jar
Expand All @@ -53,7 +53,7 @@ jobs:
- name: Build
run: |
pnpm run build
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: frontend-app
path: frontend/dist
Expand Down Expand Up @@ -98,12 +98,12 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Download frontend artifact
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: frontend-app
path: ./${{ env.REPO_NAME }}-frontend
- name: Download backend artifact
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: backend-app
- name: List
Expand Down
2 changes: 1 addition & 1 deletion backend/src/main/java/heartbeat/config/CacheConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public CacheManager ehCacheManager() {
@SuppressWarnings("unchecked")
private <K, V> javax.cache.configuration.Configuration<K, V> getCacheConfiguration(Class<V> valueType) {
val offHeap = ResourcePoolsBuilder.newResourcePoolsBuilder().offheap(2, MemoryUnit.MB);
val timeToLive = Duration.ofSeconds(20);
val timeToLive = Duration.ofSeconds(180);
CacheConfigurationBuilder<K, V> configuration = CacheConfigurationBuilder
.newCacheConfigurationBuilder((Class<K>) String.class, valueType, offHeap)
.withExpiry(ExpiryPolicyBuilder.timeToLiveExpiration(timeToLive));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class ThreadPoolConfig {
@Bean("customTaskExecutor")
public ThreadPoolTaskExecutor taskExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(10);
executor.setCorePoolSize(20);
executor.setMaxPoolSize(100);
executor.setQueueCapacity(500);
executor.setKeepAliveSeconds(60);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,16 @@ jest.mock('@src/utils/util', () => ({
filterAndMapCycleTimeSettings: jest.fn(),
}))

jest.mock('@src/hooks/useGenerateReportEffect', () => ({
useGenerateReportEffect: jest.fn().mockReturnValue({
startPollingReports: jest.fn(),
stopPollingReports: jest.fn(),
isLoading: false,
isServerError: false,
errorMessage: '',
}),
}))

const server = setupServer(rest.post(MOCK_REPORT_URL, (_, res, ctx) => res(ctx.status(HttpStatusCode.Ok))))

const mockLocation = { reload: jest.fn() }
Expand Down Expand Up @@ -342,6 +352,38 @@ describe('MetricsStepper', () => {
expect(exportToJsonFile).toHaveBeenCalledWith(expectedFileName, expectedJson)
}, 50000)

it('should export json file when click save button in report page given all content is empty', async () => {
const expectedFileName = 'config'
const expectedJson = {
assigneeFilter: ASSIGNEE_FILTER_TYPES.LAST_ASSIGNEE,
board: { boardId: '', email: '', projectKey: '', site: '', token: '', type: 'Jira' },
calendarType: 'Regular Calendar(Weekend Considered)',
dateRange: {
endDate: dayjs().endOf('date').add(13, 'day').format('YYYY-MM-DDTHH:mm:ss.SSSZ'),
startDate: dayjs().startOf('date').format('YYYY-MM-DDTHH:mm:ss.SSSZ'),
},
metrics: ['Velocity'],
pipelineTool: undefined,
projectName: 'test project Name',
sourceControl: undefined,
classification: undefined,
crews: undefined,
cycleTime: undefined,
deployment: undefined,
doneStatus: undefined,
leadTime: undefined,
}

const { getByText } = setup()
await fillConfigPageData()
await userEvent.click(getByText(NEXT))
await fillMetricsPageDate()
await userEvent.click(getByText(NEXT))
await userEvent.click(getByText(SAVE))

expect(exportToJsonFile).toHaveBeenCalledWith(expectedFileName, expectedJson)
}, 50000)

it('should clean the config information that is hidden when click next button', async () => {
const { getByText } = setup()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
EXPORT_PIPELINE_DATA,
MOCK_JIRA_VERIFY_RESPONSE,
REQUIRED_DATA_LIST,
SAVE,
} from '../../../fixtures'
import { setupStore } from '../../../utils/setupStoreUtil'
import { Provider } from 'react-redux'
Expand Down Expand Up @@ -79,6 +80,7 @@ describe('Report Step', () => {
reportHook.current.errorMessage = ''
reportHook.current.reports = EXPECTED_REPORT_VALUES
}
const handleSaveMock = jest.fn()
const setup = (params: [string]) => {
store = setupStore()
store.dispatch(
Expand Down Expand Up @@ -112,7 +114,7 @@ describe('Report Step', () => {
)
return render(
<Provider store={store}>
<ReportStep {...notificationHook.current} />
<ReportStep {...notificationHook.current} handleSave={handleSaveMock} />
</Provider>
)
}
Expand Down Expand Up @@ -153,6 +155,15 @@ describe('Report Step', () => {
expect(backStep).toHaveBeenCalledTimes(1)
})

it('should call handleSaveMock method when click save button', async () => {
const { getByText } = setup([''])

const save = getByText(SAVE)
await userEvent.click(save)

expect(handleSaveMock).toHaveBeenCalledTimes(1)
})

it('should not show export pipeline button when not select deployment frequency', () => {
const { queryByText } = setup([REQUIRED_DATA_LIST[1]])

Expand Down
16 changes: 16 additions & 0 deletions frontend/cypress/e2e/importAProject.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,18 @@ const checkRequiredFields = () => {
metricsPage.nextButton.should('be.enabled')
}

const checkProjectConfig = () => {
cy.wait(2000)
cy.fixture('config.json').then((localFileContent) => {
cy.readFile('cypress/downloads/config.json').then((fileContent) => {
expect(fileContent.sourceControl.token).to.eq(GITHUB_TOKEN)
for (const key in localFileContent) {
expect(fileContent[key]).to.deep.eq(localFileContent[key])
}
})
})
}

describe('Import project from file', () => {
beforeEach(() => {
cy.waitForNetworkIdlePrepare({
Expand Down Expand Up @@ -152,6 +164,10 @@ describe('Import project from file', () => {

checkMeanTimeToRecovery('[data-test-id="Mean Time To Recovery"]')

reportPage.exportProjectConfig()

checkProjectConfig()

reportPage.backToMetricsStep()

checkFieldsExist(metricsTextList)
Expand Down
101 changes: 101 additions & 0 deletions frontend/cypress/fixtures/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
{
"projectName": "ConfigFileForImporting",
"dateRange": {
"startDate": "2022-09-01T00:00:00.000+08:00",
"endDate": "2022-09-14T23:59:59.999+08:00"
},
"calendarType": "Calendar with Chinese Holiday",
"metrics": [
"Velocity",
"Cycle time",
"Classification",
"Lead time for changes",
"Deployment frequency",
"Mean time to recovery"
],
"board": {
"type": "Classic Jira",
"boardId": "1963",
"email": "test@test.com",
"projectKey": "PLL",
"site": "mockSite",
"token": "mockToken"
},
"pipelineTool": {
"type": "BuildKite",
"token": "mockToken"
},
"crews": ["Yu Zhang"],
"assigneeFilter": "lastAssignee",
"cycleTime": {
"jiraColumns": [
{
"In Analysis": "Analysis"
},
{
"Ready For Dev": "To do"
},
{
"In Dev": "In Dev"
},
{
"Blocked": "Block"
},
{
"Ready For Test": "Waiting for testing"
},
{
"In Test": "Testing"
},
{
"Ready to Deploy": "Review"
},
{
"Done": "Done"
}
],
"treatFlagCardAsBlock": true
},
"doneStatus": ["DONE", "CLOSED"],
"classification": [
"issuetype",
"customfield_21212",
"customfield_22466",
"parent",
"components",
"project",
"reporter",
"customfield_16400",
"fixVersions",
"priority",
"customfield_16800",
"labels",
"customfield_10004",
"customfield_10007",
"customfield_10008",
"assignee",
"customfield_22203",
"customfield_21871",
"customfield_10009",
"customfield_11700",
"environment",
"versions",
"customfield_22213",
"customfield_22231",
"customfield_17000",
"customfield_16302",
"customfield_14603",
"customfield_22229",
"customfield_22228",
"customfield_22226"
],
"deployment": [
{
"id": 0,
"organization": "XXXX",
"pipelineName": "fs-platform-onboarding",
"step": " :docker: publish gradle-cache image to cloudsmith",
"branches": ["PLL-1326", "PLL-1406", "PLL-1406-1", "master"]
}
]
}
10 changes: 9 additions & 1 deletion frontend/cypress/pages/metrics/report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ class Report {
return cy.contains('Previous')
}

get saveButton() {
return cy.contains('Save')
}

get exportMetricDataButton() {
return cy.contains('Export metric data')
}
Expand All @@ -43,7 +47,7 @@ class Report {
}

backToMetricsStep() {
this.backButton.click()
this.backButton.click({ force: true })
}

exportMetricData() {
Expand All @@ -57,6 +61,10 @@ class Report {
exportBoardData() {
this.exportBoardDataButton.click()
}

exportProjectConfig() {
this.saveButton.click({ force: true })
}
}

const reportPage = new Report()
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/components/HomeGuide/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { updateMetricsImportedData } from '@src/context/Metrics/metricsSlice'
import { resetStep } from '@src/context/stepper/StepperSlice'
import { WarningNotification } from '@src/components/Common/WarningNotification'
import { convertToNewFileConfig, NewFileConfig, OldFileConfig } from '@src/fileConfig/fileConfig'
import { GuideButton, HomeGuideContainer } from '@src/components/HomeGuide/style'
import { GuideButton, HomeGuideContainer, StyledStack } from '@src/components/HomeGuide/style'
import { MESSAGE } from '@src/constants/resources'
import { ROUTE } from '@src/constants/router'

Expand Down Expand Up @@ -70,11 +70,11 @@ export const HomeGuide = () => {
return (
<HomeGuideContainer>
{!validConfig && <WarningNotification message={MESSAGE.HOME_VERIFY_IMPORT_WARNING} />}
<Stack direction='column' justifyContent='center' alignItems='center' flex={'auto'}>
<StyledStack direction='column' justifyContent='center' alignItems='center' flex={'auto'}>
<GuideButton onClick={openFileImportBox}>Import project from file</GuideButton>
<input hidden type='file' data-testid='testInput' id='importJson' accept='.json' onChange={handleChange} />
<GuideButton onClick={createNewProject}>Create a new project</GuideButton>
</Stack>
</StyledStack>
</HomeGuideContainer>
)
}
10 changes: 9 additions & 1 deletion frontend/src/components/HomeGuide/style.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { theme } from '@src/theme'
import Button, { ButtonProps } from '@mui/material/Button'
import styled from '@emotion/styled'
import Stack from '@mui/material/Stack'

export const basicStyle = {
backgroundColor: theme.main.backgroundColor,
Expand All @@ -27,7 +28,14 @@ export const GuideButton = styled(Button)<ButtonProps>({
},
})

export const StyledStack = styled(Stack)<ButtonProps>({
position: 'absolute',
top: '50%',
left: '50%',
transform: 'translate(-50%,-50%)',
})

export const HomeGuideContainer = styled.div({
height: '44rem',
display: 'flex',
position: 'relative',
})
Loading

0 comments on commit b9eb21b

Please sign in to comment.