<commit_before>import { afterAll, beforeAll, describe, expect, it } from "@jest/globals";
import { Helper } from "./helper";

describe("crawl notfound page", () => {
  let c: Helper;

  const admin_id = "testadmin";
  const admin_pass = "<PASSWORD>";

  beforeAll(async () => {
    c = new Helper();
    await c.init();
  });

  it("open user not found page", async () => {
    const url = 'http://localhost:8080/testblog2/?no=99999999999';
    const [response] = await Promise.all([
      c.waitLoad(),
      c.page.goto(url),
    ]);

    await c.getSS("notfound");

    expect(response.status()).toEqual(404);
    expect(response.url()).toEqual(url);
    expect(await c.page.title()).toEqual("testblog2");

    const body_text = await c.page.$eval("body", elm=>elm.textContent);
    expect(body_text.match(/404 Not Found お探しのページは存在しません/));
  });

  it("login admin page", async () => {
    const start_url = "http://localhost:8080/admin/";
    const [response] = await Promise.all([
      c.waitLoad(),
      c.page.goto(start_url),
    ]);

    expect(response.status()).toEqual(200);
    expect(await c.isNotAnyNoticeOrWarningsFinishWithEndHtmlTag()).toBeTruthy();
    // ログインページにリダイレクトされる
    expect(response.url()).toEqual("http://localhost:8080/admin/users/login");

    await c.page.$eval(
        "#id_form input[name='user[login_id]']",
        (elm: HTMLInputElement) => (elm.value = "")
    );
    await c.page.type("#id_form input[name='user[login_id]']", admin_id);
    await c.page.$eval(
        "#id_form input[name='user[password]']",
        (elm: HTMLInputElement) => (elm.value = "")
    );
    await c.page.type("#id_form input[name='user[password]']", admin_pass);<commit_msg>fix broken tests.<commit_after>import { afterAll, beforeAll, describe, expect, it } from "@jest/globals";
import { Helper } from "./helper";

describe("crawl notfound page", () => {
  let c: Helper;

  const admin_id = "testadmin";
  const admin_pass = "<PASSWORD>";

  beforeAll(async () => {
    c = new Helper();
    await c.init();
  });

  it("open user not found page", async () => {
    const url = 'http://localhost:8080/testblog2/?no=99999999999';
    const [response] = await Promise.all([
      c.waitLoad(),
      c.page.goto(url),
    ]);

    await c.getSS("notfound");

    expect(response.status()).toEqual(404);
    expect(response.url()).toEqual(url);
    expect(await c.page.title()).toEqual("404 Not Found. - testblog2");

    const body_text = await c.page.$eval("body", elm=>elm.textContent);
    expect(body_text.match(/404 Not Found お探しのページは存在しません/));
  });

  it("login admin page", async () => {
    const start_url = "http://localhost:8080/admin/";
    const [response] = await Promise.all([
      c.waitLoad(),
      c.page.goto(start_url),
    ]);

    expect(response.status()).toEqual(200);
    expect(await c.isNotAnyNoticeOrWarningsFinishWithEndHtmlTag()).toBeTruthy();
    // ログインページにリダイレクトされる
    expect(response.url()).toEqual("http://localhost:8080/admin/users/login");

    await c.page.$eval(
        "#id_form input[name='user[login_id]']",
        (elm: HTMLInputElement) => (elm.value = "")
    );
    await c.page.type("#id_form input[name='user[login_id]']", admin_id);
    await c.page.$eval(
        "#id_form input[name='user[password]']",
        (elm: HTMLInputElement) => (elm.value = "")
    );
    await c.page.type("#id_form input[name='user[password]']", <PASSWORD>_pass);
{'fraction_non_alphanumeric': 0.18884997081144192, 'fraction_numerical': 0.02072387624051372, 'mean_word_length': 3.55718085106383, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1186525', 'n_tokens_mistral': 1233, 'n_tokens_neox': 1180, 'n_words': 204}