mirror of
https://github.com/Sosokker/B2D-Ventures.git
synced 2025-12-19 05:54:06 +01:00
Merge branch 'back-end' of https://github.com/Sosokker/B2D-Ventures into back-end
This commit is contained in:
commit
7a0fd4214f
29
.env.example
29
.env.example
@ -1,18 +1,25 @@
|
|||||||
|
# Supabase Configuration
|
||||||
PROJECT_ID=supabase-project-id
|
PROJECT_ID=supabase-project-id
|
||||||
NEXT_PUBLIC_SUPABASE_URL=supabase-project-url
|
NEXT_PUBLIC_SUPABASE_URL=supabase-project-url
|
||||||
NEXT_PUBLIC_SUPABASE_URL_SOURCE = supabase-project-url-without-https:// (ex: https://example.com -> example.com)
|
NEXT_PUBLIC_SUPABASE_URL_SOURCE=supabase-project-url-without-https (e.g., https://example.com -> example.com)
|
||||||
NEXT_PUBLIC_SUPABASE_ANON_KEY=supabase-anon-key
|
NEXT_PUBLIC_SUPABASE_ANON_KEY=supabase-anon-key
|
||||||
NEXT_PUBLIC_AUTH_GOOGLE_ID=google-auth-token
|
SUPABASE_SERVICE_ROLE_KEY=supabase-service-role-key
|
||||||
NEXT_PUBLIC_AUTH_GOOGLE_SECRET=google-secret-key
|
|
||||||
NEXT_PUBLIC_TEST_URL=url-to-run-testing-server
|
# Google Authentication Configuration
|
||||||
|
NEXT_PUBLIC_AUTH_GOOGLE_ID=google-auth-client-id
|
||||||
|
NEXT_PUBLIC_AUTH_GOOGLE_SECRET=google-auth-client-secret
|
||||||
|
|
||||||
|
# Stripe Configuration
|
||||||
NEXT_PUBLIC_STRIPE_PUBLIC_KEY=stripe-public-key
|
NEXT_PUBLIC_STRIPE_PUBLIC_KEY=stripe-public-key
|
||||||
STRIPE_SECRET_KEY=stripe-secret-key
|
STRIPE_SECRET_KEY=stripe-secret-key
|
||||||
SUPABASE_SERVICE_ROLE_KEY=superbase-service-role-key
|
|
||||||
|
|
||||||
# Admin User Credentials
|
# Testing Server URL
|
||||||
NEXT_PUBLIC_ADMIN_EMAIL=supabase-dummy-admin-email-for-testing
|
NEXT_PUBLIC_TEST_URL=testing-server-url
|
||||||
NEXT_PUBLIC_ADMIN_PASSWORD=supabase-dummy-admin-password-for-testing
|
|
||||||
|
|
||||||
# Regular User Credentials
|
# Admin User Credentials (Must exist in the real database)
|
||||||
NEXT_PUBLIC_USER_EMAIL=supabase-dummy-user-email-for-testing
|
NEXT_PUBLIC_ADMIN_EMAIL=admin@example.com
|
||||||
NEXT_PUBLIC_USER_PASSWORD=supabase-dummy-user-password-for-testing
|
NEXT_PUBLIC_ADMIN_PASSWORD=admin-secure-password
|
||||||
|
|
||||||
|
# Temporary Regular User Credentials for Testing (Delete after test completion)
|
||||||
|
NEXT_PUBLIC_TEST_USER_EMAIL=test-user@example.com
|
||||||
|
NEXT_PUBLIC_TEST_USER_PASSWORD=test-user-password
|
||||||
|
|||||||
@ -1,18 +1,25 @@
|
|||||||
|
# Supabase Configuration
|
||||||
PROJECT_ID=supabase-project-id
|
PROJECT_ID=supabase-project-id
|
||||||
NEXT_PUBLIC_SUPABASE_URL=supabase-project-url
|
NEXT_PUBLIC_SUPABASE_URL=supabase-project-url
|
||||||
NEXT_PUBLIC_SUPABASE_URL_SOURCE = supabase-project-url-without-https:// (ex: https://example.com -> example.com)
|
NEXT_PUBLIC_SUPABASE_URL_SOURCE=supabase-project-url-without-https (e.g., https://example.com -> example.com)
|
||||||
NEXT_PUBLIC_SUPABASE_ANON_KEY=supabase-anon-key
|
NEXT_PUBLIC_SUPABASE_ANON_KEY=supabase-anon-key
|
||||||
NEXT_PUBLIC_AUTH_GOOGLE_ID=google-auth-token
|
SUPABASE_SERVICE_ROLE_KEY=supabase-service-role-key
|
||||||
NEXT_PUBLIC_AUTH_GOOGLE_SECRET=google-secret-key
|
|
||||||
NEXT_PUBLIC_TEST_URL=url-to-run-testing-server
|
# Google Authentication Configuration
|
||||||
|
NEXT_PUBLIC_AUTH_GOOGLE_ID=google-auth-client-id
|
||||||
|
NEXT_PUBLIC_AUTH_GOOGLE_SECRET=google-auth-client-secret
|
||||||
|
|
||||||
|
# Stripe Configuration
|
||||||
NEXT_PUBLIC_STRIPE_PUBLIC_KEY=stripe-public-key
|
NEXT_PUBLIC_STRIPE_PUBLIC_KEY=stripe-public-key
|
||||||
STRIPE_SECRET_KEY=stripe-secret-key
|
STRIPE_SECRET_KEY=stripe-secret-key
|
||||||
SUPABASE_SERVICE_ROLE_KEY=superbase-service-role-key
|
|
||||||
|
|
||||||
# Admin User Credentials
|
# Testing Server URL
|
||||||
NEXT_PUBLIC_ADMIN_EMAIL=supabase-dummy-admin-email-for-testing
|
NEXT_PUBLIC_TEST_URL=testing-server-url
|
||||||
NEXT_PUBLIC_ADMIN_PASSWORD=supabase-dummy-admin-password-for-testing
|
|
||||||
|
|
||||||
# Regular User Credentials
|
# Admin User Credentials (Must exist in the real database)
|
||||||
NEXT_PUBLIC_USER_EMAIL=supabase-dummy-user-email-for-testing
|
NEXT_PUBLIC_ADMIN_EMAIL=admin@example.com
|
||||||
NEXT_PUBLIC_USER_PASSWORD=supabase-dummy-user-password-for-testing
|
NEXT_PUBLIC_ADMIN_PASSWORD=admin-secure-password
|
||||||
|
|
||||||
|
# Temporary Regular User Credentials for Testing (Delete after test completion)
|
||||||
|
NEXT_PUBLIC_TEST_USER_EMAIL=test-user@example.com
|
||||||
|
NEXT_PUBLIC_TEST_USER_PASSWORD=test-user-password
|
||||||
|
|||||||
@ -13,6 +13,7 @@ dotenv.config({ path: path.resolve(__dirname, '.env') });
|
|||||||
*/
|
*/
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
globalSetup: require.resolve('./test_util/global-setup'),
|
globalSetup: require.resolve('./test_util/global-setup'),
|
||||||
|
globalTeardown: require.resolve('./test_util/global-teardown'),
|
||||||
testDir: './tests',
|
testDir: './tests',
|
||||||
/* Run tests in files in parallel */
|
/* Run tests in files in parallel */
|
||||||
fullyParallel: true,
|
fullyParallel: true,
|
||||||
@ -27,7 +28,7 @@ export default defineConfig({
|
|||||||
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
|
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
|
||||||
use: {
|
use: {
|
||||||
/* Base URL to use in actions like `await page.goto('/')`. */
|
/* Base URL to use in actions like `await page.goto('/')`. */
|
||||||
baseURL: 'http://127.0.0.1:3000',
|
baseURL: process.env.BASE_URL,
|
||||||
|
|
||||||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
||||||
trace: 'on-first-retry',
|
trace: 'on-first-retry',
|
||||||
@ -39,19 +40,21 @@ export default defineConfig({
|
|||||||
projects: [
|
projects: [
|
||||||
{
|
{
|
||||||
name: 'chromium',
|
name: 'chromium',
|
||||||
use: { ...devices['Desktop Chrome'] },
|
use: { ...devices['Desktop Chrome'],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
name: 'firefox',
|
name: 'firefox',
|
||||||
use: { ...devices['Desktop Firefox'],
|
use: { ...devices['Desktop Firefox'],
|
||||||
storageState:"./storageState.json"
|
storageState:"./storageState.json",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
name: 'webkit',
|
name: 'webkit',
|
||||||
use: { ...devices['Desktop Safari'] },
|
use: { ...devices['Desktop Safari'] ,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
/* Test against mobile viewports. */
|
/* Test against mobile viewports. */
|
||||||
|
|||||||
@ -36,7 +36,7 @@ export async function deleteUserByEmail(email: string): Promise<boolean> {
|
|||||||
console.error(`UID is null`);
|
console.error(`UID is null`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const data = await deleteUser(uid);
|
await deleteUser(uid);
|
||||||
console.log(`Successfully delete user with email: ${email}`);
|
console.log(`Successfully delete user with email: ${email} and UID: ${uid}`);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1,24 +1,24 @@
|
|||||||
import { firefox, FullConfig } from '@playwright/test';
|
import { firefox, FullConfig } from '@playwright/test';
|
||||||
|
|
||||||
async function globalSetup(config: FullConfig) {
|
async function globalSetup(config: FullConfig) {
|
||||||
const email = process.env.NEXT_PUBLIC_DUMMY_EMAIL;
|
console.log('globalizing...');
|
||||||
const password = process.env.NEXT_PUBLIC_DUMMY_PASSWORD;
|
const email = process.env.NEXT_PUBLIC_TEST_USER_EMAIL;
|
||||||
const baseUrl = 'http://127.0.0.1:3000';
|
const password = process.env.NEXT_PUBLIC_TEST_USER_PASSWORD;
|
||||||
|
|
||||||
if (!email || !password) {
|
if (!email || !password) {
|
||||||
throw new Error('NEXT_PUBLIC_DUMMY_EMAIL and NEXT_PUBLIC_DUMMY_PASSWORD must be set');
|
throw new Error('NEXT_PUBLIC_TEST_USER_EMAIL and NEXT_PUBLIC_TEST_USER_PASSWORD must be set');
|
||||||
}
|
}
|
||||||
|
|
||||||
const browser = await firefox.launch();
|
const browser = await firefox.launch();
|
||||||
const page = await browser.newPage();
|
const page = await browser.newPage();
|
||||||
await page.goto(baseUrl + '/auth');
|
|
||||||
|
console.log('signing up user...');
|
||||||
|
await page.goto(config.projects[0].use.baseURL + '/auth/signup');
|
||||||
await page.fill('id=email', email);
|
await page.fill('id=email', email);
|
||||||
await page.fill('id=password', password);
|
await page.fill('id=password', password);
|
||||||
await Promise.all([
|
await page.fill('id=confirmPassword', password);
|
||||||
page.waitForURL(baseUrl),
|
await page.click('id=signup')
|
||||||
page.click('id=login')
|
|
||||||
]);
|
|
||||||
await page.context().storageState({ path: 'storageState.json' });
|
|
||||||
await browser.close();
|
await browser.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
13
test_util/global-teardown.ts
Normal file
13
test_util/global-teardown.ts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import { deleteUserByEmail } from './deleteUser';
|
||||||
|
|
||||||
|
async function globalTeardown() {
|
||||||
|
const email = process.env.NEXT_PUBLIC_TEST_USER_EMAIL;
|
||||||
|
|
||||||
|
if (!email) {
|
||||||
|
throw new Error('NEXT_PUBLIC_TEST_USER_EMAIL must be set');
|
||||||
|
}
|
||||||
|
console.log('deleting user...');
|
||||||
|
await deleteUserByEmail(email);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default globalTeardown;
|
||||||
@ -1,11 +1,9 @@
|
|||||||
// dropdownUtils.ts
|
|
||||||
import { Page, Locator } from '@playwright/test';
|
import { Page, Locator } from '@playwright/test';
|
||||||
|
|
||||||
export const selectFirstOption = async (page: Page, triggerLocator: Locator) => {
|
export const selectFirstOption = async (page: Page, triggerLocator: Locator) => {
|
||||||
let selected = false
|
let selected = false
|
||||||
while (!selected) {
|
while (!selected) {
|
||||||
try {
|
try {
|
||||||
await triggerLocator.hover();
|
|
||||||
await triggerLocator.click({ force: true });
|
await triggerLocator.click({ force: true });
|
||||||
|
|
||||||
// Select the first available option
|
// Select the first available option
|
||||||
@ -16,9 +14,7 @@ export const selectFirstOption = async (page: Page, triggerLocator: Locator) =>
|
|||||||
const optionText = await firstOption.textContent();
|
const optionText = await firstOption.textContent();
|
||||||
console.log(`${optionText}`);
|
console.log(`${optionText}`);
|
||||||
await firstOption.click();
|
await firstOption.click();
|
||||||
console.log("Selected.");
|
selected = true
|
||||||
|
|
||||||
selected = true;
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("Retrying as the combobox disappeared.");
|
console.log("Retrying as the combobox disappeared.");
|
||||||
await page.waitForTimeout(100);
|
await page.waitForTimeout(100);
|
||||||
|
|||||||
26
tests/helpers/login.ts
Normal file
26
tests/helpers/login.ts
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
import { Page } from '@playwright/test';
|
||||||
|
|
||||||
|
export const login = async (page: Page, role: 'user' | 'admin') => {
|
||||||
|
const email = role === 'user' ? process.env.NEXT_PUBLIC_TEST_USER_EMAIL : process.env.NEXT_PUBLIC_ADMIN_EMAIL;
|
||||||
|
const password = role === 'user' ? process.env.NEXT_PUBLIC_TEST_USER_PASSWORD : process.env.NEXT_PUBLIC_ADMIN_PASSWORD;
|
||||||
|
|
||||||
|
if (!email || !password) {
|
||||||
|
throw new Error(`${role === 'user' ? 'User' : 'Admin'} credentials must be set`);
|
||||||
|
}
|
||||||
|
|
||||||
|
await page.goto('/');
|
||||||
|
const isLoginPage = await page.locator('id=login').isVisible();
|
||||||
|
if (!isLoginPage) {
|
||||||
|
console.log(`Logging out current session...`);
|
||||||
|
await page.evaluate(() => {
|
||||||
|
localStorage.clear();
|
||||||
|
sessionStorage.clear();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`Logging in as ${role}...`);
|
||||||
|
await page.goto('/auth');
|
||||||
|
await page.fill('id=email', email);
|
||||||
|
await page.fill('id=password', password);
|
||||||
|
await page.click('id=login');
|
||||||
|
};
|
||||||
20
tests/test-01-business-apply.spec.ts
Normal file
20
tests/test-01-business-apply.spec.ts
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import { test } from "@playwright/test";
|
||||||
|
import { login } from "./helpers/login";
|
||||||
|
import { selectFirstOption } from "./helpers/dropdownUtils";
|
||||||
|
|
||||||
|
test("test", async ({ page }) => {
|
||||||
|
await login(page, "user");
|
||||||
|
await page.getByRole('button', { name: 'Businesses' }).hover();
|
||||||
|
await page.getByRole("link", { name: "Business Apply to raise on on" }).click();
|
||||||
|
|
||||||
|
await selectFirstOption(page, page.locator("button").filter({ hasText: "Select an industry" }));
|
||||||
|
await selectFirstOption(page, page.locator("button").filter({ hasText: "Select a country" }));
|
||||||
|
await page.getByPlaceholder("$").fill("999998");
|
||||||
|
await page.getByRole("button", { name: "Yes" }).first().click();
|
||||||
|
await page.getByRole("button", { name: "Yes" }).nth(1).click();
|
||||||
|
await page.getByRole("button", { name: "Yes" }).nth(2).click();
|
||||||
|
await page.getByPlaceholder('https:// ').fill('https://www.test.md');
|
||||||
|
await selectFirstOption(page, page.locator("button").filter({ hasText: "Select" }));
|
||||||
|
await page.locator("#companyName").fill("kasetsart");
|
||||||
|
await page.getByRole('button', { name: 'Submit application' }).click();
|
||||||
|
});
|
||||||
36
tests/test-03-project-apply.spec.ts
Normal file
36
tests/test-03-project-apply.spec.ts
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
// import { test } from '@playwright/test';
|
||||||
|
// import { selectFirstOption } from './helpers/dropdownUtils';
|
||||||
|
// import { login } from './helpers/login';
|
||||||
|
// import path from 'path';
|
||||||
|
//
|
||||||
|
// test('test', async ({ page }) => {
|
||||||
|
// await login(page,'user')
|
||||||
|
// await page.getByRole('button', { name: 'Projects' }).hover();
|
||||||
|
// await page.getByRole('link', { name: 'Projects Start your new' }).click();
|
||||||
|
//
|
||||||
|
// const projectName = page.locator('#projectName')
|
||||||
|
// await projectName.pressSequentially('DummyTester');
|
||||||
|
// await projectName.click();
|
||||||
|
//
|
||||||
|
// const img = path.join(__dirname, 'mockup', '1x1.png');
|
||||||
|
// await page.locator('#projectLogo').click();
|
||||||
|
// await page.locator('#projectLogo').setInputFiles(img);
|
||||||
|
// await page.locator('#projectPhotos').click();
|
||||||
|
// await page.locator('#projectPhotos').setInputFiles(img);
|
||||||
|
//
|
||||||
|
// const projectTypeButton = page.locator('button').filter({ hasText: 'Select a Project type' });
|
||||||
|
// await selectFirstOption(page, projectTypeButton);
|
||||||
|
//
|
||||||
|
// await page.locator('#shortDescription').fill('0123456789');
|
||||||
|
// await page.getByPlaceholder('https:// ').fill('https://www.test.md');
|
||||||
|
// await page.getByPlaceholder('$ 500').fill('499');
|
||||||
|
// await page.getByPlaceholder('$ 1,000,000').fill('99999999');
|
||||||
|
// await page.locator('#deadline').fill('2024-11-29T21:19');
|
||||||
|
//
|
||||||
|
// const tag = page.getByRole('combobox').nth(1);
|
||||||
|
// await selectFirstOption(page, tag);
|
||||||
|
//
|
||||||
|
// await projectName.pressSequentially('1234');
|
||||||
|
//
|
||||||
|
// await page.getByRole('button', { name: 'Submit application' }).click();
|
||||||
|
// });
|
||||||
@ -1,35 +0,0 @@
|
|||||||
import { test } from '@playwright/test';
|
|
||||||
import { selectFirstOption } from './helpers/dropdownUtils';
|
|
||||||
import path from 'path';
|
|
||||||
|
|
||||||
test('test', async ({ page }) => {
|
|
||||||
await page.goto("http://127.0.0.1:3000/");
|
|
||||||
await page.getByRole('button', { name: 'Projects' }).hover();
|
|
||||||
await page.getByRole('link', { name: 'Projects Start your new' }).click();
|
|
||||||
|
|
||||||
const projectName = page.locator('#projectName')
|
|
||||||
await projectName.pressSequentially('DummyTester');
|
|
||||||
await projectName.click();
|
|
||||||
|
|
||||||
const img = path.join(__dirname, 'mockup', '1x1.png');
|
|
||||||
await page.locator('#projectLogo').click();
|
|
||||||
await page.locator('#projectLogo').setInputFiles(img);
|
|
||||||
await page.locator('#projectPhotos').click();
|
|
||||||
await page.locator('#projectPhotos').setInputFiles(img);
|
|
||||||
|
|
||||||
const projectTypeButton = page.locator('button').filter({ hasText: 'Select a Project type' });
|
|
||||||
await selectFirstOption(page, projectTypeButton);
|
|
||||||
|
|
||||||
await page.locator('#shortDescription').fill('0123456789');
|
|
||||||
await page.getByPlaceholder('https:// ').fill('https://www.test.md');
|
|
||||||
await page.getByPlaceholder('$ 500').fill('499');
|
|
||||||
await page.getByPlaceholder('$ 1,000,000').fill('99999999');
|
|
||||||
await page.locator('#deadline').fill('2024-11-29T21:19');
|
|
||||||
|
|
||||||
const tag = page.getByRole('combobox').nth(1);
|
|
||||||
await selectFirstOption(page, tag);
|
|
||||||
|
|
||||||
await projectName.pressSequentially('1234');
|
|
||||||
|
|
||||||
await page.getByRole('button', { name: 'Submit application' }).click();
|
|
||||||
});
|
|
||||||
Loading…
Reference in New Issue
Block a user