File size: 4,997 Bytes
65d68f5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/* eslint-disable @typescript-eslint/no-require-imports */
const { chromium } = require("playwright");
const path = require("path");

const appUrl = "http://127.0.0.1:3001";
const outputDir = "C:/Users/USER/OneDrive/Desktop/STARTUP/artifacts/e2e";

async function submitAssistant(page, text) {
  const composer = page.getByPlaceholder(/Ask or change your plan|Why change the plan|Which chapters/);
  await composer.fill(text);
  await page.getByRole("button", { name: "Send to DocDoe" }).click();
}

(async () => {
  const browser = await chromium.launch({ headless: true });
  const context = await browser.newContext({
    viewport: { width: 1600, height: 1000 },
    deviceScaleFactor: 1,
  });

  await context.addInitScript(() => {
    const now = "2026-07-14T12:00:00.000Z";
    localStorage.setItem("exam_success_access_token", "docdoe-demo-preview-token");
    localStorage.setItem("docdoe-onboarding-completed", "true");
    localStorage.setItem("docdoe-onboarding-profile", JSON.stringify({
      goal: "Score 90% and above",
      class: "SSLC / 10th",
      board: "Kerala State Board",
      subjects: ["Physics", "Chemistry", "Mathematics"],
      examDate: "2027-03-10",
      dailyTime: "90 min",
      preferredTime: "Evening",
      focus: ["Board answers"],
      languagePreference: "English",
      learningStyle: "Step-by-step",
    }));
    localStorage.setItem("docdoe:beta-access", JSON.stringify({
      hasAccess: true,
      accessCodeLabel: "DOCDOE-BETA",
      grantedAt: now,
      classLevel: "Class 10",
      board: "Kerala SSLC",
      languagePreference: "English",
    }));
    localStorage.removeItem("docdoe:page-guide:/home:v2");
  });

  const page = await context.newPage();
  const pageErrors = [];
  const failedResponses = [];
  page.on("pageerror", (error) => pageErrors.push(error.message));
  page.on("response", (response) => {
    if (response.status() >= 400) failedResponses.push(`${response.status()} ${response.url()}`);
  });

  await page.goto(`${appUrl}/home`, { waitUntil: "domcontentloaded" });
  await page.getByRole("heading", { name: /Let.s make today productive/i }).waitFor({ timeout: 30000 });
  await page.waitForTimeout(1500);
  console.log(JSON.stringify({
    buttonsBeforeGuide: await page.getByRole("button").allTextContents(),
    assistantOpenButtonCount: await page.getByRole("button", { name: "Open DocDoe AI" }).count(),
    guideTextCount: await page.getByText(/Home guide/).count(),
    earlyPageErrors: pageErrors,
  }, null, 2));
  await page.getByText(/Home guide/).waitFor({ state: "visible", timeout: 10000 });
  await page.screenshot({ path: path.join(outputDir, "assistant-home-page-guide.png"), fullPage: true });

  await page.getByRole("button", { name: "Close page guide" }).click();
  await page.getByRole("button", { name: "Open DocDoe AI" }).waitFor({ state: "visible" });
  await page.screenshot({ path: path.join(outputDir, "assistant-idle-head.png"), fullPage: true });

  await page.getByRole("button", { name: "Open DocDoe AI" }).click();
  await page.getByText("DocDoe AI", { exact: true }).waitFor({ state: "visible" });
  await page.screenshot({ path: path.join(outputDir, "assistant-mini-chat-open.png"), fullPage: true });

  await submitAssistant(page, "I need to study Physics instead of Chemistry");
  await page.getByText(/Why do you need the change/i).waitFor({ state: "visible" });
  await submitAssistant(page, "I have a Physics exam tomorrow");
  await page.getByText(/Which Physics chapters are in the exam/i).waitFor({ state: "visible" });
  await submitAssistant(page, "1, 2, 3");
  await page.getByText("Confirm plan change", { exact: true }).waitFor({ state: "visible" });
  await page.screenshot({ path: path.join(outputDir, "assistant-plan-confirmation.png"), fullPage: true });

  await page.getByRole("button", { name: "Update my plan" }).click();
  await page.getByText(/Open Home or Tuition and you will see the change/i).waitFor({ state: "visible", timeout: 30000 });
  await page.screenshot({ path: path.join(outputDir, "assistant-plan-updated.png"), fullPage: true });

  const stateResponse = await context.request.get("http://127.0.0.1:8000/learning-state/me", {
    headers: { Authorization: "Bearer docdoe-demo-preview-token" },
  });
  const learningState = await stateResponse.json();
  const assistantTasks = learningState.tasks.filter((task) =>
    task.title.startsWith("Physics revision:"),
  );
  const visibleTaskTitles = await page.locator("main").getByText(/Physics|Sound Waves/).allTextContents();

  console.log(JSON.stringify({
    stateStatus: stateResponse.status(),
    assistantTaskCount: assistantTasks.length,
    activeTaskTitles: learningState.tasks.map((task) => task.title),
    visibleTaskTitles: visibleTaskTitles.slice(0, 12),
    pageErrors,
    failedResponses: failedResponses.filter((item) => !item.includes("favicon")),
  }, null, 2));

  await browser.close();
})().catch((error) => {
  console.error(error);
  process.exitCode = 1;
});