From cc63347377e1b20d53fcfd2dff02781dc33ea705 Mon Sep 17 00:00:00 2001 From: Tim Riffer Date: Fri, 24 May 2024 12:32:28 +0200 Subject: [PATCH] Fix rendering issue for multiple APIRules (#1069) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix host link when multiple APIRules exist * Add release notes * Update release notes * Add retries to reduce flakiness of tests * Make tests more reliable by using scrollIntoView * Fix scrolling issue with APIRule name * Make host in APIRules only a text field to have more reliable rendering and less UI logic * Remove unused code --------- Co-authored-by: Marek Kołodziejczak <69915024+kolodziejczak@users.noreply.github.com> --- config/ui-extensions/apirules/dataSources | 2 +- config/ui-extensions/apirules/list | 2 - docs/release-notes/2.4.0.md | 4 ++ tests/ui/tests/cypress.config.ts | 2 +- tests/ui/tests/support/commands.ts | 2 +- tests/ui/tests/support/list.ts | 8 ++-- tests/ui/tests/tests/api-rule.spec.ts | 52 +++++++++++------------ 7 files changed, 35 insertions(+), 37 deletions(-) diff --git a/config/ui-extensions/apirules/dataSources b/config/ui-extensions/apirules/dataSources index aff3c56ca..55eafa108 100644 --- a/config/ui-extensions/apirules/dataSources +++ b/config/ui-extensions/apirules/dataSources @@ -15,4 +15,4 @@ virtualServices: group: networking.istio.io version: v1beta1 namespace: null - filter: '$item.metadata.labels."apirule.gateway.kyma-project.io/v1beta1" = $root.metadata.name & "." & $root.metadata.namespace' + filter: '$item.metadata.labels."apirule.gateway.kyma-project.io/v1beta1" = $root.metadata.name & "." & $root.metadata.namespace' \ No newline at end of file diff --git a/config/ui-extensions/apirules/list b/config/ui-extensions/apirules/list index c8e4e8076..d7b8cb329 100644 --- a/config/ui-extensions/apirules/list +++ b/config/ui-extensions/apirules/list @@ -1,7 +1,5 @@ - name: host - widget: ExternalLink source: spec.host - link: 'status.APIRuleStatus.code = "OK" ? "https://" & $virtualServices().items[0].spec.hosts[0] : ""' - name: service-name source: '$string(spec.service.name) ? ($string(spec.service.name) & " (port: " & $string(spec.service.port) & ")") : ""' widget: ResourceLink diff --git a/docs/release-notes/2.4.0.md b/docs/release-notes/2.4.0.md index 821e802cb..360eefb12 100644 --- a/docs/release-notes/2.4.0.md +++ b/docs/release-notes/2.4.0.md @@ -2,3 +2,7 @@ - Change Ory Oathkeeper's scaling to be based only on CPU utilization. This adjustment ensures that the scaling is more responsive to traffic changes, as Oathkeeper memory utilization is not a good indicator of the traffic load. - Introduce APIRule in version `v1beta2` [#996](https://github.com/kyma-project/api-gateway/pull/996) + +## Bug Fixes + +- Fix rendering of APIRule list when multiple APIRules exist [#1069](https://github.com/kyma-project/api-gateway/pull/1069) diff --git a/tests/ui/tests/cypress.config.ts b/tests/ui/tests/cypress.config.ts index b59a469bf..2b117a1dd 100644 --- a/tests/ui/tests/cypress.config.ts +++ b/tests/ui/tests/cypress.config.ts @@ -35,5 +35,5 @@ module.exports = defineConfig({ }, retries: { runMode: 2, - } + }, }); diff --git a/tests/ui/tests/support/commands.ts b/tests/ui/tests/support/commands.ts index 02764587b..0436d9a16 100644 --- a/tests/ui/tests/support/commands.ts +++ b/tests/ui/tests/support/commands.ts @@ -13,7 +13,7 @@ declare global { filterWithNoValue(): Chainable inputClearAndType(selector: string, newValue: string): void hasStatusLabel(status: Status): void - hasTableRowWithLink(hrefValue: string): void + hasTableRowNumberContaining(row: number, value: string): void } } } \ No newline at end of file diff --git a/tests/ui/tests/support/list.ts b/tests/ui/tests/support/list.ts index 48184a9b5..7f1e4b5c9 100644 --- a/tests/ui/tests/support/list.ts +++ b/tests/ui/tests/support/list.ts @@ -10,8 +10,8 @@ Cypress.Commands.add('clickGenericListLink', (resourceName: string) : void => { .click(); }); -Cypress.Commands.add('hasTableRowWithLink', (hrefValue: string) : void => { - cy.get('ui5-table-row') - .find('ui5-link') - .should('have.attr', 'href', hrefValue) +Cypress.Commands.add('hasTableRowNumberContaining', (row: number, value: string) : void => { + cy.get(`ui5-table-row[slot="default-${row}"]`) + .contains(value) + .should('be.visible') }); diff --git a/tests/ui/tests/tests/api-rule.spec.ts b/tests/ui/tests/tests/api-rule.spec.ts index b6bc13692..2db20cb6b 100644 --- a/tests/ui/tests/tests/api-rule.spec.ts +++ b/tests/ui/tests/tests/api-rule.spec.ts @@ -137,6 +137,30 @@ context("API Rule", () => { cy.contains('https://trusted.com').should('exist'); }); + it("should display multiple rules are in the list", () => { + + cy.createApiRule({ + name: apiRuleName, + namespace: namespaceName, + service: serviceName, + host: apiRuleName, + handler: "no_auth", + }); + + const secondApiRuleName = `${apiRuleName}-second` + cy.createApiRule({ + name: secondApiRuleName, + namespace: namespaceName, + service: serviceName, + host: secondApiRuleName, + handler: "no_auth", + }); + + cy.navigateToApiRuleList(namespaceName); + cy.hasTableRowNumberContaining(1, apiRuleName); + cy.hasTableRowNumberContaining(2, secondApiRuleName); + }); + it('should update CORS policy', () => { cy.createApiRule({ @@ -202,20 +226,6 @@ context("API Rule", () => { context("Host", () => { context("when APIRule is in OK state", () => { - it('should build correct link in list view', () => { - cy.createApiRule({ - name: apiRuleName, - namespace: namespaceName, - service: serviceName, - host: apiRuleName, - handler: "no_auth", - }); - - cy.navigateToApiRuleList(namespaceName); - - cy.hasTableRowWithLink(`https://${apiRuleName}.local.kyma.dev`); - - }); it('should build correct link in details view', () => { cy.createApiRule({ @@ -233,20 +243,6 @@ context("API Rule", () => { }) context("when APIRule is not in OK state", () => { - it('should have dummy link in list view', () => { - cy.createApiRule({ - name: apiRuleName, - namespace: namespaceName, - service: "not_existent", - host: apiRuleName, - handler: "no_auth", - }); - - cy.navigateToApiRuleList(namespaceName); - - cy.hasTableRowWithLink(`https://${apiRuleName}`); - - }); it('should have dummy link in details view', () => { cy.createApiRule({