Skip to content

Commit

Permalink
Merge pull request #250 from OasisDEX/product-hub-open-position-pages
Browse files Browse the repository at this point in the history
Product hub - Tests for opening positions pages of availablepools
  • Loading branch information
juan-langa authored May 7, 2024
2 parents 14562f5 + c3f08bc commit b8821b5
Show file tree
Hide file tree
Showing 6 changed files with 129 additions and 52 deletions.
2 changes: 1 addition & 1 deletion src/pages/common/productsList/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class ProductsList {
this.page = page;
this.listLocator = productHubLocator.getByRole('table');
this.pool = new Pool(this.poolLocator);
this.poolLocator = this.listLocator.locator('tbody tr');
this.poolLocator = this.listLocator.locator('tbody tr[role="link"]');
this.poolPairLocator = this.poolLocator.locator('td:nth-child(1)');
}

Expand Down
34 changes: 34 additions & 0 deletions src/pages/common/productsList/pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,38 @@ export class Pool {
await this.poolLocator.click();
await this.poolLocator.locator(`li:has-text("${positionCategory}")`).click();
}

@step
async getPool() {
const pool = await this.poolLocator.locator('td').first().innerText();
return pool;
}

@step
async getStrategy() {
const strategy = await this.poolLocator.locator('td').nth(1).innerText();
return strategy;
}

@step
async getProtocol() {
const pool = await this.poolLocator
.locator('td')
.last()
.locator('img')
.first()
.getAttribute('alt');
return pool;
}

@step
async getNetwork() {
const pool = await this.poolLocator
.locator('td')
.last()
.locator('img')
.last()
.getAttribute('alt');
return pool;
}
}
1 change: 0 additions & 1 deletion src/pages/homepage/productHub/header/position.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export class PositionType {

@step
async select(positionCategory: 'Borrow' | 'Multiply' | 'Earn') {
await this.headerLocator.click();
await this.headerLocator.locator(`li:has-text("${positionCategory}")`).click();
}
}
50 changes: 20 additions & 30 deletions tests/noWallet/borrowPage.spec.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
import { test } from '#noWalletFixtures';
import { extremelyLongTestTimeout, longTestTimeout, veryLongTestTimeout } from 'utils/config';

test.describe('Borrow page', async () => {
// To be removed after 'Improved Product Discovery Experience' release
test.skip('It should list only Borrow positions', async ({ app }) => {
test.setTimeout(longTestTimeout);

await app.borrow.open();
await app.borrow.productHub.header.positionType.shouldBe('Borrow');
await app.borrow.productHub.list.allPoolsShouldBe('Borrow');
});
const numberOfPools = Array.from({ length: 20 }, (_, index) => 0 + index);

test.describe('Borrow page', async () => {
test('It should open Borrow pool finder', async ({ app }) => {
test.info().annotations.push({
type: 'Test case',
Expand All @@ -23,6 +16,24 @@ test.describe('Borrow page', async () => {
await app.poolFinder.shouldHaveHeader('Borrow');
});

numberOfPools.forEach((poolIndex) => {
test(`It should open Borrow position page for all available pairs - ${poolIndex}`, async ({
app,
}) => {
await app.borrow.open();

// Logging pool info for debugging purposes
const pool = await app.borrow.productHub.list.nthPool(poolIndex).getPool();
console.log('++++ poolIndex: ', poolIndex);
console.log('++++ Pool: ', pool);

await app.borrow.productHub.list.nthPool(poolIndex).shouldBevisible();
await app.borrow.productHub.list.nthPool(poolIndex).open();

await app.position.overview.shouldBeVisible();
});
});

(
[
{ network: 'Ethereum', protocol: 'Aave V3' },
Expand Down Expand Up @@ -74,25 +85,4 @@ test.describe('Borrow page', async () => {
}
})
);

// [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19].forEach((positionIndex) =>
// test.skip(`It should open Borrow position page for all available pairs - ${positionIndex}`, async ({
// app,
// }) => {
// test.setTimeout(longTestTimeout);

// await app.borrow.open();

// // Wait for element to be visible
// await app.borrow.productHub.list.nthPool(positionIndex).shouldBevisible();
// await app.borrow.productHub.list.byPairPool(pair).open();

// // Wait for element to be visible
// await app.borrow.productHub.list.byPairPool(pair).shouldBevisible();
// await app.borrow.productHub.list.byPairPool(pair).open();

// await app.position.shouldHaveHeader(`Open ${pair}`);
// await app.position.overview.shouldBeVisible();
// })
// );
});
84 changes: 71 additions & 13 deletions tests/noWallet/homepage.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { test } from '#noWalletFixtures';
import { longTestTimeout } from 'utils/config';

const numberOfPools = Array.from({ length: 10 }, (_, index) => 0 + index);

test.describe('Homepage', async () => {
test('It should open connect-wallet popup - Homepage', async ({ app }) => {
test.info().annotations.push({
Expand All @@ -18,20 +20,8 @@ test.describe('Homepage', async () => {
await app.homepage.productHub.header.positionType.shouldBe('earn');
});

// To be removed after 'Improved Product Discovery Experience' release
(['Borrow', 'Multiply', 'Earn'] as const).forEach((positionCategory) =>
test.skip(`It should list only ${positionCategory} positions`, async ({ app }) => {
test.setTimeout(longTestTimeout);

await app.homepage.open();
await app.homepage.productHub.header.positionType.select(positionCategory);
await app.homepage.productHub.list.allPoolsShouldBe(positionCategory);
})
);

// To be UPDATED after 'Improved Product Discovery Experience' release
(['Borrow', 'Multiply', 'Earn'] as const).forEach((positionCategory) =>
test.skip(`It should link to ${positionCategory} page`, async ({ app }) => {
test(`It should link to ${positionCategory} page`, async ({ app }) => {
test.info().annotations.push({
type: 'Test case',
description: '12334',
Expand All @@ -48,4 +38,72 @@ test.describe('Homepage', async () => {
await app.homepage.productHub.list.openPoolFinder();
await app.poolFinder.shouldHaveHeader('Earn');
});

numberOfPools.forEach((poolIndex) => {
test(`It should open position page for all available EARN pools - ${poolIndex}`, async ({
app,
}) => {
// Logging pool info for debugging purposes
const pool = await app.homepage.productHub.list.nthPool(poolIndex).getPool();
const strategy = await app.homepage.productHub.list.nthPool(poolIndex).getStrategy();
const protocol = await app.homepage.productHub.list.nthPool(poolIndex).getProtocol();
const network = await app.homepage.productHub.list.nthPool(poolIndex).getNetwork();
console.log('++++ Pool Index: ', poolIndex);
console.log('++++ Pool: ', pool);
console.log('++++ Strategy: ', strategy);
console.log('++++ Protocol: ', protocol);
console.log('++++ Network: ', network);

await app.homepage.productHub.list.nthPool(poolIndex).shouldBevisible();
await app.homepage.productHub.list.nthPool(poolIndex).open();

await app.position.overview.shouldBeVisible();
});
});

numberOfPools.forEach((poolIndex) => {
test(`It should open position page for all available BORROW pools - ${poolIndex}`, async ({
app,
}) => {
await app.homepage.productHub.header.positionType.select('Borrow');
await app.homepage.productHub.header.positionType.shouldBe('borrow');

// Logging pool info for debugging purposes
const pool = await app.homepage.productHub.list.nthPool(poolIndex).getPool();
const protocol = await app.homepage.productHub.list.nthPool(poolIndex).getProtocol();
const network = await app.homepage.productHub.list.nthPool(poolIndex).getNetwork();
console.log('++++ Pool Index: ', poolIndex);
console.log('++++ Pool: ', pool);
console.log('++++ Protocol: ', protocol);
console.log('++++ Network: ', network);

await app.homepage.productHub.list.nthPool(poolIndex).shouldBevisible();
await app.homepage.productHub.list.nthPool(poolIndex).open();

await app.position.overview.shouldBeVisible();
});
});

numberOfPools.forEach((poolIndex) => {
test(`It should open position page for all available MULTIPLY pools - ${poolIndex}`, async ({
app,
}) => {
await app.homepage.productHub.header.positionType.select('Multiply');
await app.homepage.productHub.header.positionType.shouldBe('multiply');

// Logging pool info for debugging purposes
const pool = await app.homepage.productHub.list.nthPool(poolIndex).getPool();
const protocol = await app.homepage.productHub.list.nthPool(poolIndex).getProtocol();
const network = await app.homepage.productHub.list.nthPool(poolIndex).getNetwork();
console.log('++++ Pool Index: ', poolIndex);
console.log('++++ Pool: ', pool);
console.log('++++ Protocol: ', protocol);
console.log('++++ Network: ', network);

await app.homepage.productHub.list.nthPool(poolIndex).shouldBevisible();
await app.homepage.productHub.list.nthPool(poolIndex).open();

await app.position.overview.shouldBeVisible();
});
});
});
10 changes: 3 additions & 7 deletions tests/noWallet/portfolio/openPositionPages.spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import { expect, test } from '#noWalletFixtures';
import { longTestTimeout } from 'utils/config';

const numberOfPoositions = Array.from({ length: 118 }, (_, index) => 0 + index);

test.describe('Open position pages', async () => {
[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73,
74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97,
98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116,
].forEach((positionIndex) =>
numberOfPoositions.forEach((positionIndex) =>
test(`It should open position page from Portfolio page - Position index ${positionIndex}`, async ({
app,
}) => {
Expand Down

0 comments on commit b8821b5

Please sign in to comment.