Skip to content

Commit 293cf52

Browse files
gadezisthiqsol
authored andcommitted
HP-1357 HiAPI hdomain module rewrite
1 parent 6cf0f6a commit 293cf52

File tree

8 files changed

+208
-1
lines changed

8 files changed

+208
-1
lines changed

src/widgets/ip/HdomainIpCombo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function (data) {
5858
var ret = [];
5959
var used_ips = {};
6060
$.each(data, function (i, v) {
61-
$.each(v.expanded_ips, function (ip, ipval) {
61+
$.each(v.expanded_ips, function (key, ip) {
6262
if (used_ips[ip]) return;
6363
6464
var row = {id: ip};
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { test } from "@hipanel-core/fixtures";
2+
import { expect } from "@playwright/test";
3+
import HDomainHelper from "@hipanel-module-hosting/helper/HDomainHelper";
4+
import HDomain from "@hipanel-module-hosting/model/HDomain";
5+
import HDomainForm from "@hipanel-module-hosting/page/HDomainForm";
6+
7+
const domain: HDomain = {
8+
client: "hipanel_test_reseller",
9+
server: "DSTEST02",
10+
account: "hipanel_test_account",
11+
domainName: "test.hiqdev",
12+
ip: "apache22: 223.112.1.13",
13+
}
14+
15+
test("Create domain @hipanel-module-hosting @admin", async ({ adminPage }) => {
16+
17+
const hdomainHelper = new HDomainHelper(adminPage);
18+
const hdomainForm = new HDomainForm(adminPage);
19+
20+
await hdomainHelper.gotoIndexDomain();
21+
await hdomainHelper.gotoCreateDomain();
22+
23+
await hdomainForm.fill(domain);
24+
await hdomainForm.save();
25+
await hdomainForm.seeSuccessAccountCreatingAlert();
26+
});
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 Index from "@hipanel-core/page/Index";
4+
import HDomainHelper from "@hipanel-module-hosting/helper/HDomainHelper";
5+
6+
const domain: string = 'test.hiqdev';
7+
8+
test.describe("Test domain block @hipanel-module-hosting @admin", () => {
9+
10+
let hdomainHelper: HDomainHelper;
11+
let index: Index;
12+
13+
test.beforeEach(async ({ adminPage }) => {
14+
hdomainHelper = new HDomainHelper(adminPage);
15+
index = new Index(adminPage);
16+
17+
await hdomainHelper.gotoIndexDomain();
18+
const rowNumber = await index.getRowNumberInColumnByValue("Domain name", domain);
19+
await index.chooseNumberRowOnTable(rowNumber);
20+
});
21+
22+
test("Enable domain block @hipanel-module-hosting @admin", async ({ managerPage }) => {
23+
24+
await index.clickDropdownBulkButton('Block', 'Enable');
25+
await hdomainHelper.confirmEnableBlock();
26+
27+
await hdomainHelper.seeHdomainStatus(domain, 'Blocked');
28+
});
29+
30+
test("Disable domain block @hipanel-module-hosting @admin", async ({ managerPage }) => {
31+
32+
await index.clickDropdownBulkButton('Block', 'Disable');
33+
await hdomainHelper.confirmDisableBlock();
34+
35+
await hdomainHelper.seeHdomainStatus(domain, 'Ok');
36+
});
37+
});
38+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { test } from "@hipanel-core/fixtures";
2+
import { expect } from "@playwright/test";
3+
import Index from "@hipanel-core/page/Index";
4+
import HDomainHelper from "@hipanel-module-hosting/helper/HDomainHelper";
5+
6+
const domain: string = "test.hiqdev"
7+
const domainView: object = {
8+
client: 'hipanel_test_reseller',
9+
reseller: 'reseller',
10+
account: 'hipanel_test_account',
11+
server: 'DSTEST02',
12+
}
13+
14+
test("Domain view correct @hipanel-module-hosting @admin", async ({ adminPage }) => {
15+
16+
const hdomainHelper = new HDomainHelper(adminPage);
17+
const index = new Index(adminPage);
18+
19+
await hdomainHelper.gotoIndexDomain();
20+
await hdomainHelper.gotoDomainPage(domain);
21+
22+
await hdomainHelper.checkDetailViewData(domainView);
23+
});
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { test } from "@hipanel-core/fixtures";
2+
import { expect } from "@playwright/test";
3+
import Index from "@hipanel-core/page/Index";
4+
import HDomainHelper from "@hipanel-module-hosting/helper/HDomainHelper";
5+
6+
const domain: string = "test.hiqdev"
7+
// const domain: string = "ffff.ua"
8+
9+
test("Delete domain @hipanel-module-hosting @admin", async ({ adminPage }) => {
10+
11+
const hdomainHelper = new HDomainHelper(adminPage);
12+
const index = new Index(adminPage);
13+
14+
await hdomainHelper.gotoIndexDomain();
15+
16+
const rowNumber = await index.getRowNumberInColumnByValue("Domain name", domain);
17+
await index.chooseNumberRowOnTable(rowNumber);
18+
19+
await hdomainHelper.delete();
20+
await expect(await adminPage.locator(`text=${domain}`)).not.toBeVisible();
21+
});
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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+
6+
export default class HDomainHelper {
7+
private page: Page;
8+
private index: Index;
9+
10+
public constructor(page: Page) {
11+
this.page = page;
12+
this.index = new Index(page);
13+
}
14+
15+
async gotoIndexDomain() {
16+
await this.page.goto('/hosting/hdomain/index');
17+
await expect(this.page).toHaveTitle("Domains");
18+
}
19+
20+
async gotoCreateDomain() {
21+
await this.page.locator('#dropdownMenu1').click();
22+
await this.page.locator('text=Create domain >> nth=1').click();
23+
}
24+
25+
async gotoDomainPage(domain: string) {
26+
await this.index.clickLinkOnTable('Domain name', domain);
27+
}
28+
29+
async checkDetailViewData(domainView: object) {
30+
await expect(this.page.locator('//table[contains(@class, "detail-view")]//tbody/tr[1]/td')).toContainText(domainView['client']);
31+
await expect(this.page.locator('//table[contains(@class, "detail-view")]//tbody/tr[2]/td')).toContainText(domainView['reseller']);
32+
await expect(this.page.locator('//table[contains(@class, "detail-view")]//tbody/tr[3]/td')).toContainText(domainView['account']);
33+
await expect(this.page.locator('//table[contains(@class, "detail-view")]//tbody/tr[4]/td')).toContainText(domainView['server']);
34+
}
35+
36+
async confirmEnableBlock() {
37+
await Input.field(this.page, 'input[name="comment"]').fill("Test enable comment");
38+
await this.index.clickButton('Block');
39+
}
40+
41+
async confirmDisableBlock() {
42+
await Input.field(this.page, 'input[name="comment"]').fill("Test unblock comment");
43+
await this.index.clickButton('Unblock');
44+
}
45+
46+
async confirmDelete() {
47+
await this.index.clickButton('Delete');
48+
}
49+
50+
async seeHdomainStatus(domain: string, status: string) {
51+
const rowNumber = await this.index.getRowNumberInColumnByValue('Domain name', domain);
52+
const accountStatus = await this.index.seeTextOnTable('Status', rowNumber, status);
53+
}
54+
55+
async delete() {
56+
this.page.on('dialog', dialog => dialog.accept());
57+
await this.index.clickBulkButton('Delete');
58+
}
59+
60+
async seeSuccessAlert(message: string) {
61+
await Alert.on(this.page).hasText(message);
62+
}
63+
}

tests/playwright/model/HDomain.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export default class HDomain {
2+
public client: string;
3+
public server: string;
4+
public account: string;
5+
public domainName: string;
6+
public ip: string;
7+
}

tests/playwright/page/HDomainForm.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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 HDomain from "@hipanel-module-hosting/model/HDomain";
6+
7+
export default class HDomainForm {
8+
private page: Page;
9+
10+
constructor(page: Page) {
11+
this.page = page;
12+
}
13+
14+
async fill(domain: HDomain) {
15+
await Select2.field(this.page, `#hdomain-0-client`).setValue(domain.client);
16+
await Select2.field(this.page, `#hdomain-0-server`).setValue(domain.server);
17+
await Select2.field(this.page, '#hdomain-0-account').setValue(domain.account);
18+
await Input.field(this.page, '#hdomain-0-domain').fill(domain.domainName);
19+
await Select2.field(this.page, '#hdomain-0-ip').setValue(domain.ip);
20+
}
21+
22+
async save() {
23+
await this.page.locator("text=Save").click();
24+
}
25+
26+
async seeSuccessAccountCreatingAlert() {
27+
await Alert.on(this.page).hasText("Domain has been created successfully");
28+
}
29+
}

0 commit comments

Comments
 (0)