Skip to content

Commit

Permalink
New scoutgame builders & scouts page layout (#5083)
Browse files Browse the repository at this point in the history
* Initial scout page layout changes

* Sticky builder search bar

* Added info modal for tables

* Use camel case for query params

* Added gallery builders layout

* Support for mobile screen

* Fixed search input size

* Added today's hot builders typography for scout page

* Added recent activity and leaderboard

* Refactored home page components

* Initial partner carousel

* Carousel pagination

* Fixed responsiveness for small screen

* Added info icon for mobile view in scout page

* Added pagination bullets for partner rewards

* Partner rewards for mobile screen

* builder page invite card

* Mobile view builders page

* New homepage

* Added builder invite modal

* Added pagination for mobile screen

* Fixed friends tab fill color

* Fixed scout page e2e tests

* Fixed info page e2e tests

* Fixed login page e2e tests

* fixed onboarding page e2e tests

* fixed profile page e2e tests

* fixed signout e2e tests

* buy nft e2e tests fixed

* Made landing page ssr

* Fixed broken type issues

* Fixed links for builder rewards

* Fixed issues with sunnyawards type check
  • Loading branch information
Devorein authored Dec 3, 2024
1 parent d524b59 commit f29ab2e
Show file tree
Hide file tree
Showing 85 changed files with 1,072 additions and 1,166 deletions.
14 changes: 7 additions & 7 deletions apps/scoutgame/__e2e__/buyNft.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ test.describe('Buy Nft', () => {
currentBalance: 200
});

const builderNft = await mockBuilderNft({
await mockBuilderNft({
builderId: builder.id,
chainId: 10,
contractAddress: getBuilderContractAddress(),
Expand All @@ -45,8 +45,8 @@ test.describe('Buy Nft', () => {
});

await utils.loginAsUserId(builder.id);
await page.goto(`/home`);
await page.waitForURL('**/home');
await page.goto(`/scout`);
await page.waitForURL('**/scout');

await page.goto(`/u/${builder.path}`);
await page.waitForURL(`**/u/${builder.path}`);
Expand Down Expand Up @@ -102,7 +102,7 @@ test.describe('Buy Nft', () => {
currentBalance: 200
});

const builderNft = await mockBuilderNft({
await mockBuilderNft({
builderId: builder.id,
chainId: 10,
contractAddress: getBuilderContractAddress(),
Expand All @@ -118,8 +118,8 @@ test.describe('Buy Nft', () => {
});

await utils.loginAsUserId(builder.id);
await page.goto(`/home`);
await page.waitForURL('**/home');
await page.goto(`/scout`);
await page.waitForURL('**/scout');

await page.goto(`/u/${builder.path}`);
await page.waitForURL(`**/u/${builder.path}`);
Expand All @@ -131,6 +131,6 @@ test.describe('Buy Nft', () => {

// NFT buy button
await expect(page.locator('data-test=purchase-button').first()).toBeDisabled();
expect(await page.locator('data-test=address-error')).toBeVisible();
expect(page.locator('data-test=address-error')).toBeVisible();
});
});
12 changes: 6 additions & 6 deletions apps/scoutgame/__e2e__/infoPage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,29 @@ test.describe('Info page', () => {
});

test.describe('Info page partners', () => {
test('Open Optimism from the home page', async ({ page, homePage, infoPage, utils }) => {
test('Open Optimism from the scout page', async ({ page, scoutPage, infoPage, utils }) => {
const newUser = await mockScout({
onboardedAt: new Date(),
agreedToTermsAt: new Date(),
avatar: 'https://placehold.co/256'
});
await utils.loginAsUserId(newUser.id);

await page.goto('/home');
await homePage.optimismPromoCard.click();
await page.goto('/scout');
await scoutPage.optimismPromoCard.click();

await expect(infoPage.optimismContainer).toBeVisible();
});
test('Open Moxie from the home page', async ({ page, homePage, infoPage, utils }) => {
test('Open Moxie from the scout page', async ({ page, scoutPage, infoPage, utils }) => {
const newUser = await mockScout({
onboardedAt: new Date(),
agreedToTermsAt: new Date(),
avatar: 'https://placehold.co/256'
});
await utils.loginAsUserId(newUser.id);

await page.goto('/home');
await homePage.moxiePromoCard.click();
await page.goto('/scout');
await scoutPage.moxiePromoCard.click();

await expect(infoPage.moxieContainer).toBeVisible();
});
Expand Down
10 changes: 5 additions & 5 deletions apps/scoutgame/__e2e__/loginPage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { mockBuilder } from '@packages/scoutgame/testing/database';
import { expect, test } from './test';

test.describe('Login page', () => {
test('Should redirect logged-in users to home page', async ({ homePage, utils, page }) => {
test('Should redirect logged-in users to scout page', async ({ scoutPage, homePage, utils, page }) => {
const builder = await mockBuilder({});

await page.goto('/');
await page.waitForURL('**/home');
await page.waitForURL('**/');
await expect(homePage.getStartedButton).toBeVisible();

await homePage.getStartedButton.click();
Expand All @@ -22,9 +22,9 @@ test.describe('Login page', () => {

await utils.loginAsUserId(builder.id);

await page.goto('/home');
await page.waitForURL('**/home');
await expect(homePage.container).toBeVisible();
await page.goto('/scout');
await page.waitForURL('**/scout');
await expect(scoutPage.container).toBeVisible();

const userPill = page.locator('data-test=user-menu-pill');
await expect(userPill).toBeVisible();
Expand Down
15 changes: 5 additions & 10 deletions apps/scoutgame/__e2e__/onboarding.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,13 @@ import { expect, test } from './test';
test.describe('Onboarding flow', () => {
test('Open the app to home page and go to Sign In', async ({ page, homePage, loginPage }) => {
await page.goto('/');
// Logged in user should be redirected
await page.waitForURL('**/home');

await expect(homePage.getStartedButton).toBeVisible();

await homePage.getStartedButton.click();

await page.waitForURL('**/login');
await expect(loginPage.container).toBeVisible();
});

test('Save new user preferences and get through onboarding', async ({ welcomePage, homePage, page, utils }) => {
test('Save new user preferences and get through onboarding', async ({ welcomePage, scoutPage, page, utils }) => {
const newUser = await mockScout({
onboardedAt: null,
agreedToTermsAt: null,
Expand Down Expand Up @@ -67,9 +62,9 @@ test.describe('Onboarding flow', () => {

await Promise.all([page.waitForURL('**/welcome/how-it-works'), welcomePage.continueButton.click()]);

await Promise.all([page.waitForURL('**/home', { waitUntil: 'load' }), welcomePage.continueButton.click()]);
await Promise.all([page.waitForURL('**/scout', { waitUntil: 'load' }), welcomePage.continueButton.click()]);

await expect(homePage.container).toBeVisible();
await expect(scoutPage.container).toBeVisible();

// make sure we saved onboarding preferences
const userAfterOnboarding = await prisma.scout.findFirstOrThrow({
Expand Down Expand Up @@ -97,7 +92,7 @@ test.describe('Onboarding flow', () => {
await utils.loginAsUserId(onboardedUser.id);

// Test redirect from home page
await page.goto('/home');
await page.goto('/scout');
await page.waitForURL('**/welcome');
await expect(welcomePage.container).toBeVisible();
});
Expand All @@ -110,7 +105,7 @@ test.describe('Onboarding flow', () => {
await utils.loginAsUserId(newUser.id);

// Test redirect from home page
await page.goto('/home');
await page.goto('/');
await page.waitForURL('**/welcome');
await expect(welcomePage.container).toBeVisible();

Expand Down
4 changes: 1 addition & 3 deletions apps/scoutgame/__e2e__/po/HomePage.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ export class HomePage extends GeneralPageLayout {
constructor(
protected page: Page,
public container = page.locator('data-test=home-page'),
public getStartedButton = page.locator('data-test=get-started-button'),
public optimismPromoCard = page.locator('data-test=promo-card-optimism'),
public moxiePromoCard = page.locator('data-test=promo-card-moxie')
public getStartedButton = page.locator('data-test=get-started-button')
) {
super(page);
}
Expand Down
14 changes: 14 additions & 0 deletions apps/scoutgame/__e2e__/po/ScoutPage.po.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type { Page } from '@playwright/test';

import { GeneralPageLayout } from './GeneralPageLayout.po';

export class ScoutPage extends GeneralPageLayout {
constructor(
protected page: Page,
public container = page.locator('data-test=scout-page'),
public optimismPromoCard = page.locator('data-test=promo-card-optimism'),
public moxiePromoCard = page.locator('data-test=promo-card-moxie')
) {
super(page);
}
}
6 changes: 3 additions & 3 deletions apps/scoutgame/__e2e__/profilePage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@ import { mockBuilder } from '@packages/scoutgame/testing/database';
import { expect, test } from './test';

test.describe('Profile page', () => {
test('Should redirect non-logged in users to login page', async ({ page, loginPage }) => {
test('Should redirect non-logged in users to login page', async ({ page }) => {
await page.goto('/profile');

await page.waitForURL('**/login');
const container = page.locator('data-test=login-page');
await expect(container).toBeVisible();
});

test('An onboarded user can access the profile page', async ({ page, profilePage, utils }) => {
test('An onboarded user can access the profile page', async ({ page, utils }) => {
const builder = await mockBuilder({
agreedToTermsAt: new Date(),
onboardedAt: new Date()
});
await utils.loginAsUserId(builder.id);

await page.goto('/home');
await page.goto('/scout');
const link = page.locator(`data-test=site-navigation >> [href*="/profile"]`).first();
await link.click();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ async function mockLeaderboard() {
return { builder, userWeeklyStats };
}

test.describe('Home page', () => {
test('Open the app and go to profile page as a public user', async ({ page, homePage, utils }) => {
test.describe('Scout page', () => {
test('Open the app and go to profile page as a public user', async ({ page, scoutPage, utils }) => {
const newUser = await mockScout({
onboardedAt: null,
agreedToTermsAt: null,
Expand All @@ -19,11 +19,11 @@ test.describe('Home page', () => {

await page.goto('/');
// Logged in user should be redirected
await page.waitForURL('**/home');
await page.waitForURL('**/scout');

await expect(homePage.container).toBeVisible();
await expect(scoutPage.container).toBeVisible();
});
test('Can navigate to each tab', async ({ page, homePage, utils }) => {
test('Can navigate to each scouts table tab', async ({ page, scoutPage, utils }) => {
// add some mock data
await mockLeaderboard();

Expand All @@ -34,14 +34,20 @@ test.describe('Home page', () => {
});
await utils.loginAsUserId(newUser.id);

await page.goto('/home');
await expect(homePage.container).toBeVisible();
await page.goto('/scout');
await expect(scoutPage.container).toBeVisible();

for (const tab of homePage.tabs) {
await homePage.selectTab(tab);
await expect(homePage.tabView(tab)).toBeVisible();
}
await homePage.selectTab('leaderboard');
await expect(homePage.tabView('leaderboard')).toBeVisible();
// Find the first scouts tab which is not hidden
const scoutsTab = scoutPage.container.locator('data-test=tab-scouts').last();
await scoutsTab.click();

const scoutTable = scoutPage.container.locator('data-test=scouts-table').last();
await expect(scoutTable).toBeVisible();

const newScoutsTab = scoutPage.container.locator('data-test=tab-new-scouts').last();
await newScoutsTab.click();

const newScoutTable = scoutPage.container.locator('data-test=new-scouts-table').last();
await expect(newScoutTable).toBeVisible();
});
});
6 changes: 3 additions & 3 deletions apps/scoutgame/__e2e__/signOut.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { mockBuilder } from '@packages/scoutgame/testing/database';
import { expect, test } from './test';

test.describe('Sign Out', () => {
test('Should be able to sign out', async ({ homePage, utils, page }) => {
test('Should be able to sign out', async ({ utils, page }) => {
const builder = await mockBuilder({});

await utils.loginAsUserId(builder.id);
await page.goto('/home');
await page.waitForURL('**/home');
await page.goto('/scout');
await page.waitForURL('**/scout');

const userPill = page.locator('data-test=user-menu-pill');
await expect(userPill).toBeVisible();
Expand Down
5 changes: 4 additions & 1 deletion apps/scoutgame/__e2e__/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { HomePage } from './po/HomePage.po';
import { InfoPage } from './po/InfoPage.po';
import { LoginPage } from './po/LoginPage.po';
import { ProfilePage } from './po/ProfilePage.po';
import { ScoutPage } from './po/ScoutPage.po';
import { UserPage } from './po/UserPage.po';
import { Utilities } from './po/Utilities.po';
import { WelcomePage } from './po/WelcomePage.po';
Expand All @@ -16,6 +17,7 @@ type Fixtures = {
utils: Utilities;
infoPage: InfoPage;
userPage: UserPage;
scoutPage: ScoutPage;
};

export const test = base.extend<Fixtures>({
Expand Down Expand Up @@ -46,7 +48,8 @@ export const test = base.extend<Fixtures>({
welcomePage: ({ page }, use) => use(new WelcomePage(page)),
utils: ({ page }, use) => use(new Utilities(page)),
infoPage: ({ page }, use) => use(new InfoPage(page)),
userPage: ({ page }, use) => use(new UserPage(page))
userPage: ({ page }, use) => use(new UserPage(page)),
scoutPage: ({ page }, use) => use(new ScoutPage(page))
});

export { chromium, expect } from '@playwright/test';
2 changes: 1 addition & 1 deletion apps/scoutgame/app/(general)/builders-you-know/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const metadata: Metadata = {
export default async function BuildersYouKnow() {
const user = await getUserFromSession();

const redirectPath = '/home';
const redirectPath = '/scout';

if (!user?.farcasterId) {
redirect(redirectPath);
Expand Down
14 changes: 14 additions & 0 deletions apps/scoutgame/app/(general)/builders/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { getCurrentWeek, validateISOWeek } from '@packages/scoutgame/dates';

import { BuildersPage } from 'components/builders/BuildersPage';

export default async function Builders({
searchParams
}: {
searchParams: { [key: string]: string | string[] | undefined };
}) {
const tab = (searchParams.tab as string) || 'leaderboard';
const week = searchParams.week as string | undefined;

return <BuildersPage tab={tab} week={week && validateISOWeek(week) ? week : getCurrentWeek()} />;
}
24 changes: 0 additions & 24 deletions apps/scoutgame/app/(general)/home/page.tsx

This file was deleted.

5 changes: 5 additions & 0 deletions apps/scoutgame/app/(general)/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { LandingPage } from 'components/home/LandingPage';

export default async function Home() {
return <LandingPage />;
}
22 changes: 18 additions & 4 deletions apps/scoutgame/app/(general)/scout/page.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
import { ScoutPage } from 'components/scout/ScoutPage';
import type { BuildersSort } from 'lib/builders/getSortedBuilders';

export default async function Scout({
searchParams
}: {
searchParams: { [key: string]: string | string[] | undefined };
}) {
const sortParam = searchParams.tab;
const sort = (sortParam && typeof sortParam === 'string' ? sortParam : 'top') as BuildersSort;
const scoutSort = (searchParams.scoutSort as string) || 'points';
const builderSort = (searchParams.builderSort as string) || 'rank';
const builderOrder = (searchParams.builderOrder as string) || 'asc';
const scoutOrder = (searchParams.scoutOrder as string) || 'desc';
const scoutTab = (searchParams.scoutTab as string) || 'scouts';
const buildersLayout = (searchParams.buildersLayout as string) || 'table';
const tab = (searchParams.tab as string) || 'scouts';

return <ScoutPage sort={sort} />;
return (
<ScoutPage
scoutSort={scoutSort}
builderSort={builderSort}
scoutOrder={scoutOrder}
builderOrder={builderOrder}
scoutTab={scoutTab}
buildersLayout={buildersLayout}
tab={tab}
/>
);
}
Loading

0 comments on commit f29ab2e

Please sign in to comment.