Skip to content

Commit

Permalink
fix some e2e tests
Browse files Browse the repository at this point in the history
Signed-off-by: John Cowen <[email protected]>
  • Loading branch information
johncowen committed Nov 7, 2024
1 parent c43a3f5 commit 853fc66
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
22 changes: 12 additions & 10 deletions features/zones/zone-cps/ingresses/item/Index.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ Feature: zones / ingresses / item

Background:
Given the CSS selectors
| Alias | Selector |
| detail-view | [data-testid='zone-ingress-detail-view'] |
| config-view | [data-testid='zone-ingress-config-view'] |
| detail-tabs-view | [data-testid='zone-ingress-detail-tabs-view'] |
| navigation | [data-testid='zone-ingress-tabs'] ul |
| config-tab | [data-testid='zone-ingress-config-view-tab'] a |
| Alias | Selector |
| page | [data-testid='zone-ingress-detail-tabs-view'] |
| header | $page .app-view-title-bar |
| overview-view | [data-testid='zone-ingress-detail-view'] |
| config-view | [data-testid='zone-ingress-config-view'] |
| subscriptions | [data-testid='app-collection'] tbody tr |
| subscription | $subscriptions:nth-child(1) |
| navigation | [data-testid='zone-ingress-tabs'] ul |
| config-tab | [data-testid='zone-ingress-config-view-tab'] a |
And the environment
"""
KUMA_MODE: global
Expand Down Expand Up @@ -41,9 +44,8 @@ Feature: zones / ingresses / item
disconnectTime: !!js/undefined
"""
When I visit the "/zones/zone-cp-1/ingresses/item-1/overview" URL
Then the page title contains "item-1"
Then the "$detail-tabs-view" element contains "item-1"
Then the "$detail-view" element contains "166.197.238.26:20555"
Then the "$detail-view" element contains "Connected: Jul 28, 2020, 4:18 PM"
Then the "$header" element contains "item-1"
Then the "$overview-view" element contains "166.197.238.26:20555"
Then the "$subscription" element contains "Jul 28, 2020, 4:18 PM"
When I click the "$config-tab" element
Then the "$config-view" element contains "type: ZoneIngress"
8 changes: 4 additions & 4 deletions src/app/subscriptions/data/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,24 @@ export const Subscription = {
...item,
status: ((item) => {
const { total, lastUpdateTime, stat, ...rest } = { stat: {}, ...item }
const stats = Object.keys(stat).length > 0 ? stat : rest
const stats: Record<string, Record<string, number>> = Object.keys(stat).length > 0 ? stat : rest
return {
...item,
// make sure we default to zero for all acknowledgement properties
total: {
...total,
...acknowledgements.reduce((prev, prop) => {
prev[prop] = prev[prop] ?? 0
prev[prop] = total[prop] ?? 0
return prev
}, {} as {
[key in (typeof acknowledgements)[number]]: number
}),
},
acknowledgements: {
...Object.fromEntries(
Object.entries(stats).map(([key, _value]) => {
Object.entries(stats).map(([key, value]) => {
return [key, acknowledgements.reduce((prev, prop) => {
prev[prop] = prev[prop] ?? 0
prev[prop] = value[prop] ?? 0
return prev
}, {} as {
[key in (typeof acknowledgements)[number]]: number
Expand Down
9 changes: 7 additions & 2 deletions src/test-support/mocks/src/zone-ingresses/_/_overview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@ export default ({ fake, env }: EndpointDependencies): MockResponder => (req) =>
const k8s = env('KUMA_ENVIRONMENT', 'universal') === 'kubernetes'

const parts = String(name).split('.')
const displayName = parts.slice(0, -1).join('.')
const nspace = parts.pop()
let displayName = parts.slice(0, -1).join('.')
let nspace = parts.pop()

if (displayName.length === 0) {
displayName = String(nspace)
nspace = ''
}

const zoneName = fake.hacker.noun()

Expand Down

0 comments on commit 853fc66

Please sign in to comment.