mirror of
https://github.com/Sosokker/B2D-Ventures.git
synced 2025-12-19 05:54:06 +01:00
test: update test
This commit is contained in:
parent
083335c010
commit
d6f41600e3
@ -1,20 +1,20 @@
|
|||||||
import { defineConfig, devices } from '@playwright/test';
|
import { defineConfig, devices } from "@playwright/test";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read environment variables from file.
|
* Read environment variables from file.
|
||||||
* https://github.com/motdotla/dotenv
|
* https://github.com/motdotla/dotenv
|
||||||
*/
|
*/
|
||||||
import dotenv from 'dotenv';
|
import dotenv from "dotenv";
|
||||||
import path from 'path';
|
import path from "path";
|
||||||
dotenv.config({ path: path.resolve(__dirname, '.env') });
|
dotenv.config({ path: path.resolve(__dirname, ".env") });
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See https://playwright.dev/docs/test-configuration.
|
* See https://playwright.dev/docs/test-configuration.
|
||||||
*/
|
*/
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
globalSetup: require.resolve('./test_util/global-setup'),
|
globalSetup: require.resolve("./tests/global-setup"),
|
||||||
globalTeardown: require.resolve('./test_util/global-teardown'),
|
globalTeardown: require.resolve("./tests/global-teardown"),
|
||||||
testDir: './tests',
|
testDir: "./tests",
|
||||||
/* Run tests in files in parallel */
|
/* Run tests in files in parallel */
|
||||||
fullyParallel: true,
|
fullyParallel: true,
|
||||||
/* Fail the build on CI if you accidentally left test.only in the source code. */
|
/* Fail the build on CI if you accidentally left test.only in the source code. */
|
||||||
@ -24,37 +24,41 @@ export default defineConfig({
|
|||||||
/* Opt out of parallel tests on CI. */
|
/* Opt out of parallel tests on CI. */
|
||||||
workers: process.env.CI ? 1 : undefined,
|
workers: process.env.CI ? 1 : undefined,
|
||||||
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
|
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
|
||||||
reporter: 'html',
|
reporter: "html",
|
||||||
/* 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: process.env.BASE_URL,
|
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",
|
||||||
storageState: './storageState.json',
|
storageState: "./storageState.json",
|
||||||
ignoreHTTPSErrors: true,
|
ignoreHTTPSErrors: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
/* Configure projects for major browsers */
|
/* Configure projects for major browsers */
|
||||||
projects: [
|
projects: [
|
||||||
|
// Setup project for authentication
|
||||||
{
|
{
|
||||||
name: 'chromium',
|
name: "setup",
|
||||||
use: { ...devices['Desktop Chrome'],
|
testMatch: /.*\.setup\.ts/, // Only run setup files for this project
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "chromium",
|
||||||
|
use: { ...devices["Desktop Chrome"], storageState: "./storageState.json" },
|
||||||
|
dependencies: ["setup"], // Ensure 'setup' runs before this project
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
name: 'firefox',
|
name: "firefox",
|
||||||
use: { ...devices['Desktop Firefox'],
|
use: { ...devices["Desktop Firefox"], storageState: "./storageState.json" },
|
||||||
storageState:"./storageState.json",
|
dependencies: ["setup"], // Ensure 'setup' runs before this project
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
name: 'webkit',
|
name: "webkit",
|
||||||
use: { ...devices['Desktop Safari'] ,
|
use: { ...devices["Desktop Safari"], storageState: "./storageState.json" },
|
||||||
},
|
dependencies: ["setup"], // Ensure 'setup' runs before this project
|
||||||
},
|
},
|
||||||
|
|
||||||
/* Test against mobile viewports. */
|
/* Test against mobile viewports. */
|
||||||
@ -80,8 +84,8 @@ export default defineConfig({
|
|||||||
|
|
||||||
/* Run your local dev server before starting the tests */
|
/* Run your local dev server before starting the tests */
|
||||||
webServer: {
|
webServer: {
|
||||||
command: 'npm run dev',
|
command: "npm run dev",
|
||||||
url: 'http://127.0.0.1:3000',
|
url: "http://127.0.0.1:3000",
|
||||||
reuseExistingServer: !process.env.CI,
|
reuseExistingServer: !process.env.CI,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@ -28,8 +28,8 @@ export async function getUserUidByEmail(email: string): Promise<{ data: string |
|
|||||||
return { data: null, error: error };
|
return { data: null, error: error };
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`Retrieve UID successfully.`);
|
console.log(`Retrieve UID successfully.`, data);
|
||||||
return { data: data[0].id, error: error };
|
return { data, error: error };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Error retrive user with email: ${email}`, error);
|
console.error(`Error retrive user with email: ${email}`, error);
|
||||||
throw error;
|
throw error;
|
||||||
|
|||||||
@ -1,27 +0,0 @@
|
|||||||
import { firefox, FullConfig } from '@playwright/test';
|
|
||||||
|
|
||||||
async function globalSetup(config: FullConfig) {
|
|
||||||
const { baseURL, storageState } = config.projects[0].use;
|
|
||||||
console.log('globalizing...');
|
|
||||||
const email = process.env.NEXT_PUBLIC_TEST_USER_EMAIL;
|
|
||||||
const password = process.env.NEXT_PUBLIC_TEST_USER_PASSWORD;
|
|
||||||
|
|
||||||
if (!email || !password) {
|
|
||||||
throw new Error('NEXT_PUBLIC_TEST_USER_EMAIL and NEXT_PUBLIC_TEST_USER_PASSWORD must be set');
|
|
||||||
}
|
|
||||||
|
|
||||||
const browser = await firefox.launch();
|
|
||||||
const page = await browser.newPage();
|
|
||||||
|
|
||||||
console.log('signing up user...');
|
|
||||||
await page.goto(baseURL + '/auth/signup');
|
|
||||||
await page.fill('id=email', email);
|
|
||||||
await page.fill('id=password', password);
|
|
||||||
await page.fill('id=confirmPassword', password);
|
|
||||||
await page.click('id=signup')
|
|
||||||
|
|
||||||
await page.context().storageState({ path: storageState as string });
|
|
||||||
await browser.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
export default globalSetup;
|
|
||||||
@ -1,13 +0,0 @@
|
|||||||
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;
|
|
||||||
24
tests/authenticated-page.setup.ts
Normal file
24
tests/authenticated-page.setup.ts
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import { test } from "@playwright/test";
|
||||||
|
|
||||||
|
const AUTH_USER_FILE = "./storageState.json";
|
||||||
|
const USER_EMAIL = process.env.NEXT_PUBLIC_TEST_USER_EMAIL!;
|
||||||
|
const USER_PASSWORD = process.env.NEXT_PUBLIC_TEST_USER_PASSWORD!;
|
||||||
|
|
||||||
|
test("Setup: Authenticate via login page and store session", async ({ page }) => {
|
||||||
|
if (!USER_EMAIL || !USER_PASSWORD) {
|
||||||
|
throw new Error("NEXT_PUBLIC_TEST_USER_EMAIL and NEXT_PUBLIC_TEST_USER_PASSWORD must be set");
|
||||||
|
}
|
||||||
|
|
||||||
|
await page.goto("http://localhost:3000/auth");
|
||||||
|
// fill input with id = email
|
||||||
|
await page.fill('input[id="email"]', USER_EMAIL);
|
||||||
|
await page.fill('input[id="password"]', USER_PASSWORD);
|
||||||
|
await page.click('button[id="login"]');
|
||||||
|
|
||||||
|
await page.waitForURL("http://localhost:3000/");
|
||||||
|
console.log("Login successful!");
|
||||||
|
|
||||||
|
await page.context().storageState({ path: AUTH_USER_FILE });
|
||||||
|
|
||||||
|
console.log("Storage state saved to:", AUTH_USER_FILE);
|
||||||
|
});
|
||||||
25
tests/deprecated/test-depre-admin-approve-business.spec.ts
Normal file
25
tests/deprecated/test-depre-admin-approve-business.spec.ts
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
// import { expect, test } from "@playwright/test";
|
||||||
|
// import { loginUtils } from "./helpers/loginUtils";
|
||||||
|
// import mockData from "./assets/mockData.json";
|
||||||
|
// import { searchBusiness } from "./helpers/searchUtils";
|
||||||
|
|
||||||
|
// test("test", async ({ page }) => {
|
||||||
|
// await loginUtils(page, "admin");
|
||||||
|
// await page.getByRole("button", { name: "profile" }).click();
|
||||||
|
// await page.getByRole("link", { name: "Admin" }).click();
|
||||||
|
// await page.locator("html").click();
|
||||||
|
// await page.getByRole("button", { name: "Go to Business Application" }).click();
|
||||||
|
|
||||||
|
// // if test 01 click no 'yes' use .first, or 'yes' n time use nth(n)
|
||||||
|
// console.log('approving');
|
||||||
|
// await page
|
||||||
|
// .getByRole("row", { name: mockData.company.name + " " + mockData.company.url })
|
||||||
|
// .getByRole("img")
|
||||||
|
// .nth(3)
|
||||||
|
// .click();
|
||||||
|
// const approveButton = page.getByRole("button", { name: "Approve" });
|
||||||
|
// await expect(approveButton).toBeVisible();
|
||||||
|
// await approveButton.click();
|
||||||
|
|
||||||
|
// await searchBusiness(page, mockData.company.name);
|
||||||
|
// });
|
||||||
@ -1,22 +1,22 @@
|
|||||||
// import { test, expect } from "@playwright/test";
|
// import { test, expect } from "@playwright/test";
|
||||||
//
|
|
||||||
// test.use({
|
// test.use({
|
||||||
// storageState: "./storageState.json",
|
// storageState: "./storageState.json",
|
||||||
// });
|
// });
|
||||||
//
|
|
||||||
// test("Test search businesses", async ({ page }) => {
|
// test("Test search businesses", async ({ page }) => {
|
||||||
// await page.goto("http://127.0.0.1:3000/");
|
// await page.goto("http://127.0.0.1:3000/");
|
||||||
// await page.getByLabel("Main").getByRole("img").click();
|
// await page.getByLabel("Main").getByRole("img").click();
|
||||||
//
|
|
||||||
// const businessInput = page.getByPlaceholder("Enter business name...");
|
// const businessInput = page.getByPlaceholder("Enter business name...");
|
||||||
// await expect(businessInput).toBeVisible();
|
// await expect(businessInput).toBeVisible();
|
||||||
// await businessInput.fill("Project Blackwell");
|
// await businessInput.fill("Project Blackwell");
|
||||||
// await businessInput.press("Enter");
|
// await businessInput.press("Enter");
|
||||||
//
|
|
||||||
// const heading = page.getByRole("heading", { name: "Project Blackwell" });
|
// const heading = page.getByRole("heading", { name: "Project Blackwell" });
|
||||||
// await expect(heading).toBeVisible();
|
// await expect(heading).toBeVisible();
|
||||||
// await heading.click();
|
// await heading.click();
|
||||||
//
|
|
||||||
// const fundSection = page.locator("div").filter({ hasText: /^Project Blackwell$/ });
|
// const fundSection = page.locator("div").filter({ hasText: /^Project Blackwell$/ });
|
||||||
// await expect(fundSection).toBeVisible();
|
// await expect(fundSection).toBeVisible();
|
||||||
// await fundSection.click();
|
// await fundSection.click();
|
||||||
39
tests/deprecated/test-depre-project-apply.spec.ts
Normal file
39
tests/deprecated/test-depre-project-apply.spec.ts
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
// import { test } from "@playwright/test";
|
||||||
|
// import { selectFirstOption } from "./helpers/dropdownUtils";
|
||||||
|
// import path from "path";
|
||||||
|
|
||||||
|
// test.use({
|
||||||
|
// storageState: "./storageState.json",
|
||||||
|
// });
|
||||||
|
|
||||||
|
// test("test", async ({ page }) => {
|
||||||
|
// await page.goto("http://localhost: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();
|
||||||
|
// });
|
||||||
53
tests/global-setup.ts
Normal file
53
tests/global-setup.ts
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
import { FullConfig } from "@playwright/test";
|
||||||
|
import { createClient } from "@supabase/supabase-js";
|
||||||
|
|
||||||
|
async function globalSetup(config: FullConfig) {
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
const { baseURL, storageState } = config.projects[0].use;
|
||||||
|
console.log("setting up...");
|
||||||
|
const email = process.env.NEXT_PUBLIC_TEST_USER_EMAIL;
|
||||||
|
const password = process.env.NEXT_PUBLIC_TEST_USER_PASSWORD;
|
||||||
|
const project_url = process.env.NEXT_PUBLIC_SUPABASE_URL;
|
||||||
|
const service_role_key = process.env.SUPABASE_SERVICE_ROLE_KEY;
|
||||||
|
|
||||||
|
if (!email || !password) {
|
||||||
|
throw new Error("NEXT_PUBLIC_TEST_USER_EMAIL and NEXT_PUBLIC_TEST_USER_PASSWORD must be set");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!project_url || !service_role_key) {
|
||||||
|
throw new Error("NEXT_PUBLIC_SUPABASE_URL and NEXT_PUBLIC_SUPABASE_ANON_KEY must be set");
|
||||||
|
}
|
||||||
|
|
||||||
|
const supabase = createClient(project_url, service_role_key);
|
||||||
|
const { error } = await supabase.auth.admin.createUser({
|
||||||
|
email,
|
||||||
|
password,
|
||||||
|
email_confirm: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (error != null) {
|
||||||
|
console.error("Error details:", error);
|
||||||
|
throw new Error(`Sign-up failed: ${error.message}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("User signed up successfully");
|
||||||
|
|
||||||
|
// const browser = await firefox.launch();
|
||||||
|
// const page = await browser.newPage();
|
||||||
|
|
||||||
|
// await page.goto(baseURL + "/auth");
|
||||||
|
// await page.fill("id=email", email);
|
||||||
|
// await page.fill("id=password", password);
|
||||||
|
// await page.click("id=login");
|
||||||
|
|
||||||
|
// await page.context().storageState({ path: storageState as string });
|
||||||
|
// // show the storage state and context
|
||||||
|
// const storage = await page.context().storageState();
|
||||||
|
// console.log("storage", storage);
|
||||||
|
// const context = page.context();
|
||||||
|
// console.log("context", context);
|
||||||
|
// console.log("setup done");
|
||||||
|
// await browser.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
export default globalSetup;
|
||||||
13
tests/global-teardown.ts
Normal file
13
tests/global-teardown.ts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import { deleteUserByEmail } from "../test_util/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,27 +1,91 @@
|
|||||||
|
// import { expect, test } from "@playwright/test";
|
||||||
|
// import { selectFirstOption } from "./helpers/dropdownUtils";
|
||||||
|
// import mockData from "./assets/mockData.json";
|
||||||
|
// import { searchBusiness } from "./helpers/searchUtils";
|
||||||
|
// import fs from "fs";
|
||||||
|
|
||||||
|
// const AUTH_USER_FILE = "./storageState.json";
|
||||||
|
// const SUPABASE_APP_ID = process.env.PROJECT_ID!;
|
||||||
|
|
||||||
|
// test("Submit a business application and search for it", async ({ page, context }) => {
|
||||||
|
// const session = JSON.parse(fs.readFileSync(AUTH_USER_FILE, "utf-8"));
|
||||||
|
|
||||||
|
// await context.addInitScript(
|
||||||
|
// (data) => {
|
||||||
|
// localStorage.setItem(`sb-${data.appId}-auth-token`, JSON.stringify(data.session));
|
||||||
|
// },
|
||||||
|
// { session, appId: SUPABASE_APP_ID }
|
||||||
|
// );
|
||||||
|
|
||||||
|
// await page.goto("http://localhost:3000/");
|
||||||
|
|
||||||
|
// 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(mockData.company.raised);
|
||||||
|
// 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(mockData.company.url);
|
||||||
|
// await selectFirstOption(page, page.locator("button").filter({ hasText: "Select" }));
|
||||||
|
// await page.locator("#companyName").fill(mockData.company.name);
|
||||||
|
// await page.getByRole("button", { name: "Submit application" }).click();
|
||||||
|
|
||||||
|
// const okButton = page.getByRole("button", { name: "OK" });
|
||||||
|
// await expect(okButton).toBeVisible();
|
||||||
|
// await okButton.click();
|
||||||
|
|
||||||
|
// await searchBusiness(page, mockData.company.name);
|
||||||
|
// });
|
||||||
|
|
||||||
import { expect, test } from "@playwright/test";
|
import { expect, test } from "@playwright/test";
|
||||||
import { loginUtils } from "./helpers/loginUtils";
|
import fs from "fs";
|
||||||
import { selectFirstOption } from "./helpers/dropdownUtils";
|
|
||||||
import mockData from "./assets/mockData.json";
|
|
||||||
import { searchBusiness } from "./helpers/searchUtils";
|
|
||||||
|
|
||||||
test("test", async ({ page }) => {
|
const AUTH_USER_FILE = "./storageState.json";
|
||||||
await loginUtils(page, "user");
|
const SUPABASE_APP_ID = process.env.PROJECT_ID!;
|
||||||
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" }));
|
test("Check visibility of elements on the business application page", async ({ page, context }) => {
|
||||||
await selectFirstOption(page, page.locator("button").filter({ hasText: "Select a country" }));
|
const session = JSON.parse(fs.readFileSync(AUTH_USER_FILE, "utf-8"));
|
||||||
await page.getByPlaceholder("$").fill(mockData.company.raised);
|
|
||||||
|
await context.addInitScript(
|
||||||
|
(data) => {
|
||||||
|
localStorage.setItem(`sb-${data.appId}-auth-token`, JSON.stringify(data.session));
|
||||||
|
},
|
||||||
|
{ session, appId: SUPABASE_APP_ID }
|
||||||
|
);
|
||||||
|
|
||||||
|
await page.goto("http://localhost:3000/business/apply");
|
||||||
|
|
||||||
|
await expect(page.locator('button:has-text("Select an industry")')).toBeVisible();
|
||||||
|
await page.locator("#companyName").click();
|
||||||
|
|
||||||
|
await expect(page.locator('button:has-text("Select a country")')).toBeVisible();
|
||||||
|
await expect(page.getByPlaceholder("$")).toBeVisible();
|
||||||
|
await expect(page.getByRole("button", { name: "Yes" }).first()).toBeVisible();
|
||||||
|
await expect(page.getByPlaceholder("https:// ")).toBeVisible();
|
||||||
|
await expect(page.locator("#companyName")).toBeVisible();
|
||||||
|
await expect(page.getByRole("button", { name: "Submit application" })).toBeVisible();
|
||||||
|
|
||||||
|
await page.locator("#companyName").fill("Hello Company");
|
||||||
|
await page.locator("button").filter({ hasText: "Select a country" }).click();
|
||||||
|
await page.getByLabel("Afghanistan").getByText("Afghanistan").click();
|
||||||
|
await page.locator("button").filter({ hasText: "Select an industry" }).click();
|
||||||
|
await page.getByLabel("LLC").getByText("LLC").click();
|
||||||
|
await page.getByPlaceholder("$").click();
|
||||||
|
await page.getByPlaceholder("$").fill("1000000");
|
||||||
await page.getByRole("button", { name: "Yes" }).first().click();
|
await page.getByRole("button", { name: "Yes" }).first().click();
|
||||||
await page.getByRole("button", { name: "Yes" }).nth(1).click();
|
await page.getByRole("button", { name: "Yes" }).nth(1).click();
|
||||||
await page.getByRole("button", { name: "Yes" }).nth(2).click();
|
await page.getByRole("button", { name: "Yes" }).nth(2).click();
|
||||||
await page.getByPlaceholder("https:// ").fill(mockData.company.url);
|
await page.getByPlaceholder("https:// ").click();
|
||||||
await selectFirstOption(page, page.locator("button").filter({ hasText: "Select" }));
|
await page.getByPlaceholder("https:// ").fill("https://example.com.md");
|
||||||
await page.locator("#companyName").fill(mockData.company.name);
|
await page.locator("button").filter({ hasText: "Select" }).click();
|
||||||
await page.getByRole("button", { name: "Submit application" }).click();
|
await page.getByLabel("N/A").click();
|
||||||
const okButton = page.getByRole("button", { name: "OK" });
|
|
||||||
await expect(okButton).toBeVisible();
|
|
||||||
await okButton.click();
|
|
||||||
|
|
||||||
await searchBusiness(page, mockData.company.name);
|
await page.getByRole("button", { name: "Submit application" }).click();
|
||||||
|
|
||||||
|
const successLabel = page.getByLabel("success");
|
||||||
|
await expect(successLabel).toBeVisible();
|
||||||
|
await successLabel.click();
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,25 +0,0 @@
|
|||||||
import { expect, test } from "@playwright/test";
|
|
||||||
import { loginUtils } from "./helpers/loginUtils";
|
|
||||||
import mockData from "./assets/mockData.json";
|
|
||||||
import { searchBusiness } from "./helpers/searchUtils";
|
|
||||||
|
|
||||||
test("test", async ({ page }) => {
|
|
||||||
await loginUtils(page, "admin");
|
|
||||||
await page.getByRole("button", { name: "profile" }).click();
|
|
||||||
await page.getByRole("link", { name: "Admin" }).click();
|
|
||||||
await page.locator("html").click();
|
|
||||||
await page.getByRole("button", { name: "Go to Business Application" }).click();
|
|
||||||
|
|
||||||
// if test 01 click no 'yes' use .first, or 'yes' n time use nth(n)
|
|
||||||
console.log('approving');
|
|
||||||
await page
|
|
||||||
.getByRole("row", { name: mockData.company.name + " " + mockData.company.url })
|
|
||||||
.getByRole("img")
|
|
||||||
.nth(3)
|
|
||||||
.click();
|
|
||||||
const approveButton = page.getByRole("button", { name: "Approve" });
|
|
||||||
await expect(approveButton).toBeVisible();
|
|
||||||
await approveButton.click();
|
|
||||||
|
|
||||||
await searchBusiness(page, mockData.company.name);
|
|
||||||
});
|
|
||||||
@ -1,42 +1,68 @@
|
|||||||
// import { test, expect } from '@playwright/test';
|
// import { test, expect } from '@playwright/test';
|
||||||
//
|
|
||||||
// test.use({
|
// test.use({
|
||||||
// storageState: './storageState.json'
|
// storageState: './storageState.json'
|
||||||
// });
|
// });
|
||||||
//
|
|
||||||
// test('Test filter with tags', async ({ page }) => {
|
// test('Test filter with tags', async ({ page }) => {
|
||||||
// await page.goto('http://127.0.0.1:3000/');
|
// await page.goto('http://127.0.0.1:3000/');
|
||||||
//
|
|
||||||
// // Start Investing
|
// // Start Investing
|
||||||
// await page.getByRole('button', { name: 'Start Investing' }).click();
|
// await page.getByRole('button', { name: 'Start Investing' }).click();
|
||||||
//
|
|
||||||
// // Filter by AI tag
|
// // Filter by AI tag
|
||||||
// await page.locator('button').filter({ hasText: 'Tags' }).click();
|
// await page.locator('button').filter({ hasText: 'Tags' }).click();
|
||||||
// await page.getByLabel('AI', { exact: true }).click();
|
// await page.getByLabel('AI', { exact: true }).click();
|
||||||
// const aiTag = page.locator('span#tag', { hasText: 'AI' });
|
// const aiTag = page.locator('span#tag', { hasText: 'AI' });
|
||||||
// await expect(aiTag).toBeVisible();
|
// await expect(aiTag).toBeVisible();
|
||||||
//
|
|
||||||
// // Filter by Technology tag
|
// // Filter by Technology tag
|
||||||
// await page.locator('button').filter({ hasText: 'AI' }).click();
|
// await page.locator('button').filter({ hasText: 'AI' }).click();
|
||||||
// await page.getByLabel('Technology').click();
|
// await page.getByLabel('Technology').click();
|
||||||
// const techTag = page.locator('span#tag', { hasText: 'Technology' });
|
// const techTag = page.locator('span#tag', { hasText: 'Technology' });
|
||||||
// await expect(techTag).toBeVisible();
|
// await expect(techTag).toBeVisible();
|
||||||
//
|
|
||||||
// // Filter by Consumer Electronics tag
|
// // Filter by Consumer Electronics tag
|
||||||
// await page.locator('button').filter({ hasText: 'Technology' }).click();
|
// await page.locator('button').filter({ hasText: 'Technology' }).click();
|
||||||
// await page.getByLabel('Consumer Electronics').click();
|
// await page.getByLabel('Consumer Electronics').click();
|
||||||
// const consumerElectronicsTag = page.locator('span#tag', { hasText: 'Consumer Electronics' });
|
// const consumerElectronicsTag = page.locator('span#tag', { hasText: 'Consumer Electronics' });
|
||||||
// await expect(consumerElectronicsTag).toBeVisible();
|
// await expect(consumerElectronicsTag).toBeVisible();
|
||||||
//
|
|
||||||
// // Filter by Software tag
|
// // Filter by Software tag
|
||||||
// await page.locator('button').filter({ hasText: 'Consumer Electronics' }).click();
|
// await page.locator('button').filter({ hasText: 'Consumer Electronics' }).click();
|
||||||
// await page.getByLabel('Software').click();
|
// await page.getByLabel('Software').click();
|
||||||
// const softwareTag = page.locator('span#tag', { hasText: 'Software' });
|
// const softwareTag = page.locator('span#tag', { hasText: 'Software' });
|
||||||
// await expect(softwareTag).toBeVisible();
|
// await expect(softwareTag).toBeVisible();
|
||||||
//
|
|
||||||
// // Filter by Internet tag
|
// // Filter by Internet tag
|
||||||
// await page.locator('button').filter({ hasText: 'Software' }).click();
|
// await page.locator('button').filter({ hasText: 'Software' }).click();
|
||||||
// await page.getByLabel('Internet').click();
|
// await page.getByLabel('Internet').click();
|
||||||
// const internetTag = page.locator('span#tag', { hasText: 'Internet' });
|
// const internetTag = page.locator('span#tag', { hasText: 'Internet' });
|
||||||
// await expect(internetTag).toBeVisible();
|
// 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://localhost:3000/");
|
||||||
|
await page.getByRole("link", { name: "View all" }).click();
|
||||||
|
await page.getByPlaceholder("Search projects").fill("Chat");
|
||||||
|
await page.getByPlaceholder("Search projects").press("Enter");
|
||||||
|
|
||||||
|
const chatGPTCard = page.getByRole("link", { name: "Card image ChatGPT ChatGPT is" });
|
||||||
|
await expect(chatGPTCard).toBeVisible();
|
||||||
|
|
||||||
|
await page.locator("button").filter({ hasText: "All Types" }).click();
|
||||||
|
await page.getByLabel("All Types").getByText("All Types").click();
|
||||||
|
|
||||||
|
await page.locator("button").filter({ hasText: "All Statuses" }).click();
|
||||||
|
await page.getByLabel("All Statuses").getByText("All Statuses").click();
|
||||||
|
|
||||||
|
await page.locator("button").filter({ hasText: "All Tags" }).click();
|
||||||
|
await page.getByLabel("All Tags").getByText("All Tags").click();
|
||||||
|
await page.getByPlaceholder("Search projects").click();
|
||||||
|
});
|
||||||
@ -104,4 +104,43 @@
|
|||||||
// async function closeErrorDialog(page: Page): Promise<void> {
|
// async function closeErrorDialog(page: Page): Promise<void> {
|
||||||
// await page.getByRole('button', { name: 'Close' }).first().click();
|
// await page.getByRole('button', { name: 'Close' }).first().click();
|
||||||
// }
|
// }
|
||||||
// });
|
// });
|
||||||
|
|
||||||
|
import { test, expect } from "@playwright/test";
|
||||||
|
|
||||||
|
test.use({
|
||||||
|
storageState: "./storageState.json",
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Investment process test", async ({ page }) => {
|
||||||
|
await page.goto("http://localhost:3000/");
|
||||||
|
|
||||||
|
await page.getByRole("link", { name: "Card image Project Blackwell" }).click();
|
||||||
|
await page.getByRole("link", { name: "Invest in Project Blackwell" }).click();
|
||||||
|
|
||||||
|
await page.getByPlaceholder("min $").click();
|
||||||
|
await page.getByPlaceholder("min $").fill("99");
|
||||||
|
|
||||||
|
await page.getByRole("checkbox").first().check();
|
||||||
|
await page
|
||||||
|
.locator("div")
|
||||||
|
.filter({ hasText: /^I have read and accept the terms of investment\.$/ })
|
||||||
|
.getByRole("checkbox")
|
||||||
|
.check();
|
||||||
|
await page.getByRole("button", { name: "Proceed to Payment" }).click();
|
||||||
|
|
||||||
|
const paymentInfo = page.getByLabel("Payment Information");
|
||||||
|
await expect(paymentInfo).toBeVisible();
|
||||||
|
|
||||||
|
const cardNumber = page.getByText("Card Number");
|
||||||
|
await expect(cardNumber).toBeVisible();
|
||||||
|
|
||||||
|
const expirationDate = page.getByText("Expiration Date");
|
||||||
|
await expect(expirationDate).toBeVisible();
|
||||||
|
|
||||||
|
const cvc = page.getByText("CVC");
|
||||||
|
await expect(cvc).toBeVisible();
|
||||||
|
|
||||||
|
const cancelButton = page.getByRole("button", { name: "Cancel" });
|
||||||
|
await expect(cancelButton).toBeVisible();
|
||||||
|
});
|
||||||
@ -1,36 +0,0 @@
|
|||||||
// 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();
|
|
||||||
// });
|
|
||||||
34
tests/test-04-admin-page.spec.ts
Normal file
34
tests/test-04-admin-page.spec.ts
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
import { test, expect } from "@playwright/test";
|
||||||
|
|
||||||
|
const ADMIN_USERNAME = process.env.NEXT_PUBLIC_ADMIN_EMAIL!;
|
||||||
|
const ADMIN_PASSWORD = process.env.NEXT_PUBLIC_ADMIN_PASSWORD!;
|
||||||
|
|
||||||
|
test("Test admin page funtionality", async ({ page }) => {
|
||||||
|
if (!ADMIN_USERNAME || !ADMIN_PASSWORD) {
|
||||||
|
throw new Error("NEXT_PUBLIC_TEST_USER_EMAIL and NEXT_PUBLIC_TEST_USER_PASSWORD must be set");
|
||||||
|
}
|
||||||
|
|
||||||
|
await page.goto("http://localhost:3000/");
|
||||||
|
await page.getByRole("button", { name: "profile" }).click();
|
||||||
|
await page.getByRole("button", { name: "Logout" }).click();
|
||||||
|
await page.getByRole("button", { name: "Login" }).click();
|
||||||
|
await page.reload();
|
||||||
|
|
||||||
|
const emailInput = page.locator('input[id="email"]');
|
||||||
|
const passwordInput = page.locator('input[id="password"]');
|
||||||
|
const loginButton = page.locator('button[id="login"]');
|
||||||
|
|
||||||
|
await emailInput.fill(ADMIN_USERNAME);
|
||||||
|
await passwordInput.fill(ADMIN_PASSWORD);
|
||||||
|
await loginButton.click();
|
||||||
|
|
||||||
|
await expect(page.getByRole("button", { name: "profile" })).toBeVisible();
|
||||||
|
await page.getByRole("button", { name: "profile" }).click();
|
||||||
|
await expect(page.getByRole("link", { name: "Admin" })).toBeVisible();
|
||||||
|
await page.getByRole("link", { name: "Admin" }).click();
|
||||||
|
await page.locator("html").click();
|
||||||
|
await page.getByRole("button", { name: "Go to Business Application" }).click();
|
||||||
|
|
||||||
|
await expect(page.getByText("Admin Page")).toBeVisible();
|
||||||
|
await expect(page.getByRole("cell", { name: "Hello Company" })).toBeVisible();
|
||||||
|
});
|
||||||
@ -1,26 +0,0 @@
|
|||||||
// 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();
|
|
||||||
// });
|
|
||||||
26
tests/test-depre-dashboard-visibility.spec.ts
Normal file
26
tests/test-depre-dashboard-visibility.spec.ts
Normal file
@ -0,0 +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();
|
||||||
|
// });
|
||||||
Loading…
Reference in New Issue
Block a user