diff --git a/UI/Web/e2e-tests/pages/login-page.ts b/UI/Web/e2e-tests/pages/login-page.ts new file mode 100644 index 000000000..9501081e7 --- /dev/null +++ b/UI/Web/e2e-tests/pages/login-page.ts @@ -0,0 +1,19 @@ +import { Page } from '@playwright/test'; + +export class LoginPage { + readonly page: Page; + + constructor(page: Page) { + this.page = page; + } + + async navigate() { + await this.page.goto('/login'); + } + + async login(username: string, password: string) { + await this.page.fill('input[formControlName="username"]', username); + await this.page.fill('input[formControlName="password"]', password); + await this.page.click('button[type="submit"]'); + } +} diff --git a/UI/Web/e2e-tests/tests/Login/login.spec.ts b/UI/Web/e2e-tests/tests/Login/login.spec.ts new file mode 100644 index 000000000..e7f4fb9fe --- /dev/null +++ b/UI/Web/e2e-tests/tests/Login/login.spec.ts @@ -0,0 +1,27 @@ +import { test, expect } from '@playwright/test'; +import { LoginPage } from 'e2e-tests/pages/login-page'; + + +const url = 'https://demo.kavitareader.com/'; + +test('has title', async ({ page }) => { + await page.goto(url); + + // Expect a title "to contain" a substring. + await expect(page).toHaveTitle(/Kavita/); +}); + +test('login functionality', async ({ page }) => { + // Navigate to the login page + await page.goto(url); + + // Verify the page title + await expect(page).toHaveTitle(/Kavita/); + + const loginPage = new LoginPage(page); + await loginPage.navigate(); + await loginPage.login('demouser', 'Demouser64'); + + // Verify successful login by checking for Home on side nav + await expect(page.locator('#null')).toBeVisible(); +});