From 9f3167cc81c895a8f2bcba3b3695aab9a64b284c Mon Sep 17 00:00:00 2001 From: Maximilian Wesener Date: Wed, 20 Mar 2024 08:08:15 +0100 Subject: [PATCH 1/9] chore(exception): 606 - Added discovery finder exception to make sure it will per saved as error. --- .../domain/service/DiscoveryServiceImpl.java | 2 +- .../service/EdcNotificationServiceImpl.java | 47 +++++++++++-------- 2 files changed, 28 insertions(+), 21 deletions(-) diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/discovery/domain/service/DiscoveryServiceImpl.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/discovery/domain/service/DiscoveryServiceImpl.java index e36ca98051..7008c60202 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/discovery/domain/service/DiscoveryServiceImpl.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/discovery/domain/service/DiscoveryServiceImpl.java @@ -64,7 +64,7 @@ public Discovery getDiscoveryByBPN(String bpn) { }); optionalDiscoveryFromDiscoveryService.ifPresent(discoveryList::add); } catch (Exception e) { - throw new DiscoveryFinderException("DiscoverFinder not reachable."); + throw new DiscoveryFinderException("DiscoverFinder could not determine result."); } Optional optionalDiscoveryFromBpnDatabase = getOptionalDiscoveryFromBpnDatabase(bpn); diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/service/EdcNotificationServiceImpl.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/service/EdcNotificationServiceImpl.java index f7c98a05d5..5b993aff66 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/service/EdcNotificationServiceImpl.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/service/EdcNotificationServiceImpl.java @@ -62,30 +62,37 @@ public class EdcNotificationServiceImpl implements EdcNotificationService { @Async(value = AssetsAsyncConfig.UPDATE_NOTIFICATION_EXECUTOR) public CompletableFuture asyncNotificationMessageExecutor(QualityNotificationMessage message) { log.info("::asyncNotificationExecutor::message {}", message); - Discovery discovery = discoveryService.getDiscoveryByBPN(message.getSendTo()); - String senderEdcUrl = discovery.getSenderUrl(); - List receiverUrls = emptyIfNull(discovery.getReceiverUrls()); - List sendResults = List.of(); - - if (message.getType().equals(QualityNotificationType.ALERT)) { - log.info("::asyncNotificationExecutor::isQualityAlert"); - sendResults = receiverUrls - .stream().map(receiverUrl -> handleSendingNotification(message, senderEdcUrl, receiverUrl)).toList(); - } + try { + Discovery discovery = discoveryService.getDiscoveryByBPN(message.getSendTo()); - if (message.getType().equals(QualityNotificationType.INVESTIGATION)) { - log.info("::asyncNotificationExecutor::isQualityInvestigation"); - sendResults = receiverUrls - .stream().map(receiverUrl -> handleSendingNotification(message, senderEdcUrl, receiverUrl)).toList(); - } + String senderEdcUrl = discovery.getSenderUrl(); + List receiverUrls = emptyIfNull(discovery.getReceiverUrls()); + List sendResults = List.of(); - Boolean wasSent = sendResults.stream().anyMatch(Boolean.TRUE::equals); + if (message.getType().equals(QualityNotificationType.ALERT)) { + log.info("::asyncNotificationExecutor::isQualityAlert"); + sendResults = receiverUrls + .stream().map(receiverUrl -> handleSendingNotification(message, senderEdcUrl, receiverUrl)).toList(); + } - if (Boolean.TRUE.equals(wasSent)) { - return CompletableFuture.completedFuture(message); - } + if (message.getType().equals(QualityNotificationType.INVESTIGATION)) { + log.info("::asyncNotificationExecutor::isQualityInvestigation"); + sendResults = receiverUrls + .stream().map(receiverUrl -> handleSendingNotification(message, senderEdcUrl, receiverUrl)).toList(); + } - return CompletableFuture.completedFuture(null); + Boolean wasSent = sendResults.stream().anyMatch(Boolean.TRUE::equals); + + if (Boolean.TRUE.equals(wasSent)) { + return CompletableFuture.completedFuture(message); + } + + return CompletableFuture.completedFuture(null); + + } catch (DiscoveryFinderException discoveryFinderException) { + enrichQualityNotificationByError(discoveryFinderException, message); + return CompletableFuture.completedFuture(null); + } } private boolean handleSendingNotification(QualityNotificationMessage message, String senderEdcUrl, String receiverUrl) { From 54c55409cd0c2686ddd10db45296024cd3cf6cce Mon Sep 17 00:00:00 2001 From: Maximilian Wesener Date: Wed, 20 Mar 2024 08:23:14 +0100 Subject: [PATCH 2/9] chore(exception): 606 - Added discovery finder exception to make sure it will per saved as error. --- .../domain/base/service/EdcNotificationServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/service/EdcNotificationServiceImpl.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/service/EdcNotificationServiceImpl.java index 5b993aff66..d071faf69d 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/service/EdcNotificationServiceImpl.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/service/EdcNotificationServiceImpl.java @@ -118,7 +118,7 @@ private boolean handleSendingNotification(QualityNotificationMessage message, St private void enrichQualityNotificationByError(Exception e, QualityNotificationMessage message) { log.info("Retrieving quality notification by message id {}", message.getEdcNotificationId()); - Optional optionalQualityNotificationById = investigationRepository.findByNotificationMessageId(message.getEdcNotificationId()); + Optional optionalQualityNotificationById = investigationRepository.findByEdcNotificationId(message.getEdcNotificationId()); log.info("Successfully executed retrieving quality notification by message id"); if (optionalQualityNotificationById.isPresent()) { log.info("Quality Notification for error message enrichment {}", optionalQualityNotificationById.get()); From 337f181919ffbc11531983d6bc57166bc92bd493 Mon Sep 17 00:00:00 2001 From: Maximilian Wesener Date: Wed, 20 Mar 2024 08:34:15 +0100 Subject: [PATCH 3/9] chore(exception): 606 - Added discovery finder exception to make sure it will per saved as error. --- .../base/service/EdcNotificationServiceImpl.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/service/EdcNotificationServiceImpl.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/service/EdcNotificationServiceImpl.java index d071faf69d..d90e6ea06d 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/service/EdcNotificationServiceImpl.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/service/EdcNotificationServiceImpl.java @@ -28,6 +28,7 @@ import org.eclipse.tractusx.traceability.discovery.domain.model.Discovery; import org.eclipse.tractusx.traceability.discovery.domain.service.DiscoveryService; import org.eclipse.tractusx.traceability.discovery.infrastructure.exception.DiscoveryFinderException; +import org.eclipse.tractusx.traceability.qualitynotification.domain.base.AlertRepository; import org.eclipse.tractusx.traceability.qualitynotification.domain.base.InvestigationRepository; import org.eclipse.tractusx.traceability.qualitynotification.domain.base.exception.ContractNegotiationException; import org.eclipse.tractusx.traceability.qualitynotification.domain.base.exception.NoCatalogItemException; @@ -57,6 +58,7 @@ public class EdcNotificationServiceImpl implements EdcNotificationService { private final InvestigationsEDCFacade edcFacade; private final DiscoveryService discoveryService; private final InvestigationRepository investigationRepository; + private final AlertRepository alertRepository; @Override @Async(value = AssetsAsyncConfig.UPDATE_NOTIFICATION_EXECUTOR) @@ -117,14 +119,17 @@ private boolean handleSendingNotification(QualityNotificationMessage message, St private void enrichQualityNotificationByError(Exception e, QualityNotificationMessage message) { log.info("Retrieving quality notification by message id {}", message.getEdcNotificationId()); + Optional optionalQualityNotificationById = Optional.empty(); + if (message.getType().equals(QualityNotificationType.INVESTIGATION)){ + optionalQualityNotificationById = investigationRepository.findByEdcNotificationId(message.getEdcNotificationId()); + } else { + optionalQualityNotificationById = alertRepository.findByEdcNotificationId(message.getEdcNotificationId()); + } - Optional optionalQualityNotificationById = investigationRepository.findByEdcNotificationId(message.getEdcNotificationId()); log.info("Successfully executed retrieving quality notification by message id"); if (optionalQualityNotificationById.isPresent()) { log.info("Quality Notification for error message enrichment {}", optionalQualityNotificationById.get()); - optionalQualityNotificationById.get().getNotifications().forEach(message1 -> { - log.info("Message found {}", message1); - }); + optionalQualityNotificationById.get().getNotifications().forEach(message1 -> log.info("Message found {}", message1)); optionalQualityNotificationById.get().secondLatestNotifications().forEach(qmMessage -> { log.info("Message from second latest notification {}", qmMessage); qmMessage.setErrorMessage(e.getMessage()); From a950a6d4c1adcbf28812649098d1024035ca7713 Mon Sep 17 00:00:00 2001 From: Maximilian Wesener Date: Wed, 20 Mar 2024 09:10:08 +0100 Subject: [PATCH 4/9] chore(exception): 606 - Fixed test. --- .../EdcNotificationServiceImplTest.java | 20 ++++--------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/qualitynotification/domain/service/EdcNotificationServiceImplTest.java b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/qualitynotification/domain/service/EdcNotificationServiceImplTest.java index 34d7fbe6ac..b98753d762 100644 --- a/tx-backend/src/test/java/org/eclipse/tractusx/traceability/qualitynotification/domain/service/EdcNotificationServiceImplTest.java +++ b/tx-backend/src/test/java/org/eclipse/tractusx/traceability/qualitynotification/domain/service/EdcNotificationServiceImplTest.java @@ -133,8 +133,6 @@ void givenNoCatalogItemException_whenHandleSendingInvestigation_thenHandleIt() { .severity(QualityNotificationSeverity.MINOR) .build(); doThrow(new NoCatalogItemException()).when(edcFacade).startEdcTransfer(notification, edcReceiverUrl, edcSenderUrl); - QualityNotification qualityNotification = QualityNotification.builder().build(); - when(investigationRepository.findByNotificationMessageId(any())).thenReturn(Optional.of(qualityNotification)); // when notificationsService.asyncNotificationMessageExecutor(notification); @@ -158,8 +156,6 @@ void givenSendNotificationException_whenHandleSendingInvestigation_thenHandleIt( .severity(QualityNotificationSeverity.MINOR) .build(); doThrow(new SendNotificationException("message", new RuntimeException())).when(edcFacade).startEdcTransfer(notification, edcReceiverUrl, edcSenderUrl); - QualityNotification qualityNotification = QualityNotification.builder().build(); - when(investigationRepository.findByNotificationMessageId(any())).thenReturn(Optional.of(qualityNotification)); // when notificationsService.asyncNotificationMessageExecutor(notification); @@ -183,8 +179,7 @@ void givenSendNoEndpointDataReferenceException_whenHandleSendingInvestigation_th .severity(QualityNotificationSeverity.MINOR) .build(); doThrow(new NoEndpointDataReferenceException("message")).when(edcFacade).startEdcTransfer(notification, edcReceiverUrl, edcSenderUrl); - QualityNotification qualityNotification = QualityNotification.builder().build(); - when(investigationRepository.findByNotificationMessageId(any())).thenReturn(Optional.of(qualityNotification)); + // when notificationsService.asyncNotificationMessageExecutor(notification); @@ -208,8 +203,7 @@ void givenContractNegotiationException_whenHandleSendingInvestigation_thenHandle .severity(QualityNotificationSeverity.MINOR) .build(); doThrow(new ContractNegotiationException("message")).when(edcFacade).startEdcTransfer(notification, edcReceiverUrl, edcSenderUrl); - QualityNotification qualityNotification = QualityNotification.builder().build(); - when(investigationRepository.findByNotificationMessageId(any())).thenReturn(Optional.of(qualityNotification)); + // when notificationsService.asyncNotificationMessageExecutor(notification); @@ -234,8 +228,6 @@ void givenNoCatalogItemException_whenHandleSendingAlert_thenHandleIt() { .severity(QualityNotificationSeverity.MINOR) .build(); doThrow(new NoCatalogItemException()).when(edcFacade).startEdcTransfer(notification, edcReceiverUrl, edcSenderUrl); - QualityNotification qualityNotification = QualityNotification.builder().build(); - when(investigationRepository.findByNotificationMessageId(any())).thenReturn(Optional.of(qualityNotification)); // when notificationsService.asyncNotificationMessageExecutor(notification); @@ -262,8 +254,6 @@ void givenSendNotificationException_whenHandleSendingAlert_thenHandleIt() { .build(); doThrow(new SendNotificationException("message", new RuntimeException())).when(edcFacade).startEdcTransfer(notification, edcReceiverUrl, edcSenderUrl); - QualityNotification qualityNotification = QualityNotification.builder().build(); - when(investigationRepository.findByNotificationMessageId(any())).thenReturn(Optional.of(qualityNotification)); // when notificationsService.asyncNotificationMessageExecutor(notification); @@ -288,8 +278,7 @@ void givenSendNoEndpointDataReferenceException_whenHandleSendingAlert_thenHandle .severity(QualityNotificationSeverity.MINOR) .build(); doThrow(new NoEndpointDataReferenceException("message")).when(edcFacade).startEdcTransfer(notification, edcReceiverUrl, edcSenderUrl); - QualityNotification qualityNotification = QualityNotification.builder().build(); - when(investigationRepository.findByNotificationMessageId(any())).thenReturn(Optional.of(qualityNotification)); + // when notificationsService.asyncNotificationMessageExecutor(notification); @@ -313,8 +302,7 @@ void givenContractNegotiationException_whenHandleSendingAlert_thenHandleIt() { .severity(QualityNotificationSeverity.MINOR) .build(); doThrow(new ContractNegotiationException("message")).when(edcFacade).startEdcTransfer(notification, edcReceiverUrl, edcSenderUrl); - QualityNotification qualityNotification = QualityNotification.builder().build(); - when(investigationRepository.findByNotificationMessageId(any())).thenReturn(Optional.of(qualityNotification)); + // when notificationsService.asyncNotificationMessageExecutor(notification); From 7b257c14e0a1a4052570cb63217e7b5ff51cacfc Mon Sep 17 00:00:00 2001 From: Maximilian Wesener Date: Wed, 20 Mar 2024 09:20:09 +0100 Subject: [PATCH 5/9] chore(docs): 606 - Fixed repository imp. --- .../base/service/EdcNotificationServiceImpl.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/service/EdcNotificationServiceImpl.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/service/EdcNotificationServiceImpl.java index d90e6ea06d..577c623376 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/service/EdcNotificationServiceImpl.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/service/EdcNotificationServiceImpl.java @@ -119,11 +119,13 @@ private boolean handleSendingNotification(QualityNotificationMessage message, St private void enrichQualityNotificationByError(Exception e, QualityNotificationMessage message) { log.info("Retrieving quality notification by message id {}", message.getEdcNotificationId()); - Optional optionalQualityNotificationById = Optional.empty(); - if (message.getType().equals(QualityNotificationType.INVESTIGATION)){ - optionalQualityNotificationById = investigationRepository.findByEdcNotificationId(message.getEdcNotificationId()); + Optional optionalQualityNotificationById; + if (message.getType().equals(QualityNotificationType.INVESTIGATION)) { + log.info("Investigation update"); + optionalQualityNotificationById = investigationRepository.findByEdcNotificationId(message.getEdcNotificationId()); } else { - optionalQualityNotificationById = alertRepository.findByEdcNotificationId(message.getEdcNotificationId()); + log.info("Alert update"); + optionalQualityNotificationById = alertRepository.findByEdcNotificationId(message.getEdcNotificationId()); } log.info("Successfully executed retrieving quality notification by message id"); From 48a249d5786bb2443e599134ac833a3aa7e21b59 Mon Sep 17 00:00:00 2001 From: Maximilian Wesener Date: Wed, 20 Mar 2024 09:39:20 +0100 Subject: [PATCH 6/9] chore(docs): 606 - Fixed repository imp. --- .../domain/base/service/EdcNotificationServiceImpl.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/service/EdcNotificationServiceImpl.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/service/EdcNotificationServiceImpl.java index 577c623376..b54ecc86c5 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/service/EdcNotificationServiceImpl.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/domain/base/service/EdcNotificationServiceImpl.java @@ -121,10 +121,8 @@ private void enrichQualityNotificationByError(Exception e, QualityNotificationMe log.info("Retrieving quality notification by message id {}", message.getEdcNotificationId()); Optional optionalQualityNotificationById; if (message.getType().equals(QualityNotificationType.INVESTIGATION)) { - log.info("Investigation update"); optionalQualityNotificationById = investigationRepository.findByEdcNotificationId(message.getEdcNotificationId()); } else { - log.info("Alert update"); optionalQualityNotificationById = alertRepository.findByEdcNotificationId(message.getEdcNotificationId()); } @@ -136,7 +134,12 @@ private void enrichQualityNotificationByError(Exception e, QualityNotificationMe log.info("Message from second latest notification {}", qmMessage); qmMessage.setErrorMessage(e.getMessage()); }); - investigationRepository.updateErrorMessage(optionalQualityNotificationById.get()); + + if (message.getType().equals(QualityNotificationType.INVESTIGATION)) { + investigationRepository.updateErrorMessage(optionalQualityNotificationById.get()); + } else { + alertRepository.updateErrorMessage(optionalQualityNotificationById.get()); + } } else { log.warn("Quality Notification NOT FOUND for error message enrichment notification id {}", message.getId()); } From e08e523ba39edb9323e123618c75e1b768a0bedb Mon Sep 17 00:00:00 2001 From: Maximilian Wesener Date: Wed, 20 Mar 2024 09:53:52 +0100 Subject: [PATCH 7/9] chore(docs): 606 - Fixed repository imp. --- .../infrastructure/alert/model/AlertNotificationEntity.java | 1 + 1 file changed, 1 insertion(+) diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/alert/model/AlertNotificationEntity.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/alert/model/AlertNotificationEntity.java index 6be4d379ed..a300eb38a5 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/alert/model/AlertNotificationEntity.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/qualitynotification/infrastructure/alert/model/AlertNotificationEntity.java @@ -102,6 +102,7 @@ public static AlertNotificationEntity from(AlertEntity alertEntity, .assets(notificationAssets) .notificationReferenceId(qualityNotificationMessage.getNotificationReferenceId()) .targetDate(qualityNotificationMessage.getTargetDate()) + .errorMessage(qualityNotificationMessage.getErrorMessage()) .severity(qualityNotificationMessage.getSeverity()) .edcNotificationId(qualityNotificationMessage.getEdcNotificationId()) .status(NotificationStatusBaseEntity.fromStringValue(qualityNotificationMessage.getNotificationStatus().name())) From 170669556e822fad6ed535acfd44370f2e744c86 Mon Sep 17 00:00:00 2001 From: Maximilian Wesener Date: Wed, 20 Mar 2024 10:57:50 +0100 Subject: [PATCH 8/9] chore(docs): 606 - Fixed repository imp. --- .../discovery/domain/service/DiscoveryServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/discovery/domain/service/DiscoveryServiceImpl.java b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/discovery/domain/service/DiscoveryServiceImpl.java index 7008c60202..7f094a4b63 100644 --- a/tx-backend/src/main/java/org/eclipse/tractusx/traceability/discovery/domain/service/DiscoveryServiceImpl.java +++ b/tx-backend/src/main/java/org/eclipse/tractusx/traceability/discovery/domain/service/DiscoveryServiceImpl.java @@ -64,7 +64,7 @@ public Discovery getDiscoveryByBPN(String bpn) { }); optionalDiscoveryFromDiscoveryService.ifPresent(discoveryList::add); } catch (Exception e) { - throw new DiscoveryFinderException("DiscoverFinder could not determine result."); + throw new DiscoveryFinderException("DiscoveryFinder could not determine result."); } Optional optionalDiscoveryFromBpnDatabase = getOptionalDiscoveryFromBpnDatabase(bpn); From 78bc1c2a74479c97098b9c2e77e787c537bc49da Mon Sep 17 00:00:00 2001 From: Martin Maul Date: Wed, 20 Mar 2024 12:35:18 +0100 Subject: [PATCH 9/9] chore(e2e): fix failing tests --- frontend/cypress/integration/pages/AdminPage.ts | 11 +++++++++++ .../support/step_definitions/admin-contracts.ts | 13 ++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/frontend/cypress/integration/pages/AdminPage.ts b/frontend/cypress/integration/pages/AdminPage.ts index 317548e64e..7f381661dc 100644 --- a/frontend/cypress/integration/pages/AdminPage.ts +++ b/frontend/cypress/integration/pages/AdminPage.ts @@ -39,6 +39,17 @@ export class AdminPage { return cy.get('td').contains(contractId).parent('tr').find('td mat-checkbox').click(); } + static clickCheckBoxForFirstContractInTable() { + return cy.get('td').first().parent('tr').find('td mat-checkbox').click(); + } + + static getContractIdOfFirstContractInTable() { + return cy.get('[data-testid="table-component--cell-data"]').first().then(contractId => { + return contractId.text(); + }); + } + + static clickExportContractsButton() { return cy.get('[data-testid="export-contracts-button"]').click(); } diff --git a/frontend/cypress/support/step_definitions/admin-contracts.ts b/frontend/cypress/support/step_definitions/admin-contracts.ts index b403bc36d3..1b96cb26d9 100644 --- a/frontend/cypress/support/step_definitions/admin-contracts.ts +++ b/frontend/cypress/support/step_definitions/admin-contracts.ts @@ -27,6 +27,16 @@ When('select contract with contract-id {string}', function(contractId: string) { AdminPage.clickCheckBoxForContractId(contractId).should('have.class', 'mat-mdc-checkbox-checked'); }); +When('select the first contract in the contracts table', function() { + AdminPage.getContractIdOfFirstContractInTable().then(contractId => { + currentContractId = contractId; + expect(currentContractId).not.to.be.null + }); + cy.wait(1000); + + AdminPage.clickCheckBoxForFirstContractInTable().should('have.class', 'mat-mdc-checkbox-checked'); +}) + When('export selected contracts', function() { AdminPage.clickExportContractsButton().should('be.visible'); }); @@ -40,7 +50,8 @@ Then('exported contracts csv file is existing', function() { Then('exported csv file has correct content', function() { AdminPage.getExportedContractsFileData().then((data) => { - expect(data).to.equal(`contractId,counterpartyAddress,creationDate,endDate,state\n${ currentContractId },https://trace-x-edc-e2e-a.dev.demo.catena-x.net/api/v1/dsp,Thu Mar 07 2024,Thu Jan 01 1970,FINALIZED`); + let expectedData = "contractId,counterpartyAddress,creationDate,endDate,state\n" + currentContractId.trim().replace(/\n/g,'') + ",https://trace-x-edc-e2e-a.dev.demo.catena-x.net/api/v1/dsp,Mon Mar 18 2024,Thu Jan 01 1970,FINALIZED"; + expect(data).to.equal(expectedData); }); });