feat(e2e): add default test setup, update playwright config
This commit is contained in:
parent
b8d7bd57c8
commit
7c14cf7bf1
|
@ -0,0 +1,19 @@
|
|||
import { seedUser } from "@/e2e/data/user";
|
||||
import { test as setup } from "../../index";
|
||||
import { STORAGE_STATE } from "../../../playwright.config";
|
||||
|
||||
setup("Setup the default user", async ({ page, dashboardPage, loginPage }) => {
|
||||
const username = process.env["TEST_USERNAME"] || "";
|
||||
const password = process.env["TEST_PASSWORD"] || "";
|
||||
await seedUser(username, password);
|
||||
|
||||
await loginPage.goto();
|
||||
await loginPage.usernameInput.fill(username);
|
||||
await loginPage.passwordInput.fill(password);
|
||||
await loginPage.submitLoginButton.click();
|
||||
await dashboardPage.container.waitFor({ state: "visible" });
|
||||
|
||||
await page.context().storageState({
|
||||
path: STORAGE_STATE,
|
||||
});
|
||||
});
|
|
@ -0,0 +1,8 @@
|
|||
import { seedUser } from "@/e2e/data/user";
|
||||
import { test as setup } from "../../index";
|
||||
|
||||
setup("Setup the default user", async () => {
|
||||
const username = process.env["TEST_USERNAME"] || "";
|
||||
const password = process.env["TEST_PASSWORD"] || "";
|
||||
await seedUser(username, password);
|
||||
});
|
|
@ -1,11 +1,8 @@
|
|||
import { defineConfig, devices } from "@playwright/test";
|
||||
import path from "path";
|
||||
import "dotenv/config.js";
|
||||
|
||||
/**
|
||||
* Read environment variables from file.
|
||||
* https://github.com/motdotla/dotenv
|
||||
*/
|
||||
// require('dotenv').config();
|
||||
|
||||
export const STORAGE_STATE = path.join(__dirname, "playwright/.auth/user.json");
|
||||
/**
|
||||
* See https://playwright.dev/docs/test-configuration.
|
||||
*/
|
||||
|
@ -24,7 +21,7 @@ export default defineConfig({
|
|||
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
|
||||
use: {
|
||||
/* Base URL to use in actions like `await page.goto('/')`. */
|
||||
// baseURL: 'http://127.0.0.1:3000',
|
||||
baseURL: "http://127.0.0.1:3000",
|
||||
|
||||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
||||
trace: "on-first-retry",
|
||||
|
@ -33,10 +30,27 @@ export default defineConfig({
|
|||
/* Configure projects for major browsers */
|
||||
projects: [
|
||||
{
|
||||
name: "chromium",
|
||||
name: "setup dashboard",
|
||||
testMatch: /global\/setup\.dashboard\.ts/,
|
||||
},
|
||||
{
|
||||
name: "setup public",
|
||||
testMatch: /global\/setup\.public\.ts/,
|
||||
},
|
||||
{
|
||||
name: "chromium dashboard",
|
||||
dependencies: ["setup dashboard"],
|
||||
testMatch: "dashboard/*.spec.ts",
|
||||
use: { ...devices["Desktop Chrome"], storageState: STORAGE_STATE },
|
||||
},
|
||||
{
|
||||
name: "chromium public",
|
||||
dependencies: ["setup public"],
|
||||
testMatch: "public/*.spec.ts",
|
||||
use: { ...devices["Desktop Chrome"] },
|
||||
},
|
||||
|
||||
/*
|
||||
{
|
||||
name: "firefox",
|
||||
use: { ...devices["Desktop Firefox"] },
|
||||
|
@ -46,6 +60,7 @@ export default defineConfig({
|
|||
name: "webkit",
|
||||
use: { ...devices["Desktop Safari"] },
|
||||
},
|
||||
*/
|
||||
|
||||
/* Test against mobile viewports. */
|
||||
// {
|
||||
|
|
Ŝarĝante…
Reference in New Issue