Skip to content

Commit c68fbcb

Browse files
committed
StatsMetadata i18n fix
1 parent 7352797 commit c68fbcb

File tree

4 files changed

+94
-33
lines changed

4 files changed

+94
-33
lines changed

packages/app/src/debug/GroupedDebugFailedTest.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const props = defineProps<{
4747
4848
const debugArtifacts = computed(() => {
4949
return props.failedTests.reduce<{[groupID: string]: {icon: string, text: string, url: string | null | undefined }[] }>((acc, curr) => {
50-
//TODO Update logic to not rely on defaulting to empty strings
50+
//TODO Update logic to not rely on defaulting to empty strings and only render appropriate links See https://github.com/cypress-io/cypress/issues/25319
5151
acc[curr.instance?.groupId ?? ''] = [
5252
{ icon: 'TERMINAL_LOG', text: 'View Log', url: curr.instance!.stdoutUrl ?? '' },
5353
{ icon: 'IMAGE_SCREENSHOT', text: 'View Screenshot', url: curr.instance!.screenshotsUrl ?? '' },

packages/app/src/debug/StatsMetadata.cy.tsx

+85-14
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import StatsMetadata from './StatsMetadata.vue'
22

33
describe('mounts correctly', () => {
4-
const group1 = {
4+
const group_linux_chrome = {
55
id: '123',
66
os: {
77
id: '123',
@@ -16,7 +16,7 @@ describe('mounts correctly', () => {
1616
groupName: 'Staging',
1717
}
1818

19-
const group2 = {
19+
const group_macos_edge = {
2020
id: '123',
2121
os: {
2222
id: '123',
@@ -31,7 +31,7 @@ describe('mounts correctly', () => {
3131
groupName: 'Production',
3232
}
3333

34-
const group3 = {
34+
const group_windows_webkit = {
3535
id: '123',
3636
os: {
3737
id: '123',
@@ -46,16 +46,31 @@ describe('mounts correctly', () => {
4646
groupName: 'Production',
4747
}
4848

49+
const group_windows_chrome = {
50+
id: '123',
51+
os: {
52+
id: '123',
53+
name: 'Windows',
54+
nameWithVersion: 'Windows 12.3',
55+
},
56+
browser: {
57+
id: '123',
58+
formattedName: 'Chrome',
59+
formattedNameWithVersion: 'Chrome 106',
60+
},
61+
groupName: 'Production',
62+
}
63+
4964
it('single values', () => {
5065
const testingOrder = ['spec-duration 2:23', 'operating-system Linux Debian', 'browser Chrome 106', 'testing-type component']
5166

5267
cy.mount(() => (
53-
<div class='bg-gray-50'>
68+
<div class='flex bg-gray-50 gap-x-3'>
5469
<StatsMetadata
5570
order={['DURATION', 'OS', 'BROWSER', 'TESTING']}
5671
specDuration={'2:23'}
5772
testing={'component'}
58-
groups={[group1]}
73+
groups={[group_linux_chrome]}
5974
/>
6075
</div>
6176
))
@@ -79,12 +94,12 @@ describe('mounts correctly', () => {
7994
]
8095

8196
cy.mount(() => (
82-
<div class='bg-gray-50'>
97+
<div class='flex bg-gray-50 gap-x-3'>
8398
<StatsMetadata
8499
order={['DURATION', 'GROUPS', 'G_OS', 'G_BROWSERS', 'TESTING']}
85100
specDuration={'2:23-3:40'}
86101
testing={'e2e'}
87-
groups={[group2, group1, group3]}
102+
groups={[group_macos_edge, group_linux_chrome, group_windows_webkit]}
88103
/>
89104
</div>
90105
))
@@ -98,13 +113,69 @@ describe('mounts correctly', () => {
98113
cy.percySnapshot()
99114
})
100115

116+
it('group values with 1 browser', () => {
117+
const testingOrder = [
118+
'spec-duration 2:23-3:40',
119+
'group-server 2 groups',
120+
'operating-system-groups 2 operating systems',
121+
'browser-groups 1 browser',
122+
'testing-type e2e',
123+
]
124+
125+
cy.mount(() => (
126+
<div class='flex bg-gray-50 gap-x-3'>
127+
<StatsMetadata
128+
order={['DURATION', 'GROUPS', 'G_OS', 'G_BROWSERS', 'TESTING']}
129+
specDuration={'2:23-3:40'}
130+
testing={'e2e'}
131+
groups={[group_linux_chrome, group_windows_chrome]}
132+
/>
133+
</div>
134+
))
135+
136+
cy.findByTestId('stats-metadata').children().should('have.length', 5)
137+
cy.findByTestId('stats-metadata').children().each((ele, index) => {
138+
cy.wrap(ele).should('have.text', testingOrder[index])
139+
cy.findByTestId(testingOrder[index]).should('be.visible')
140+
})
141+
})
142+
143+
it('group values with 1 os', () => {
144+
const testingOrder = [
145+
'spec-duration 2:23-3:40',
146+
'group-server 2 groups',
147+
'operating-system-groups 1 operating system',
148+
'browser-groups 2 browsers',
149+
'testing-type e2e',
150+
]
151+
152+
cy.mount(() => (
153+
<div class='flex bg-gray-50 gap-x-3'>
154+
<StatsMetadata
155+
order={['DURATION', 'GROUPS', 'G_OS', 'G_BROWSERS', 'TESTING']}
156+
specDuration={'2:23-3:40'}
157+
testing={'e2e'}
158+
groups={[group_windows_webkit, group_windows_chrome]}
159+
/>
160+
</div>
161+
))
162+
163+
cy.findByTestId('stats-metadata').children().should('have.length', 5)
164+
cy.findByTestId('stats-metadata').children().each((ele, index) => {
165+
cy.wrap(ele).should('have.text', testingOrder[index])
166+
cy.findByTestId(testingOrder[index]).should('be.visible')
167+
})
168+
})
169+
101170
it('shows the correct groupName', () => {
102171
cy.mount(() => (
103-
<StatsMetadata
104-
order={['GROUP_NAME', 'OS', 'BROWSER']}
105-
groups={[group1]}
106-
groupName={group1.groupName}
107-
/>
172+
<div class='flex bg-gray-50 gap-x-3'>
173+
<StatsMetadata
174+
order={['GROUP_NAME', 'OS', 'BROWSER']}
175+
groups={[group_linux_chrome]}
176+
groupName={group_linux_chrome.groupName}
177+
/>
178+
</div>
108179
))
109180

110181
cy.findByTestId('group_name Staging').should('be.visible')
@@ -113,12 +184,12 @@ describe('mounts correctly', () => {
113184
// This tests the functionality for arrMapping in StatsMetadata
114185
it('only displays unique browsers and calculates correct number of OS', () => {
115186
cy.mount(() => (
116-
<div class='bg-gray-50'>
187+
<div class='flex bg-gray-50 gap-x-3'>
117188
<StatsMetadata
118189
order={['DURATION', 'GROUPS', 'G_OS', 'G_BROWSERS', 'TESTING']}
119190
specDuration={'2:23-3:40'}
120191
testing={'component'}
121-
groups={[group2, group1, group2]}
192+
groups={[group_macos_edge, group_linux_chrome, group_macos_edge]}
122193
/>
123194
</div>
124195
))

packages/app/src/debug/StatsMetadata.vue

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<ul
33
data-cy="stats-metadata"
4-
class="contents items-center gap-x-2 text-gray-700 whitespace-nowrap children:flex children:items-center font-normal text-sm w-full stats-metadata-class"
4+
class="font-normal text-sm w-full text-gray-700 gap-x-2 contents items-center whitespace-nowrap stats-metadata-class children:flex children:items-center"
55
>
66
<li
77
v-for="(result, i) in results"
@@ -163,20 +163,17 @@ const ORDER_MAP = computed<Record<StatType, Metadata>>(() => {
163163
name: 'testing-type',
164164
},
165165
'GROUPS': {
166-
value: props.groups!.length > 1 ? `${props.groups!.length} ${t('debugPage.groups.pluralTitle')}` :
167-
`${props.groups!.length} ${t('debugPage.groups.singleTitle')}`,
166+
value: t('debugPage.stats.groups', props.groups!.length),
168167
icon: IconTechnologyServer,
169168
name: 'group-server',
170169
},
171170
'G_OS': {
172-
value: arrMapping.value.oses.length > 1 ? `${arrMapping.value.oses.length} ${t('debugPage.operatingSystems.pluralTitle')}` :
173-
`${arrMapping.value.oses.length} ${t('debugPage.operatingSystems.singleTitle')}`,
171+
value: t('debugPage.stats.operatingSystems', arrMapping.value.oses.length),
174172
icon: OS_MAP['GROUP'],
175173
name: 'operating-system-groups',
176174
},
177175
'G_BROWSERS': {
178-
value: arrMapping.value.browsers.length > 1 ? `${arrMapping.value.browsers.length} ${t('debugPage.browsers.pluralTitle')}` :
179-
`${arrMapping.value.browsers.length} ${t('debugPage.browsers.singleTitle')}`,
176+
value: t('debugPage.stats.browsers', arrMapping.value.browsers.length),
180177
icon: arrMapping.value.browsers,
181178
name: 'browser-groups',
182179
},

packages/frontend-shared/src/locales/en-US.json

+4-11
Original file line numberDiff line numberDiff line change
@@ -685,17 +685,10 @@
685685
"runUrl": "View in Cypress Cloud",
686686
"commitsAhead": "You are {n} commit ahead | You are {n} commits ahead"
687687
},
688-
"groups": {
689-
"singleTitle": "group",
690-
"pluralTitle": "groups"
691-
},
692-
"operatingSystems": {
693-
"singleTitle": "operating system",
694-
"pluralTitle": "operating systems"
695-
},
696-
"browsers": {
697-
"singleTitle": "browser",
698-
"pluralTitle": "browsers"
688+
"stats": {
689+
"groups": "{n} group | {n} groups",
690+
"operatingSystems": "{n} operating system | {n} operating systems",
691+
"browsers": "{n} browser | {n} browsers"
699692
}
700693
},
701694
"testingType": {

0 commit comments

Comments
 (0)