From b21ceace3f6f7670383c4629db62aa9772d3a2fa Mon Sep 17 00:00:00 2001 From: Andrea Fazzi Date: Tue, 11 Feb 2020 10:10:10 +0100 Subject: [PATCH] Improve regression tests --- regression_test/Makefile | 3 +- regression_test/regression_test.go | 61 ++++++++++++++++++++++++++++-- templates/participants.html.tpl | 2 +- 3 files changed, 61 insertions(+), 5 deletions(-) diff --git a/regression_test/Makefile b/regression_test/Makefile index 076eefa8..409055f2 100644 --- a/regression_test/Makefile +++ b/regression_test/Makefile @@ -5,7 +5,8 @@ test: docker exec -d oef_regression_test_selenium_1 ffmpeg -y -video_size 1360x1020 -framerate 15 -f x11grab -i :99.0 /tmp/recording.mp4 go test docker exec oef_regression_test_selenium_1 killall -s SIGINT ffmpeg - docker exec oef_regression_test_selenium_1 MP4Box -isma -inter 500 -out /tmp/recording_cleaned_up.mp4 /tmp/recording.mp4 + docker exec oef_regression_test_selenium_1 ffmpeg -y -i /tmp/recording.mp4 -filter:v "setpts=5*PTS" /tmp/recording_slow.mp4 + docker exec oef_regression_test_selenium_1 MP4Box -isma -inter 500 -out /tmp/recording_cleaned_up.mp4 /tmp/recording_slow.mp4 docker cp oef_regression_test_selenium_1:/tmp/recording_cleaned_up.mp4 recordings/recording.mp4 all: test diff --git a/regression_test/regression_test.go b/regression_test/regression_test.go index 18466021..536a96fc 100644 --- a/regression_test/regression_test.go +++ b/regression_test/regression_test.go @@ -172,8 +172,57 @@ func (t *testSuite) TestSchoolSubscription() { t.Contain(expected[i], text) } + // Open the participant view + + first := findElements("#partecipanti_list_group a")[0] + err = first.Click() + if err != nil { + panic(err) + } + + // Remove the participant + err = findElement("button.karmen-ajax-delete").Click() + if err != nil { + panic(err) + } + err = findElement("#karmen-modal-btn-confirm").Click() + if err != nil { + panic(err) + } + + // Subscribe a participant of the same existing category + addParticipantAsSchool(&orm.Participant{ + Firstname: "Luigi", + Lastname: "VERDI", + FiscalCode: "VRDLGSR1234567", + Category: &orm.Category{Name: "Senior"}, + }) + + alert, err = findElement(".alert").Text() + t.Nil(err) + + t.Contain("partecipante di questa categoria", alert) + + err = findElement(".alert a").Click() + if err != nil { + panic(err) + } + + // Subscribe a participant with the same fiscal code + + populateParticipantForm(&orm.Participant{ + Firstname: "Luigi", + Lastname: "VERDI", + FiscalCode: "BNCSR1234567", + Category: &orm.Category{Name: "Senior"}, + }) + + alert, err = findElement(".alert").Text() + t.Nil(err) + + t.Contain("codice fiscale è già presente", alert) + removeSchoolAsAdmin("Liceo GALILEI") - removeParticipantAsAdmin("ROSSI") removeParticipantAsAdmin("BIANCA") } @@ -341,8 +390,12 @@ func addParticipantAsSchool(participant *orm.Participant) { if err != nil { panic(err) } + populateParticipantForm(participant) + clickPrimaryButton() +} - err = findElement("#participant_firstname").SendKeys(participant.Firstname) +func populateParticipantForm(participant *orm.Participant) { + err := findElement("#participant_firstname").SendKeys(participant.Firstname) if err != nil { panic(err) } @@ -371,8 +424,10 @@ func addParticipantAsSchool(participant *orm.Participant) { if err != nil { panic(err) } +} - err = findElement("button.btn.btn-primary").Click() +func clickPrimaryButton() { + err := findElement("button.btn.btn-primary").Click() if err != nil { panic(err) } diff --git a/templates/participants.html.tpl b/templates/participants.html.tpl index 3e2c97f7..dbbbb316 100644 --- a/templates/participants.html.tpl +++ b/templates/participants.html.tpl @@ -60,7 +60,7 @@ {{if le (len .Data) 1}}

E' possibile iscrivere fino a due partecipanti alla gara (di diversa categoria). - + Iscrivi un nuovo partecipante