Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor explore.spec.ts #7301

Merged
merged 7 commits into from
Sep 24, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion components/shared/filters/SidebarFilter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
<NeoSidebar :reduce="false" :open="open" fullheight>
<EventTypeFilter v-if="isCollectionActivityTab" expanded fluid-padding />
<StatusFilter v-else expanded fluid-padding />
<PriceFilter v-if="!isCollectionActivityTab" fluid-padding />
<PriceFilter
v-if="!isCollectionActivityTab"
fluid-padding
data-testid="expand-search" />
<PopularCollections v-if="isExploreItems" expanded fluid-padding />
</NeoSidebar>
</div>
Expand Down
1 change: 1 addition & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,6 @@ export default defineConfig({
command: process.env.CI ? 'pnpm start:static' : 'pnpm run dev',
url: 'http://localhost:9090',
reuseExistingServer: !process.env.CI,
timeout: 2 * 60 * 1000,
Jarsen136 marked this conversation as resolved.
Show resolved Hide resolved
},
})
75 changes: 0 additions & 75 deletions tests/cypress-deprecated/explore.cy.ts

This file was deleted.

73 changes: 73 additions & 0 deletions tests/e2e/explore.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import { test } from '@playwright/test'

const SORT_SAMPLES = ['blockNumber_DESC', 'updatedAt_ASC']

test.describe('Explore collections', async () => {
const routes = ['/rmrk/explore/collectibles', '/bsx/explore/collectibles']

for (const route of routes)
test(`Collections explore at ${route}`, async ({ page }) => {
await page.goto(route)
await testCollections(page)
})
})

const testCollections = async (page) => {
const tabs = await page.getByTestId('tabs')
await tabs.nth(2).waitFor()

await tabs.nth(2).getByText('Collections')
await tabs.nth(2).getByText('Items')

const exploreSort = await page.getByTestId('explore-sort')
await exploreSort.nth(2).click()

await Promise.all(SORT_SAMPLES.map((sort) => page.$(`[value="${sort}"]`)))

await Promise.all(
[...Array(5).keys()].map(async (i) => {
const collectionIndex = await page.getByTestId(`collection-index-${i}`)
await collectionIndex.waitFor()
})
)
}

test.describe('Explore items', async () => {
const routes = ['/rmrk/explore/items?page=1', '/bsx/explore/items?page=1']

for (const route of routes)
test(`Items explore at ${route}`, async ({ page }) => {
await page.goto(route)
await testItems(page)
})
})

const testItems = async (page) => {
const tabs = await page.getByTestId('tabs')
await tabs.nth(2).waitFor()

await tabs.nth(2).getByText('Collections')
await tabs.nth(2).getByText('Items')

const expandSearch = await page.getByTestId('expand-search')
await expandSearch.click()
const inputMin = await expandSearch.getByTestId('input-min')
await inputMin.type('100')
const btnApply = await expandSearch.getByTestId('apply')

await Promise.all([
page.waitForResponse(
(resp) => resp.url().includes('squid.subsquid.io') && resp.ok()
),
btnApply.click(),
])

const exploreSort = await page.getByTestId('explore-sort')
await exploreSort.nth(2).click()

const btnAsc = await page.$('[value="price_ASC"]')
await btnAsc?.click()

const firstItem = await page.getByTestId('0')
await firstItem.getByText(/\d+(\.\d+)?\s+[A-Z]{1,4}/)
}