From 4c69991106ffc9a6369a2b0a2f0e5b7476a2a940 Mon Sep 17 00:00:00 2001 From: 0xtzData Date: Sun, 25 Aug 2024 18:45:32 +0200 Subject: [PATCH] 10 envs --- .github/workflows/e2e_matrix.yaml | 32 ++++-------------- README.md | 3 +- tests/e2e/package.json | 2 +- tests/e2e/pages/NewHome.ts | 33 +++++++++++-------- tests/e2e/static/explorer.json | 16 +++++++++ tests/e2e/static/neon.json | 14 ++++++++ tests/e2e/static/polygon.json | 19 +++++++++++ tests/e2e/static/rootstock.json | 14 ++++++++ tests/e2e/static/zkevm.json | 16 +++++++++ .../tests/functional/SmokeOnDemand.test.ts | 33 +++++++++++++------ 10 files changed, 131 insertions(+), 51 deletions(-) create mode 100644 tests/e2e/static/explorer.json create mode 100644 tests/e2e/static/neon.json create mode 100644 tests/e2e/static/polygon.json create mode 100644 tests/e2e/static/rootstock.json create mode 100644 tests/e2e/static/zkevm.json diff --git a/.github/workflows/e2e_matrix.yaml b/.github/workflows/e2e_matrix.yaml index 3572f6b5..9ad0f5d6 100644 --- a/.github/workflows/e2e_matrix.yaml +++ b/.github/workflows/e2e_matrix.yaml @@ -16,34 +16,14 @@ jobs: url: [ "https://eth.blockscout.com", "https://eth-sepolia.blockscout.com", - "https://eth-sepolia.k8s-dev.blockscout.com", "https://base.blockscout.com", "https://gnosis.blockscout.com", - "https://optimism.blockscout.com" -# "https://gnosis-chiado.blockscout.com", -# "https://blockscout.com/astar", -# "https://blockscout.com/shiden", -# "https://blockscout.com/shibuya", -# "https://neon.blockscout.com", -# "https://neon-devnet.blockscout.com", -# "https://zetachain-athens-3.blockscout.com", -# "https://pegasus.lightlink.io", -# "https://phoenix.lightlink.io", -# "https://explorer.testnet.immutable.com", -# "https://www.shibariumscan.io", -# "https://explorer.fuse.io", -# "https://explorer.fusespark.io", -# "https://puppyscan.shib.io", -# "https://optimism-sepolia.blockscout.com", -# "https://rootstock.blockscout.com", -# "https://base.blockscout.com", -# "https://base-sepolia.blockscout.com", -# "https://etc-mordor.blockscout.com", -# "https://etc.blockscout.com", -# "https://explorer.evm.shimmer.network", -# "https://explorer.evm.testnet.shimmer.network", -# "https://zksync.blockscout.com", -# "https://stability-betanet.blockscout.com", + "https://optimism.blockscout.com", + "https://neon.blockscout.com", + "https://rootstock.blockscout.com", + "https://polygon.blockscout.com", + "https://explorer.immutable.com", + "https://zkevm.blockscout.com" ] steps: - uses: actions/checkout@v3 diff --git a/README.md b/README.md index 285ebc31..36f49bcf 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,8 @@ This repo contains E2E and stress/load tests for Blockscout APIs ## Production tests To add your environment to the E2E tests suite you need to: -1. Create a new JSON file for static data under `tests/e2e/data/static` +1. Create a new JSON file for static data under `tests/e2e/data/static`. +File should be called by domain, for example for `https://eth-sepolia.blockscout.com` file should have name `eth-sepolia.json` 2. Fill different entities data (tokens/blobs/etc), [eth-sepolia.json](tests/e2e/static/eth-sepolia.json) 3. Add your environment URL to [e2e_matrix](.github/workflows/e2e_matrix.yaml) diff --git a/tests/e2e/package.json b/tests/e2e/package.json index e6a783c1..db87bd8d 100644 --- a/tests/e2e/package.json +++ b/tests/e2e/package.json @@ -44,7 +44,7 @@ "test:prod:smoke:native_accounts": "npx playwright test --project=Chrome --grep=@NativeAccounts --retries=3 --timeout=60000", "test:prod:smoke:userops": "npx playwright test --project=Chrome --grep=@UserOps --retries=3 --timeout=60000", "test:prod:smoke:ens": "npx playwright test --project=Chrome --grep=@ENS --retries=3 --timeout=60000", - "test:ondemand": "npx playwright test --project=Chrome --grep=@OnDemandSmoke --retries=0 --timeout=40000", + "test:ondemand": "npx playwright test --project=Chrome --grep=@OnDemandSmoke --retries=0 --timeout=30000", "test:prod:smoke:marketplace": "npx playwright test --project=Chrome --grep=@Marketplace --retries=3 --timeout=30000", "test:rollup": "npx playwright test --project=Chrome --grep=@Rollup", "test:authorized": "npx playwright test --project=Chrome --grep=@Authorized", diff --git a/tests/e2e/pages/NewHome.ts b/tests/e2e/pages/NewHome.ts index f622c8ec..48446b6e 100644 --- a/tests/e2e/pages/NewHome.ts +++ b/tests/e2e/pages/NewHome.ts @@ -13,9 +13,7 @@ export class NewHomePage extends CommonPage { SEARCH_ITEMS_ICONS = `div[id="search_bar_popover_content"] >> nth=1 >> svg` - BLOCKS_WIDGET = `text=/Latest blocks/ >> ..` - - BATCHES_WIDGET = `text=/Latest batch/ >> ..` + BLOCKS_WIDGET = `text=/Latest blocks|Latest batch/ >> ..` BLOCKS_WIDGET_LAST_BLOCK = `${this.BLOCKS_WIDGET} >> div >> div >> nth=0` @@ -147,16 +145,20 @@ export class NewHomePage extends CommonPage { async checkInventoryERC721Element(data: any): Promise { await expect(this.page.getByText(`ERC-721`)).toBeVisible() - await expect(this.page.getByText(`Owner`)).toBeVisible() + // await expect(this.page.getByText(`Owner`)).toBeVisible() await expect(this.page.getByText(`Creator`)).toBeVisible() await expect(this.page.getByText(`Transfers`, { exact: true })).toBeVisible() - await expect(this.page.getByText(`Name`)).toBeVisible() - await expect(this.page.getByText(`Description`)).toBeVisible() - await expect(this.page.getByText(`Attributes`)).toBeVisible() - await expect(this.page.getByText(`Sponsored`)).toBeVisible() + // await expect(this.page.getByText(`Name`)).toBeVisible() + // await expect(this.page.getByText(`Description`)).toBeVisible() + // await expect(this.page.getByText(`Attributes`)).toBeVisible() + // await expect(this.page.getByText(`Sponsored`)).toBeVisible() } async checkInventoryERC721MetadataTab(data: any): Promise { + if (data.metadata === undefined) { + console.log(chalk.yellow(`No metadata for ERC-721 token!`)) + return + } await this.page.getByRole(`tab`, { name: `Metadata` }).click() await this.page.getByRole(`combobox`).selectOption(`JSON`) const textContent = await this.page.locator(`body >> section >> div >> nth=26`).textContent() @@ -186,7 +188,7 @@ export class NewHomePage extends CommonPage { await expect(this.page.getByText(`Name`)).toBeVisible() await expect(this.page.getByText(`Description`)).toBeVisible() await expect(this.page.getByText(`Attributes`)).toBeVisible() - await expect(this.page.getByText(`Sponsored`)).toBeVisible() + // await expect(this.page.getByText(`Sponsored`)).toBeVisible() } async checkInventoryERC404MetadataTab(data: any): Promise { @@ -212,15 +214,15 @@ export class NewHomePage extends CommonPage { async checkInventoryERC1155Element(data: any): Promise { await expect(this.page.getByText(`ERC-1155`)).toBeVisible() - await expect(this.page.getByText(`Owner`, { exact: true })).toBeVisible() - await expect(this.page.getByText(`Creator`)).toBeVisible() + // await expect(this.page.getByText(`Owner`, { exact: true })).toBeVisible() + // await expect(this.page.getByText(`Creator`)).toBeVisible() await expect(this.page.getByText(`Transfers`, { exact: true })).toBeVisible() await expect(this.page.getByText(`Sponsored`)).toBeVisible() } async checkInventoryERC1155MetadataTab(data: any): Promise { if (data.metadata === undefined) { - console.log(chalk.yellow(`No metadata for 1155!`)) + console.log(chalk.yellow(`No metadata for ERC-1155 token!`)) return } await this.page.getByRole(`tab`, { name: `Metadata` }).click() @@ -300,6 +302,11 @@ export class NewHomePage extends CommonPage { await this.delay(5000) } + async isStatsEnabled(): Promise { + await this.delay(1000) + return this.page.isVisible(`text=/Charts & stats/`) + } + async isENSEnabled(): Promise { await this.actions.page.hover(`text=/Blockchain/`) await this.delay(1000) @@ -507,7 +514,7 @@ export class NewHomePage extends CommonPage { } async checkHeader(): Promise { - await this.displayed_in_parent(`text=/Total blocks/`, `text=/\\d+.*/`, 2, `no total blocks`) + await this.displayed_in_parent(`text=/Total blocks|Latest batch/`, `text=/\\d+.*/`, 2, `no total blocks`) await this.displayed_in_parent(`text=/Average block time/`, `text=/\\d+.*/`, 2, `no avg block time`) await this.displayed_in_parent(`text=/Total transactions/`, `text=/\\d+.*/`, 2, `no total transactions`) await this.displayed_in_parent(`text=/Wallet addresses/`, `text=/\\d+.*/`, 2, `no wallet addresses`) diff --git a/tests/e2e/static/explorer.json b/tests/e2e/static/explorer.json new file mode 100644 index 00000000..b60d0653 --- /dev/null +++ b/tests/e2e/static/explorer.json @@ -0,0 +1,16 @@ +{ + "search": { + "query": "USDT", + "result": "Tether USD" + }, + "erc721": { + "address": "0xdcaf350d82f222a2430CaFCEE2838A5085D18230", + "instance": "12876409", + "metadata": "{\"attributes\":[{\"trait_type\":\"Grade\",\"value\":\"R\"},{\"trait_type\":\"Level\",\"value\":1},{\"trait_type\":\"Category\",\"value\":\"Material\"},{\"trait_type\":\"Location\",\"value\":\"Marketplace Only\"}],\"description\":\"A stone with mysterious power that can enchant items. It disappears after use.\",\"image\":\"https://resource.babysharkuniverse.io/imx/images/nft_9000_EnchantmentStone.png\",\"itemid\":\"9000\",\"name\":\"Enchantment Stone\",\"timestamp\":1718878242}" + }, + "erc1155": { + "address": "0xf289B7a941EaD265eA189FC7D452119A8f497Ed7", + "instance": "4670300", + "metadata": "{\"attributes\":[{\"trait_type\":\"app\",\"value\":\"overtake\"},{\"trait_type\":\"tier\",\"value\":\"RARE\"},{\"trait_type\":\"category\",\"value\":\"COMMUNITY\"},{\"trait_type\":\"collection\",\"value\":\"OVERTAKE\"}],\"description\":\"Join CoinFest, GM us, and get your exclusive POP—because who doesn't love a little crypto bling?\",\"external_url\":\"https://overtake.world/explore/pops/COINFEST_OVERTAKER\",\"image\":\"https://static.overtake.world/ottm-platform/images/pop_thumbnail/467_3R_H.webp\",\"name\":\"Coinfest Overtaker\"}" + } +} \ No newline at end of file diff --git a/tests/e2e/static/neon.json b/tests/e2e/static/neon.json new file mode 100644 index 00000000..cb9aef2c --- /dev/null +++ b/tests/e2e/static/neon.json @@ -0,0 +1,14 @@ +{ + "search": { + "query": "USDT", + "result": "Tether USD" + }, + "erc721": { + "address": "0x599329D5838d505f1ff39955D544a7d696C6bdD0", + "instance": "1000010313" + }, + "erc1155": { + "address": "0x07CdC97Ca96Ff755d0f380AaB039b84ce51E2714", + "instance": "8391542" + } +} \ No newline at end of file diff --git a/tests/e2e/static/polygon.json b/tests/e2e/static/polygon.json new file mode 100644 index 00000000..27c5dab4 --- /dev/null +++ b/tests/e2e/static/polygon.json @@ -0,0 +1,19 @@ +{ + "search": { + "query": "USDT", + "result": "Tether USD" + }, + "erc404": { + "address": "0xAd34776C9FEeE12A87BEa6491bB58D02933a872B", + "instance": "333", + "metadata": "{\"attributes\":[{\"trait_type\":\"Background\",\"value\":\"Spring Sunset\"},{\"trait_type\":\"Body\",\"value\":\"Yellow Sunglasses\"},{\"trait_type\":\"Legendary Items\",\"value\":\"Bong 3\"},{\"display_type\":\"number\",\"trait_type\":\"Rarity Rank\",\"value\":39}],\"description\":\"Error 404 | LlamaNotFound #333 - The first ever ERC404 token standard collection in Polygon Blockchain\",\"image\":\"ipfs://QmeKKcyz6Ly694pM54zCPodAPMinoaDvozwhAcQ3kxPBAz/333.jpeg\",\"name\":\"Error 404 | LlamaNotFound #333\"}" + }, + "erc721": { + "address": "0xE9d2FA815B95A9d087862a09079549F351DaB9bd", + "instance": "8100" + }, + "erc1155": { + "address": "0x127E47abA094a9a87D084a3a93732909Ff031419", + "instance": "0" + } +} \ No newline at end of file diff --git a/tests/e2e/static/rootstock.json b/tests/e2e/static/rootstock.json new file mode 100644 index 00000000..7af72042 --- /dev/null +++ b/tests/e2e/static/rootstock.json @@ -0,0 +1,14 @@ +{ + "search": { + "query": "USDT", + "result": "Tether USD" + }, + "erc721": { + "address": "0x857a62c9C0B6F1211E04275A1F0c5f26FcE2021F", + "instance": "2113" + }, + "erc1155": { + "address": "0xB8Ef8a681c00D41cc0cA6E64b7415B020a6A206a", + "instance": "0" + } +} \ No newline at end of file diff --git a/tests/e2e/static/zkevm.json b/tests/e2e/static/zkevm.json new file mode 100644 index 00000000..f7574785 --- /dev/null +++ b/tests/e2e/static/zkevm.json @@ -0,0 +1,16 @@ +{ + "search": { + "query": "USDT", + "result": "Tether USD" + }, + "erc721": { + "address": "0x91553861aA69B17F2d0302811B4CeC0626602174", + "instance": "192028", + "metadata": "{\"attributes\":{\"trait_type\":\"Name\",\"value\":\"Unconstrained\"},\"image\":\"ipfs://bafybeifkvbtrx5mw4r2y6755vechzrdcdsbv23qd46324ut5wq6hwkceem/3.gif\",\"name\":\"To Ethereum, with Love\"}" + }, + "erc1155": { + "address": "0xF57Cb671D50535126694Ce5Cc3CeBe3F32794896", + "instance": "10", + "metadata": "{\"properties\":{\"description\":{\"description\":\"Rubyscore_ZkEVM\",\"type\":\"string\"},\"image\":{\"description\":\"ipfs://QmUxmwtBFmCYbKJmoR7KwBAVb2Trs5HVmkw57D4hbFTqPP/10.png\",\"type\":\"string\"},\"name\":{\"description\":\"Rubyscore_ZkEVM 10 level\",\"type\":\"string\"}},\"title\":\"Rubyscore_Achievement\",\"type\":\"object\"}" + } +} \ No newline at end of file diff --git a/tests/e2e/tests/functional/SmokeOnDemand.test.ts b/tests/e2e/tests/functional/SmokeOnDemand.test.ts index 4ac12224..b8dd7e70 100644 --- a/tests/e2e/tests/functional/SmokeOnDemand.test.ts +++ b/tests/e2e/tests/functional/SmokeOnDemand.test.ts @@ -14,8 +14,13 @@ const url = process.env.BLOCKSCOUT_URL let staticData test.beforeAll(async () => { - const fileName = url.split(`//`)[1].split(`.`).slice(0, -2).join(`.`) - staticData = JSON.parse(readFileSync(`static/${fileName}.json`).toString()) + const u = url.endsWith(`/`) ? url.slice(0, -1) : url + const fileName = u.split(`//`)[1].split(`.`).slice(0, -2).join(`.`) + try { + staticData = JSON.parse(readFileSync(`static/${fileName}.json`).toString()) + } catch (err) { + console.log(chalk.red(`Error reading static data for ${fileName}, file should be named as domain in URL: ${u}`)) + } }) test(`@OnDemandSmoke Main page components`, async ({ newHomePage }) => { @@ -30,6 +35,10 @@ test(`@OnDemandSmoke Main page components`, async ({ newHomePage }) => { test(`@OnDemandSmoke Check blocks`, async ({ context, newHomePage }) => { await newHomePage.checkRequests(newHomePage.page) await newHomePage.open_custom(`${url}/blocks`) + // TODO: make it header dependent + if (url.includes(`explorer`)) { + return + } await newHomePage.checkBlocks() }) @@ -47,10 +56,14 @@ test(`@OnDemandSmoke Check search`, async ({ newHomePage }) => { }) test(`@OnDemandSmoke Check stats`, async ({ newHomePage }) => { - // await newHomePage.checkRequests(newHomePage.page) - await newHomePage.open_custom(`${url}/stats`) - await newHomePage.checkStatsCounters() - await newHomePage.checkStatsGraphsDisplayed() + await newHomePage.checkRequests(newHomePage.page) + if (await newHomePage.isStatsEnabled()) { + await newHomePage.open_custom(`${url}/stats`) + await newHomePage.checkStatsCounters() + await newHomePage.checkStatsGraphsDisplayed() + } else { + console.log(chalk.yellow(`Stats Services are OFF!`)) + } }) test(`@OnDemandSmoke Check accounts`, async ({ newHomePage }) => { @@ -102,7 +115,7 @@ test(`@OnDemandSmoke Check market`, async ({ marketplace }) => { }) test(`@OnDemandSmoke Check user operations`, async ({ newHomePage }) => { - // await newHomePage.checkRequests(newHomePage.page) + await newHomePage.checkRequests(newHomePage.page) await newHomePage.open_custom(url) if (await newHomePage.UserOpsIsOn()) { await newHomePage.open_custom(`${url}/ops`) @@ -123,12 +136,12 @@ test(`@OnDemandSmoke Check blobs`, async ({ newHomePage }) => { await newHomePage.checkBlobTransactions() await newHomePage.checkParticularBlob(url, staticData.blob) } else { - console.log(chalk.yellow(`Blob txns is OFF!`)) + console.log(chalk.yellow(`Blob txns are OFF!`)) } }) test(`@OnDemandSmoke Check read contract tabs`, async ({ newHomePage }) => { - // await newHomePage.checkRequests(newHomePage.page) + await newHomePage.checkRequests(newHomePage.page) await newHomePage.openFirstVerifiedContract(url) await newHomePage.checkContractReadTabs() }) @@ -173,7 +186,7 @@ test(`@OnDemandSmoke Check ERC-404 inventory tab`, async ({ newHomePage }) => { }) test(`@OnDemandSmoke Check ERC-1155 inventory tab`, async ({ newHomePage }) => { - // await newHomePage.checkRequests(newHomePage.page) + await newHomePage.checkRequests(newHomePage.page) await newHomePage.open_custom(`${url}/token/${staticData.erc1155.address}`) await newHomePage.checkERC1155Inventory(staticData.erc1155) await newHomePage.open_custom(`${url}/token/${staticData.erc1155.address}/instance/${staticData.erc1155.instance}`)