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

Tests: More tests and some tweaks #7721

Merged
merged 8 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions components/CookieBanner.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
variant="text"
no-shadow
class="has-text-weight-bold ml-3"
data-testid="cookie-banner-button-accept"
@click="acceptCookies">
{{ $t('cookies.accept') }}
</NeoButton>
Expand Down
5 changes: 4 additions & 1 deletion components/Navbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,12 @@

<NotificationBoxButton
v-if="account"
data-testid="navbar-button-notification"
:show-label="isMobile"
@closeBurgerMenu="showMobileNavbar" />

<ShoppingCartButton
data-testid="navbar-button-cart"
:show-label="isMobile"
@closeBurgerMenu="showMobileNavbar" />

Expand All @@ -165,6 +167,7 @@
<div v-if="!account" id="NavProfile">
<ConnectWalletButton
class="button-connect-wallet"
data-testid="navbar-button-connect-wallet"
variant="connect"
@closeBurgerMenu="showMobileNavbar" />
</div>
Expand All @@ -174,7 +177,7 @@
v-if="!isMobile"
id="NavProfile"
:chain="urlPrefix"
data-testid="profileDropdown"
data-testid="navbar-profile-dropdown"
@closeBurgerMenu="closeBurgerMenu" />
</div>
<!-- END NAV END -->
Expand Down
4 changes: 3 additions & 1 deletion components/common/ConnectWallet/WalletAssetMenu.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<template>
<div
class="wallet-asset-container mt-4 is-flex is-flex-direction-column is-justify-content-space-between">
class="wallet-asset-container mt-4 is-flex is-flex-direction-column is-justify-content-space-between"
data-testid="sidebar-wallet-container">
<div>
<a
v-for="menu in menus"
Expand Down Expand Up @@ -47,6 +48,7 @@
<nuxt-link
to="/settings"
class="has-text-grey is-align-items-center"
data-testid="sidebar-link-settings"
@click="closeModal">
<NeoIcon icon="gear" />
<span>{{ $t('settings') }}</span>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<template>
<div
v-if="isOpen"
class="notification-modal-container theme-background-color border-left is-flex is-flex-direction-column">
class="notification-modal-container theme-background-color border-left is-flex is-flex-direction-column"
data-testid="notification-modal-container">
<NeoModalHead
:title="$t('notification.notifications')"
@close="closeModal" />
Expand Down
3 changes: 2 additions & 1 deletion components/common/shoppingCart/ShoppingCartModal.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<template>
<div>
<div
class="shopping-cart-modal-container theme-background-color border-left is-flex is-flex-direction-column">
class="shopping-cart-modal-container theme-background-color border-left is-flex is-flex-direction-column"
data-testid="shopping-cart-modal-container">
<NeoModalHead
:title="$t('shoppingCart.title')"
@close="closeShoppingCart(ModalCloseType.BACK)" />
Expand Down
6 changes: 4 additions & 2 deletions components/identity/module/IdentityPopover.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
boundary="viewport"
placement="bottom"
:delay="0"
data-testid="identity">
data-testid="identity-tippy-link">
<slot name="content" />

<template #content>
<div class="popover-content-container p-5">
<div
class="popover-content-container p-5"
data-testid="identity-popover-container">
<IdentityPopoverHeader />
<IdentityPopoverFooter :sold-items="nftEntities" />
</div>
Expand Down
11 changes: 8 additions & 3 deletions components/profile/ProfileDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<div class="container image is-64x64 mb-2">
<Avatar :value="id" />
</div>
<h1 class="title is-2" data-testid="user-identity">
<h1 class="title is-2" data-testid="profile-user-identity">
<a
v-if="hasBlockExplorer"
v-safe-href="explorer"
Expand Down Expand Up @@ -49,7 +49,8 @@
</NeoButton>

<div
class="is-flex is-align-items-center is-justify-content-center is-flex-wrap-wrap">
class="is-flex is-align-items-center is-justify-content-center is-flex-wrap-wrap"
data-testid="profile-identity-buttons">
<NeoButton
v-safe-href="`https://subscan.io/account/${id}`"
no-shadow
Expand Down Expand Up @@ -104,6 +105,7 @@
v-for="tab in tabs"
:key="tab"
class="is-capitalized"
data-testid="profile-tabs"
:active="activeTab === tab"
:count="counts[tab]"
:show-active-check="false"
Expand Down Expand Up @@ -138,7 +140,10 @@
<div
class="is-flex is-justify-content-space-between pb-4 pt-5 is-align-content-center">
<div class="is-flex">
<FilterButton :label="$t('sort.listed')" url-param="buy_now" />
<FilterButton
:label="$t('sort.listed')"
url-param="buy_now"
data-testid="profile-filter-button-buynow" />
<FilterButton
v-if="activeTab === 'created'"
:label="$t('activity.sold')"
Expand Down
2 changes: 2 additions & 0 deletions components/profile/activityTab/Activity.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
<NeoButton
no-shadow
rounded
data-testid="profile-activity-button-all"
label="All"
variant="text"
@click="activateAllFilter" />
<FilterButton
v-for="param in filters"
:key="param"
:label="param"
data-testid="profile-activity-button-filter"
class="is-capitalized"
:url-param="param" />
</div>
Expand Down
1 change: 1 addition & 0 deletions components/profile/activityTab/History.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
<HistoryRow
v-for="item in showList"
:key="item.ID"
data-testid="history-item-row"
:event="item"
:variant="variant"
:with-to-column="isToColumnVisible" />
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/basic.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ test('Landing Elements', async ({ page }) => {
await expect(page.getByTestId('explore').last()).toBeVisible()
await expect(page.getByTestId('search-bar')).toBeVisible()
await expect(page.getByTestId('footer-container')).toBeVisible()
await expect(page.getByTestId('profileDropdown')).toBeVisible()
await expect(page.getByTestId('navbar-profile-dropdown')).toBeVisible()
}
})
27 changes: 21 additions & 6 deletions tests/e2e/custom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ export class Commands {

async e2elogin() {
await this.page.goto('/e2e-login')
//await Promise.all([
// //this.page.waitForRequest('http://localhost:9090/_nuxt/pages/e2e-login.js')
// this.page.waitForResponse(resp => resp.status() === 200)
// ])
await this.page.waitForTimeout(10000)
await expect(this.page.getByTestId('mockAddress')).toHaveText('true')
await expect(this.page.getByTestId('navbar-profile-dropdown')).toBeVisible()
await expect(
this.page.getByTestId('navbar-button-connect-wallet'),
).toBeHidden()
await expect(this.page.getByTestId('mockAddress')).toHaveText('true', {
timeout: 15000,
})
}

async copyText(paste: string) {
Expand All @@ -20,4 +21,18 @@ export class Commands {
)
expect(clipboardText1).toContain(paste)
}

async scrollDownSlow() {
await this.page.evaluate(async () => {
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms))
// eslint-disable-next-line no-restricted-syntax
for (let i = 0; i < document.body.scrollHeight; i += 100) {
window.scrollTo(0, i)
await delay(200)
}
})
}
async acceptCookies() {
await this.page.getByTestId('cookie-banner-button-accept').click()
}
}
2 changes: 1 addition & 1 deletion tests/e2e/footer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const footerSocialMediaLinks = [
//},
{
linkName: 'Youtube',
linkAddress: 'https://www.youtube.com/channel/UCEULduld5NrqOL49k1KVjoA',
linkAddress: 'https://www.youtube.com/channel/UCEULduld5NrqOL49k1KVjoA/',
},
//{
// linkName: 'Instagram',
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/language.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ test('Check Language translations', async ({ page }) => {
await expect(page.getByTestId('mockAddress')).toHaveText('true')
await page.goto('')
//DE
await page.getByTestId('profileDropdown').click()
await page.getByTestId('navbar-profile-dropdown').click()
await page.getByTestId('sidebar-language').click()
await expect(page.getByRole('menu')).toBeVisible()
//await expect(page.getByTestId('skeleton-multiple-balances')).toHaveCount(0)
Expand Down
19 changes: 19 additions & 0 deletions tests/e2e/prefix.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,22 @@ test('Switch network', async ({ page }) => {
await page.getByTestId('chain-dropdown-rmrk').click()
await expect(page.getByTestId('chain')).toHaveText('rmrk')
})

test('Check if RMRK2 NFT URL is correct', async ({ page }) => {
//RMRK2
await page.goto('/ksm/explore/items?listed=false&search=Spirit+Key+%232112')
await page.locator('[class="infinite-scroll-item"]').click()
await expect(page).toHaveURL(
'/ksm/gallery/15024340-b6e98494bff52d3b1e-SPIRIT-SPIRIT2112-00002112',
)
})

//will not work because filtering on Assethubs still not implemented
/*
test('Check if Ahk NFT URL is correct', async ({ page }) => {
//AHK
await page.goto('/ahk/explore/items?listed=false&search=Susanne')
await page.locator('[class="infinite-scroll-item"]').click()
await expect(page).toHaveURL('/ahk/gallery/111-2')
})
*/
79 changes: 79 additions & 0 deletions tests/e2e/profile.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import { expect, test } from './fixtures'

test('Profile Interactions', async ({ page, Commands }) => {
const testAddress = 'FSMdmCLv5gFZ87YerB3M8ZSQ58BGHdSnreC4J6znWpqPQK9'
await page.goto(`ahk/u/${testAddress}?tab=owned`)
await Commands.scrollDownSlow()
//test step - will check if buy now has items that are not listed
await test.step('Buy Now', async () => {
await Commands.acceptCookies()
await page.getByTestId('profile-filter-button-buynow').click()
await Commands.scrollDownSlow()
for (const li of await page.locator('[class="nft-card"]').all()) {
await expect(li.getByText('KSM')).toBeVisible()
}
})
//test step
await test.step('Activity Tab', async () => {
await page.getByTestId('profile-tabs').last().click()
//usually sale and buy are active when you enter the page
//SALE
await page.getByTestId('profile-activity-button-filter').nth(1).click()
//checks if sale tag exists
await expect(page.getByTestId('history-item-row').first()).toBeVisible()
await expect(
page.getByTestId('history-item-row').first().filter({ hasText: 'Sale' }),
).toBeVisible()
await page.getByTestId('identity-tippy-link').first().hover()
await expect(page.getByTestId('identity-popover-container')).toBeVisible()
//BUY
await page.getByTestId('profile-activity-button-filter').nth(0).click()
await page.getByTestId('profile-activity-button-filter').nth(1).click()
await page.getByTestId('identity-tippy-link').last().hover()
await expect(page.getByTestId('identity-popover-container')).toBeVisible()
await expect(
page.getByTestId('history-item-row').first().filter({ hasText: 'Buy' }),
).toBeVisible()
//TRANSFER
await page.getByTestId('profile-activity-button-filter').nth(1).click()
await page.getByTestId('profile-activity-button-filter').nth(3).click()
await expect(
page
.getByTestId('history-item-row')
.first()
.filter({ hasText: 'Transfer' }),
).toBeVisible()
//LIST
await page.getByTestId('profile-activity-button-filter').nth(3).click()
await page.getByTestId('profile-activity-button-filter').nth(4).click()
await expect(
page.getByTestId('history-item-row').first().filter({ hasText: 'List' }),
).toBeVisible()
//ALL
await page.getByTestId('profile-activity-button-all').click()
})
//test step
await test.step('Profile Links', async () => {
//copy address
await page
.getByTestId('profile-identity-buttons')
.getByText('Copy Address')
.click()
await Commands.copyText(testAddress)
//QR Code
await page
.getByTestId('profile-identity-buttons')
.getByText('QR Code')
.click()
await expect(page.locator('[class="card-header-title"]')).toBeVisible()
await page.keyboard.press('Escape')
//Transfer
await page
.getByTestId('profile-identity-buttons')
.getByText('Transfer')
.click()
await expect(page).toHaveURL(
`/ahk/transfer?target=${testAddress}&usdamount=10&donation=true`,
)
})
})
11 changes: 11 additions & 0 deletions tests/e2e/settings.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { expect, test } from './fixtures'

test('Settings', async ({ page, Commands }) => {
await Commands.e2elogin()
await page.goto('/ahk')
//click on settings and check if page redirects correctly
await page.getByTestId('navbar-profile-dropdown').click()
await page.getByTestId('sidebar-link-settings').click()
await expect(page).toHaveURL('/settings')
await expect(page.getByTestId('sidebar-wallet-container')).toBeHidden()
})
19 changes: 19 additions & 0 deletions tests/e2e/sidebar.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { expect, test } from './fixtures'

test('Sidebar Interactions', async ({ page, Commands }) => {
await Commands.e2elogin()
await page.goto('/ahk')
//checks if sidebar closes when clicking another sidebar
//profile
await page.getByTestId('navbar-profile-dropdown').click()
await expect(page.getByTestId('sidebar-wallet-container')).toBeVisible()
//cart
await page.getByTestId('navbar-button-cart').click()
await expect(page.getByTestId('sidebar-wallet-container')).toBeHidden()
//notification
await page.getByTestId('navbar-button-notification').click()
await expect(page.getByTestId('shopping-cart-modal-container')).toBeHidden()
//profile
await page.getByTestId('navbar-profile-dropdown').click()
await expect(page.getByTestId('notification-modal-container')).toBeHidden()
})