Working on school subscription regression test
This commit is contained in:
parent
317f950cac
commit
ea99d47b9a
8 changed files with 102 additions and 9 deletions
1
Makefile
1
Makefile
|
@ -23,6 +23,7 @@ regression_test:
|
||||||
go build .
|
go build .
|
||||||
docker-compose -f docker/oef_regression_test/docker-compose.yaml up --build -d
|
docker-compose -f docker/oef_regression_test/docker-compose.yaml up --build -d
|
||||||
./bash/wait_until_up.bash oef_regression_test
|
./bash/wait_until_up.bash oef_regression_test
|
||||||
|
./bash/wait_until_up.bash oef_regression_test_selenium_1
|
||||||
cd regression_test && make
|
cd regression_test && make
|
||||||
|
|
||||||
all: prod
|
all: prod
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
url: "http://localhost:3000"
|
url: "http://oef_regression_test:3000"
|
||||||
log_level: 2
|
log_level: 2
|
||||||
language: "it"
|
language: "it"
|
||||||
|
|
||||||
|
@ -20,8 +20,8 @@ subscriber:
|
||||||
password: "subscribe"
|
password: "subscribe"
|
||||||
|
|
||||||
smtp:
|
smtp:
|
||||||
host: "localhost"
|
host: "smtp"
|
||||||
port: 1025
|
port: 25
|
||||||
username: ""
|
username: ""
|
||||||
password: ""
|
password: ""
|
||||||
from: "no-reply@olimpiadi-economiaefinanza.it"
|
from: "no-reply@olimpiadi-economiaefinanza.it"
|
||||||
|
|
1
go.sum
1
go.sum
|
@ -3,6 +3,7 @@ cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT
|
||||||
cloud.google.com/go v0.37.4 h1:glPeL3BQJsbF6aIIYfZizMwc5LTYz250bDMjttbBGAU=
|
cloud.google.com/go v0.37.4 h1:glPeL3BQJsbF6aIIYfZizMwc5LTYz250bDMjttbBGAU=
|
||||||
cloud.google.com/go v0.37.4/go.mod h1:NHPJ89PdicEuT9hdPXMROBD91xc5uRDxsMtSB16k7hw=
|
cloud.google.com/go v0.37.4/go.mod h1:NHPJ89PdicEuT9hdPXMROBD91xc5uRDxsMtSB16k7hw=
|
||||||
cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
|
cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
|
||||||
|
cloud.google.com/go v0.41.0 h1:NFvqUTDnSNYPX5oReekmB+D+90jrJIcVImxQ3qrBVgM=
|
||||||
cloud.google.com/go v0.41.0/go.mod h1:OauMR7DV8fzvZIl2qg6rkaIhD/vmgk4iwEw/h6ercmg=
|
cloud.google.com/go v0.41.0/go.mod h1:OauMR7DV8fzvZIl2qg6rkaIhD/vmgk4iwEw/h6ercmg=
|
||||||
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
|
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
|
||||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||||
|
|
|
@ -55,6 +55,13 @@ func (db *Database) AutoMigrate() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (db *Database) Reset() {
|
||||||
|
if err := db._db.DropTable(db.models...).Error; err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
func (db *Database) GetUser(username, password string) (*User, error) {
|
func (db *Database) GetUser(username, password string) (*User, error) {
|
||||||
var user User
|
var user User
|
||||||
if err := db._db.Where("username = ? AND password = ?", username, password).First(&user).Error; err != nil {
|
if err := db._db.Where("username = ? AND password = ?", username, password).First(&user).Error; err != nil {
|
||||||
|
|
|
@ -4,7 +4,8 @@
|
||||||
test:
|
test:
|
||||||
docker exec -d oef_regression_test_selenium_1 ffmpeg -y -video_size 1360x1020 -framerate 15 -f x11grab -i :99.0 /tmp/recording.mp4
|
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
|
go test
|
||||||
docker exec oef_regression_test_selenium_1 killall -s QUIT ffmpeg
|
docker exec oef_regression_test_selenium_1 killall -s SIGINT ffmpeg
|
||||||
docker cp oef_regression_test_selenium_1:/tmp/recording.mp4 recordings/recording.mp4
|
docker exec oef_regression_test_selenium_1 MP4Box -isma -inter 500 -out /tmp/recording_cleaned_up.mp4 /tmp/recording.mp4
|
||||||
|
docker cp oef_regression_test_selenium_1:/tmp/recording_cleaned_up.mp4 recordings/recording.mp4
|
||||||
|
|
||||||
all: test
|
all: test
|
||||||
|
|
|
@ -2,6 +2,7 @@ package regression_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/remogatto/prettytest"
|
"github.com/remogatto/prettytest"
|
||||||
|
@ -126,22 +127,81 @@ func (t *testSuite) TestSchoolSubscription() {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = findElement("#school_email").SendKeys("foo.bar@school.org")
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = findElement("#school_contact_person_firstname").SendKeys("Mario")
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
err = findElement("#school_contact_person_lastname").SendKeys("BROS")
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = findElement("#school_contest_director_firstname").SendKeys("Luigi")
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
err = findElement("#school_contest_director_lastname").SendKeys("BROS")
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
err = findElement("button.btn.btn-primary").Click()
|
err = findElement("button.btn.btn-primary").Click()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
expected := []string{"JUNIOR Contest", "SENIOR Contest"}
|
expected := []string{"Liceo GALILEI", "foo.bar@school.org"}
|
||||||
elements := findElements(".list-group a")
|
elements := findElements("p strong")
|
||||||
|
t.True(len(elements) > 0)
|
||||||
for i, el := range elements {
|
for i, el := range elements {
|
||||||
text, err := el.Text()
|
text, err := el.Text()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
t.Contain(expected[i], text)
|
t.Equal(expected[i], text)
|
||||||
|
}
|
||||||
|
|
||||||
|
credentials := findElements("dd")
|
||||||
|
log.Println("DD", credentials)
|
||||||
|
if len(credentials) == 0 {
|
||||||
|
panic("Can't find credentials in the renderered HTML page")
|
||||||
|
}
|
||||||
|
|
||||||
|
username, err := credentials[0].Text()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
password, err := credentials[1].Text()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
logout()
|
logout()
|
||||||
|
|
||||||
|
login(username, password)
|
||||||
|
|
||||||
|
logout()
|
||||||
|
|
||||||
|
login("admin", "admin")
|
||||||
|
|
||||||
|
err = findElement("#schools_navbar_link").Click()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
err = findElement("#myInput").SendKeys("Liceo GALILEI")
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
err = findElement("a.list-group-item").Click()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func findElement(selector string) selenium.WebElement {
|
func findElement(selector string) selenium.WebElement {
|
||||||
|
@ -160,6 +220,23 @@ func findElements(selector string) []selenium.WebElement {
|
||||||
return elements
|
return elements
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func login(username, password string) {
|
||||||
|
err := findElement("#username").SendKeys(username)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = findElement("#password").SendKeys(password)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = findElement("button").Click()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func logout() {
|
func logout() {
|
||||||
err := findElement("a#logout").Click()
|
err := findElement("a#logout").Click()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
<a class="nav-item nav-link {{.Options|active "Contest"}}" href="{{all "Contest"}}">Gare</a>
|
<a class="nav-item nav-link {{.Options|active "Contest"}}" href="{{all "Contest"}}">Gare</a>
|
||||||
<a class="nav-item nav-link {{.Options|active "Question"}}" href="{{all "Question"}}">Domande</a>
|
<a class="nav-item nav-link {{.Options|active "Question"}}" href="{{all "Question"}}">Domande</a>
|
||||||
<a class="nav-item nav-link {{.Options|active "Answer"}}" href="{{all "Answer"}}">Risposte</a>
|
<a class="nav-item nav-link {{.Options|active "Answer"}}" href="{{all "Answer"}}">Risposte</a>
|
||||||
<a class="nav-item nav-link {{.Options|active "School"}}" href="{{all "School"}}">Scuole</a>
|
<a id="schools_navbar_link" class="nav-item nav-link {{.Options|active "School"}}" href="{{all "School"}}">Scuole</a>
|
||||||
<a class="nav-item nav-link {{.Options|active "Participant"}}" href="{{all "Participant"}}">Partecipanti</a>
|
<a class="nav-item nav-link {{.Options|active "Participant"}}" href="{{all "Participant"}}">Partecipanti</a>
|
||||||
<a class="nav-item nav-link {{.Options|active "Response"}}" href="{{all "Response"}}">Prove</a>
|
<a class="nav-item nav-link {{.Options|active "Response"}}" href="{{all "Response"}}">Prove</a>
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
|
@ -19,6 +19,12 @@
|
||||||
messaggio non fosse stato recapitato nella cartella "Posta in
|
messaggio non fosse stato recapitato nella cartella "Posta in
|
||||||
arrivo" si prega di controllare la cartella "Spam".
|
arrivo" si prega di controllare la cartella "Spam".
|
||||||
</p>
|
</p>
|
||||||
|
<p>
|
||||||
|
Le credenziali generate sono:
|
||||||
|
<dl>
|
||||||
|
<dt>Username</dt><dd class="text-monospace">{{.Data.Username}}</dd>
|
||||||
|
<dt>Password</dt><dd class="text-monospace">{{.Data.Password}}</dd>
|
||||||
|
</dl>
|
||||||
<p>
|
<p>
|
||||||
Ora è possibile <a href="/logout">uscire</a> da questa sessione e
|
Ora è possibile <a href="/logout">uscire</a> da questa sessione e
|
||||||
utilizzare le credenziali ricevute per iscrivere gli studenti alla
|
utilizzare le credenziali ricevute per iscrivere gli studenti alla
|
||||||
|
|
Loading…
Reference in a new issue