From 54782f58c8d3c32ac165ceebbd25ec48240b9b44 Mon Sep 17 00:00:00 2001 From: Andrea Fuso Date: Tue, 28 May 2024 15:39:04 +0200 Subject: [PATCH 01/14] feat: add `apiBaseUrl` property Signed-off-by: Andrea Fuso --- .../it/pn/frontend/e2e/run/RunCucumberTest.java | 13 +++++++++++++ src/test/resources/test-config.properties | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/test/java/it/pn/frontend/e2e/run/RunCucumberTest.java b/src/test/java/it/pn/frontend/e2e/run/RunCucumberTest.java index 8312575d1..1c0550c48 100644 --- a/src/test/java/it/pn/frontend/e2e/run/RunCucumberTest.java +++ b/src/test/java/it/pn/frontend/e2e/run/RunCucumberTest.java @@ -48,8 +48,21 @@ private static boolean loadProperties() { return false; } + private static void setApiBaseUrl() { + String baseUrlProperty = System.getProperty("apiBaseUrl"); + String env = System.getProperty("environment"); + if (baseUrlProperty == null || env == null) { + logger.error("apiBaseUrl property not set"); + return; + } + String apiBaseUrl = baseUrlProperty.replace("{ENV}", env); + logger.info("apiBaseUrl = " + apiBaseUrl); + System.setProperty("apiBaseUrl", apiBaseUrl); + } + @BeforeClass public static void startTestSuite() { + setApiBaseUrl(); if (loadProperties()) { logger.info("properties loaded"); properties.forEach((property, value) -> { diff --git a/src/test/resources/test-config.properties b/src/test/resources/test-config.properties index 6cdc18af3..413426f6a 100644 --- a/src/test/resources/test-config.properties +++ b/src/test/resources/test-config.properties @@ -3,4 +3,5 @@ browser=chrome environment=test cookie.config=true headless=true -loadComponentWaitTime=120 \ No newline at end of file +loadComponentWaitTime=120 +apiBaseUrl=https://webapi.{ENV}.notifichedigitali.it/bff/v1/ \ No newline at end of file From 7aa59031ff6fba01d509a65c49a0948ec78943a1 Mon Sep 17 00:00:00 2001 From: Andrea Fuso Date: Fri, 31 May 2024 14:49:50 +0200 Subject: [PATCH 02/14] text(API): update api paths Signed-off-by: Andrea Fuso --- .../RecapitiPersonaFisicaTest.java | 8 ++-- .../NotifichePGPagoPATest.java | 37 +++++++++---------- .../mittente/NotificaMittentePagoPATest.java | 2 +- .../dataPopulation/personaFisica.yaml | 2 +- 4 files changed, 24 insertions(+), 25 deletions(-) diff --git a/src/test/java/it/pn/frontend/e2e/stepDefinitions/destinatario/personaFisica/RecapitiPersonaFisicaTest.java b/src/test/java/it/pn/frontend/e2e/stepDefinitions/destinatario/personaFisica/RecapitiPersonaFisicaTest.java index 87b5378a0..a811c9766 100644 --- a/src/test/java/it/pn/frontend/e2e/stepDefinitions/destinatario/personaFisica/RecapitiPersonaFisicaTest.java +++ b/src/test/java/it/pn/frontend/e2e/stepDefinitions/destinatario/personaFisica/RecapitiPersonaFisicaTest.java @@ -84,7 +84,7 @@ public void nellaPaginaITuoiRecapitiSiCliccaSulBottoneConferma() { public void nellaPaginaITuoiRecapitiSiVisualizzaCorrettamenteIlPopUpDiInserimentoOTP() { logger.info("Si visualizza correttamente il pop-up di inserimento OTP"); String varabileAmbiente = System.getProperty("environment"); - String url = "https://webapi." + varabileAmbiente + ".notifichedigitali.it/address-book/v1/digital-address"; + String url = "https://webapi." + varabileAmbiente + ".notifichedigitali.it/bff/v1/address"; recapitiDestinatarioPage.waitLoadPopUp(); try { TimeUnit.SECONDS.sleep(3); @@ -218,6 +218,7 @@ public void nellaPaginaITuoiRecapitiSiInserisceIlNumeroDiTelefonoDelPF(String dp iTuoiRecapitiPage.insertTelephoneNumber(phoneNumber); iTuoiRecapitiPage.clickAvvisamiViaSMS(); } + @And("Nella pagina I Tuoi Recapiti si inserisce il numero di telefono PF {string} e clicca sul bottone avvisami via SMS") public void nellaPaginaITuoiRecapitiSiInserisceIlNumeroDiTelefonoPF(String phoneNumber) { @@ -596,7 +597,7 @@ public void nellaPaginaITuoiRecapitiSiControllaCheLIndirizzoEmailNonSiaPresente( logger.info("Si controlla che l'indirizzo Email non sia presente"); if (recapitiDestinatarioPage.verificaMailField()) { logger.info("Email è stata eliminata correttamente"); - }else { + } else { logger.error("Email non è stata eliminata"); Assert.fail("Email non è stata eliminata"); } @@ -797,7 +798,6 @@ public void nellaPaginaITuoiRecapitiSiControllaCheLIndirizzoPecPresente() { } - @And("Nella sezione altri recapiti si seleziona l'ente {string}") public void nellaSezioneAltriRecapitiSiSelezionaLEnte(String dpFile) { logger.info("Si sceglie l'ente"); @@ -977,7 +977,7 @@ public void nellaPaginaITuoiRecapitiSiVisualizzaCorrettamenteIlRiquadroRelativoA } @And("Nella sezione altri recapiti si clicca sul bottone conferma per inserire un recapito") - public void nellaSezioneAltriRecapitiSiCliccaSulBottoneConfermaPerInserireUnRecapito(){ + public void nellaSezioneAltriRecapitiSiCliccaSulBottoneConfermaPerInserireUnRecapito() { logger.info("Si clicca su conferma"); recapitiDestinatarioPage.clickConfermaRecapitoGiaPresente(); } diff --git a/src/test/java/it/pn/frontend/e2e/stepDefinitions/destinatario/personaGiuridica/NotifichePGPagoPATest.java b/src/test/java/it/pn/frontend/e2e/stepDefinitions/destinatario/personaGiuridica/NotifichePGPagoPATest.java index 05dfe9a44..f9f751af9 100644 --- a/src/test/java/it/pn/frontend/e2e/stepDefinitions/destinatario/personaGiuridica/NotifichePGPagoPATest.java +++ b/src/test/java/it/pn/frontend/e2e/stepDefinitions/destinatario/personaGiuridica/NotifichePGPagoPATest.java @@ -1,6 +1,5 @@ package it.pn.frontend.e2e.stepDefinitions.destinatario.personaGiuridica; -import io.cucumber.java.bs.A; import io.cucumber.java.en.And; import io.cucumber.java.en.Then; import io.cucumber.java.en.When; @@ -67,7 +66,7 @@ public void siVisualizzaCorrettamenteLaPaginaNotifichePersonaGiuridica(String ra piattaformaNotifichePGPAPage.waitLoadPiattaformaNotificaPage(ragioneSociale); String variabileAmbiente = System.getProperty("environment"); - String urlChiamata = "https://webapi." + variabileAmbiente + ".notifichedigitali.it/delivery/notifications/received?"; + String urlChiamata = "https://webapi." + variabileAmbiente + ".notifichedigitali.it/bff/v1/notifications/received?"; int codiceRispostaChiamataApi = getCodiceRispostaChiamataApi(urlChiamata); if (codiceRispostaChiamataApi != 200 && codiceRispostaChiamataApi != 0) { @@ -113,7 +112,7 @@ public void nellaPaginaNotifichePersonaGiuridicaSiCliccaSuNotificheDelegate() { } @And("Nella sezione Deleghe si verifica sia presente una delega accettata per PG") - public void nellaSezioneDelegheSiVerificaSiaPresenteUnaDelegaAccettataPerPG(){ + public void nellaSezioneDelegheSiVerificaSiaPresenteUnaDelegaAccettataPerPG() { logger.info("Si controlla che sia presente una delega"); BackgroundTest backgroundTest = new BackgroundTest(); if (!this.deleghePage.siVisualizzaUnaDelegaPG()) { @@ -123,8 +122,8 @@ public void nellaSezioneDelegheSiVerificaSiaPresenteUnaDelegaAccettataPerPG(){ backgroundTest.loginPGDeleghe("delegatoPG"); backgroundTest.accettazioneDelegaPG(); } else if (this.leTueDelegheSection.controlloPresenzaBottoneAccetta()) { - backgroundTest.accettazioneDelegaPG(); - } + backgroundTest.accettazioneDelegaPG(); + } this.driver.navigate().refresh(); } @@ -220,7 +219,7 @@ public void nellaSezioneDettaglioNotificheSiCliccaSuLopzioneIndietro() { @And("Si clicca sul radio bottone di pagamento") - public void siCliccaRadioButtonPagamento(){ + public void siCliccaRadioButtonPagamento() { PiattaformaNotifichePGPAPage piattaformaNotifichePGPAPage = new PiattaformaNotifichePGPAPage(this.driver); piattaformaNotifichePGPAPage.clickRadioBoxButton(); } @@ -229,9 +228,9 @@ public void siCliccaRadioButtonPagamento(){ public void siControllaSiaPresenteIlModelloF24PG() { logger.info("Si controlla sia presente il modello F24 PG"); PiattaformaNotifichePGPAPage piattaformaNotifichePGPAPage = new PiattaformaNotifichePGPAPage(this.driver); - if(piattaformaNotifichePGPAPage.modelloF24Displayed()){ - logger.info("Il modello F24 è trovato"); - }else{ + if (piattaformaNotifichePGPAPage.modelloF24Displayed()) { + logger.info("Il modello F24 è trovato"); + } else { logger.error("Il modello F24 non è trovato"); Assert.fail("Il modello F24 non è trovato"); } @@ -241,9 +240,9 @@ public void siControllaSiaPresenteIlModelloF24PG() { public void siControllaNonSiaPresenteIlModelloF24PG() { logger.info("Si controlla non sia presente il modello F24 PG"); PiattaformaNotifichePGPAPage piattaformaNotifichePGPAPage = new PiattaformaNotifichePGPAPage(this.driver); - if(!piattaformaNotifichePGPAPage.modelloF24Displayed()){ + if (!piattaformaNotifichePGPAPage.modelloF24Displayed()) { logger.info("Il modello F24 non è trovato"); - }else{ + } else { logger.error("Il modello F24 è trovato"); Assert.fail("Il modello F24 è trovato"); } @@ -267,9 +266,9 @@ public void siCliccaIlSecondoModelloF24PG() { public void siControllaSiaPresenteLAvvisoPagoPaPG() { logger.info("Si controlla la presenza del box per il pagamento della notifica"); AccediAPiattaformaNotifichePage accediAPiattaformaNotifichePage = new AccediAPiattaformaNotifichePage(this.driver); - if(accediAPiattaformaNotifichePage.scaricaAvvisoDisplayed()){ + if (accediAPiattaformaNotifichePage.scaricaAvvisoDisplayed()) { logger.info("Avviso PagoPA è trovato"); - }else{ + } else { logger.error("Avviso PagoPA non è trovato"); Assert.fail("Avviso PagoPA non è trovato"); } @@ -279,9 +278,9 @@ public void siControllaSiaPresenteLAvvisoPagoPaPG() { public void siControllaNonSiaPresenteLAvvisoPagoPaPG() { logger.info("Si controlla la presenza del box per il pagamento della notifica"); AccediAPiattaformaNotifichePage accediAPiattaformaNotifichePage = new AccediAPiattaformaNotifichePage(this.driver); - if(!accediAPiattaformaNotifichePage.scaricaAvvisoDisplayed()){ + if (!accediAPiattaformaNotifichePage.scaricaAvvisoDisplayed()) { logger.info("Avviso PagoPA non è trovato"); - }else{ + } else { logger.error("Avviso PagoPA è trovato"); Assert.fail("Avviso PagoPA è trovato"); } @@ -310,12 +309,12 @@ public void nellaPaginaPiattformaNotificheSiEffettuaLaRicercaPerCodiceIUN(String } @And("Si controlla la presenza di codice avviso") - public void siControllaLaPresenzaDiCodiceAvviso(){ + public void siControllaLaPresenzaDiCodiceAvviso() { logger.info("Si controlla la presenza di codice avviso"); - AccediAPiattaformaNotifichePage accediAPiattaformaNotifichePage = new AccediAPiattaformaNotifichePage(this.driver); - if(accediAPiattaformaNotifichePage.codiceAvvisoDisplayed()){ + AccediAPiattaformaNotifichePage accediAPiattaformaNotifichePage = new AccediAPiattaformaNotifichePage(this.driver); + if (accediAPiattaformaNotifichePage.codiceAvvisoDisplayed()) { logger.info("Codice avviso è visuallizato corrttamente"); - }else { + } else { logger.error("Codice avviso non è visuallizato corrttamente"); Assert.fail("Codice avviso non è visuallizato corrttamente"); } diff --git a/src/test/java/it/pn/frontend/e2e/stepDefinitions/mittente/NotificaMittentePagoPATest.java b/src/test/java/it/pn/frontend/e2e/stepDefinitions/mittente/NotificaMittentePagoPATest.java index 4fbf18d11..8a9dbb8e4 100644 --- a/src/test/java/it/pn/frontend/e2e/stepDefinitions/mittente/NotificaMittentePagoPATest.java +++ b/src/test/java/it/pn/frontend/e2e/stepDefinitions/mittente/NotificaMittentePagoPATest.java @@ -84,7 +84,7 @@ public void siVisualizzaCorrettamenteLaPaginaPiattaformaNotifiche() { throw new RuntimeException(e); } - String urlChiamata = "https://webapi." + variabileAmbiente + ".notifichedigitali.it/delivery/notifications/sent?"; + String urlChiamata = "https://webapi." + variabileAmbiente + ".notifichedigitali.it/bff/v1/notifications/sent?"; int codiceRispostaChiamataApi = getCodiceRispostaChiamataApi(urlChiamata); if (codiceRispostaChiamataApi != 200 && codiceRispostaChiamataApi != 0) { logger.error("TA_QA: La chiamata, " + urlChiamata + " è andata in errore"); diff --git a/src/test/resources/dataPopulation/personaFisica.yaml b/src/test/resources/dataPopulation/personaFisica.yaml index a9b7f5eee..727c5029b 100644 --- a/src/test/resources/dataPopulation/personaFisica.yaml +++ b/src/test/resources/dataPopulation/personaFisica.yaml @@ -21,5 +21,5 @@ provincia: "MI" codicepostale: "20147" stato: "ITALIA" OTPpec: "40266" -OTPmail: "53138" +OTPmail: "67379" additionalEmail: "test2@test.com" From 342f13420714982c8ff78f6e852d7a3cba44e3b9 Mon Sep 17 00:00:00 2001 From: Andrea Fuso Date: Fri, 31 May 2024 15:01:02 +0200 Subject: [PATCH 03/14] text(API): update api paths Signed-off-by: Andrea Fuso --- .../LoginPersonaFisicaPagoPA.java | 19 ++-- .../NotifichePGPagoPATest.java | 2 +- .../DownloadFileMittentePagoPATest.java | 101 +++++++++--------- .../mittente/NotificaMittentePagoPATest.java | 2 +- 4 files changed, 63 insertions(+), 61 deletions(-) diff --git a/src/test/java/it/pn/frontend/e2e/stepDefinitions/destinatario/personaFisica/LoginPersonaFisicaPagoPA.java b/src/test/java/it/pn/frontend/e2e/stepDefinitions/destinatario/personaFisica/LoginPersonaFisicaPagoPA.java index 72b2d5e1d..58edb0cd2 100644 --- a/src/test/java/it/pn/frontend/e2e/stepDefinitions/destinatario/personaFisica/LoginPersonaFisicaPagoPA.java +++ b/src/test/java/it/pn/frontend/e2e/stepDefinitions/destinatario/personaFisica/LoginPersonaFisicaPagoPA.java @@ -21,7 +21,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.net.URL; import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; @@ -49,11 +48,12 @@ public void loginPageDestinatarioVieneVisualizzata(String datipersonaFisica) { Assert.fail("Non stato possibile trovare l'ambiente inserito, Inserisci in -Denvironment test o dev o uat"); } } - @Given("Login Page persona fisica test viene visualizzata") - public void loginPageDestinatarioVieneVisualizzataConUrl() { - String url = "https://cittadini.test.notifichedigitali.it/"; - this.driver.get(url); + @Given("Login Page persona fisica test viene visualizzata") + public void loginPageDestinatarioVieneVisualizzataConUrl() { + + String url = "https://cittadini.test.notifichedigitali.it/"; + this.driver.get(url); } @Given("PF - Si effettua la login tramite token exchange come {string}, e viene visualizzata la dashboard") @@ -99,8 +99,8 @@ public void loginMittenteConTokenExchangeEUtente(String utente) { //ToDo add token for dev } case "test" -> { - if(utente.equalsIgnoreCase("Cristoforo Colombo")) { - token = dataPopulation.readDataPopulation(FILE_TOKEN_LOGIN).get("tokentestPFColombo").toString(); + if (utente.equalsIgnoreCase("Cristoforo Colombo")) { + token = dataPopulation.readDataPopulation(FILE_TOKEN_LOGIN).get("tokentestPFColombo").toString(); } } default -> { @@ -192,8 +192,9 @@ public void loginConDestinatario(String datipersonaFisica) { confermaDatiSpidPFPage.selezionaConfermaButton(); headerPFSection.waitUrlToken(); } + @When("Login con persona fisica") - public void loginConDestinatario(Map datiPF) { + public void loginConDestinatario(Map datiPF) { logger.info("user persona fisica : " + datiPF.get("user")); logger.info("cookies start"); CookiesSection cookiesPage; @@ -314,7 +315,7 @@ public void homePageDestinatarioVieneVisualizzataCorrettamente() { } String variabileAmbiente = System.getProperty("environment"); - String urlChiamata = "https://webapi." + variabileAmbiente + ".notifichedigitali.it/delivery/notifications/received?"; + String urlChiamata = "https://webapi." + variabileAmbiente + ".notifichedigitali.it/bff/v1/notifications/received?"; int codiceRispostaChiamataApi = getCodiceRispostaChiamataApi(urlChiamata); if (codiceRispostaChiamataApi != 200 && codiceRispostaChiamataApi != 0) { diff --git a/src/test/java/it/pn/frontend/e2e/stepDefinitions/destinatario/personaGiuridica/NotifichePGPagoPATest.java b/src/test/java/it/pn/frontend/e2e/stepDefinitions/destinatario/personaGiuridica/NotifichePGPagoPATest.java index f9f751af9..e2de7ff40 100644 --- a/src/test/java/it/pn/frontend/e2e/stepDefinitions/destinatario/personaGiuridica/NotifichePGPagoPATest.java +++ b/src/test/java/it/pn/frontend/e2e/stepDefinitions/destinatario/personaGiuridica/NotifichePGPagoPATest.java @@ -180,7 +180,7 @@ private String getBearerToken() { String bearerToken = ""; for (NetWorkInfo netWorkInfo : netWorkInfos) { String variabileAmbiente = System.getProperty("environment"); - String urlChiamata = "https://webapi." + variabileAmbiente + ".notifichedigitali.it/delivery/notifications/received?"; + String urlChiamata = "https://webapi." + variabileAmbiente + ".notifichedigitali.it/bff/v1/notifications/received?"; if (netWorkInfo.getRequestUrl().contains(urlChiamata)) { bearerToken = netWorkInfo.getAuthorizationBearer(); } diff --git a/src/test/java/it/pn/frontend/e2e/stepDefinitions/mittente/DownloadFileMittentePagoPATest.java b/src/test/java/it/pn/frontend/e2e/stepDefinitions/mittente/DownloadFileMittentePagoPATest.java index c56a42a87..99419cd58 100644 --- a/src/test/java/it/pn/frontend/e2e/stepDefinitions/mittente/DownloadFileMittentePagoPATest.java +++ b/src/test/java/it/pn/frontend/e2e/stepDefinitions/mittente/DownloadFileMittentePagoPATest.java @@ -81,7 +81,7 @@ public void downloadECheckFile() { final String filepath = workingDirectory + "/src/test/resources/dataPopulation/downloadFileNotifica/mittente/notificaN"; - final String urlDocumenti = "https://webapi." + variabileAmbiente + ".notifichedigitali.it/delivery/notifications/sent/" + codiceIUN + "/attachments/documents/0"; + final String urlDocumenti = "https://webapi." + variabileAmbiente + ".notifichedigitali.it/bff/v1/notifications/sent/" + codiceIUN + "/attachments/documents/0"; final String urlDocumentiAllegati = downloadFile.getUrl(urlDocumenti); File file = new File(filepath + count + ".pdf"); @@ -105,7 +105,7 @@ public void downloadECheckFile() { } catch (InterruptedException e) { throw new RuntimeException(e); } - final String url = "https://webapi." + variabileAmbiente + ".notifichedigitali.it/delivery-push/" + codiceIUN + "/document/AAR?documentId=safestorage:"; + final String url = "https://webapi." + variabileAmbiente + ".notifichedigitali.it/bff/v1/" + codiceIUN + "/document/AAR?documentId=safestorage:"; final String urlAvvenutaRicezione = downloadFile.getUrl(url); if (headless && urlAvvenutaRicezione.isEmpty()) { String testoLink = dettaglioNotificaMittenteSection.getTextLinkAvvenutaRicezione(i); @@ -131,7 +131,7 @@ public void downloadECheckFile() { } catch (InterruptedException e) { throw new RuntimeException(e); } - final String urlAttestazione = "https://webapi." + variabileAmbiente + ".notifichedigitali.it/delivery-push/"; + final String urlAttestazione = "https://webapi." + variabileAmbiente + ".notifichedigitali.it/bff/v1/"; final String urlFileAttestazioneOppponubile = downloadFile.getUrl(urlAttestazione); if (headless && urlFileAttestazioneOppponubile.isEmpty()) { String testoLink = dettaglioNotificaSection.getTextLinkAttestazioniOpponibili(i); @@ -153,7 +153,7 @@ public void downloadECheckFile() { } @And("Nella sezione Dettaglio Notifiche si scarica il documento allegato") - public void downloadDocumentiAllegati(){ + public void downloadDocumentiAllegati() { logger.info("Si scaricano solo i documenti Allegati all'interno della notifica"); DettaglioNotificaMittenteSection dettaglioNotificaMittenteSection = new DettaglioNotificaMittenteSection(this.driver); @@ -186,7 +186,7 @@ public void downloadDocumentiAllegati(){ } final String filepath = workingDirectory + "/src/test/resources/dataPopulation/downloadFileNotifica/mittente/notificaN"; - final String urlDocumenti = "https://webapi." + variabileAmbiente + ".notifichedigitali.it/delivery/notifications/sent/" + codiceIUN + "/attachments/documents/0"; + final String urlDocumenti = "https://webapi." + variabileAmbiente + ".notifichedigitali.it/bff/v1/notifications/sent/" + codiceIUN + "/attachments/documents/0"; final String urlDocumentiAllegati = downloadFile.getUrl(urlDocumenti); File file = new File(filepath + count + "PN_NOTIFICATION_ATTACHMENTS.pdf"); @@ -206,27 +206,28 @@ public void downloadDocumentiAllegati(){ } @Then("Si clicca sul documento allegato") - public void clickDocumentoAllegato(){ + public void clickDocumentoAllegato() { DettaglioNotificaMittenteSection dettaglioNotificaMittenteSection = new DettaglioNotificaMittenteSection(this.driver); dettaglioNotificaMittenteSection.clickLinkDocumentiAllegati(); driver.navigate().back(); } @Then("Si clicca sul documento AAR") - public void clickDocumentoAAR(){ + public void clickDocumentoAAR() { DettaglioNotificaMittenteSection dettaglioNotificaMittenteSection = new DettaglioNotificaMittenteSection(this.driver); dettaglioNotificaMittenteSection.clickLinkAvvenutaRicezione(0); driver.navigate().back(); } @Then("Si clicca sul documento Attestazione") - public void clickDocumentoAttestazione(){ + public void clickDocumentoAttestazione() { DettaglioNotificaSection dettaglioNotificaSection = new DettaglioNotificaSection(this.driver); dettaglioNotificaSection.clickLinkAttestazioniOpponibile(0); driver.navigate().back(); } + @And("Nella sezione Dettaglio Notifiche si scarica il file AAR") - public void downloadFileAAR(){ + public void downloadFileAAR() { logger.info("Si scaricano solo i file AAR all'interno della notifica"); DettaglioNotificaMittenteSection dettaglioNotificaMittenteSection = new DettaglioNotificaMittenteSection(this.driver); @@ -280,22 +281,22 @@ public void downloadFileAAR(){ } @And("Nella sezione Dettaglio Notifiche si scarica il file Attestazioni Opponibili") - public void downloadAttestazioniOpponibili(){ - logger.info("Si scaricano solo i file per attestazioni opponibili all'interno della notifica"); - - DettaglioNotificaMittenteSection dettaglioNotificaMittenteSection = new DettaglioNotificaMittenteSection(this.driver); - DettaglioNotificaSection dettaglioNotificaSection = new DettaglioNotificaSection(this.driver); - DataPopulation dataPopulation = new DataPopulation(); - - String workingDirectory = System.getProperty("user.dir"); - String variabileAmbiente = System.getProperty("environment"); - File pathCartella = new File(workingDirectory + "/src/test/resources/dataPopulation/downloadFileNotifica/mittente"); - DownloadFile downloadFile = new DownloadFile(this.driver); - boolean headless = System.getProperty("headless").equalsIgnoreCase("true"); - if (!downloadFile.controlloEsistenzaCartella(pathCartella)) { - pathCartella.mkdirs(); - } - int count = 1; + public void downloadAttestazioniOpponibili() { + logger.info("Si scaricano solo i file per attestazioni opponibili all'interno della notifica"); + + DettaglioNotificaMittenteSection dettaglioNotificaMittenteSection = new DettaglioNotificaMittenteSection(this.driver); + DettaglioNotificaSection dettaglioNotificaSection = new DettaglioNotificaSection(this.driver); + DataPopulation dataPopulation = new DataPopulation(); + + String workingDirectory = System.getProperty("user.dir"); + String variabileAmbiente = System.getProperty("environment"); + File pathCartella = new File(workingDirectory + "/src/test/resources/dataPopulation/downloadFileNotifica/mittente"); + DownloadFile downloadFile = new DownloadFile(this.driver); + boolean headless = System.getProperty("headless").equalsIgnoreCase("true"); + if (!downloadFile.controlloEsistenzaCartella(pathCartella)) { + pathCartella.mkdirs(); + } + int count = 1; dettaglioNotificaMittenteSection.waitLoadingSpinner(); String codiceIUN; @@ -306,33 +307,33 @@ public void downloadAttestazioniOpponibili(){ codiceIUN = dettaglioNotificaMittenteSection.getInfoNotifica(4); } int numeroLinkAttestazioniOpponibile = dettaglioNotificaSection.getLinkAttestazioniOpponibili(); - for (int i = 0; i < numeroLinkAttestazioniOpponibile; i++) { - dettaglioNotificaSection.clickLinkAttestazioniOpponibile(i); - try { - TimeUnit.SECONDS.sleep(5); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - final String urlAttestazione = "https://webapi." + variabileAmbiente + ".notifichedigitali.it/delivery-push/"; - final String urlFileAttestazioneOpponibile = downloadFile.getUrl(urlAttestazione); - if (urlFileAttestazioneOpponibile.isEmpty()) { - String testoLink = dettaglioNotificaSection.getTextLinkAttestazioniOpponibili(i); - logger.error("Non è stato recuperato l'URL per il download per il link: " + testoLink); - Assert.fail("Non è stato recuperato l'URL per il download per il link: " + testoLink); - } - File file = new File(workingDirectory + "/src/test/resources/dataPopulation/downloadFileNotifica/mittente/notificaN" + count + "Attestazioni_Opponoboli.pdf"); - downloadFile.download(urlFileAttestazioneOpponibile, file, headless); - if (!headless) { - dettaglioNotificaSection.goBack(); - } - dettaglioNotificaSection.waitLoadDettaglioNotificaDESection(); - count++; + for (int i = 0; i < numeroLinkAttestazioniOpponibile; i++) { + dettaglioNotificaSection.clickLinkAttestazioniOpponibile(i); + try { + TimeUnit.SECONDS.sleep(5); + } catch (InterruptedException e) { + throw new RuntimeException(e); } - - final String pathOfDownloadedFile = workingDirectory + "/src/test/resources/dataPopulation/downloadFileNotifica/mittente"; - downloadFile.controlloDownload(pathOfDownloadedFile, count); + final String urlAttestazione = "https://webapi." + variabileAmbiente + ".notifichedigitali.it/bff/v1/"; + final String urlFileAttestazioneOpponibile = downloadFile.getUrl(urlAttestazione); + if (urlFileAttestazioneOpponibile.isEmpty()) { + String testoLink = dettaglioNotificaSection.getTextLinkAttestazioniOpponibili(i); + logger.error("Non è stato recuperato l'URL per il download per il link: " + testoLink); + Assert.fail("Non è stato recuperato l'URL per il download per il link: " + testoLink); + } + File file = new File(workingDirectory + "/src/test/resources/dataPopulation/downloadFileNotifica/mittente/notificaN" + count + "Attestazioni_Opponoboli.pdf"); + downloadFile.download(urlFileAttestazioneOpponibile, file, headless); + if (!headless) { + dettaglioNotificaSection.goBack(); + } + dettaglioNotificaSection.waitLoadDettaglioNotificaDESection(); + count++; } + final String pathOfDownloadedFile = workingDirectory + "/src/test/resources/dataPopulation/downloadFileNotifica/mittente"; + downloadFile.controlloDownload(pathOfDownloadedFile, count); + } + @When("Cliccare sulla notifica restituita") public void cliccareSullaNotificaRestituita() { logger.info("Si clicca sulla notifica"); @@ -384,7 +385,7 @@ public void siControllaIlTestoAlSuoInterno(String nomeFile) { DettaglioNotificaMittenteSection dettaglioNotificaMittenteSection = new DettaglioNotificaMittenteSection(this.driver); Map infoNotifiche = dettaglioNotificaMittenteSection.recuperoInfoNotifiche(); - if (nomeFile.contains("PN_NOTIFICATION_ATTACHMENTS")){ + if (nomeFile.contains("PN_NOTIFICATION_ATTACHMENTS")) { if (dettaglioNotificaMittenteSection.controlloTestoFile(nomeFile, "A Simple PDF File")) { logger.info("Il testo all'interno del file è corretto"); } else { diff --git a/src/test/java/it/pn/frontend/e2e/stepDefinitions/mittente/NotificaMittentePagoPATest.java b/src/test/java/it/pn/frontend/e2e/stepDefinitions/mittente/NotificaMittentePagoPATest.java index 8a9dbb8e4..9a7b68ad4 100644 --- a/src/test/java/it/pn/frontend/e2e/stepDefinitions/mittente/NotificaMittentePagoPATest.java +++ b/src/test/java/it/pn/frontend/e2e/stepDefinitions/mittente/NotificaMittentePagoPATest.java @@ -117,7 +117,7 @@ public String getNumeroProtocollo() { } catch (InterruptedException e) { throw new RuntimeException(e); } - String urlNotifiche = "https://webapi.test.notifichedigitali.it/delivery/notifications/"; + String urlNotifiche = "https://webapi.test.notifichedigitali.it/bff/v1/notifications/"; for (NetWorkInfo netWorkInfo : netWorkInfos) { if (netWorkInfo.getRequestUrl().contains(urlNotifiche) && netWorkInfo.getRequestUrl().endsWith("size=50")) { String responseBody = netWorkInfo.getResponseBody(); From 7204348b69fc1c97574d34f4a000b9f30682a1ca Mon Sep 17 00:00:00 2001 From: Andrea Fuso Date: Mon, 3 Jun 2024 12:28:09 +0200 Subject: [PATCH 04/14] text(API): update api paths Signed-off-by: Andrea Fuso --- .../mittente/DownloadFileMittentePagoPATest.java | 9 +++------ .../mittente/NotificaMittentePagoPATest.java | 16 ++++------------ 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/src/test/java/it/pn/frontend/e2e/stepDefinitions/mittente/DownloadFileMittentePagoPATest.java b/src/test/java/it/pn/frontend/e2e/stepDefinitions/mittente/DownloadFileMittentePagoPATest.java index 99419cd58..41081bfd1 100644 --- a/src/test/java/it/pn/frontend/e2e/stepDefinitions/mittente/DownloadFileMittentePagoPATest.java +++ b/src/test/java/it/pn/frontend/e2e/stepDefinitions/mittente/DownloadFileMittentePagoPATest.java @@ -10,6 +10,7 @@ import it.pn.frontend.e2e.stepDefinitions.common.BackgroundTest; import it.pn.frontend.e2e.utility.DataPopulation; import it.pn.frontend.e2e.utility.DownloadFile; +import it.pn.frontend.e2e.utility.WebTool; import org.junit.Assert; import org.openqa.selenium.WebDriver; import org.slf4j.Logger; @@ -357,15 +358,11 @@ public void siSelezionanoIlFileDaScaricare(String nomeFile) { this.datiNotifica = dataPopulation.readDataPopulation("datiNotifica.yaml"); DettaglioNotificaMittenteSection dettaglioNotificaMittenteSection = new DettaglioNotificaMittenteSection(this.driver); dettaglioNotificaMittenteSection.clickLinkAttestazioneOpponibile(nomeFile); - try { - TimeUnit.SECONDS.sleep(5); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } + WebTool.waitTime(5); downloadFile = new DownloadFile(this.driver); String varabileAmbiente = System.getProperty("environment"); - final String url = downloadFile.getUrl("https://webapi." + varabileAmbiente + ".notifichedigitali.it/delivery-push/"); + final String url = downloadFile.getUrl("https://webapi." + varabileAmbiente + ".notifichedigitali.it/bff/v1/notifications/sent/"); if (headless && url.isEmpty()) { logger.error("Non è stato recuperato url per il download per il link: " + nomeFile); Assert.fail("Non è stato recuperato url per il download per il link: " + nomeFile); diff --git a/src/test/java/it/pn/frontend/e2e/stepDefinitions/mittente/NotificaMittentePagoPATest.java b/src/test/java/it/pn/frontend/e2e/stepDefinitions/mittente/NotificaMittentePagoPATest.java index 9a7b68ad4..46145a794 100644 --- a/src/test/java/it/pn/frontend/e2e/stepDefinitions/mittente/NotificaMittentePagoPATest.java +++ b/src/test/java/it/pn/frontend/e2e/stepDefinitions/mittente/NotificaMittentePagoPATest.java @@ -112,14 +112,10 @@ public String getNumeroProtocollo() { logger.info("Si recupera l'ultimo numero protocollo utilizzato"); this.piattaformaNotifichePage.siCambiaIlNumeroElementiVisualizzatiAttraversoIlFiltro(); - try { - TimeUnit.SECONDS.sleep(5); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } + WebTool.waitTime(5); String urlNotifiche = "https://webapi.test.notifichedigitali.it/bff/v1/notifications/"; for (NetWorkInfo netWorkInfo : netWorkInfos) { - if (netWorkInfo.getRequestUrl().contains(urlNotifiche) && netWorkInfo.getRequestUrl().endsWith("size=50")) { + if (netWorkInfo.getRequestUrl().contains(urlNotifiche) && netWorkInfo.getRequestUrl().endsWith("size=10")) { String responseBody = netWorkInfo.getResponseBody(); String[] allNotifiche = responseBody.split("],\"moreResult\":"); String[] notifiche = allNotifiche[0].split("},"); @@ -1331,7 +1327,7 @@ public void siSelezionaUnDestinatario() { */ protected EsitoNotifica siVerificaEsitoNotifica(String dpFile) { logger.info("si verifica se la notifica è stata accettata o rifiutata"); - final String urlNotificationRequest = "https://webapi." + variabileAmbiente + ".notifichedigitali.it/delivery/v2.3/requests"; + final String urlNotificationRequest = "https://webapi." + variabileAmbiente + ".notifichedigitali.it/bff/v1/notifications/sent"; final String urlRichiestaNotifica = "https://api." + variabileAmbiente + ".notifichedigitali.it/delivery/v2.3/requests/"; AccettazioneRichiestaNotifica accettazioneRichiestaNotifica = new AccettazioneRichiestaNotifica(); String codiceApi; @@ -1342,11 +1338,7 @@ protected EsitoNotifica siVerificaEsitoNotifica(String dpFile) { } accettazioneRichiestaNotifica.setxApikey(codiceApi); String statusNotifica = "WAITING"; - try { - TimeUnit.SECONDS.sleep(5); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } + WebTool.waitTime(5); String notificationRequestId = getNotificationRequestId(urlNotificationRequest); if (notificationRequestId == null) { logger.error("NotificationRequestId non trovato, il codice della risposta al url " + urlNotificationRequest + " è diverso di 202 "); From a19c5bb170949b5fa0f65a593f8802ff0e810da9 Mon Sep 17 00:00:00 2001 From: Andrea Fuso Date: Mon, 3 Jun 2024 14:48:13 +0200 Subject: [PATCH 05/14] text(API): update api paths Signed-off-by: Andrea Fuso --- .../frontend/e2e/pages/mittente/PiattaformaNotifichePage.java | 3 +-- .../mittente/DownloadFileMittentePagoPATest.java | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/it/pn/frontend/e2e/pages/mittente/PiattaformaNotifichePage.java b/src/main/java/it/pn/frontend/e2e/pages/mittente/PiattaformaNotifichePage.java index 303a81c79..9c771a641 100644 --- a/src/main/java/it/pn/frontend/e2e/pages/mittente/PiattaformaNotifichePage.java +++ b/src/main/java/it/pn/frontend/e2e/pages/mittente/PiattaformaNotifichePage.java @@ -19,7 +19,6 @@ import java.util.concurrent.TimeUnit; import static org.openqa.selenium.support.ui.ExpectedConditions.elementToBeClickable; -import static org.openqa.selenium.support.ui.ExpectedConditions.visibilityOfElementLocated; public class PiattaformaNotifichePage extends BasePage { @@ -789,7 +788,7 @@ public void verificaPresenzaStato(String stato) { public void verificaNotificaCreata() { String notificationRequestId = ""; for (NetWorkInfo netWorkInfo : netWorkInfos) { - if (netWorkInfo.getRequestUrl().contains("/delivery/v2.3/requests") && netWorkInfo.getRequestMethod().equals("POST")) { + if (netWorkInfo.getRequestUrl().contains("/bff/v1/notifications/") && netWorkInfo.getRequestMethod().equals("POST")) { if (netWorkInfo.getResponseStatus().equals("202") && !netWorkInfo.getResponseBody().isEmpty()) { notificationRequestId = netWorkInfo.getResponseBody().split("\"notificationRequestId\":\"")[1].split("\"")[0]; logger.info("NotificationRequestId: " + notificationRequestId); diff --git a/src/test/java/it/pn/frontend/e2e/stepDefinitions/mittente/DownloadFileMittentePagoPATest.java b/src/test/java/it/pn/frontend/e2e/stepDefinitions/mittente/DownloadFileMittentePagoPATest.java index 41081bfd1..480fb0f83 100644 --- a/src/test/java/it/pn/frontend/e2e/stepDefinitions/mittente/DownloadFileMittentePagoPATest.java +++ b/src/test/java/it/pn/frontend/e2e/stepDefinitions/mittente/DownloadFileMittentePagoPATest.java @@ -82,7 +82,7 @@ public void downloadECheckFile() { final String filepath = workingDirectory + "/src/test/resources/dataPopulation/downloadFileNotifica/mittente/notificaN"; - final String urlDocumenti = "https://webapi." + variabileAmbiente + ".notifichedigitali.it/bff/v1/notifications/sent/" + codiceIUN + "/attachments/documents/0"; + final String urlDocumenti = "https://webapi." + variabileAmbiente + ".notifichedigitali.it/bff/v1/notifications/sent/" + codiceIUN + "/documents/"; final String urlDocumentiAllegati = downloadFile.getUrl(urlDocumenti); File file = new File(filepath + count + ".pdf"); From cf983c314805f6fdffa0f027073881cdfe84220d Mon Sep 17 00:00:00 2001 From: Andrea Fuso Date: Tue, 4 Jun 2024 10:49:39 +0200 Subject: [PATCH 06/14] text(API): update api paths Signed-off-by: Andrea Fuso --- .../mittente/DisserviziAppPATest.java | 26 +++++++------------ 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/src/test/java/it/pn/frontend/e2e/stepDefinitions/mittente/DisserviziAppPATest.java b/src/test/java/it/pn/frontend/e2e/stepDefinitions/mittente/DisserviziAppPATest.java index 9b25702ea..cab64160c 100644 --- a/src/test/java/it/pn/frontend/e2e/stepDefinitions/mittente/DisserviziAppPATest.java +++ b/src/test/java/it/pn/frontend/e2e/stepDefinitions/mittente/DisserviziAppPATest.java @@ -3,19 +3,17 @@ import io.cucumber.java.en.And; import io.cucumber.java.en.Then; import io.cucumber.java.en.When; -import it.pn.frontend.e2e.common.DettaglioNotificaSection; import it.pn.frontend.e2e.listeners.Hooks; import it.pn.frontend.e2e.pages.destinatario.personaFisica.AccediAPiattaformaNotifichePage; import it.pn.frontend.e2e.pages.mittente.DisserviziAppPAPage; import it.pn.frontend.e2e.utility.DownloadFile; -import it.pn.frontend.e2e.utility.DownloadFile; +import it.pn.frontend.e2e.utility.WebTool; import org.openqa.selenium.WebDriver; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.File; import java.io.IOException; -import java.util.concurrent.TimeUnit; public class DisserviziAppPATest { private static final Logger logger = LoggerFactory.getLogger("DisserviziAppPATest"); @@ -64,20 +62,16 @@ public void siScaricaAttestazioneOpponibileDisservizi() throws IOException { if (!downloadFile.controlloEsistenzaCartella(pathCartella)) { pathCartella.mkdirs(); } - disserviziAppPAPage.clickLinkAttestazioniOpponibileDisservizi(0); - try { - TimeUnit.SECONDS.sleep(5); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - String legalFactId = downloadFile.getLegalFactId(); - String urlFileAttestazioneOpponibile ="https://webapi.test.notifichedigitali.it/downtime/v1/legal-facts/" + legalFactId; + disserviziAppPAPage.clickLinkAttestazioniOpponibileDisservizi(0); + WebTool.waitTime(5); + String legalFactId = downloadFile.getLegalFactId(); + String urlFileAttestazioneOpponibile = "https://webapi.test.notifichedigitali.it/bff/v1/downtime/legal-facts/" + legalFactId; - File file = new File(workingDirectory + "/src/test/resources/dataPopulation/downloadFileNotifica/destinatario/notificaN" + 0 + ".pdf"); - downloadFile.downloadAttestazioneDisservizi(urlFileAttestazioneOpponibile, file, headless); - if (!headless) { - disserviziAppPAPage.goBack(); - } + File file = new File(workingDirectory + "/src/test/resources/dataPopulation/downloadFileNotifica/destinatario/notificaN" + 0 + ".pdf"); + downloadFile.downloadAttestazioneDisservizi(urlFileAttestazioneOpponibile, file, headless); + if (!headless) { + disserviziAppPAPage.goBack(); + } downloadFile.controlloDownload(workingDirectory + "/src/test/resources/dataPopulation/downloadFileNotifica/destinatario", 1); } From f66e61e5389212b8eaeac80aa03f5b5edb593ec6 Mon Sep 17 00:00:00 2001 From: Andrea Fuso Date: Tue, 4 Jun 2024 15:06:35 +0200 Subject: [PATCH 07/14] text(API): update api paths Signed-off-by: Andrea Fuso --- .../e2e/common/DettaglioNotificaSection.java | 6 +++ .../it/pn/frontend/e2e/listeners/Hooks.java | 11 ++++- .../pn/frontend/e2e/run/RunCucumberTest.java | 48 +++++++++++++++++++ .../NotifichePersonaFisicaPagoPATest.java | 14 +++--- .../dataPopulation/datiNotifica.yaml | 2 +- src/test/resources/test-config.properties | 4 +- 6 files changed, 76 insertions(+), 9 deletions(-) diff --git a/src/main/java/it/pn/frontend/e2e/common/DettaglioNotificaSection.java b/src/main/java/it/pn/frontend/e2e/common/DettaglioNotificaSection.java index 7fbee0855..847e2958a 100644 --- a/src/main/java/it/pn/frontend/e2e/common/DettaglioNotificaSection.java +++ b/src/main/java/it/pn/frontend/e2e/common/DettaglioNotificaSection.java @@ -174,4 +174,10 @@ public void selezioneAvvisoPagoPa() { Assert.fail("check su avviso pagopa non avvenuto con successo: " + e.getMessage()); } } + + public void clickFile(String fileName) { + By file = By.xpath("//button[contains(text(),'" + fileName + "')]"); + getWebDriverWait(10).until(ExpectedConditions.visibilityOfElementLocated(file)); + element(file).click(); + } } diff --git a/src/main/java/it/pn/frontend/e2e/listeners/Hooks.java b/src/main/java/it/pn/frontend/e2e/listeners/Hooks.java index ca8c33599..65a4a1084 100644 --- a/src/main/java/it/pn/frontend/e2e/listeners/Hooks.java +++ b/src/main/java/it/pn/frontend/e2e/listeners/Hooks.java @@ -33,6 +33,7 @@ import java.io.File; import java.io.IOException; +import java.nio.file.Path; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.time.Duration; @@ -78,8 +79,16 @@ protected void chrome() { chromeOptions.addArguments("--remote-allow-origins=*"); chromeOptions.addArguments("--enable-clipboard"); if (this.headless != null && this.headless.equalsIgnoreCase("true")) { + String downloadFilepath = Path.of("").toAbsolutePath().toString() + System.getProperty("downloadFolder").replace("/", File.separator); + Map prefs = new HashMap<>(); + prefs.put("plugins.always_open_pdf_externally", true); + prefs.put("plugins.plugins_disabled", new String[]{"Chrome PDF Viewer"}); + prefs.put("download.default_directory", downloadFilepath); + prefs.put("download.prompt_for_download", false); + prefs.put("profile.default_content_settings.popups", 0); + chromeOptions.setExperimentalOption("prefs", prefs); chromeOptions.addArguments("no-sandbox"); - chromeOptions.addArguments("headless"); + chromeOptions.addArguments("--headless"); chromeOptions.addArguments("window-size=1920,1080"); } diff --git a/src/test/java/it/pn/frontend/e2e/run/RunCucumberTest.java b/src/test/java/it/pn/frontend/e2e/run/RunCucumberTest.java index 1c0550c48..74c5d2a3b 100644 --- a/src/test/java/it/pn/frontend/e2e/run/RunCucumberTest.java +++ b/src/test/java/it/pn/frontend/e2e/run/RunCucumberTest.java @@ -8,8 +8,13 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.File; import java.io.IOException; import java.io.InputStream; +import java.nio.file.DirectoryStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.Properties; @RunWith(Cucumber.class) @@ -60,6 +65,47 @@ private static void setApiBaseUrl() { System.setProperty("apiBaseUrl", apiBaseUrl); } + private static void setUpDownloadFolder() { + String downloadDir = System.getProperty("downloadFolder"); + Path fullPath = Paths.get(System.getProperty("user.dir"), downloadDir.replace("/", File.separator)); + if (Files.notExists(fullPath)) { + try { + Files.createDirectories(fullPath); + logger.info("Download directory created: " + fullPath.toAbsolutePath()); + } catch (IOException e) { + logger.error("Error creating download folder: " + fullPath.toAbsolutePath(), e); + } + } else { + logger.info("Download directory already exists: " + fullPath.toAbsolutePath()); + } + } + + private static void removeDownloadFolder() { + String downloadDir = System.getProperty("downloadFolder", "/src/test/resources/dataPopulation/downloadFileNotifica"); + Path fullPath = Paths.get(System.getProperty("user.dir"), downloadDir.replace("/", File.separator)); + if (Files.exists(fullPath)) { + try { + deleteRecursively(fullPath); + logger.info("Download directory deleted: " + fullPath.toAbsolutePath()); + } catch (IOException e) { + logger.error("Error deleting download folder: " + fullPath.toAbsolutePath(), e); + } + } else { + logger.info("Download directory does not exist: " + fullPath.toAbsolutePath()); + } + } + + private static void deleteRecursively(Path path) throws IOException { + if (Files.isDirectory(path)) { + try (DirectoryStream entries = Files.newDirectoryStream(path)) { + for (Path entry : entries) { + deleteRecursively(entry); + } + } + } + Files.delete(path); + } + @BeforeClass public static void startTestSuite() { setApiBaseUrl(); @@ -73,6 +119,7 @@ public static void startTestSuite() { } ); } + setUpDownloadFolder(); if (System.getProperty("cucumber.filter.tags") != null) { testSuite = System.getProperty("cucumber.filter.tags").substring(1); logger.info("run test della test suite = " + testSuite); @@ -84,6 +131,7 @@ public static void startTestSuite() { @AfterClass public static void finishTestSuite() { + removeDownloadFolder(); logger.info("finish the test suite = " + testSuite); } } diff --git a/src/test/java/it/pn/frontend/e2e/stepDefinitions/destinatario/personaFisica/NotifichePersonaFisicaPagoPATest.java b/src/test/java/it/pn/frontend/e2e/stepDefinitions/destinatario/personaFisica/NotifichePersonaFisicaPagoPATest.java index 6c0128d8b..a2e4c7f95 100644 --- a/src/test/java/it/pn/frontend/e2e/stepDefinitions/destinatario/personaFisica/NotifichePersonaFisicaPagoPATest.java +++ b/src/test/java/it/pn/frontend/e2e/stepDefinitions/destinatario/personaFisica/NotifichePersonaFisicaPagoPATest.java @@ -285,12 +285,8 @@ public void siSelezionanoIFileAttestazioniOpponibiliDaScaricareAllInternoDellaNo } for (int i = 0; i < numeroLinkAttestazioniOpponibile; i++) { dettaglioNotificaSection.clickLinkAttestazioniOpponibile(i); - try { - TimeUnit.SECONDS.sleep(5); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - String urlFileAttestazioneOppponibile = downloadFile.getUrl("https://webapi.test.notifichedigitali.it/delivery-push/" + datiNotifica.get("codiceIUN").toString() + "/legal-facts/"); + WebTool.waitTime(5); + String urlFileAttestazioneOppponibile = downloadFile.getUrl("https://webapi.test.notifichedigitali.it/bff/v1/notifications/received/" + datiNotifica.get("codiceIUN").toString()); if (headless && urlFileAttestazioneOppponibile.isEmpty()) { String testoLink = dettaglioNotificaSection.getTextLinkAttestazioniOpponibili(i); @@ -409,6 +405,12 @@ public void siControllaLoStatoTimelineInDettaglioNotificaPF(Map public void siSelezionaUnAvvisoPagopa() { dettaglioNotifica.selezioneAvvisoPagoPa(); } + + @Then("Si seleziona il file {string} da scaricare, all'interno della notifica persona fisica, e si controlla che il download sia avvenuto con successo") + public void siSelezionaIlFileDaScaricareAllInternoDellaNotificaPersonaFisicaESiControllaCheIlDownloadSiaAvvenutoConSuccesso(String fileName) { + dettaglioNotifica.clickFile(fileName); + dettaglioNotifica.goBack(); + } } diff --git a/src/test/resources/dataPopulation/datiNotifica.yaml b/src/test/resources/dataPopulation/datiNotifica.yaml index c57778fea..7e2b54fdc 100644 --- a/src/test/resources/dataPopulation/datiNotifica.yaml +++ b/src/test/resources/dataPopulation/datiNotifica.yaml @@ -5,4 +5,4 @@ gruppoTest: "test-TA-FE-TEST" gruppoDev: "GruppoTest" codiceTassonometrico: "123456A" nomeDocumentoNotifica: "RATA SCADUTA IMU" -codiceIUN: "WLGA-LMUZ-JAQR-202311-G-1" +codiceIUN: "LXPN-YLPU-XDRG-202405-P-1" diff --git a/src/test/resources/test-config.properties b/src/test/resources/test-config.properties index 413426f6a..144055ee0 100644 --- a/src/test/resources/test-config.properties +++ b/src/test/resources/test-config.properties @@ -4,4 +4,6 @@ environment=test cookie.config=true headless=true loadComponentWaitTime=120 -apiBaseUrl=https://webapi.{ENV}.notifichedigitali.it/bff/v1/ \ No newline at end of file +apiBaseUrl=https://webapi.{ENV}.notifichedigitali.it/bff/v1/ +# the folder path must start with / and end with / +downloadFolder=/src/test/resources/dataPopulation/downloadPdf/ \ No newline at end of file From 8b6a6fb2afdd438ba80e3be1a35836410106c070 Mon Sep 17 00:00:00 2001 From: Andrea Fuso Date: Wed, 5 Jun 2024 11:52:27 +0200 Subject: [PATCH 08/14] chore: replace api path with system ENV --- .../it/pn/frontend/e2e/utility/WebTool.java | 4 ++++ .../LoginPersonaFisicaPagoPA.java | 2 +- .../NotifichePersonaFisicaPagoPATest.java | 3 ++- .../RecapitiPersonaFisicaTest.java | 2 +- .../NotifichePGPagoPATest.java | 5 +++-- .../mittente/DisserviziAppPATest.java | 2 +- .../DownloadFileMittentePagoPATest.java | 20 +++++++------------ .../mittente/NotificaMittentePagoPATest.java | 6 +++--- 8 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/main/java/it/pn/frontend/e2e/utility/WebTool.java b/src/main/java/it/pn/frontend/e2e/utility/WebTool.java index eca939fb3..e92173aaa 100644 --- a/src/main/java/it/pn/frontend/e2e/utility/WebTool.java +++ b/src/main/java/it/pn/frontend/e2e/utility/WebTool.java @@ -9,6 +9,7 @@ import it.pn.frontend.e2e.section.destinatario.personaFisica.HeaderPFSection; import it.pn.frontend.e2e.section.destinatario.personaGiuridica.HeaderPGSection; import it.pn.frontend.e2e.section.mittente.HeaderPASection; +import lombok.Getter; import org.junit.Assert; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebDriver; @@ -27,6 +28,9 @@ public class WebTool { private final List netWorkInfos = Hooks.netWorkInfos; private final String env = System.getProperty("environment"); + @Getter + private static final String apiBaseUrl = System.getProperty("apiBaseUrl"); + public static String switchToPortal(AppPortal portal) { openNewTab(); switch (portal) { diff --git a/src/test/java/it/pn/frontend/e2e/stepDefinitions/destinatario/personaFisica/LoginPersonaFisicaPagoPA.java b/src/test/java/it/pn/frontend/e2e/stepDefinitions/destinatario/personaFisica/LoginPersonaFisicaPagoPA.java index 58edb0cd2..eca7d2459 100644 --- a/src/test/java/it/pn/frontend/e2e/stepDefinitions/destinatario/personaFisica/LoginPersonaFisicaPagoPA.java +++ b/src/test/java/it/pn/frontend/e2e/stepDefinitions/destinatario/personaFisica/LoginPersonaFisicaPagoPA.java @@ -315,7 +315,7 @@ public void homePageDestinatarioVieneVisualizzataCorrettamente() { } String variabileAmbiente = System.getProperty("environment"); - String urlChiamata = "https://webapi." + variabileAmbiente + ".notifichedigitali.it/bff/v1/notifications/received?"; + String urlChiamata = WebTool.getApiBaseUrl() + "notifications/received?"; int codiceRispostaChiamataApi = getCodiceRispostaChiamataApi(urlChiamata); if (codiceRispostaChiamataApi != 200 && codiceRispostaChiamataApi != 0) { diff --git a/src/test/java/it/pn/frontend/e2e/stepDefinitions/destinatario/personaFisica/NotifichePersonaFisicaPagoPATest.java b/src/test/java/it/pn/frontend/e2e/stepDefinitions/destinatario/personaFisica/NotifichePersonaFisicaPagoPATest.java index a2e4c7f95..b196f5425 100644 --- a/src/test/java/it/pn/frontend/e2e/stepDefinitions/destinatario/personaFisica/NotifichePersonaFisicaPagoPATest.java +++ b/src/test/java/it/pn/frontend/e2e/stepDefinitions/destinatario/personaFisica/NotifichePersonaFisicaPagoPATest.java @@ -286,7 +286,8 @@ public void siSelezionanoIFileAttestazioniOpponibiliDaScaricareAllInternoDellaNo for (int i = 0; i < numeroLinkAttestazioniOpponibile; i++) { dettaglioNotificaSection.clickLinkAttestazioniOpponibile(i); WebTool.waitTime(5); - String urlFileAttestazioneOppponibile = downloadFile.getUrl("https://webapi.test.notifichedigitali.it/bff/v1/notifications/received/" + datiNotifica.get("codiceIUN").toString()); + String fullPath = WebTool.getApiBaseUrl() + "/bff/v1/notifications/received/" + datiNotifica.get("codiceIUN").toString(); + String urlFileAttestazioneOppponibile = downloadFile.getUrl(fullPath); if (headless && urlFileAttestazioneOppponibile.isEmpty()) { String testoLink = dettaglioNotificaSection.getTextLinkAttestazioniOpponibili(i); diff --git a/src/test/java/it/pn/frontend/e2e/stepDefinitions/destinatario/personaFisica/RecapitiPersonaFisicaTest.java b/src/test/java/it/pn/frontend/e2e/stepDefinitions/destinatario/personaFisica/RecapitiPersonaFisicaTest.java index a811c9766..a3ba3e192 100644 --- a/src/test/java/it/pn/frontend/e2e/stepDefinitions/destinatario/personaFisica/RecapitiPersonaFisicaTest.java +++ b/src/test/java/it/pn/frontend/e2e/stepDefinitions/destinatario/personaFisica/RecapitiPersonaFisicaTest.java @@ -84,7 +84,7 @@ public void nellaPaginaITuoiRecapitiSiCliccaSulBottoneConferma() { public void nellaPaginaITuoiRecapitiSiVisualizzaCorrettamenteIlPopUpDiInserimentoOTP() { logger.info("Si visualizza correttamente il pop-up di inserimento OTP"); String varabileAmbiente = System.getProperty("environment"); - String url = "https://webapi." + varabileAmbiente + ".notifichedigitali.it/bff/v1/address"; + String url = WebTool.getApiBaseUrl() + "address"; recapitiDestinatarioPage.waitLoadPopUp(); try { TimeUnit.SECONDS.sleep(3); diff --git a/src/test/java/it/pn/frontend/e2e/stepDefinitions/destinatario/personaGiuridica/NotifichePGPagoPATest.java b/src/test/java/it/pn/frontend/e2e/stepDefinitions/destinatario/personaGiuridica/NotifichePGPagoPATest.java index e2de7ff40..dd4536fdd 100644 --- a/src/test/java/it/pn/frontend/e2e/stepDefinitions/destinatario/personaGiuridica/NotifichePGPagoPATest.java +++ b/src/test/java/it/pn/frontend/e2e/stepDefinitions/destinatario/personaGiuridica/NotifichePGPagoPATest.java @@ -17,6 +17,7 @@ import it.pn.frontend.e2e.utility.CookieConfig; import it.pn.frontend.e2e.utility.DataPopulation; import it.pn.frontend.e2e.utility.DownloadFile; +import it.pn.frontend.e2e.utility.WebTool; import org.junit.Assert; import org.openqa.selenium.WebDriver; import org.slf4j.Logger; @@ -66,7 +67,7 @@ public void siVisualizzaCorrettamenteLaPaginaNotifichePersonaGiuridica(String ra piattaformaNotifichePGPAPage.waitLoadPiattaformaNotificaPage(ragioneSociale); String variabileAmbiente = System.getProperty("environment"); - String urlChiamata = "https://webapi." + variabileAmbiente + ".notifichedigitali.it/bff/v1/notifications/received?"; + String urlChiamata = WebTool.getApiBaseUrl() + "notifications/received?"; int codiceRispostaChiamataApi = getCodiceRispostaChiamataApi(urlChiamata); if (codiceRispostaChiamataApi != 200 && codiceRispostaChiamataApi != 0) { @@ -180,7 +181,7 @@ private String getBearerToken() { String bearerToken = ""; for (NetWorkInfo netWorkInfo : netWorkInfos) { String variabileAmbiente = System.getProperty("environment"); - String urlChiamata = "https://webapi." + variabileAmbiente + ".notifichedigitali.it/bff/v1/notifications/received?"; + String urlChiamata = WebTool.getApiBaseUrl() + "notifications/received?"; if (netWorkInfo.getRequestUrl().contains(urlChiamata)) { bearerToken = netWorkInfo.getAuthorizationBearer(); } diff --git a/src/test/java/it/pn/frontend/e2e/stepDefinitions/mittente/DisserviziAppPATest.java b/src/test/java/it/pn/frontend/e2e/stepDefinitions/mittente/DisserviziAppPATest.java index cab64160c..d5f7f8718 100644 --- a/src/test/java/it/pn/frontend/e2e/stepDefinitions/mittente/DisserviziAppPATest.java +++ b/src/test/java/it/pn/frontend/e2e/stepDefinitions/mittente/DisserviziAppPATest.java @@ -65,7 +65,7 @@ public void siScaricaAttestazioneOpponibileDisservizi() throws IOException { disserviziAppPAPage.clickLinkAttestazioniOpponibileDisservizi(0); WebTool.waitTime(5); String legalFactId = downloadFile.getLegalFactId(); - String urlFileAttestazioneOpponibile = "https://webapi.test.notifichedigitali.it/bff/v1/downtime/legal-facts/" + legalFactId; + String urlFileAttestazioneOpponibile = WebTool.getApiBaseUrl() + "downtime/legal-facts/" + legalFactId; File file = new File(workingDirectory + "/src/test/resources/dataPopulation/downloadFileNotifica/destinatario/notificaN" + 0 + ".pdf"); downloadFile.downloadAttestazioneDisservizi(urlFileAttestazioneOpponibile, file, headless); diff --git a/src/test/java/it/pn/frontend/e2e/stepDefinitions/mittente/DownloadFileMittentePagoPATest.java b/src/test/java/it/pn/frontend/e2e/stepDefinitions/mittente/DownloadFileMittentePagoPATest.java index 480fb0f83..82d82ff75 100644 --- a/src/test/java/it/pn/frontend/e2e/stepDefinitions/mittente/DownloadFileMittentePagoPATest.java +++ b/src/test/java/it/pn/frontend/e2e/stepDefinitions/mittente/DownloadFileMittentePagoPATest.java @@ -82,7 +82,7 @@ public void downloadECheckFile() { final String filepath = workingDirectory + "/src/test/resources/dataPopulation/downloadFileNotifica/mittente/notificaN"; - final String urlDocumenti = "https://webapi." + variabileAmbiente + ".notifichedigitali.it/bff/v1/notifications/sent/" + codiceIUN + "/documents/"; + final String urlDocumenti = WebTool.getApiBaseUrl() + "notifications/sent/" + codiceIUN + "/documents/"; final String urlDocumentiAllegati = downloadFile.getUrl(urlDocumenti); File file = new File(filepath + count + ".pdf"); @@ -106,7 +106,7 @@ public void downloadECheckFile() { } catch (InterruptedException e) { throw new RuntimeException(e); } - final String url = "https://webapi." + variabileAmbiente + ".notifichedigitali.it/bff/v1/" + codiceIUN + "/document/AAR?documentId=safestorage:"; + final String url = WebTool.getApiBaseUrl() + "notifications/sent/" + codiceIUN + "/documents/AAR?documentId=safestorage:"; final String urlAvvenutaRicezione = downloadFile.getUrl(url); if (headless && urlAvvenutaRicezione.isEmpty()) { String testoLink = dettaglioNotificaMittenteSection.getTextLinkAvvenutaRicezione(i); @@ -132,8 +132,7 @@ public void downloadECheckFile() { } catch (InterruptedException e) { throw new RuntimeException(e); } - final String urlAttestazione = "https://webapi." + variabileAmbiente + ".notifichedigitali.it/bff/v1/"; - final String urlFileAttestazioneOppponubile = downloadFile.getUrl(urlAttestazione); + final String urlFileAttestazioneOppponubile = downloadFile.getUrl(WebTool.getApiBaseUrl()); if (headless && urlFileAttestazioneOppponubile.isEmpty()) { String testoLink = dettaglioNotificaSection.getTextLinkAttestazioniOpponibili(i); logger.error("Non è stato recuperato url per il download per il link: " + testoLink); @@ -187,7 +186,7 @@ public void downloadDocumentiAllegati() { } final String filepath = workingDirectory + "/src/test/resources/dataPopulation/downloadFileNotifica/mittente/notificaN"; - final String urlDocumenti = "https://webapi." + variabileAmbiente + ".notifichedigitali.it/bff/v1/notifications/sent/" + codiceIUN + "/attachments/documents/0"; + final String urlDocumenti = WebTool.getApiBaseUrl() + "notifications/sent/" + codiceIUN + "/attachments/documents/0"; final String urlDocumentiAllegati = downloadFile.getUrl(urlDocumenti); File file = new File(filepath + count + "PN_NOTIFICATION_ATTACHMENTS.pdf"); @@ -256,11 +255,7 @@ public void downloadFileAAR() { int numeroLinkAvvenutaRicezione = dettaglioNotificaMittenteSection.getLinkAvvenutaRicezione(); for (int i = 1; i < numeroLinkAvvenutaRicezione; i++) { dettaglioNotificaMittenteSection.clickLinkAvvenutaRicezione(i); - try { - TimeUnit.SECONDS.sleep(5); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } + WebTool.waitTime(5); final String url = "https://webapi." + variabileAmbiente + ".notifichedigitali.it/delivery-push/" + codiceIUN + "/document/AAR?documentId=safestorage:"; final String urlAvvenutaRicezione = downloadFile.getUrl(url); if (urlAvvenutaRicezione.isEmpty()) { @@ -315,8 +310,7 @@ public void downloadAttestazioniOpponibili() { } catch (InterruptedException e) { throw new RuntimeException(e); } - final String urlAttestazione = "https://webapi." + variabileAmbiente + ".notifichedigitali.it/bff/v1/"; - final String urlFileAttestazioneOpponibile = downloadFile.getUrl(urlAttestazione); + final String urlFileAttestazioneOpponibile = downloadFile.getUrl(WebTool.getApiBaseUrl()); if (urlFileAttestazioneOpponibile.isEmpty()) { String testoLink = dettaglioNotificaSection.getTextLinkAttestazioniOpponibili(i); logger.error("Non è stato recuperato l'URL per il download per il link: " + testoLink); @@ -362,7 +356,7 @@ public void siSelezionanoIlFileDaScaricare(String nomeFile) { downloadFile = new DownloadFile(this.driver); String varabileAmbiente = System.getProperty("environment"); - final String url = downloadFile.getUrl("https://webapi." + varabileAmbiente + ".notifichedigitali.it/bff/v1/notifications/sent/"); + final String url = downloadFile.getUrl(WebTool.getApiBaseUrl() + "notifications/sent/"); if (headless && url.isEmpty()) { logger.error("Non è stato recuperato url per il download per il link: " + nomeFile); Assert.fail("Non è stato recuperato url per il download per il link: " + nomeFile); diff --git a/src/test/java/it/pn/frontend/e2e/stepDefinitions/mittente/NotificaMittentePagoPATest.java b/src/test/java/it/pn/frontend/e2e/stepDefinitions/mittente/NotificaMittentePagoPATest.java index 46145a794..6ee545d93 100644 --- a/src/test/java/it/pn/frontend/e2e/stepDefinitions/mittente/NotificaMittentePagoPATest.java +++ b/src/test/java/it/pn/frontend/e2e/stepDefinitions/mittente/NotificaMittentePagoPATest.java @@ -84,7 +84,7 @@ public void siVisualizzaCorrettamenteLaPaginaPiattaformaNotifiche() { throw new RuntimeException(e); } - String urlChiamata = "https://webapi." + variabileAmbiente + ".notifichedigitali.it/bff/v1/notifications/sent?"; + String urlChiamata = WebTool.getApiBaseUrl() + "notifications/sent?"; int codiceRispostaChiamataApi = getCodiceRispostaChiamataApi(urlChiamata); if (codiceRispostaChiamataApi != 200 && codiceRispostaChiamataApi != 0) { logger.error("TA_QA: La chiamata, " + urlChiamata + " è andata in errore"); @@ -113,7 +113,7 @@ public String getNumeroProtocollo() { this.piattaformaNotifichePage.siCambiaIlNumeroElementiVisualizzatiAttraversoIlFiltro(); WebTool.waitTime(5); - String urlNotifiche = "https://webapi.test.notifichedigitali.it/bff/v1/notifications/"; + String urlNotifiche = WebTool.getApiBaseUrl() + "notifications/"; for (NetWorkInfo netWorkInfo : netWorkInfos) { if (netWorkInfo.getRequestUrl().contains(urlNotifiche) && netWorkInfo.getRequestUrl().endsWith("size=10")) { String responseBody = netWorkInfo.getResponseBody(); @@ -1327,7 +1327,7 @@ public void siSelezionaUnDestinatario() { */ protected EsitoNotifica siVerificaEsitoNotifica(String dpFile) { logger.info("si verifica se la notifica è stata accettata o rifiutata"); - final String urlNotificationRequest = "https://webapi." + variabileAmbiente + ".notifichedigitali.it/bff/v1/notifications/sent"; + final String urlNotificationRequest = WebTool.getApiBaseUrl() + "notifications/sent"; final String urlRichiestaNotifica = "https://api." + variabileAmbiente + ".notifichedigitali.it/delivery/v2.3/requests/"; AccettazioneRichiestaNotifica accettazioneRichiestaNotifica = new AccettazioneRichiestaNotifica(); String codiceApi; From 8c56ca2c75bc19741822e32a13a4a7e8103325ba Mon Sep 17 00:00:00 2001 From: Andrea Fuso Date: Thu, 6 Jun 2024 09:41:34 +0200 Subject: [PATCH 09/14] chore: fix duplicate variable --- src/main/java/it/pn/frontend/e2e/listeners/Hooks.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/it/pn/frontend/e2e/listeners/Hooks.java b/src/main/java/it/pn/frontend/e2e/listeners/Hooks.java index f313b86e7..1aa4278ed 100644 --- a/src/main/java/it/pn/frontend/e2e/listeners/Hooks.java +++ b/src/main/java/it/pn/frontend/e2e/listeners/Hooks.java @@ -85,7 +85,7 @@ protected void chrome() { chromeOptions.setExperimentalOption("prefs", chromePrefs); if (this.headless != null && this.headless.equalsIgnoreCase("true")) { - String downloadFilepath = Path.of("").toAbsolutePath().toString() + System.getProperty("downloadFolder").replace("/", File.separator); + downloadFilepath = Path.of("").toAbsolutePath().toString() + System.getProperty("downloadFolder").replace("/", File.separator); Map prefs = new HashMap<>(); prefs.put("plugins.always_open_pdf_externally", true); prefs.put("plugins.plugins_disabled", new String[]{"Chrome PDF Viewer"}); From 6f80b41fa179dd00276e9f5495327f10f3fa0688 Mon Sep 17 00:00:00 2001 From: Andrea Fuso Date: Thu, 6 Jun 2024 09:49:24 +0200 Subject: [PATCH 10/14] chore: fix download path into `test-config.properties` --- src/test/resources/test-config.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/resources/test-config.properties b/src/test/resources/test-config.properties index e74fe58e0..7549fb322 100644 --- a/src/test/resources/test-config.properties +++ b/src/test/resources/test-config.properties @@ -4,6 +4,6 @@ environment=test cookie.config=true headless=true # the folder path must start with / and end with / -downloadFilePath=src/test/resources/dataPopulation/downloads +downloadFilePath=src/test/resources/dataPopulation/downloads/ loadComponentWaitTime=120 apiBaseUrl=https://webapi.{ENV}.notifichedigitali.it/bff/v1/ \ No newline at end of file From 423d0016a2c3d4b44d443239b9a63d84ae847059 Mon Sep 17 00:00:00 2001 From: Andrea Fuso Date: Thu, 6 Jun 2024 12:31:40 +0200 Subject: [PATCH 11/14] chore: remove unused methods --- .../e2e/common/DettaglioNotificaSection.java | 6 -- .../pn/frontend/e2e/run/RunCucumberTest.java | 56 ------------------- 2 files changed, 62 deletions(-) diff --git a/src/main/java/it/pn/frontend/e2e/common/DettaglioNotificaSection.java b/src/main/java/it/pn/frontend/e2e/common/DettaglioNotificaSection.java index 847e2958a..7fbee0855 100644 --- a/src/main/java/it/pn/frontend/e2e/common/DettaglioNotificaSection.java +++ b/src/main/java/it/pn/frontend/e2e/common/DettaglioNotificaSection.java @@ -174,10 +174,4 @@ public void selezioneAvvisoPagoPa() { Assert.fail("check su avviso pagopa non avvenuto con successo: " + e.getMessage()); } } - - public void clickFile(String fileName) { - By file = By.xpath("//button[contains(text(),'" + fileName + "')]"); - getWebDriverWait(10).until(ExpectedConditions.visibilityOfElementLocated(file)); - element(file).click(); - } } diff --git a/src/test/java/it/pn/frontend/e2e/run/RunCucumberTest.java b/src/test/java/it/pn/frontend/e2e/run/RunCucumberTest.java index 7d2f8eb81..38bc3985d 100644 --- a/src/test/java/it/pn/frontend/e2e/run/RunCucumberTest.java +++ b/src/test/java/it/pn/frontend/e2e/run/RunCucumberTest.java @@ -54,62 +54,8 @@ private static boolean loadProperties() { return false; } - private static void setApiBaseUrl() { - String baseUrlProperty = System.getProperty("apiBaseUrl"); - String env = System.getProperty("environment"); - if (baseUrlProperty == null || env == null) { - logger.error("apiBaseUrl property not set"); - return; - } - String apiBaseUrl = baseUrlProperty.replace("{ENV}", env); - logger.info("apiBaseUrl = " + apiBaseUrl); - System.setProperty("apiBaseUrl", apiBaseUrl); - } - - private static void setUpDownloadFolder() { - String downloadDir = System.getProperty("downloadFolder"); - Path fullPath = Paths.get(System.getProperty("user.dir"), downloadDir.replace("/", File.separator)); - if (Files.notExists(fullPath)) { - try { - Files.createDirectories(fullPath); - logger.info("Download directory created: " + fullPath.toAbsolutePath()); - } catch (IOException e) { - logger.error("Error creating download folder: " + fullPath.toAbsolutePath(), e); - } - } else { - logger.info("Download directory already exists: " + fullPath.toAbsolutePath()); - } - } - - private static void removeDownloadFolder() { - String downloadDir = System.getProperty("downloadFolder", "/src/test/resources/dataPopulation/downloadFileNotifica"); - Path fullPath = Paths.get(System.getProperty("user.dir"), downloadDir.replace("/", File.separator)); - if (Files.exists(fullPath)) { - try { - deleteRecursively(fullPath); - logger.info("Download directory deleted: " + fullPath.toAbsolutePath()); - } catch (IOException e) { - logger.error("Error deleting download folder: " + fullPath.toAbsolutePath(), e); - } - } else { - logger.info("Download directory does not exist: " + fullPath.toAbsolutePath()); - } - } - - private static void deleteRecursively(Path path) throws IOException { - if (Files.isDirectory(path)) { - try (DirectoryStream entries = Files.newDirectoryStream(path)) { - for (Path entry : entries) { - deleteRecursively(entry); - } - } - } - Files.delete(path); - } - @BeforeClass public static void startTestSuite() { - setApiBaseUrl(); if (loadProperties()) { logger.info("properties loaded"); properties.forEach((property, value) -> { @@ -120,7 +66,6 @@ public static void startTestSuite() { } ); } - setUpDownloadFolder(); if (System.getProperty("cucumber.filter.tags") != null) { testSuite = System.getProperty("cucumber.filter.tags").substring(1); logger.info("run test della test suite = " + testSuite); @@ -132,7 +77,6 @@ public static void startTestSuite() { @AfterClass public static void finishTestSuite() { - removeDownloadFolder(); logger.info("finish the test suite = " + testSuite); } } From 29e730ff0dbc928a4b9e1240bf01c293725770c1 Mon Sep 17 00:00:00 2001 From: Andrea Fuso Date: Thu, 6 Jun 2024 12:36:09 +0200 Subject: [PATCH 12/14] chore: remove unused methods --- src/main/java/it/pn/frontend/e2e/listeners/Hooks.java | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/main/java/it/pn/frontend/e2e/listeners/Hooks.java b/src/main/java/it/pn/frontend/e2e/listeners/Hooks.java index 1aa4278ed..9fe307d50 100644 --- a/src/main/java/it/pn/frontend/e2e/listeners/Hooks.java +++ b/src/main/java/it/pn/frontend/e2e/listeners/Hooks.java @@ -85,16 +85,8 @@ protected void chrome() { chromeOptions.setExperimentalOption("prefs", chromePrefs); if (this.headless != null && this.headless.equalsIgnoreCase("true")) { - downloadFilepath = Path.of("").toAbsolutePath().toString() + System.getProperty("downloadFolder").replace("/", File.separator); - Map prefs = new HashMap<>(); - prefs.put("plugins.always_open_pdf_externally", true); - prefs.put("plugins.plugins_disabled", new String[]{"Chrome PDF Viewer"}); - prefs.put("download.default_directory", downloadFilepath); - prefs.put("download.prompt_for_download", false); - prefs.put("profile.default_content_settings.popups", 0); - chromeOptions.setExperimentalOption("prefs", prefs); chromeOptions.addArguments("no-sandbox"); - chromeOptions.addArguments("--headless"); + chromeOptions.addArguments("headless"); chromeOptions.addArguments("window-size=1920,1080"); } @@ -116,7 +108,6 @@ protected void chrome() { this.captureHttpRequests(); this.captureHttpResponse(); logger.info("chromedriver started"); - } private void captureHttpRequests() { From f564fbff160ac41eccd6d277d5fa817643208779 Mon Sep 17 00:00:00 2001 From: Andrea Fuso Date: Thu, 6 Jun 2024 12:39:29 +0200 Subject: [PATCH 13/14] chore: remove unused variables --- .../mittente/DownloadFileMittentePagoPATest.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/test/java/it/pn/frontend/e2e/stepDefinitions/mittente/DownloadFileMittentePagoPATest.java b/src/test/java/it/pn/frontend/e2e/stepDefinitions/mittente/DownloadFileMittentePagoPATest.java index 21db14c2d..f4e574598 100644 --- a/src/test/java/it/pn/frontend/e2e/stepDefinitions/mittente/DownloadFileMittentePagoPATest.java +++ b/src/test/java/it/pn/frontend/e2e/stepDefinitions/mittente/DownloadFileMittentePagoPATest.java @@ -55,7 +55,6 @@ public void downloadECheckFile() { DataPopulation dataPopulation = new DataPopulation(); String workingDirectory = System.getProperty("user.dir"); - String variabileAmbiente = System.getProperty("environment"); File pathCartella = new File(workingDirectory + "/src/test/resources/dataPopulation/downloadFileNotifica/mittente"); downloadFile = new DownloadFile(this.driver); boolean headless = System.getProperty("headless").equalsIgnoreCase("true"); @@ -162,7 +161,6 @@ public void downloadDocumentiAllegati() { DataPopulation dataPopulation = new DataPopulation(); String workingDirectory = System.getProperty("user.dir"); - String variabileAmbiente = System.getProperty("environment"); File pathCartella = new File(workingDirectory + "/src/test/resources/dataPopulation/downloadFileNotifica/mittente"); DownloadFile downloadFile = new DownloadFile(this.driver); boolean headless = System.getProperty("headless").equalsIgnoreCase("true"); @@ -286,7 +284,6 @@ public void downloadAttestazioniOpponibili() { DataPopulation dataPopulation = new DataPopulation(); String workingDirectory = System.getProperty("user.dir"); - String variabileAmbiente = System.getProperty("environment"); File pathCartella = new File(workingDirectory + "/src/test/resources/dataPopulation/downloadFileNotifica/mittente"); DownloadFile downloadFile = new DownloadFile(this.driver); boolean headless = System.getProperty("headless").equalsIgnoreCase("true"); @@ -356,7 +353,6 @@ public void siSelezionanoIlFileDaScaricare(String nomeFile) { WebTool.waitTime(5); downloadFile = new DownloadFile(this.driver); - String varabileAmbiente = System.getProperty("environment"); final String url = downloadFile.getUrl(WebTool.getApiBaseUrl() + "notifications/sent/"); if (headless && url.isEmpty()) { logger.error("Non è stato recuperato url per il download per il link: " + nomeFile); From 5de28f57b780c78d8fd03822757ca4b32f94b84b Mon Sep 17 00:00:00 2001 From: Andrea Fuso Date: Thu, 6 Jun 2024 12:58:34 +0200 Subject: [PATCH 14/14] chore: remove unused feature step --- .../personaFisica/NotifichePersonaFisicaPagoPATest.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/test/java/it/pn/frontend/e2e/stepDefinitions/destinatario/personaFisica/NotifichePersonaFisicaPagoPATest.java b/src/test/java/it/pn/frontend/e2e/stepDefinitions/destinatario/personaFisica/NotifichePersonaFisicaPagoPATest.java index b196f5425..8c2851ddb 100644 --- a/src/test/java/it/pn/frontend/e2e/stepDefinitions/destinatario/personaFisica/NotifichePersonaFisicaPagoPATest.java +++ b/src/test/java/it/pn/frontend/e2e/stepDefinitions/destinatario/personaFisica/NotifichePersonaFisicaPagoPATest.java @@ -407,11 +407,6 @@ public void siSelezionaUnAvvisoPagopa() { dettaglioNotifica.selezioneAvvisoPagoPa(); } - @Then("Si seleziona il file {string} da scaricare, all'interno della notifica persona fisica, e si controlla che il download sia avvenuto con successo") - public void siSelezionaIlFileDaScaricareAllInternoDellaNotificaPersonaFisicaESiControllaCheIlDownloadSiaAvvenutoConSuccesso(String fileName) { - dettaglioNotifica.clickFile(fileName); - dettaglioNotifica.goBack(); - } }