chore: test for login gui
This commit is contained in:
parent
728536e50b
commit
7c6f0710a1
2 changed files with 33 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
||||||
package web
|
package web
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"git.keks.cloud/kekskurse/miniauth/pkg/miniauth"
|
"git.keks.cloud/kekskurse/miniauth/pkg/miniauth"
|
||||||
|
@ -69,7 +70,7 @@ func (w Web) PostLoginPage(c *gin.Context) {
|
||||||
|
|
||||||
err := w.ma.UserLogin(username, password)
|
err := w.ma.UserLogin(username, password)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.HTML(http.StatusOK, "login.html", gin.H{"msg": err.Error()})
|
c.HTML(http.StatusOK, "login.html", gin.H{"msg": errors.Unwrap(err).Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,4 +74,35 @@ test('login page exists', async ({page}) => {
|
||||||
|
|
||||||
test('login faild user not exists', async ({page, browserName}) => {
|
test('login faild user not exists', async ({page, browserName}) => {
|
||||||
|
|
||||||
|
await page.goto('/web/login');
|
||||||
|
await page.getByLabel('Username').fill('kekskurseNO'+browserName);
|
||||||
|
await page.getByLabel('Password', {name: 'password', exact: true}).fill('7Jw^zNhk!NU3a8qfVp%a*VV!&Won1gD9zVHr&pgNairR5U6^h^$D%TxyJ2qHp%');
|
||||||
|
await page.getByRole('button', { name: 'Login' }).click();
|
||||||
|
await expect(page.getByText('cant login')).toBeVisible();
|
||||||
|
|
||||||
|
const text = 'cant execute query';
|
||||||
|
const textLocator = page.locator(`text=${text}`);
|
||||||
|
await expect(textLocator).toHaveCount(0);
|
||||||
|
})
|
||||||
|
|
||||||
|
test('login faild passwordwrong', async ({page, browserName}) => {
|
||||||
|
|
||||||
|
await page.goto('/web/login');
|
||||||
|
await page.getByLabel('Username').fill('kekskurse'+browserName);
|
||||||
|
await page.getByLabel('Password', {name: 'password', exact: true}).fill('NO7Jw^zNhk!NU3a8qfVp%a*VV!&Won1gD9zVHr&pgNairR5U6^h^$D%TxyJ2qHp%');
|
||||||
|
await page.getByRole('button', { name: 'Login' }).click();
|
||||||
|
await expect(page.getByText('cant login')).toBeVisible();
|
||||||
|
|
||||||
|
const text = 'cant execute query';
|
||||||
|
const textLocator = page.locator(`text=${text}`);
|
||||||
|
await expect(textLocator).toHaveCount(0);
|
||||||
|
})
|
||||||
|
test('login success', async ({page, browserName}) => {
|
||||||
|
|
||||||
|
await page.goto('/web/login');
|
||||||
|
await page.getByLabel('Username').fill('kekskurse'+browserName);
|
||||||
|
await page.getByLabel('Password', {name: 'password', exact: true}).fill('7Jw^zNhk!NU3a8qfVp%a*VV!&Won1gD9zVHr&pgNairR5U6^h^$D%TxyJ2qHp%');
|
||||||
|
await page.getByRole('button', { name: 'Login' }).click();
|
||||||
|
await expect(page.getByText('Login ok!')).toBeVisible();
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Reference in a new issue