From 3cd2d908ad3919ff978ed6bd6979a90007b88632 Mon Sep 17 00:00:00 2001 From: LightOfHeaven1994 Date: Thu, 5 Dec 2024 11:41:11 +0100 Subject: [PATCH 01/11] feat(CI): enable unit-tests for Konflux builds --- .tekton/compliance-frontend-pull-request.yaml | 89 +++++++++--------- .tekton/compliance-frontend-push.yaml | 92 +++++++++---------- .../CreatePolicy/CreatePolicy.test.js | 11 ++- 3 files changed, 103 insertions(+), 89 deletions(-) diff --git a/.tekton/compliance-frontend-pull-request.yaml b/.tekton/compliance-frontend-pull-request.yaml index eccf4fc6e..6feaceb94 100644 --- a/.tekton/compliance-frontend-pull-request.yaml +++ b/.tekton/compliance-frontend-pull-request.yaml @@ -301,48 +301,55 @@ spec: workspaces: - name: basic-auth workspace: git-auth - # - name: run-unit-tests - # description: Validates frontend unit tests - # params: - # - name: SOURCE_ARTIFACT - # value: $(tasks.clone-repository-oci-ta.results.SOURCE_ARTIFACT) - # runAfter: - # - clone-repository-oci-ta - # workspaces: - # - name: basic-auth - # workspace: git-auth - # taskSpec: - # params: - # - description: The Trusted Artifact URI pointing to the artifact with the application source code. - # name: SOURCE_ARTIFACT - # type: string - # volumes: - # # New volume to store a copy of the source code accessible only to this Task. - # - name: workdir - # emptyDir: {} - # stepTemplate: - # volumeMounts: - # - mountPath: /var/workdir - # name: workdir - # readOnly: false - # sidecars: - # steps: - # - name: use-trusted-artifact - # image: quay.io/redhat-appstudio/build-trusted-artifacts:latest@sha256:8391272c4e5011120e9e7fee2c1f339e9405366110bf239dadcbc21e953ce099 - # args: - # - use - # - $(params.SOURCE_ARTIFACT)=/var/workdir - # - image: registry.access.redhat.com/ubi8/nodejs-20 - # workingDir: /var/workdir - # name: unit-tests - # securityContext: - # runAsUser: 0 - # script: | - # #!/bin/bash - # set -ex + - name: run-unit-tests + description: Validates frontend unit tests + params: + - name: SOURCE_ARTIFACT + value: $(tasks.clone-repository-oci-ta.results.SOURCE_ARTIFACT) + runAfter: + - clone-repository-oci-ta + workspaces: + - name: basic-auth + workspace: git-auth + taskSpec: + params: + - description: The Trusted Artifact URI pointing to the artifact with the application source code. + name: SOURCE_ARTIFACT + type: string + volumes: + # New volume to store a copy of the source code accessible only to this Task. + - name: workdir + emptyDir: {} + stepTemplate: + volumeMounts: + - mountPath: /var/workdir + name: workdir + readOnly: false + sidecars: + steps: + - name: use-trusted-artifact + image: quay.io/redhat-appstudio/build-trusted-artifacts:latest@sha256:52f1391e6f1c472fd10bb838f64fae2ed3320c636f536014978a5ddbdfc6b3af + args: + - use + - $(params.SOURCE_ARTIFACT)=/var/workdir + - image: registry.access.redhat.com/ubi8/nodejs-20 + workingDir: /var/workdir + name: unit-tests + computeResources: + requests: + memory: 7Gi + cpu: 1000m + limits: + memory: 14Gi + cpu: 2000m + securityContext: + runAsUser: 0 + script: | + #!/bin/bash + set -ex - # npm install - # npm test + npm install + npm test - name: build-container params: - name: IMAGE diff --git a/.tekton/compliance-frontend-push.yaml b/.tekton/compliance-frontend-push.yaml index 6e1f0c98e..b366021a0 100644 --- a/.tekton/compliance-frontend-push.yaml +++ b/.tekton/compliance-frontend-push.yaml @@ -298,53 +298,53 @@ spec: workspaces: - name: basic-auth workspace: git-auth - # - name: run-unit-tests - # description: Validates frontend unit tests - # params: - # - name: SOURCE_ARTIFACT - # value: $(tasks.clone-repository-oci-ta.results.SOURCE_ARTIFACT) - # runAfter: - # - clone-repository-oci-ta - # computeResources: - # requests: - # memory: 1Gi - # requests: - # memory: 2Gi - # workspaces: - # - name: basic-auth - # workspace: git-auth - # taskSpec: - # params: - # - description: The Trusted Artifact URI pointing to the artifact with the application source code. - # name: SOURCE_ARTIFACT - # type: string - # volumes: - # # New volume to store a copy of the source code accessible only to this Task. - # - name: workdir - # emptyDir: {} - # stepTemplate: - # volumeMounts: - # - mountPath: /var/workdir - # name: workdir - # readOnly: false - # sidecars: - # steps: - # - name: use-trusted-artifact - # image: quay.io/redhat-appstudio/build-trusted-artifacts:latest@sha256:8391272c4e5011120e9e7fee2c1f339e9405366110bf239dadcbc21e953ce099 - # args: - # - use - # - $(params.SOURCE_ARTIFACT)=/var/workdir - # - image: registry.access.redhat.com/ubi8/nodejs-20 - # workingDir: /var/workdir - # name: unit-tests - # securityContext: - # runAsUser: 0 - # script: | - # #!/bin/bash - # set -ex + - name: run-unit-tests + description: Validates frontend unit tests + params: + - name: SOURCE_ARTIFACT + value: $(tasks.clone-repository-oci-ta.results.SOURCE_ARTIFACT) + runAfter: + - clone-repository-oci-ta + computeResources: + requests: + memory: 1Gi + requests: + memory: 2Gi + workspaces: + - name: basic-auth + workspace: git-auth + taskSpec: + params: + - description: The Trusted Artifact URI pointing to the artifact with the application source code. + name: SOURCE_ARTIFACT + type: string + volumes: + # New volume to store a copy of the source code accessible only to this Task. + - name: workdir + emptyDir: {} + stepTemplate: + volumeMounts: + - mountPath: /var/workdir + name: workdir + readOnly: false + sidecars: + steps: + - name: use-trusted-artifact + image: quay.io/redhat-appstudio/build-trusted-artifacts:latest@sha256:52f1391e6f1c472fd10bb838f64fae2ed3320c636f536014978a5ddbdfc6b3af + args: + - use + - $(params.SOURCE_ARTIFACT)=/var/workdir + - image: registry.access.redhat.com/ubi8/nodejs-20 + workingDir: /var/workdir + name: unit-tests + securityContext: + runAsUser: 0 + script: | + #!/bin/bash + set -ex - # npm install - # npm test + npm install + npm test - name: build-container params: - name: IMAGE diff --git a/src/SmartComponents/CreatePolicy/CreatePolicy.test.js b/src/SmartComponents/CreatePolicy/CreatePolicy.test.js index 654d8915f..327ea584f 100644 --- a/src/SmartComponents/CreatePolicy/CreatePolicy.test.js +++ b/src/SmartComponents/CreatePolicy/CreatePolicy.test.js @@ -47,14 +47,15 @@ describe('CreatePolicy', () => { randomSystems, randomSystemsCounts, } = graphqlQueryMocks(['7']); - + console.log('Start rendering'); render( ); - + console.log('TEST 1'); expect(screen.getByRole('button', { name: 'Next' })).toBeDisabled(); + console.log('TEST 2'); await checkStep('Create SCAP policy', async () => { await screen.findByText('Operating system'); @@ -63,6 +64,7 @@ describe('CreatePolicy', () => { name: 'RHEL ' + osMajorVersionToSelect.osMajorVersion, }) ); + console.log('TEST 3'); expect(screen.getByText('Policy type')).toBeInTheDocument(); @@ -71,21 +73,26 @@ describe('CreatePolicy', () => { screen.getByRole('textbox', { name: 'text input' }), profileToSelect.name ); + console.log('TEST 4'); await userEvent.click( screen.getByRole('radio', { name: 'Select row 0' }) ); }); + console.log('TEST 5'); await nextStep('Details', async () => { expect(screen.getByText('Policy name')).toBeInTheDocument(); }); + console.log('TEST 6'); await nextStep('Systems', async () => { // Since we mock InventoryTable we need to dispatch a change manually dispatchFieldChange(store, 'systems', randomSystems); dispatchFieldChange(store, 'osMinorVersionCounts', randomSystemsCounts); }); + console.log('TEST 7'); + // TODO add proper rules data // await nextStep('Rules', async () => { // expect(screen.getByText(profileToSelect.name)).toBeInTheDocument(); From 662283144f68b74dc53a6c779a00f157e10bb843 Mon Sep 17 00:00:00 2001 From: LightOfHeaven1994 Date: Mon, 20 Jan 2025 16:33:38 +0100 Subject: [PATCH 02/11] skip failing test --- src/SmartComponents/CreatePolicy/CreatePolicy.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SmartComponents/CreatePolicy/CreatePolicy.test.js b/src/SmartComponents/CreatePolicy/CreatePolicy.test.js index 327ea584f..c084d52d5 100644 --- a/src/SmartComponents/CreatePolicy/CreatePolicy.test.js +++ b/src/SmartComponents/CreatePolicy/CreatePolicy.test.js @@ -39,7 +39,7 @@ describe('CreatePolicy', () => { beforeEach(() => { useAPIV2FeatureFlag.mockImplementation(() => false); }); - it('expect to render the Create Policy wizard', async () => { + it.skip('expect to render the Create Policy wizard', async () => { const { mocks, osMajorVersionToSelect, From efd081173b9857e8b5388965c8d0637caea6bb20 Mon Sep 17 00:00:00 2001 From: LightOfHeaven1994 Date: Mon, 20 Jan 2025 16:45:18 +0100 Subject: [PATCH 03/11] remove custom resources bump --- .tekton/compliance-frontend-pull-request.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.tekton/compliance-frontend-pull-request.yaml b/.tekton/compliance-frontend-pull-request.yaml index 6feaceb94..00a0247ac 100644 --- a/.tekton/compliance-frontend-pull-request.yaml +++ b/.tekton/compliance-frontend-pull-request.yaml @@ -335,13 +335,13 @@ spec: - image: registry.access.redhat.com/ubi8/nodejs-20 workingDir: /var/workdir name: unit-tests - computeResources: - requests: - memory: 7Gi - cpu: 1000m - limits: - memory: 14Gi - cpu: 2000m + # computeResources: + # requests: + # memory: 7Gi + # cpu: 1000m + # limits: + # memory: 14Gi + # cpu: 2000m securityContext: runAsUser: 0 script: | From 8f3a116c6318edc46a4b40d7ca286828486c2c2e Mon Sep 17 00:00:00 2001 From: LightOfHeaven1994 Date: Mon, 20 Jan 2025 17:07:39 +0100 Subject: [PATCH 04/11] bump mem&cpu --- .tekton/compliance-frontend-pull-request.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.tekton/compliance-frontend-pull-request.yaml b/.tekton/compliance-frontend-pull-request.yaml index 00a0247ac..7077f5be9 100644 --- a/.tekton/compliance-frontend-pull-request.yaml +++ b/.tekton/compliance-frontend-pull-request.yaml @@ -335,13 +335,13 @@ spec: - image: registry.access.redhat.com/ubi8/nodejs-20 workingDir: /var/workdir name: unit-tests - # computeResources: - # requests: - # memory: 7Gi - # cpu: 1000m - # limits: - # memory: 14Gi - # cpu: 2000m + computeResources: + requests: + memory: 2Gi + cpu: 500m + limits: + memory: 4Gi + cpu: 1000m securityContext: runAsUser: 0 script: | From cea22fe03bd9130bbee4a6f8dc2b702de7bfca67 Mon Sep 17 00:00:00 2001 From: LightOfHeaven1994 Date: Mon, 20 Jan 2025 17:18:44 +0100 Subject: [PATCH 05/11] bump mem&cpu --- .tekton/compliance-frontend-pull-request.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.tekton/compliance-frontend-pull-request.yaml b/.tekton/compliance-frontend-pull-request.yaml index 7077f5be9..7e54de559 100644 --- a/.tekton/compliance-frontend-pull-request.yaml +++ b/.tekton/compliance-frontend-pull-request.yaml @@ -337,10 +337,10 @@ spec: name: unit-tests computeResources: requests: - memory: 2Gi + memory: 4Gi cpu: 500m limits: - memory: 4Gi + memory: 8Gi cpu: 1000m securityContext: runAsUser: 0 From cf5b1edbe2e80fb1161cf910483c0255ef3ec40b Mon Sep 17 00:00:00 2001 From: LightOfHeaven1994 Date: Mon, 20 Jan 2025 17:29:55 +0100 Subject: [PATCH 06/11] bump mem&cpu --- .tekton/compliance-frontend-pull-request.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.tekton/compliance-frontend-pull-request.yaml b/.tekton/compliance-frontend-pull-request.yaml index 7e54de559..b3b545246 100644 --- a/.tekton/compliance-frontend-pull-request.yaml +++ b/.tekton/compliance-frontend-pull-request.yaml @@ -337,10 +337,10 @@ spec: name: unit-tests computeResources: requests: - memory: 4Gi + memory: 3Gi cpu: 500m limits: - memory: 8Gi + memory: 6Gi cpu: 1000m securityContext: runAsUser: 0 From 0a0e815281e4bddcddce13adc55a9560a9664929 Mon Sep 17 00:00:00 2001 From: LightOfHeaven1994 Date: Mon, 20 Jan 2025 17:45:39 +0100 Subject: [PATCH 07/11] bump mem&cpu --- .tekton/compliance-frontend-pull-request.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.tekton/compliance-frontend-pull-request.yaml b/.tekton/compliance-frontend-pull-request.yaml index b3b545246..7e54de559 100644 --- a/.tekton/compliance-frontend-pull-request.yaml +++ b/.tekton/compliance-frontend-pull-request.yaml @@ -337,10 +337,10 @@ spec: name: unit-tests computeResources: requests: - memory: 3Gi + memory: 4Gi cpu: 500m limits: - memory: 6Gi + memory: 8Gi cpu: 1000m securityContext: runAsUser: 0 From 2aca8a9dec4fcb9052b17363935c16a109854f74 Mon Sep 17 00:00:00 2001 From: LightOfHeaven1994 Date: Mon, 20 Jan 2025 18:03:02 +0100 Subject: [PATCH 08/11] test --- src/SmartComponents/CreatePolicy/CreatePolicy.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SmartComponents/CreatePolicy/CreatePolicy.test.js b/src/SmartComponents/CreatePolicy/CreatePolicy.test.js index c084d52d5..327ea584f 100644 --- a/src/SmartComponents/CreatePolicy/CreatePolicy.test.js +++ b/src/SmartComponents/CreatePolicy/CreatePolicy.test.js @@ -39,7 +39,7 @@ describe('CreatePolicy', () => { beforeEach(() => { useAPIV2FeatureFlag.mockImplementation(() => false); }); - it.skip('expect to render the Create Policy wizard', async () => { + it('expect to render the Create Policy wizard', async () => { const { mocks, osMajorVersionToSelect, From 7c44d0e8da6bd58aeb7e5cddcddc354695fe4059 Mon Sep 17 00:00:00 2001 From: LightOfHeaven1994 Date: Mon, 20 Jan 2025 18:39:50 +0100 Subject: [PATCH 09/11] test --- src/SmartComponents/CreatePolicy/CreatePolicy.test.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/SmartComponents/CreatePolicy/CreatePolicy.test.js b/src/SmartComponents/CreatePolicy/CreatePolicy.test.js index 327ea584f..6a3b59208 100644 --- a/src/SmartComponents/CreatePolicy/CreatePolicy.test.js +++ b/src/SmartComponents/CreatePolicy/CreatePolicy.test.js @@ -53,18 +53,20 @@ describe('CreatePolicy', () => { ); - console.log('TEST 1'); + console.log('eshamard TEST 1'); expect(screen.getByRole('button', { name: 'Next' })).toBeDisabled(); - console.log('TEST 2'); + console.log('eshamard TEST 2'); await checkStep('Create SCAP policy', async () => { + console.log('eshamard TEST 2.1') await screen.findByText('Operating system'); + console.log('eshamard TEST 2.2') await userEvent.click( screen.getByRole('option', { name: 'RHEL ' + osMajorVersionToSelect.osMajorVersion, }) ); - console.log('TEST 3'); + console.log('eshamard TEST 3'); expect(screen.getByText('Policy type')).toBeInTheDocument(); From 9bc9756916354c8c28b7a1d340a48ddcd2e8152a Mon Sep 17 00:00:00 2001 From: LightOfHeaven1994 Date: Mon, 20 Jan 2025 19:25:01 +0100 Subject: [PATCH 10/11] test --- src/SmartComponents/CreatePolicy/CreatePolicy.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SmartComponents/CreatePolicy/CreatePolicy.test.js b/src/SmartComponents/CreatePolicy/CreatePolicy.test.js index 6a3b59208..59c975101 100644 --- a/src/SmartComponents/CreatePolicy/CreatePolicy.test.js +++ b/src/SmartComponents/CreatePolicy/CreatePolicy.test.js @@ -59,7 +59,7 @@ describe('CreatePolicy', () => { await checkStep('Create SCAP policy', async () => { console.log('eshamard TEST 2.1') - await screen.findByText('Operating system'); + await screen.findByText('Operating system', {}, { timeout: 15000 }); console.log('eshamard TEST 2.2') await userEvent.click( screen.getByRole('option', { From fcc845fe94e19a941c20e1940a5bfc590780fa74 Mon Sep 17 00:00:00 2001 From: LightOfHeaven1994 Date: Mon, 20 Jan 2025 21:04:21 +0100 Subject: [PATCH 11/11] test --- src/SmartComponents/CreatePolicy/CreatePolicy.test.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/SmartComponents/CreatePolicy/CreatePolicy.test.js b/src/SmartComponents/CreatePolicy/CreatePolicy.test.js index 59c975101..7db9b9b0e 100644 --- a/src/SmartComponents/CreatePolicy/CreatePolicy.test.js +++ b/src/SmartComponents/CreatePolicy/CreatePolicy.test.js @@ -59,7 +59,11 @@ describe('CreatePolicy', () => { await checkStep('Create SCAP policy', async () => { console.log('eshamard TEST 2.1') - await screen.findByText('Operating system', {}, { timeout: 15000 }); + await waitFor( + () => expect(screen.getByText('Operating system')).toBeInTheDocument(), + { timeout: 15000 } + ); + // await screen.findByText('Operating system', {}, { timeout: 15000 }); console.log('eshamard TEST 2.2') await userEvent.click( screen.getByRole('option', {