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

test: Enhance Snap home page #29765

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
26 changes: 26 additions & 0 deletions test/e2e/page-objects/pages/snap-list-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ class SnapListPage {
// this selector needs to be combined with snap name to be unique.
private readonly snapListItem = '.snap-list-item';

private readonly defaultSnap = {
text: 'Home Page Example Snap',
tag: 'p',
};

private readonly title = {
text: 'Welcome to my Snap home page!',
tag: 'p',
};

constructor(driver: Driver) {
this.driver = driver;
}
Expand Down Expand Up @@ -75,6 +85,22 @@ class SnapListPage {
console.log('Verifying no snaps is installed for current account');
await this.driver.waitForSelector(this.noSnapInstalledMessage);
}

async clickDefaultSnap(): Promise<void> {
console.log('Clicking default snap');
await this.driver.waitForSelector(this.defaultSnap);
await this.driver.clickElement(this.defaultSnap);
}

async check_title(): Promise<void> {
try {
await this.driver.waitForSelector(this.title);
} catch (e) {
console.log('Timeout while waiting for title to be loaded', e);
throw e;
}
console.log('Title is loaded');
}
}

export default SnapListPage;
56 changes: 44 additions & 12 deletions test/e2e/page-objects/pages/test-snaps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,26 @@ export class TestSnaps {

private readonly dialogsSnapConfirmationButton = '#sendConfirmationButton';

private readonly dialogConnectButton = {
text: 'Connect',
tag: 'button',
css: '[data-testid="page-container-footer-next"]',
};

private readonly dialogConfirmButton = {
text: 'Confirm',
tag: 'button',
css: '[data-testid="page-container-footer-next"]',
};

private readonly dialogOkButton = {
text: 'OK',
tag: 'button',
css: '[data-testid="page-container-footer-next"]',
};

private readonly connectHomePage = '#connecthomepage';

constructor(driver: Driver) {
this.driver = driver;
}
Expand All @@ -36,21 +56,33 @@ export class TestSnaps {
async completeSnapInstallConfirmation() {
await this.driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog);

await this.driver.clickElement({
text: 'Connect',
tag: 'button',
});
await this.driver.waitForSelector(this.dialogConnectButton);

await this.driver.clickElement(this.dialogConnectButton);

await this.driver.waitForSelector(this.dialogConfirmButton);

await this.driver.clickElement({
text: 'Confirm',
tag: 'button',
});
await this.driver.clickElement(this.dialogConfirmButton);

await this.driver.clickElement({
text: 'OK',
tag: 'button',
});
await this.driver.waitForSelector(this.dialogOkButton);

await this.driver.clickElement(this.dialogOkButton);

await this.driver.switchToWindowWithTitle(WINDOW_TITLES.TestSnaps);
}

async clickConnectHomePage() {
// find and scroll to the homepage snap
const connectHomePageButton = await this.driver.findElement(
this.connectHomePage,
);
await this.driver.scrollToElement(connectHomePageButton);

// added delay for firefox
await this.driver.delayFirefox(1000);

// wait for and click connect
await this.driver.waitForSelector(this.connectHomePage);
await this.driver.clickElement(this.connectHomePage);
}
}
108 changes: 0 additions & 108 deletions test/e2e/snaps/test-snap-homepage.spec.js

This file was deleted.

41 changes: 41 additions & 0 deletions test/e2e/snaps/test-snap-homepage.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { Suite } from 'mocha';
import { Driver } from '../webdriver/driver';
import { withFixtures, WINDOW_TITLES } from '../helpers';
import FixtureBuilder from '../fixture-builder';
import { TestSnaps } from '../page-objects/pages/test-snaps';
import HeaderNavbar from '../page-objects/pages/header-navbar';
import SnapListPage from '../page-objects/pages/snap-list-page';
import { loginWithoutBalanceValidation } from '../page-objects/flows/login.flow';

describe('Test Snap Homepage', function (this: Suite) {
it('tests snap home page functionality', async function () {
await withFixtures(
{
fixtures: new FixtureBuilder().build(),
title: this.test?.fullTitle(),
},
async ({ driver }: { driver: Driver }) => {
await loginWithoutBalanceValidation(driver);

const testSnaps = new TestSnaps(driver);
const headerNavbar = new HeaderNavbar(driver);
const snapListPage = new SnapListPage(driver);

await testSnaps.openPage();
await testSnaps.clickConnectHomePage();
await testSnaps.completeSnapInstallConfirmation();

// switch to metamask page and open the three dots menu
await driver.switchToWindowWithTitle(
WINDOW_TITLES.ExtensionInFullScreenView,
);

await headerNavbar.openSnapListPage();
await snapListPage.clickDefaultSnap();

// check that the home page appears and contains the right info
await snapListPage.check_title();
},
);
});
});
Loading