Compare commits
2 Commits
038a41648a
...
b09d5ce6c4
Author | SHA1 | Date |
---|---|---|
Aravinth Manivannan | b09d5ce6c4 | |
Aravinth Manivannan | 782cb765c5 |
1
.env
1
.env
|
@ -1 +1,2 @@
|
|||
export INSTANCE_URL=http://localhost:3001
|
||||
export MAILDEV_URL=http://localhost:1080
|
||||
|
|
|
@ -3,11 +3,12 @@ steps:
|
|||
image: realaravinth/forgejo-frontend-integration-base # ./Dockerfile
|
||||
environment:
|
||||
- INSTANCE_URL=http://forgejo
|
||||
- MAILDEV_URL=http://maildev:1080
|
||||
commands:
|
||||
- npm ci
|
||||
- npx playwright install --with-deps
|
||||
- npx playwright test --project=firefox --grep @setup
|
||||
- npx playwright test --project=firefox --grep-invert @setup
|
||||
- npx playwright test --grep-invert @setup
|
||||
|
||||
services:
|
||||
forgejo:
|
||||
|
@ -17,17 +18,17 @@ services:
|
|||
- FORGEJO__federation__ENABLED=true
|
||||
- FORGEJO__server__ROOT_URL=http://forgejo
|
||||
- FORGEJO__server__HTTP_PORT=80
|
||||
- FORGEJO__service_ENABLE_NOTIFY_MAIL=true
|
||||
- FORGEJO__service_REGISTER_EMAIL_CONFIRM=true
|
||||
- FORGEJO__admin_DEFAULT_EMAIL_NOTIFICATIONS=enabled
|
||||
- FORGEJO__admin_SEND_NOTIFICATION_EMAIL_ON_NEW_USER=true
|
||||
- FORGEJO__mailer_ENABLED=true
|
||||
- FORGEJO__mailer_PROTOCOL=smtp
|
||||
- FORGEJO__mailer_SMTP_ADDR=maildev
|
||||
- FORGEJO__mailer_SMTP_PORT=10025
|
||||
- FORGEJO__mailer_FROM=forgejo@ci.local
|
||||
- FORGEJO__mailer_USER=admin
|
||||
- FORGEJO__mailer_PASSWORD=password
|
||||
- FORGEJO__service__ENABLE_NOTIFY_MAIL=true
|
||||
- FORGEJO__service__REGISTER_EMAIL_CONFIRM=true
|
||||
- FORGEJO__admin__DEFAULT_EMAIL_NOTIFICATIONS=enabled
|
||||
- FORGEJO__admin__SEND_NOTIFICATION_EMAIL_ON_NEW_USER=true
|
||||
- FORGEJO__mailer__ENABLED=true
|
||||
- FORGEJO__mailer__PROTOCOL=smtp
|
||||
- FORGEJO__mailer__SMTP_ADDR=maildev
|
||||
- FORGEJO__mailer__SMTP_PORT=10025
|
||||
- FORGEJO__mailer__FROM=forgejo@ci.local
|
||||
- FORGEJO__mailer__USER=admin
|
||||
- FORGEJO__mailer__PASSWORD=password
|
||||
|
||||
maildev:
|
||||
image: maildev/maildev:latest
|
||||
|
|
|
@ -7,19 +7,19 @@ services:
|
|||
environment:
|
||||
FORGEJO__security__INSTALL_LOCK: true
|
||||
FORGEJO__federation__ENABLED: true
|
||||
FORGEJO__server__ROOT_URL: http://localhost
|
||||
FORGEJO__server__ROOT_URL: http://localhost:3001
|
||||
FORGEJO__server__HTTP_PORT: 3001
|
||||
FORGEJO__service_ENABLE_NOTIFY_MAIL: true
|
||||
FORGEJO__service_REGISTER_EMAIL_CONFIRM: true
|
||||
FORGEJO__admin_DEFAULT_EMAIL_NOTIFICATIONS: enabled
|
||||
FORGEJO__admin_SEND_NOTIFICATION_EMAIL_ON_NEW_USER: true
|
||||
FORGEJO__mailer_ENABLED: true
|
||||
FORGEJO__mailer_PROTOCOL: smtp
|
||||
FORGEJO__mailer_SMTP_ADDR: maildev
|
||||
FORGEJO__mailer_SMTP_PORT: 10025
|
||||
FORGEJO__mailer_FROM: forgejo@ci.local
|
||||
FORGEJO__mailer_USER: admin
|
||||
FORGEJO__mailer_PASSWORD: password
|
||||
FORGEJO__service__ENABLE_NOTIFY_MAIL: true
|
||||
FORGEJO__service__REGISTER_EMAIL_CONFIRM: true
|
||||
FORGEJO__admin__DEFAULT_EMAIL_NOTIFICATIONS: enabled
|
||||
FORGEJO__admin__SEND_NOTIFICATION_EMAIL_ON_NEW_USER: true
|
||||
FORGEJO__mailer__ENABLED: true
|
||||
FORGEJO__mailer__PROTOCOL: "smtp"
|
||||
FORGEJO__mailer__SMTP_ADDR: "maildev"
|
||||
FORGEJO__mailer__SMTP_PORT: 10025
|
||||
FORGEJO__mailer__FROM: "TEST <forgejo@ci.local>"
|
||||
FORGEJO__mailer__USER: admin
|
||||
FORGEJO__mailer__PASSWD: password
|
||||
|
||||
maildev:
|
||||
image: maildev/maildev:latest
|
||||
|
|
|
@ -40,7 +40,7 @@ test("Test registration error: password mismatch", async ({ page }) => {
|
|||
"Register - Forgejo: Beyond coding. We forge."
|
||||
);
|
||||
expect(page.locator(".negative > p:nth-child(1)")).toContainText(
|
||||
"passwords do not match"
|
||||
"The passwords do not match"
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -113,7 +113,7 @@ test("Test successful registration", async ({ page }) => {
|
|||
);
|
||||
|
||||
expect(page.locator(".positive > p:nth-child(1)")).toContainText(
|
||||
"Account was successfully created. Welcome!"
|
||||
"Account has been activated"
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
@ -3,4 +3,5 @@
|
|||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
export const INSTANCE_URL = new URL(process.env.INSTANCE_URL)
|
||||
export const MAILDEV_URL = new URL(process.env.MAILDEV_URL)
|
||||
export const ADMIN_USERNAME = "admin";
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
import * as config from "./config";
|
||||
|
||||
export const getEmails = async (toAddr: string) => {
|
||||
const url = new URL(config.MAILDEV_URL);
|
||||
url.pathname = "/email";
|
||||
let res = await fetch(url);
|
||||
let data = await res.json();
|
||||
let mails = [];
|
||||
Array.from(data).forEach((mail: any) => {
|
||||
if (mail.to[0].address == toAddr) {
|
||||
mails.push(mail);
|
||||
}
|
||||
});
|
||||
return mails;
|
||||
};
|
||||
|
||||
export const getActivationLink = async (
|
||||
toAddr: string
|
||||
): Promise<string | void> => {
|
||||
let emails = await getEmails(toAddr);
|
||||
for (let i = 0; i < emails.length; i++) {
|
||||
let mail = emails[i];
|
||||
if (mail.subject.includes("Please activate your account")) {
|
||||
return mail.text.split('\n')[4]
|
||||
}
|
||||
}
|
||||
};
|
|
@ -1,6 +1,7 @@
|
|||
import { Page, expect } from "@playwright/test";
|
||||
import { getRandomString } from "./utils";
|
||||
import * as config from "./config";
|
||||
import { getActivationLink } from "./maildev";
|
||||
|
||||
export default class User {
|
||||
username: string;
|
||||
|
@ -78,14 +79,37 @@ export default class User {
|
|||
await page.getByLabel("Password", { exact: true }).fill(this.password);
|
||||
await page.getByLabel("Confirm Password").fill(this.password);
|
||||
await page.getByRole("button", { name: "Register Account" }).click();
|
||||
await page.waitForURL(config.INSTANCE_URL.toString());
|
||||
|
||||
await page.waitForURL("**/user/sign_up");
|
||||
|
||||
// account activation through email
|
||||
await expect(page.locator("h2.ui")).toContainText("Activate Your Account");
|
||||
await expect(
|
||||
page.locator("div.ui:nth-child(3) > p:nth-child(1)")
|
||||
).toContainText(this.email);
|
||||
|
||||
let activationEmail: String | null = null;
|
||||
while (true) {
|
||||
let x = await getActivationLink(this.email);
|
||||
if (typeof x === "string") {
|
||||
activationEmail = x;
|
||||
break;
|
||||
}
|
||||
}
|
||||
await page.goto(activationEmail.toString());
|
||||
// go to forgejo
|
||||
await page.waitForURL("**/user/activate**");
|
||||
await page.getByLabel("Password", { exact: true }).fill(this.password);
|
||||
// click verify account btn
|
||||
await page.getByRole("button", { name: "Confirm Password" }).click();
|
||||
|
||||
// registration successful
|
||||
await page.waitForURL(config.INSTANCE_URL.toString());
|
||||
await expect(page).toHaveTitle(
|
||||
`${this.username} - Dashboard - Forgejo: Beyond coding. We forge.`
|
||||
);
|
||||
|
||||
expect(page.locator(".positive > p:nth-child(1)")).toContainText(
|
||||
"Account was successfully created. Welcome!"
|
||||
"Account has been activated"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue