Skip to content

Commit

Permalink
Merge branch 'main' into feat(backend)/function-to-add-hidden-dapps
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonioVentilii authored Dec 3, 2024
2 parents d0fe47c + 80ffa9c commit 1d7bc0d
Show file tree
Hide file tree
Showing 14 changed files with 68 additions and 3 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion e2e/transactions-page.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ testWithII('should display BTC transactions page', async ({ page, iiPage }) => {
});

// TODO: resolve the below test flakiness
testWithII.skip('should display ETH transactions page', async ({ page, iiPage }) => {
testWithII('should display ETH transactions page', async ({ page, iiPage }) => {
const transactionsPage = new TransactionsPage({ page, iiPage, tokenSymbol: 'ETH' });

await transactionsPage.waitForReady();
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions e2e/utils/components/promotion-carousel.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import type { Page } from '@playwright/test';

export class PromotionCarousel {
#page: Page;

constructor(page: Page) {
this.#page = page;
}

public async navigateToSlide(slideNumber: number): Promise<void> {
const navigation1Selector = `[data-tid="carousel-slide-navigation-${slideNumber}"]:visible`;
await this.#page.click(navigation1Selector);
}

public async freezeCarousel(): Promise<void> {
// Freeze the carousel by applying the first slide's transform style to all visible slides
await this.#page.$$eval(`div[data-tid="carousel-slide"]:visible`, (elements) => {
elements.forEach((el) => {
const slideStyle = el.style.transform;
el.style.transform = slideStyle;
});
});
// Freeze the carousel navigation indicators by fixing their current width and background color styles
await this.#page.$$eval(`[data-tid^="carousel-slide-navigation-"]:visible`, (elements) => {
elements.forEach((el) => {
const indicatorWidth = el.style.width;
const indicatorBackgroundColor = el.style.backgroundColor;
el.style.width = indicatorWidth;
el.style.backgroundColor = indicatorBackgroundColor;
});
});
}
}
1 change: 1 addition & 0 deletions e2e/utils/pages/activity.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ export class ActivityPage extends HomepageLoggedIn {
// TODO: Implement this method clicking on the navigation item instead of using the URL, when the activity page is implemented
override async extendWaitForReady(): Promise<void> {
await this.#page.goto(ACTIVITY_URL);
await this.waitForLoadState();
}
}
1 change: 1 addition & 0 deletions e2e/utils/pages/explorer.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ export class ExplorerPage extends HomepageLoggedIn {

override async extendWaitForReady(): Promise<void> {
await this.clickByTestId(NAVIGATION_ITEM_EXPLORER);
await this.waitForLoadState();
}
}
22 changes: 21 additions & 1 deletion e2e/utils/pages/homepage.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ import {
TOKEN_CARD
} from '$lib/constants/test-ids.constants';
import { type InternetIdentityPage } from '@dfinity/internet-identity-playwright';
import { nonNullish } from '@dfinity/utils';
import { isNullish, nonNullish } from '@dfinity/utils';
import { expect, type Locator, type Page, type ViewportSize } from '@playwright/test';
import { PromotionCarousel } from '../components/promotion-carousel.component';
import { HOMEPAGE_URL, LOCAL_REPLICA_URL } from '../constants/e2e.constants';
import { getQRCodeValueFromDataURL } from '../qr-code.utils';
import { getReceiveTokensModalQrCodeButtonSelector } from '../selectors.utils';
Expand Down Expand Up @@ -55,6 +56,7 @@ interface WaitForLocatorOptions {
abstract class Homepage {
readonly #page: Page;
readonly #viewportSize?: ViewportSize;
private promotionCarousel?: PromotionCarousel;

protected constructor({ page, viewportSize }: HomepageParams) {
this.#page = page;
Expand Down Expand Up @@ -201,6 +203,19 @@ abstract class Homepage {
await expect(modal).toHaveScreenshot();
}

async setCarouselFirstSlide(): Promise<void> {
if (isNullish(this.promotionCarousel)) {
this.promotionCarousel = new PromotionCarousel(this.#page);
}

await this.promotionCarousel.navigateToSlide(1);
await this.promotionCarousel.freezeCarousel();
}

async waitForLoadState() {
await this.#page.waitForLoadState('networkidle');
}

abstract extendWaitForReady(): Promise<void>;

abstract waitForReady(): Promise<void>;
Expand All @@ -218,6 +233,7 @@ export class HomepageLoggedOut extends Homepage {
*/
async waitForReady(): Promise<void> {
await this.waitForHomepageReady();
await this.waitForLoadState();
}
}

Expand Down Expand Up @@ -299,6 +315,10 @@ export class HomepageLoggedIn extends Homepage {

await this.waitForTokensInitialization();

await this.waitForLoadState();

await this.setCarouselFirstSlide();

await this.extendWaitForReady();
}
}
2 changes: 2 additions & 0 deletions e2e/utils/pages/settings.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@ export class SettingsPage extends HomepageLoggedIn {
await this.clickByTestId(NAVIGATION_ITEM_SETTINGS);

await this.mockSelector({ selector: `[data-tid="${SETTINGS_ADDRESS_LABEL}"]` });

await this.waitForLoadState();
}
}
1 change: 1 addition & 0 deletions e2e/utils/pages/transactions.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ export class TransactionsPage extends HomepageLoggedIn {

override async extendWaitForReady(): Promise<void> {
await this.clickByTestId(`${TOKEN_CARD}-${this.#tokenSymbol}`);
await this.waitForLoadState();
}
}
4 changes: 3 additions & 1 deletion src/frontend/src/lib/components/carousel/Carousel.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { onMount } from 'svelte';
import Controls from '$lib/components/carousel/Controls.svelte';
import Indicators from '$lib/components/carousel/Indicators.svelte';
import { CAROUSEL_CONTAINER } from '$lib/constants/test-ids.constants';
import { moveSlider, extendCarouselSliderFrame } from '$lib/utils/carousel.utils';
export let autoplay = 5000;
Expand Down Expand Up @@ -245,10 +246,11 @@
<svelte:window on:resize={onResize} />

<div
data-tid={CAROUSEL_CONTAINER}
class={`${styleClass ?? ''} relative overflow-hidden rounded-3xl bg-white px-3 pb-10 pt-3 shadow`}
>
<div class="w-full overflow-hidden" bind:this={container}>
<div class="flex" bind:this={sliderFrame}>
<div data-tid="carousel-slide" class="flex" bind:this={sliderFrame}>
<slot />
</div>
</div>
Expand Down
2 changes: 2 additions & 0 deletions src/frontend/src/lib/components/carousel/Indicator.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script lang="ts">
import { CAROUSEL_SLIDE_NAVIGATION } from '$lib/constants/test-ids.constants';
import { i18n } from '$lib/stores/i18n.store';
import { replacePlaceholders } from '$lib/utils/i18n.utils';
Expand All @@ -20,5 +21,6 @@
<button
on:click
aria-label={replacePlaceholders($i18n.carousel.text.indicator, { $index: `${index + 1}` })}
data-tid={`${CAROUSEL_SLIDE_NAVIGATION}${index + 1}`}
class="{`${isActive ? 'w-7 bg-black' : 'w-4 bg-dust'} mr-1 h-1.5 transition-all duration-300 ease-linear last:mr-0`}}"
></button>
3 changes: 3 additions & 0 deletions src/frontend/src/lib/constants/test-ids.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,6 @@ export const NAVIGATION_ITEM_TOKENS = 'navigation-item-tokens';
export const NAVIGATION_ITEM_ACTIVITY = 'navigation-item-activity';
export const NAVIGATION_ITEM_EXPLORER = 'navigation-item-explore';
export const NAVIGATION_ITEM_SETTINGS = 'navigation-item-settings';

export const CAROUSEL_CONTAINER = 'carousel-container';
export const CAROUSEL_SLIDE_NAVIGATION = 'carousel-slide-navigation-';

0 comments on commit 1d7bc0d

Please sign in to comment.