From 932346e991d4df38e50a83761bdc18a46e573195 Mon Sep 17 00:00:00 2001 From: 0xtzData Date: Sun, 17 Mar 2024 19:25:50 +0100 Subject: [PATCH] admin tests for new entities --- tests/e2e/pages/Admin.ts | 42 ++++++++++++-- tests/e2e/tests/functional/Admin.test.ts | 73 ++++++++++++++++++------ 2 files changed, 91 insertions(+), 24 deletions(-) diff --git a/tests/e2e/pages/Admin.ts b/tests/e2e/pages/Admin.ts index 12ef16b9..9eb2244e 100644 --- a/tests/e2e/pages/Admin.ts +++ b/tests/e2e/pages/Admin.ts @@ -119,7 +119,7 @@ export class AdminPage extends CommonPage { if (noRecords) { return } - await this.selectFirstSubmission() + await this.selectFirstListElement() await this.deleteTokenInfo() } @@ -140,13 +140,45 @@ export class AdminPage extends CommonPage { await this.actions.clickElement(`text=Apply changes`) } + async filterByAddress(addr: string): Promise { + await this.actions.clickElement(`text=Filter`) + await this.actions.enterElementText(`input[name="filter-address"]`, addr) + await this.actions.clickElement(`text=Apply changes`) + } + + async filterByInputRef(inputName: string, filter: string): Promise { + await this.actions.clickElement(`text=Filter`) + await this.actions.enterElementText(`input[name="${inputName}"]`, filter) + await this.actions.clickElement(`text=Apply changes`) + } + + async filterBySlug(addr: string): Promise { + await this.actions.clickElement(`text=Filter`) + await this.actions.enterElementText(`input[name="filter-address"]`, addr) + await this.actions.clickElement(`text=Apply changes`) + } + + async filterByEmailProjectName(projectName: string): Promise { + await this.actions.clickElement(`text=Filter`) + await this.actions.enterElementText(`input[name="filter-project_name"]`, projectName) + await this.actions.clickElement(`text=Apply changes`) + } + + async filterByEmailStatus(email: string, status: string): Promise { + await this.actions.clickElement(`text=Filter`) + await this.actions.enterElementText(`input[name="filter-blockscout_user_email"]`, email) + await this.actions.clickElement(`input[id="react-select-5-input"]`) + await this.actions.clickElement(`form >> text=/${status}/ >> nth=1`) + await this.actions.clickElement(`text=Apply changes`) + } + async filterByTokenAddress(email: string): Promise { await this.actions.clickElement(`text=Filter`) await this.actions.enterElementText(`input[name="filter-address"]`, email) await this.actions.clickElement(`text=Apply changes`) } - async selectFirstSubmission(): Promise { + async selectFirstListElement(): Promise { await this.actions.clickElement(`tr >> nth=1 >> td >> nth=1`) } @@ -154,7 +186,7 @@ export class AdminPage extends CommonPage { await this.actions.clickElement(`text=/Id/ >> nth=0`) await this.actions.clickElement(`text=/Id/ >> nth=0`) await this.delay(3000) - await this.selectFirstSubmission() + await this.selectFirstListElement() } async deleteTokenInfo(): Promise { @@ -175,7 +207,7 @@ export class AdminPage extends CommonPage { await this.actions.clickElement(`text=Create new`) await this.actions.enterElementText(`input >> nth=0`, sub.TokenAddress) await this.actions.clickElement(`input >> nth=1`) - await this.actions.clickElement(`text=${sub.ChainID}`) + await this.actions.clickElement(`body >> section >> nth=5 >> text=${sub.ChainID} >> nth=1`) await this.actions.enterElementText(`input >> nth=2`, sub.ProjectName) await this.actions.enterElementText(`input >> nth=3`, sub.ProjectWebSite) await this.actions.enterElementText(`input >> nth=4`, sub.ProjectEmail) @@ -204,7 +236,7 @@ export class AdminPage extends CommonPage { async createNewAdminSubmission(sub: SuperSubmission): Promise { await this.actions.clickElement(`text=Create new`) await this.actions.clickElement(`input >> nth=0`) - await this.actions.clickElement(`text=${sub.ChainID}`) + await this.actions.clickElement(`body >> section >> nth=5 >> text=${sub.ChainID} >> nth=1`) await this.actions.enterElementText(`input >> nth=1`, sub.TokenAddress) await this.actions.enterElementText(`input >> nth=2`, sub.BlockscoutUserEmail) await this.actions.enterElementText(`input >> nth=3`, sub.RequesterName) diff --git a/tests/e2e/tests/functional/Admin.test.ts b/tests/e2e/tests/functional/Admin.test.ts index 5833cb4d..3ee618c7 100644 --- a/tests/e2e/tests/functional/Admin.test.ts +++ b/tests/e2e/tests/functional/Admin.test.ts @@ -4,10 +4,15 @@ import test from '@lib/BaseTest' test.describe.configure({ mode: `parallel` }) -test.skip(`@Admin Delete/Create SuperSubmission`, async ({ tokenPage, newHomeGoerli, adminPage }) => { - adminPage.setBaseURL(`https://admin.services.blockscout.com`) +const envURL = `https://admin-ts-test.k8s-dev.blockscout.com` + +test.beforeEach(async ({ adminPage }) => { + adminPage.setBaseURL(envURL) await adminPage.open() await adminPage.login(process.env.ACCOUNT_USERNAME, process.env.ACCOUNT_PASSWORD) +}); + +test(`@Admin Delete/Create SuperSubmission`, async ({ tokenPage, newHomeGoerli, adminPage }) => { await adminPage.selectSuperUserTab() await adminPage.selectSuperUserTabSubmissions() await adminPage.clearMySubmissions(process.env.ACCOUNT_USERNAME) @@ -21,7 +26,7 @@ test.skip(`@Admin Delete/Create SuperSubmission`, async ({ tokenPage, newHomeGoe BlockscoutUserEmail: process.env.ACCOUNT_USERNAME, RequesterName: `test_submission_user`, RequesterEmail: process.env.ACCOUNT_USERNAME, - ProjectName: `test_project`, + ProjectName: uniqueSupportURL, ProjectWebSite: `https://ya.ru`, IconURL: iconURL, ProjectDescription: `desc`, @@ -44,25 +49,22 @@ test.skip(`@Admin Delete/Create SuperSubmission`, async ({ tokenPage, newHomeGoe CGTickerURL: iconURL, LlamaTickerURL: iconURL, }) - await adminPage.filterByEmail(process.env.ACCOUNT_USERNAME) - await adminPage.selectFirstSubmission() + await adminPage.filterByEmailProjectName(uniqueSupportURL) + await adminPage.selectFirstListElement() await adminPage.openSubmissions() await adminPage.selectTokenServicesTab() await adminPage.selectTODOSubmissions() - await adminPage.filterByEmail(process.env.ACCOUNT_USERNAME) - await adminPage.selectLastSubmissionSorted() + await adminPage.filterByEmailProjectName(uniqueSupportURL) + await adminPage.selectFirstListElement() await adminPage.approve() - await adminPage.delay(10000) + // await adminPage.delay(10000) - await newHomeGoerli.openAddress(tokenAddr) - await tokenPage.selectProjectInfo() - await tokenPage.actions.verifyElementIsDisplayed(`text=${uniqueSupportURL}`) + // await newHomeGoerli.openAddress(tokenAddr) + // await tokenPage.selectProjectInfo() + // await tokenPage.actions.verifyElementIsDisplayed(`text=${uniqueSupportURL}`) }) -test.skip(`@Admin Delete/Create TokenInfo`, async ({ newHomeGoerli, tokenPage, adminPage }) => { - adminPage.setBaseURL(`https://admin.services.blockscout.com`) - await adminPage.open() - await adminPage.login(process.env.ACCOUNT_USERNAME, process.env.ACCOUNT_PASSWORD) +test(`@Admin Delete/Create TokenInfo`, async ({ newHomeGoerli, tokenPage, adminPage }) => { await adminPage.selectTokenServicesTab() await adminPage.selectTokenInfosTab() const iconURL = `https://cdn-icons-png.flaticon.com/128/2989/2989898.png` @@ -102,8 +104,41 @@ test.skip(`@Admin Delete/Create TokenInfo`, async ({ newHomeGoerli, tokenPage, a LlamaTickerURL: iconURL, }) - await newHomeGoerli.openAddress(tokenAddr) - await newHomeGoerli.delay(3000) - await tokenPage.selectProjectInfo() - await tokenPage.actions.verifyElementIsDisplayed(`text=${uniqueSupportURL}`) + // await newHomeGoerli.openAddress(tokenAddr) + // await newHomeGoerli.delay(3000) + // await tokenPage.selectProjectInfo() + // await tokenPage.actions.verifyElementIsDisplayed(`text=${uniqueSupportURL}`) }) + +test(`@Admin Delete/Create Address`, async ({ newHomeGoerli, tokenPage, adminPage }) => { + const addr = `0x54FA517F05e11Ffa87f4b22AE87d91Cec0C2D7E1` + await adminPage.actions.clickElement(`section >> nth=1 >> text=/Metadata/`) + await adminPage.actions.clickElement(`section >> nth=1 >> text=/Addresses/`) + await adminPage.actions.clickElement(`section >> nth=5 >> text=/Create new/`) + await adminPage.actions.enterElementText(`input >> nth=0`, addr) + await adminPage.actions.clickElement(`section >> nth=5 >> text=/Save/`) + + await adminPage.filterByAddress(addr) + await adminPage.selectFirstListElement() + await adminPage.actions.clickElement(`section >> nth=5 >> text=/Delete/`) + await adminPage.actions.clickElement(`button[label="Confirm"]`) +}) + +test(`@Admin Delete/Create Public tag`, async ({ newHomeGoerli, tokenPage, adminPage }) => { + const publicTag = `PlaywrightTestTag` + const slug = faker.random.alphaNumeric(8) + await adminPage.actions.clickElement(`section >> nth=1 >> text=/Metadata/`) + await adminPage.actions.clickElement(`section >> nth=1 >> text=/^Public Tags/`) + await adminPage.actions.clickElement(`section >> nth=5 >> text=/Create new/`) + await adminPage.actions.enterElementText(`input[name="name"]`, publicTag) + await adminPage.actions.enterElementText(`input[name="slug"]`, slug) + await adminPage.actions.enterElementText(`input[name="ordinal"]`, `0`) + await adminPage.actions.clickElement(`input[id="react-select-4-input"]`) + await adminPage.actions.clickElement(`section >> nth=5 >> text=/classifier/ >> nth=1`) + await adminPage.actions.clickElement(`section >> nth=5 >> text=/Save/`) + + await adminPage.filterByInputRef(`filter-slug`, slug) + await adminPage.selectFirstListElement() + await adminPage.actions.clickElement(`section >> nth=5 >> text=/Delete/`) + await adminPage.actions.clickElement(`button[label="Confirm"]`) +}) \ No newline at end of file