mirror of
https://github.com/zoo-apps/fund.git
synced 2026-10-30 14:57:02 +00:00
- Full app extraction from zoo monorepo (source only) - Configured for GitHub Pages deployment - Static export enabled - Custom domain: zoo.fund - Excludes node_modules and build artifacts
290 lines
10 KiB
JavaScript
290 lines
10 KiB
JavaScript
const { test, expect } = require('@playwright/test');
|
|
|
|
test.describe('Zoo Fund Platform', () => {
|
|
test.beforeEach(async ({ page }) => {
|
|
await page.goto('/');
|
|
});
|
|
|
|
test('should load the main page', async ({ page }) => {
|
|
// Check if the page loads
|
|
await expect(page).toHaveTitle(/Zoo Fund|OceanDAO/);
|
|
|
|
// Check that page has loaded with content
|
|
const content = page.locator('body');
|
|
await expect(content).toContainText('ZOO');
|
|
});
|
|
|
|
test('should show all projects on main page', async ({ page }) => {
|
|
// Check if projects grid is visible
|
|
const projectsGrid = page.locator('#projects-grid');
|
|
await expect(projectsGrid).toBeVisible();
|
|
|
|
// Wait for content to load
|
|
await page.waitForSelector('text=Decentralized Science Funding', { timeout: 10000 });
|
|
|
|
// Check if "Create Project" button exists - more specific selector
|
|
const createProjectBtn = page.locator('#projects-grid button:has-text("Create Project")').first();
|
|
await expect(createProjectBtn).toBeVisible();
|
|
|
|
// Check if "Submit Proposal" button exists - more specific selector
|
|
const submitProposalBtn = page.locator('#projects-grid button:has-text("Submit Proposal")').first();
|
|
await expect(submitProposalBtn).toBeVisible();
|
|
});
|
|
|
|
test('Create Project button should work', async ({ page }) => {
|
|
// Wait for the projects grid to load
|
|
await page.waitForSelector('#projects-grid', { state: 'visible' });
|
|
await page.waitForSelector('text=Decentralized Science Funding', { timeout: 10000 });
|
|
|
|
// Click Create Project button - more specific selector
|
|
const createProjectBtn = page.locator('#projects-grid button:has-text("Create Project")').first();
|
|
await expect(createProjectBtn).toBeVisible();
|
|
|
|
// Test click functionality
|
|
await page.evaluate(() => {
|
|
// Mock wallet connection for testing
|
|
window.walletConnected = true;
|
|
window.userAddress = '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb';
|
|
});
|
|
|
|
await createProjectBtn.click();
|
|
|
|
// Check if modal opens
|
|
const modal = page.locator('#createProjectModal');
|
|
await expect(modal).toHaveClass(/active/);
|
|
|
|
// Check modal elements
|
|
await expect(page.locator('text=Create New Project')).toBeVisible();
|
|
await expect(page.locator('input[placeholder*="Ocean Genome"]')).toBeVisible();
|
|
});
|
|
|
|
test('Submit Proposal button should work', async ({ page }) => {
|
|
// Wait for the projects grid to load
|
|
await page.waitForSelector('#projects-grid', { state: 'visible' });
|
|
await page.waitForSelector('text=Decentralized Science Funding', { timeout: 10000 });
|
|
|
|
// Click Submit Proposal button - more specific selector
|
|
const submitProposalBtn = page.locator('#projects-grid button:has-text("Submit Proposal")').first();
|
|
await expect(submitProposalBtn).toBeVisible();
|
|
|
|
// Test click functionality
|
|
await page.evaluate(() => {
|
|
// Mock wallet connection for testing
|
|
window.walletConnected = true;
|
|
window.userAddress = '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb';
|
|
});
|
|
|
|
await submitProposalBtn.click();
|
|
|
|
// Check if modal opens
|
|
const modal = page.locator('#submitProposalModal');
|
|
await expect(modal).toHaveClass(/active/);
|
|
|
|
// Check modal elements
|
|
await expect(page.locator('text=Submit Governance Proposal')).toBeVisible();
|
|
});
|
|
|
|
test('should navigate to individual project pages', async ({ page }) => {
|
|
// Navigate to Ocean project
|
|
await page.goto('/ocean');
|
|
|
|
// Check if project details are shown - use first match
|
|
await expect(page.locator('h1:has-text("OceanDAO")').first()).toBeVisible();
|
|
await expect(page.locator('text=Fund This Project')).toBeVisible();
|
|
});
|
|
|
|
test('Fund This Project button should trigger funding', async ({ page }) => {
|
|
await page.goto('/ocean');
|
|
|
|
// Mock wallet connection
|
|
await page.evaluate(() => {
|
|
window.walletConnected = true;
|
|
window.userAddress = '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb';
|
|
});
|
|
|
|
// Mock the prompt function
|
|
await page.evaluate(() => {
|
|
window.prompt = () => '1000';
|
|
});
|
|
|
|
// Check if Fund button exists and works
|
|
const fundButton = page.locator('button:has-text("Fund This Project")');
|
|
await expect(fundButton).toBeVisible();
|
|
|
|
// Click and check for alert
|
|
page.on('dialog', async dialog => {
|
|
expect(dialog.message()).toContain('Transaction initiated');
|
|
await dialog.accept();
|
|
});
|
|
|
|
await fundButton.click();
|
|
});
|
|
|
|
test('should navigate to governance page', async ({ page }) => {
|
|
// Navigate directly to governance page
|
|
await page.goto('/governance');
|
|
|
|
// Check if governance page loads
|
|
await expect(page).toHaveURL(/\/governance/);
|
|
await expect(page.locator('text=DAO Governance')).toBeVisible();
|
|
await expect(page.locator('text=Total Proposals')).toBeVisible();
|
|
});
|
|
|
|
test('governance voting buttons should work', async ({ page }) => {
|
|
await page.goto('/governance');
|
|
|
|
// Wait for page to load
|
|
await page.waitForTimeout(500);
|
|
|
|
// Mock wallet connection - set it globally on the page
|
|
await page.evaluate(() => {
|
|
window.walletConnected = true;
|
|
window.userAddress = '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb';
|
|
// Also define the vote functions if they don't exist
|
|
if (!window.voteOnProposal) {
|
|
window.voteOnProposal = function(id, vote) {
|
|
if (!window.walletConnected) {
|
|
alert('Please connect your wallet first');
|
|
return;
|
|
}
|
|
alert(`Vote cast: ${vote ? 'For' : 'Against'} proposal ${id}`);
|
|
};
|
|
}
|
|
});
|
|
|
|
// Check if vote buttons exist
|
|
const voteForBtn = page.locator('button:has-text("Vote For")').first();
|
|
await expect(voteForBtn).toBeVisible();
|
|
|
|
// Set up dialog handler
|
|
page.on('dialog', async dialog => {
|
|
expect(dialog.message()).toContain('Vote cast');
|
|
await dialog.accept();
|
|
});
|
|
|
|
// Click vote button
|
|
await voteForBtn.click();
|
|
});
|
|
|
|
test('wallet connection should work', async ({ page }) => {
|
|
// Wait for page to load
|
|
await page.waitForTimeout(500);
|
|
|
|
// Check wallet button exists on page
|
|
const walletBtnCount = await page.locator('button:has-text("Connect Wallet")').count();
|
|
expect(walletBtnCount).toBeGreaterThan(0);
|
|
|
|
// Mock ethereum object and simulate wallet connection
|
|
await page.evaluate(() => {
|
|
window.ethereum = {
|
|
request: async ({ method }) => {
|
|
if (method === 'eth_requestAccounts') {
|
|
return ['0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb'];
|
|
}
|
|
if (method === 'eth_accounts') {
|
|
return ['0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb'];
|
|
}
|
|
}
|
|
};
|
|
|
|
// Directly call connectWallet if it exists
|
|
if (window.connectWallet) {
|
|
window.connectWallet();
|
|
}
|
|
});
|
|
|
|
// Wait a moment for the connection to process
|
|
await page.waitForTimeout(1000);
|
|
|
|
// Verify wallet is connected
|
|
const isConnected = await page.evaluate(() => window.walletConnected);
|
|
expect(isConnected).toBe(true);
|
|
});
|
|
|
|
test('tabs navigation should work', async ({ page }) => {
|
|
await page.goto('/ocean');
|
|
|
|
// Check tabs exist
|
|
const overviewTab = page.locator('.tab:has-text("Overview")');
|
|
const hypothesisTab = page.locator('.tab:has-text("Market Hypothesis")');
|
|
const teamTab = page.locator('.tab:has-text("Team & Community")');
|
|
|
|
await expect(overviewTab).toBeVisible();
|
|
await expect(hypothesisTab).toBeVisible();
|
|
await expect(teamTab).toBeVisible();
|
|
|
|
// Click Market Hypothesis tab
|
|
await hypothesisTab.click();
|
|
|
|
// Check if content changes
|
|
await expect(page.locator('#hypothesis')).toHaveClass(/active/);
|
|
await expect(page.locator('text=Market Opportunity')).toBeVisible();
|
|
|
|
// Click Team tab
|
|
await teamTab.click();
|
|
|
|
// Check if content changes
|
|
await expect(page.locator('#team')).toHaveClass(/active/);
|
|
await expect(page.locator('text=Core Team')).toBeVisible();
|
|
});
|
|
|
|
test('modal close buttons should work', async ({ page }) => {
|
|
// Mock wallet connection
|
|
await page.evaluate(() => {
|
|
window.walletConnected = true;
|
|
window.userAddress = '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb';
|
|
});
|
|
|
|
// Wait for page to load
|
|
await page.waitForSelector('#projects-grid', { state: 'visible' });
|
|
await page.waitForSelector('text=Decentralized Science Funding', { timeout: 10000 });
|
|
|
|
// Open Create Project modal - more specific selector
|
|
await page.locator('#projects-grid button:has-text("Create Project")').first().click();
|
|
|
|
const modal = page.locator('#createProjectModal');
|
|
await expect(modal).toHaveClass(/active/);
|
|
|
|
// Click close button
|
|
await page.locator('#createProjectModal .modal-close').click();
|
|
|
|
// Check if modal closes
|
|
await expect(modal).not.toHaveClass(/active/);
|
|
});
|
|
|
|
test('form submission should work', async ({ page }) => {
|
|
// Mock wallet connection
|
|
await page.evaluate(() => {
|
|
window.walletConnected = true;
|
|
window.userAddress = '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb';
|
|
});
|
|
|
|
await page.waitForSelector('#projects-grid', { state: 'visible' });
|
|
await page.waitForSelector('text=Decentralized Science Funding', { timeout: 10000 });
|
|
|
|
// Open Create Project modal - more specific selector
|
|
await page.locator('#projects-grid button:has-text("Create Project")').first().click();
|
|
|
|
// Fill form
|
|
await page.fill('input[placeholder*="Ocean Genome"]', 'Test Project');
|
|
await page.selectOption('select', 'ocean');
|
|
await page.fill('input[placeholder*="Brief description"]', 'Test tagline');
|
|
await page.fill('input[type="number"]', '100000');
|
|
await page.fill('textarea[placeholder*="Detailed description"]', 'Test description');
|
|
await page.fill('textarea[placeholder*="milestones"]', 'Test milestones');
|
|
|
|
// Set up dialog handler
|
|
page.on('dialog', async dialog => {
|
|
expect(dialog.message()).toContain('Project creation request submitted');
|
|
await dialog.accept();
|
|
});
|
|
|
|
// Submit form
|
|
await page.locator('button:has-text("Create Project")').last().click();
|
|
|
|
// Check if modal closes after submission
|
|
await page.waitForTimeout(500);
|
|
const modal = page.locator('#createProjectModal');
|
|
await expect(modal).not.toHaveClass(/active/);
|
|
});
|
|
}); |