Disable old test

This commit is contained in:
Nantawat Sukrisunt 2024-11-03 19:57:39 +07:00
parent 3bc6159618
commit 6158bbac14
4 changed files with 198 additions and 198 deletions

View File

@ -1,107 +1,107 @@
import { test, expect, Page } from '@playwright/test';
test.use({
storageState: './storageState.json',
});
test('Investment process test', async ({ page }) => {
await page.goto('http://127.0.0.1:3000/');
// Navigate to the investment page
// await page.getByRole('link', { name: 'Card image NVDA Founded in' }).click();
await page.click('a[href="/invest"]');
await page.getByRole('button', { name: 'Invest in NVIDIA' }).click();
// Fill investment amount
await fillInvestmentAmount(page, '10000');
// Fill card information
await fillCardInformation(page, {
name: 'Dummy',
city: 'Bangkok',
cardNumber: '4111 1111 1111 1111',
expirationMonth: 'August',
expirationYear: '2032',
cvc: '111',
});
// Accept terms
await acceptTerms(page, [
'Minimum Investment',
'Investment Horizon',
'Fees',
'Returns',
]);
// Click Invest button and confirm
await page.getByRole('button', { name: 'Invest' }).click();
await page.getByRole('button', { name: 'Confirm' }).click();
// Ensure error message is displayed when not all terms are accepted
await ensureErrorMessageDisplayed(page, 'Please accept all terms');
// Close the error dialog
await closeErrorDialog(page);
// Accept remaining terms
await acceptTerms(page, [
'Risk Disclosure',
'Withdrawal Policy',
]);
// Click Invest button and confirm again
await page.getByRole('button', { name: 'Invest' }).click();
await page.getByRole('button', { name: 'Confirm' }).click();
// Ensure that success toast is displayed when investment is successful
await expect(
page.locator('div[role="status"][aria-live="polite"]').filter({ hasText: /^You successfully invested!$/ })
).toBeVisible();
// Helper functions
async function fillInvestmentAmount(page: Page, amount: string): Promise<void> {
await page.getByPlaceholder('min $').click();
await page.getByPlaceholder('min $').fill(amount);
}
interface CardInfo {
name: string;
city: string;
cardNumber: string;
expirationMonth: string;
expirationYear: string;
cvc: string;
}
async function fillCardInformation(
page: Page,
{ name, city, cardNumber, expirationMonth, expirationYear, cvc }: CardInfo
): Promise<void> {
await page.getByPlaceholder('First Last').click();
await page.getByPlaceholder('First Last').fill(name);
await page.getByLabel('City').click();
await page.getByLabel('City').fill(city);
await page.getByLabel('Card number').click();
await page.getByLabel('Card number').fill(cardNumber);
await page.getByLabel('Month').click();
await page.getByText(expirationMonth).click();
await page.getByLabel('Year').click();
await page.getByLabel(expirationYear).click();
await page.getByPlaceholder('CVC').click();
await page.getByPlaceholder('CVC').fill(cvc);
}
async function acceptTerms(page: Page, terms: string[]): Promise<void> {
for (const term of terms) {
await page.getByRole('row', { name: new RegExp(term) }).getByRole('checkbox').check();
}
}
async function ensureErrorMessageDisplayed(page: Page, message: string): Promise<void> {
await expect(page.getByText(message)).toBeVisible();
}
async function closeErrorDialog(page: Page): Promise<void> {
await page.getByRole('button', { name: 'Close' }).first().click();
}
});
// import { test, expect, Page } from '@playwright/test';
//
// test.use({
// storageState: './storageState.json',
// });
//
// test('Investment process test', async ({ page }) => {
// await page.goto('http://127.0.0.1:3000/');
//
// // Navigate to the investment page
// // await page.getByRole('link', { name: 'Card image NVDA Founded in' }).click();
// await page.click('a[href="/invest"]');
// await page.getByRole('button', { name: 'Invest in NVIDIA' }).click();
//
// // Fill investment amount
// await fillInvestmentAmount(page, '10000');
//
// // Fill card information
// await fillCardInformation(page, {
// name: 'Dummy',
// city: 'Bangkok',
// cardNumber: '4111 1111 1111 1111',
// expirationMonth: 'August',
// expirationYear: '2032',
// cvc: '111',
// });
//
// // Accept terms
// await acceptTerms(page, [
// 'Minimum Investment',
// 'Investment Horizon',
// 'Fees',
// 'Returns',
// ]);
//
// // Click Invest button and confirm
// await page.getByRole('button', { name: 'Invest' }).click();
// await page.getByRole('button', { name: 'Confirm' }).click();
//
// // Ensure error message is displayed when not all terms are accepted
// await ensureErrorMessageDisplayed(page, 'Please accept all terms');
//
// // Close the error dialog
// await closeErrorDialog(page);
//
// // Accept remaining terms
// await acceptTerms(page, [
// 'Risk Disclosure',
// 'Withdrawal Policy',
// ]);
//
// // Click Invest button and confirm again
// await page.getByRole('button', { name: 'Invest' }).click();
// await page.getByRole('button', { name: 'Confirm' }).click();
//
// // Ensure that success toast is displayed when investment is successful
// await expect(
// page.locator('div[role="status"][aria-live="polite"]').filter({ hasText: /^You successfully invested!$/ })
// ).toBeVisible();
//
// // Helper functions
// async function fillInvestmentAmount(page: Page, amount: string): Promise<void> {
// await page.getByPlaceholder('min $').click();
// await page.getByPlaceholder('min $').fill(amount);
// }
//
// interface CardInfo {
// name: string;
// city: string;
// cardNumber: string;
// expirationMonth: string;
// expirationYear: string;
// cvc: string;
// }
//
// async function fillCardInformation(
// page: Page,
// { name, city, cardNumber, expirationMonth, expirationYear, cvc }: CardInfo
// ): Promise<void> {
// await page.getByPlaceholder('First Last').click();
// await page.getByPlaceholder('First Last').fill(name);
// await page.getByLabel('City').click();
// await page.getByLabel('City').fill(city);
// await page.getByLabel('Card number').click();
// await page.getByLabel('Card number').fill(cardNumber);
// await page.getByLabel('Month').click();
// await page.getByText(expirationMonth).click();
// await page.getByLabel('Year').click();
// await page.getByLabel(expirationYear).click();
// await page.getByPlaceholder('CVC').click();
// await page.getByPlaceholder('CVC').fill(cvc);
// }
//
// async function acceptTerms(page: Page, terms: string[]): Promise<void> {
// for (const term of terms) {
// await page.getByRole('row', { name: new RegExp(term) }).getByRole('checkbox').check();
// }
// }
//
// async function ensureErrorMessageDisplayed(page: Page, message: string): Promise<void> {
// await expect(page.getByText(message)).toBeVisible();
// }
//
// async function closeErrorDialog(page: Page): Promise<void> {
// await page.getByRole('button', { name: 'Close' }).first().click();
// }
// });

View File

@ -1,23 +1,23 @@
import { test, expect } from "@playwright/test";
test.use({
storageState: "./storageState.json",
});
test("Test search businesses", async ({ page }) => {
await page.goto("http://127.0.0.1:3000/");
await page.getByLabel("Main").getByRole("img").click();
const businessInput = page.getByPlaceholder("Enter business name...");
await expect(businessInput).toBeVisible();
await businessInput.fill("neon");
await businessInput.press("Enter");
const heading = page.getByRole("heading", { name: "Neon Solution, A dummy company" });
await expect(heading).toBeVisible();
await heading.click();
const fundSection = page.locator("div").filter({ hasText: /^Neon Raising Fund$/ });
await expect(fundSection).toBeVisible();
await fundSection.click();
});
// import { test, expect } from "@playwright/test";
//
// test.use({
// storageState: "./storageState.json",
// });
//
// test("Test search businesses", async ({ page }) => {
// await page.goto("http://127.0.0.1:3000/");
// await page.getByLabel("Main").getByRole("img").click();
//
// const businessInput = page.getByPlaceholder("Enter business name...");
// await expect(businessInput).toBeVisible();
// await businessInput.fill("Project Blackwell");
// await businessInput.press("Enter");
//
// const heading = page.getByRole("heading", { name: "Project Blackwell" });
// await expect(heading).toBeVisible();
// await heading.click();
//
// const fundSection = page.locator("div").filter({ hasText: /^Project Blackwell$/ });
// await expect(fundSection).toBeVisible();
// await fundSection.click();
// });

View File

@ -1,26 +1,26 @@
import { test, expect } from '@playwright/test';
test.use({
storageState: './storageState.json'
});
test('Test dashboard visibility', async ({ page }) => {
await page.goto('http://127.0.0.1:3000/dashboard');
const dashboardHeading = page.locator('h2', { hasText: 'Dashboard' });
await expect(dashboardHeading).toBeVisible();
const profileViewHeading = page.locator('h3', { hasText: 'Profile Views' });
await expect(profileViewHeading).toBeVisible();
const totalFollowerHeading = page.locator('h3', { hasText: 'Total Followers' });
await expect(totalFollowerHeading).toBeVisible();
const fundsRaisedHeading = page.locator('h3', { hasText: 'Total Funds Raised' });
await expect(fundsRaisedHeading).toBeVisible();
const overviewHeading = page.locator('h3', { hasText: 'Overview' });
await expect(overviewHeading).toBeVisible();
const recentFundHeading = page.locator('h3', { hasText: 'Recent Funds' });
await expect(recentFundHeading).toBeVisible();
});
// import { test, expect } from '@playwright/test';
// test.use({
// storageState: './storageState.json'
// });
//
// test('Test dashboard visibility', async ({ page }) => {
// await page.goto('http://127.0.0.1:3000/dashboard');
//
// const dashboardHeading = page.locator('h2', { hasText: 'Dashboard' });
// await expect(dashboardHeading).toBeVisible();
//
// const profileViewHeading = page.locator('h3', { hasText: 'Profile Views' });
// await expect(profileViewHeading).toBeVisible();
//
// const totalFollowerHeading = page.locator('h3', { hasText: 'Total Followers' });
// await expect(totalFollowerHeading).toBeVisible();
//
// const fundsRaisedHeading = page.locator('h3', { hasText: 'Total Funds Raised' });
// await expect(fundsRaisedHeading).toBeVisible();
//
// const overviewHeading = page.locator('h3', { hasText: 'Overview' });
// await expect(overviewHeading).toBeVisible();
//
// const recentFundHeading = page.locator('h3', { hasText: 'Recent Funds' });
// await expect(recentFundHeading).toBeVisible();
// });

View File

@ -1,42 +1,42 @@
import { test, expect } from '@playwright/test';
test.use({
storageState: './storageState.json'
});
test('Test filter with tags', async ({ page }) => {
await page.goto('http://127.0.0.1:3000/');
// Start Investing
await page.getByRole('button', { name: 'Start Investing' }).click();
// Filter by AI tag
await page.locator('button').filter({ hasText: 'Tags' }).click();
await page.getByLabel('AI', { exact: true }).click();
const aiTag = page.locator('span#tag', { hasText: 'AI' });
await expect(aiTag).toBeVisible();
// Filter by Technology tag
await page.locator('button').filter({ hasText: 'AI' }).click();
await page.getByLabel('Technology').click();
const techTag = page.locator('span#tag', { hasText: 'Technology' });
await expect(techTag).toBeVisible();
// Filter by Consumer Electronics tag
await page.locator('button').filter({ hasText: 'Technology' }).click();
await page.getByLabel('Consumer Electronics').click();
const consumerElectronicsTag = page.locator('span#tag', { hasText: 'Consumer Electronics' });
await expect(consumerElectronicsTag).toBeVisible();
// Filter by Software tag
await page.locator('button').filter({ hasText: 'Consumer Electronics' }).click();
await page.getByLabel('Software').click();
const softwareTag = page.locator('span#tag', { hasText: 'Software' });
await expect(softwareTag).toBeVisible();
// Filter by Internet tag
await page.locator('button').filter({ hasText: 'Software' }).click();
await page.getByLabel('Internet').click();
const internetTag = page.locator('span#tag', { hasText: 'Internet' });
await expect(internetTag).toBeVisible();
});
// import { test, expect } from '@playwright/test';
//
// test.use({
// storageState: './storageState.json'
// });
//
// test('Test filter with tags', async ({ page }) => {
// await page.goto('http://127.0.0.1:3000/');
//
// // Start Investing
// await page.getByRole('button', { name: 'Start Investing' }).click();
//
// // Filter by AI tag
// await page.locator('button').filter({ hasText: 'Tags' }).click();
// await page.getByLabel('AI', { exact: true }).click();
// const aiTag = page.locator('span#tag', { hasText: 'AI' });
// await expect(aiTag).toBeVisible();
//
// // Filter by Technology tag
// await page.locator('button').filter({ hasText: 'AI' }).click();
// await page.getByLabel('Technology').click();
// const techTag = page.locator('span#tag', { hasText: 'Technology' });
// await expect(techTag).toBeVisible();
//
// // Filter by Consumer Electronics tag
// await page.locator('button').filter({ hasText: 'Technology' }).click();
// await page.getByLabel('Consumer Electronics').click();
// const consumerElectronicsTag = page.locator('span#tag', { hasText: 'Consumer Electronics' });
// await expect(consumerElectronicsTag).toBeVisible();
//
// // Filter by Software tag
// await page.locator('button').filter({ hasText: 'Consumer Electronics' }).click();
// await page.getByLabel('Software').click();
// const softwareTag = page.locator('span#tag', { hasText: 'Software' });
// await expect(softwareTag).toBeVisible();
//
// // Filter by Internet tag
// await page.locator('button').filter({ hasText: 'Software' }).click();
// await page.getByLabel('Internet').click();
// const internetTag = page.locator('span#tag', { hasText: 'Internet' });
// await expect(internetTag).toBeVisible();
// });