diff --git a/core/playwright.config.ts b/core/playwright.config.ts index b41cd1c7c..42cd55466 100644 --- a/core/playwright.config.ts +++ b/core/playwright.config.ts @@ -69,9 +69,9 @@ export default defineConfig({ ], /* Run your local dev server before starting the tests */ - // webServer: { - // command: 'npm run start', - // url: 'http://127.0.0.1:3000', - // reuseExistingServer: !process.env.CI, - // }, + webServer: { + command: 'pnpm dev', + url: 'http://127.0.0.1:3000', + reuseExistingServer: !process.env.CI, + }, }); diff --git a/core/playwright/assign.spec.ts b/core/playwright/assign.spec.ts index 6cf6899a8..565c916ff 100644 --- a/core/playwright/assign.spec.ts +++ b/core/playwright/assign.spec.ts @@ -3,11 +3,17 @@ import { expect, test } from "@playwright/test"; const authFile = "playwright/.auth/user.json"; test("Assigning members to a pub", async ({ page }) => { - // move a pub to to evaluate or just add it there in seed??? - await page.goto("/c/unjournal/stages"); - await page.getByRole("button", { name: "Create stage" }).click(); - await page.getByRole("textbox", { name: "title" }).fill("Test stage"); - await page.getByRole("button", { name: "Create" }).click(); - await page.waitForURL("/c/unjournal/stages/test-stage"); + await page.goto("/login"); + await page.getByLabel("email").fill("all@pubpub.org"); + await page.getByRole("textbox", { name: "password" }).fill("pubpub-all"); + await page.getByRole("button", { name: "Sign in" }).click(); + // Wait until the page receives the cookies. + // + // Sometimes login flow sets cookies in the process of several redirects. + // Wait for the final URL to ensure that the cookies are actually set. + await page.waitForURL("/c/unjournal/stages"); + await page.getByRole("button", { name: "Assign" }).click(); + await page.getByRole("option", { name: "Jill Admin" }).click(); + await page.getByText("Succes").waitFor({ state: "hidden" }); await page.context().storageState({ path: authFile }); }); diff --git a/core/prisma/exampleCommunitySeeds/unjournal.ts b/core/prisma/exampleCommunitySeeds/unjournal.ts index 99f31652f..f00845e9f 100644 --- a/core/prisma/exampleCommunitySeeds/unjournal.ts +++ b/core/prisma/exampleCommunitySeeds/unjournal.ts @@ -1,13 +1,22 @@ import { faker } from "@faker-js/faker"; -import { PrismaClient } from "@prisma/client"; +import { PrismaClient, PubType } from "@prisma/client"; import { v4 as uuidv4 } from "uuid"; +import type { db as kyselyDb } from "~/kysely/database"; +import type { CommunitiesId } from "~/kysely/types/public/Communities"; +import type { PubTypesId } from "~/kysely/types/public/PubTypes"; +import { corePubFields } from "~/actions/corePubFields"; +import { StagesId } from "~/kysely/types/public/Stages"; import { env } from "../../lib/env/env.mjs"; import { FileUpload } from "../../lib/fields/fileUpload"; export const unJournalId = "03e7a5fd-bdca-4682-9221-3a69992c1f3b"; -export default async function main(prisma: PrismaClient, communityUUID: string) { +export default async function main( + db: typeof kyselyDb, + prisma: PrismaClient, + communityUUID: string +) { await prisma.community.create({ data: { id: communityUUID, @@ -627,7 +636,45 @@ export default async function main(prisma: PrismaClient, communityUUID: string) }, }, }); - + const corePubSlugs = corePubFields.map((field) => field.slug); + const persistedCorePubFields = await db + .selectFrom("pub_fields") + .selectAll() + .where("pub_fields.slug", "in", corePubSlugs) + .execute(); + await db + .with("new_pubs", (db) => + db + .insertInto("pubs") + .values({ + community_id: communityUUID as CommunitiesId, + pub_type_id: submissionTypeId as PubTypesId, + }) + .returning("id") + ) + .with("pubs_in_stages", (db) => + db.insertInto("PubsInStages").values((eb) => [ + { + pubId: eb.selectFrom("new_pubs").select("id"), + stageId: stageIds[3] as StagesId, + }, + ]) + ) + .insertInto("pub_values") + .values((eb) => [ + { + pub_id: eb.selectFrom("new_pubs").select("new_pubs.id"), + field_id: persistedCorePubFields.find((field) => field.slug === "pubpub:title")!.id, + value: '"It Aint Ease Bein Cheese"', + }, + { + pub_id: eb.selectFrom("new_pubs").select("new_pubs.id"), + field_id: persistedCorePubFields.find((field) => field.slug === "pubpub:content")! + .id, + value: '"# Abstract"', + }, + ]) + .execute(); // await prisma.pub.update({ // where: { id: submission.id }, // data: { @@ -776,32 +823,4 @@ export default async function main(prisma: PrismaClient, communityUUID: string) }); }) ); - - // const pubIds = [...Array(7)].map((x) => uuidv4()); - // const submissionToEvaluate = await prisma.pub.create({ - // data: { - // pubTypeId: submissionTypeId, - // communityId: communityUUID, - // stages: { connect: { id: stageIds[3] } }, - - // values: { - // createMany: { - // data: [ - // { - // fieldId: fieldIds[0], - // value: "When Celebrities Speak: A Nationwide Twitter Experiment Promoting Vaccination In Indonesia", - // }, - // { - // fieldId: fieldIds[1], - // value: "Celebrity endorsements are often sought to influence public opinion. We ask whether celebrity endorsement per se has an effect beyond the fact that their statements are seen by many, and whether on net their statements actually lead people to change their beliefs. To do so, we conducted a nationwide Twitter experiment in Indonesia with 46 high-profile celebrities and organizations, with a total of 7.8 million followers, who agreed to let us randomly tweet or retweet content promoting immunization from their accounts. Our design exploits the structure of what information is passed on along a retweet chain on Twitter to parse reach versus endorsement effects. Endorsements matter: tweets that users can identify as being originated by a celebrity are far more likely to be liked or retweeted by users than similar tweets seen by the same users but without the celebrities' imprimatur. By contrast, explicitly citing sources in the tweets actually reduces diffusion. By randomizing which celebrities tweeted when, we find suggestive evidence that overall exposure to the campaign may influence beliefs about vaccination and knowledge of immunization-seeking behavior by one's network. Taken together, the findings suggest an important role for celebrity endorsement.", - // }, - // { - // fieldId: fieldIds[8], - // value: "10.3386/w25589", - // }, - // ], - // }, - // }, - // }, - // }); } diff --git a/core/prisma/seed.ts b/core/prisma/seed.ts index a1f1c11a0..8a6f5e0d4 100644 --- a/core/prisma/seed.ts +++ b/core/prisma/seed.ts @@ -67,7 +67,7 @@ async function main() { logger.info("build crocroc"); await buildCrocCroc(db, crocCrocId); logger.info("build unjournal"); - await buildUnjournal(prisma, unJournalId); + await buildUnjournal(db, prisma, unJournalId); try { await createUserMembers(