Skip to content

Commit 0c6b0e2

Browse files
gadezisthiqsol
authored andcommitted
HP-1378 HiAPI mail module rewrite
1 parent 2fa7405 commit 0c6b0e2

File tree

6 files changed

+177
-0
lines changed

6 files changed

+177
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { test } from "@hipanel-core/fixtures";
2+
import { expect } from "@playwright/test";
3+
import MailHelper from "@hipanel-module-hosting/helper/MailHelper";
4+
import Index from "@hipanel-core/page/Index";
5+
6+
const mail: string = 'hipanel_test@test.hiqdev';
7+
8+
test.describe("Test mail block @hipanel-module-hosting @admin", () => {
9+
10+
let mailHelper: MailHelper;
11+
let index: Index;
12+
13+
test.beforeEach(async ({ adminPage }) => {
14+
mailHelper = new MailHelper(adminPage);
15+
index = new Index(adminPage);
16+
17+
await mailHelper.gotoIndexMail();
18+
const rowNumber = await index.getRowNumberInColumnByValue("E-mail", mail);
19+
await index.chooseNumberRowOnTable(rowNumber);
20+
});
21+
22+
test("Disable mail @hipanel-module-hosting @admin", async ({ managerPage }) => {
23+
24+
await index.clickBulkButton('Disable');
25+
26+
await mailHelper.seeSuccessAlert('Mailbox has been disabled.');
27+
await mailHelper.seeMailStatus(mail, 'Disabled');
28+
});
29+
30+
test("Enable mail @hipanel-module-hosting @admin", async ({ managerPage }) => {
31+
32+
await index.clickBulkButton('Enable');
33+
34+
await mailHelper.seeSuccessAlert('Mailbox has been enabled.');
35+
await mailHelper.seeMailStatus(mail, 'Active');
36+
});
37+
});
38+
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { test } from "@hipanel-core/fixtures";
2+
import { expect } from "@playwright/test";
3+
import MailHelper from "@hipanel-module-hosting/helper/MailHelper";
4+
import MailForm from "@hipanel-module-hosting/page/MailForm";
5+
import Mail from "@hipanel-module-hosting/model/Mail";
6+
7+
const mail: Mail = {
8+
client: 'hipanel_test_reseller',
9+
server: 'DSTEST02',
10+
account: 'hipanel_test_account',
11+
email: 'hipanel_test',
12+
domain: 'domain.hiqdev',
13+
password: '12345',
14+
};
15+
16+
test("Create IP @hipanel-module-hosting @admin", async ({ adminPage }) => {
17+
18+
const mailHelper = new MailHelper(adminPage);
19+
const mailForm = new MailForm(adminPage);
20+
21+
await mailHelper.gotoIndexMail();
22+
await mailHelper.gotoCreateMail();
23+
24+
await mailForm.fill(mail);
25+
await mailForm.save();
26+
27+
await mailForm.seeSuccessMailCreatingAlert();
28+
});
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { test } from "@hipanel-core/fixtures";
2+
import { expect } from "@playwright/test";
3+
import MailHelper from "@hipanel-module-hosting/helper/MailHelper";
4+
import Index from "@hipanel-core/page/Index";
5+
6+
const mail: string = "hipanel_test@test.hiqdev"
7+
8+
test("Delete mail @hipanel-module-hosting @admin", async ({ adminPage }) => {
9+
10+
const mailHelper = new MailHelper(adminPage);
11+
const index = new Index(adminPage);
12+
13+
await mailHelper.gotoIndexMail();
14+
const rowNumber = await index.getRowNumberInColumnByValue("E-mail", mail);
15+
await index.chooseNumberRowOnTable(rowNumber);
16+
17+
await mailHelper.delete();
18+
19+
await mailHelper.seeSuccessAlert('Mailbox delete task has been created successfully');
20+
});

tests/playwright/helper/MailHelper.ts

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { expect, Locator, Page } from "@playwright/test";
2+
import Input from "@hipanel-core/input/Input";
3+
import Index from "@hipanel-core/page/Index";
4+
import Alert from "@hipanel-core/ui/Alert";
5+
import Select2 from "@hipanel-core/input/Select2";
6+
7+
export default class IPHelper {
8+
private page: Page;
9+
private index: Index;
10+
11+
public constructor(page: Page) {
12+
this.page = page;
13+
this.index = new Index(page);
14+
}
15+
16+
async gotoIndexMail() {
17+
await this.page.goto('/hosting/mail/index');
18+
await expect(this.page).toHaveTitle("Mailboxes");
19+
}
20+
21+
async gotoCreateMail() {
22+
await this.page.locator('text=Create mailbox').click();
23+
}
24+
25+
async gotoMailPage( ip: string) {
26+
const rowNumber = await this.index.getRowNumberInColumnByValue('IP', ip, false);
27+
await this.page.locator('tr td button').nth(rowNumber + 1).click();
28+
await this.page.locator('div[role="tooltip"] >> text=View').click();
29+
}
30+
31+
async seeMailStatus(account: string, status: string) {
32+
const rowNumber = await this.index.getRowNumberInColumnByValue('E-mail', account);
33+
const accountStatus = await this.index.seeTextOnTable('Status', rowNumber, status);
34+
}
35+
36+
async checkDetailViewData(ip: object) {
37+
await expect(this.page.locator('//table[contains(@class, "detail-view")]//tbody/tr[1]/td')).toContainText(ip['ip']);
38+
await expect(this.page.locator('//table[contains(@class, "detail-view")]//tbody/tr[5]/td')).toContainText(ip['links']);
39+
}
40+
41+
async delete() {
42+
this.page.on('dialog', dialog => dialog.accept());
43+
await this.index.clickBulkButton('Delete');
44+
}
45+
46+
async seeSuccessAlert(message: string) {
47+
await Alert.on(this.page).hasText(message);
48+
}
49+
50+
async save() {
51+
await this.page.locator("text=Save").click();
52+
}
53+
}

tests/playwright/model/Mail.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export default class Mail {
2+
public client: string;
3+
public server: string;
4+
public account: string;
5+
public email: string;
6+
public domain: string;
7+
public password?: string;
8+
}

tests/playwright/page/MailForm.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { expect, Locator, Page } from "@playwright/test";
2+
import Select2 from "@hipanel-core/input/Select2";
3+
import Alert from "@hipanel-core/ui/Alert";
4+
import Input from "@hipanel-core/input/Input";
5+
import Mail from "@hipanel-module-hosting/model/Mail";
6+
7+
export default class MailForm {
8+
private page: Page;
9+
10+
constructor(page: Page) {
11+
this.page = page;
12+
}
13+
14+
async fill(mail: Mail) {
15+
await Select2.field(this.page, `#mail-0-client`).setValue(mail.client);
16+
await Select2.field(this.page, `#mail-0-server`).setValue(mail.server);
17+
await Select2.field(this.page, `#mail-0-account`).setValue(mail.account);
18+
await Input.field(this.page, '#mail-0-nick').fill(mail.email);
19+
await Select2.field(this.page, `#mail-0-hdomain_id`).setValue(mail.domain);
20+
await Input.field(this.page, '#mail-0-password').fill(mail.password);
21+
}
22+
23+
async save() {
24+
await this.page.locator("text=Save").click();
25+
}
26+
27+
async seeSuccessMailCreatingAlert() {
28+
await Alert.on(this.page).hasText("Mailbox creating task has been added to queue");
29+
}
30+
}

0 commit comments

Comments
 (0)