chore: import upstream snapshot with attribution
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import { test, expect } from "@playwright/test";
|
||||
|
||||
test("Create an account", async ({ page }) => {
|
||||
await page.goto("/login");
|
||||
await page.getByRole("link", { name: "Continue with Email" }).click();
|
||||
|
||||
await page.getByPlaceholder("Email Address").type(`test_${Math.random()}@test.com`);
|
||||
await page.getByRole("button", { name: "Send a magic link" }).click();
|
||||
|
||||
await expect(page.getByText("Welcome to Trigger.dev")).toBeVisible();
|
||||
await page.getByLabel("Full name").type("John Doe");
|
||||
await page.getByRole("button", { name: "Continue" }).click();
|
||||
|
||||
await page.getByLabel("Organization name").type("Test Org");
|
||||
await page.getByLabel("Project name").type("Test Project");
|
||||
await page.getByRole("button", { name: "Create" }).click();
|
||||
|
||||
await expect(
|
||||
page.locator("h1").filter({ hasText: /^Choose a framework to get started/ })
|
||||
).toBeVisible();
|
||||
});
|
||||
|
||||
test("Verify jobs from the test nextjs project", async ({ page }) => {
|
||||
await page.goto("/");
|
||||
await page.getByRole("link", { name: "Continue with Email" }).click();
|
||||
|
||||
await page.getByPlaceholder("Email Address").type("test-user@test.com");
|
||||
await page.getByRole("button", { name: "Send a magic link" }).click();
|
||||
|
||||
await page.getByRole("link", { name: "Projects" }).click();
|
||||
await page.locator("a").filter({ hasText: "Test Project" }).click();
|
||||
|
||||
await page.getByRole("link", { name: "Environments & API Keys" }).click();
|
||||
await expect(page.locator("h2").filter({ hasText: "Environments & API Keys" })).toBeVisible();
|
||||
await expect(
|
||||
page.locator("h3").filter({ hasText: "nextjs-test" })
|
||||
// Set the timeout high to allow the cli to register jobs
|
||||
).toBeVisible({ timeout: 15000 });
|
||||
|
||||
await page.getByRole("link", { name: "Jobs" }).click();
|
||||
await expect(page.locator("h2").filter({ hasText: /^Jobs$/ })).toBeVisible();
|
||||
await expect(page.getByRole("link", { name: /Test Job One/ })).toBeVisible();
|
||||
});
|
||||
@@ -0,0 +1,102 @@
|
||||
import { setDB } from "./utils";
|
||||
|
||||
const setup = async () => {
|
||||
await setDB(async (prisma) => {
|
||||
// Create test user
|
||||
const user = await prisma.user.create({
|
||||
data: {
|
||||
email: "test-user@test.com",
|
||||
name: "Test User",
|
||||
authenticationMethod: "MAGIC_LINK",
|
||||
confirmedBasicDetails: true,
|
||||
},
|
||||
});
|
||||
|
||||
// Create test organization
|
||||
const organization = await prisma.organization.create({
|
||||
data: {
|
||||
title: "Test Organization",
|
||||
slug: "test-org",
|
||||
members: {
|
||||
create: {
|
||||
userId: user.id,
|
||||
role: "ADMIN",
|
||||
},
|
||||
},
|
||||
},
|
||||
include: {
|
||||
members: true,
|
||||
},
|
||||
});
|
||||
|
||||
// Create test project
|
||||
const project = await prisma.project.create({
|
||||
data: {
|
||||
name: "Test Project",
|
||||
slug: "test-project",
|
||||
organization: {
|
||||
connect: {
|
||||
slug: organization.slug,
|
||||
},
|
||||
},
|
||||
externalRef: "test-project-123",
|
||||
},
|
||||
include: {
|
||||
organization: {
|
||||
include: {
|
||||
members: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
// Create test environment
|
||||
await prisma.runtimeEnvironment.create({
|
||||
data: {
|
||||
slug: "dev",
|
||||
// Fixed e2e test API key
|
||||
apiKey: "tr_dev_test-api-key",
|
||||
pkApiKey: "tr_dev_pk_test-api-key",
|
||||
autoEnableInternalSources: false,
|
||||
organization: {
|
||||
connect: {
|
||||
id: organization.id,
|
||||
},
|
||||
},
|
||||
project: {
|
||||
connect: {
|
||||
id: project.id,
|
||||
},
|
||||
},
|
||||
orgMember: { connect: { id: project.organization.members[0].id } },
|
||||
type: "DEVELOPMENT",
|
||||
shortcode: "octopus-tentacles",
|
||||
},
|
||||
});
|
||||
|
||||
await prisma.runtimeEnvironment.create({
|
||||
data: {
|
||||
slug: "prod",
|
||||
// Fixed e2e test API key
|
||||
apiKey: "tr_prod_test-api-key",
|
||||
pkApiKey: "tr_prod_pk_test-api-key",
|
||||
autoEnableInternalSources: false,
|
||||
organization: {
|
||||
connect: {
|
||||
id: organization.id,
|
||||
},
|
||||
},
|
||||
project: {
|
||||
connect: {
|
||||
id: project.id,
|
||||
},
|
||||
},
|
||||
orgMember: { connect: { id: project.organization.members[0].id } },
|
||||
type: "PRODUCTION",
|
||||
shortcode: "stripey-zebra",
|
||||
},
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export default setup;
|
||||
@@ -0,0 +1,17 @@
|
||||
import { setDB } from "./utils";
|
||||
|
||||
const teardown = async () => {
|
||||
await setDB(async (prisma) => {
|
||||
// Delete test organization
|
||||
await prisma.organization.delete({
|
||||
where: { slug: "test-org" },
|
||||
});
|
||||
|
||||
// Delete test user
|
||||
await prisma.user.delete({
|
||||
where: { email: "test-user@test.com" },
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export default teardown;
|
||||
@@ -0,0 +1,20 @@
|
||||
import { PrismaClient } from "@trigger.dev/database";
|
||||
|
||||
type SetDBCallback = (prisma: PrismaClient) => Promise<void>;
|
||||
|
||||
export const setDB = async (cb: SetDBCallback) => {
|
||||
const { DATABASE_URL } = process.env;
|
||||
|
||||
const prisma = new PrismaClient({
|
||||
datasources: {
|
||||
db: {
|
||||
url: DATABASE_URL,
|
||||
// We can't set directUrl here, and we don't have to
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
await prisma.$connect();
|
||||
await cb(prisma);
|
||||
await prisma.$disconnect();
|
||||
};
|
||||
Reference in New Issue
Block a user