<commit_before>describe("Forums", () => {
    before(() => {
        cy.login({next: "/forum/"});
    });

    beforeEach(() => {
        Cypress.Cookies.preserveOnce("sessionid", "csrftoken", "astrobin_lang", "cookielaw_accepted");
    });

    it("should have default forum", () => {
        cy.get(".forum-name").contains("AstroBin Meta Forums").should("exist");
        cy.get(".forum-name a").contains("Announcements").should("exist");
    });

    it("should post", () => {
        cy.visit("/forum/c/astrobin/announcements/");
        cy.get("a").contains("New topic").click();
        cy.url().should("contain", "/topic/add/");

        cy.get('#forum-usage-modal .btn-primary').click();

        // Give the editor 10 seconds to appear
        cy.get(".post-form input[name='name']", {timeout: 10000}).should('be.visible');

        cy.get(".post-form input[name='name']").type("Test topic");
        cy.get("#cke_id_body .cke_wysiwyg_div").type("Hello, this is a test topic.");
        cy.get(".post-form button[type='submit']").click();

        cy.url().should("contain", "/forum/c/astrobin/announcements/test-topic");
        cy.get(".topic h1").contains("Test topic").should("exist");
        cy.get(".post-content").contains("Hello, this is a test topic.").should("exist");
    });

    it("should edit", () => {
        cy.get(".post-related a").contains("Edit").click();
        cy.url().should("match", /\/forum\/post\/\d+\/edit\//);

        // Give the editor 10 seconds to appear
        cy.get(".post-form input[name='name']", {timeout: 10000}).should('be.visible');

        cy.get(".post-form input[name='name']").clear().type("Edited test topic");
        cy.get("#cke_id_body .cke_wysiwyg_div")
            .clear()
            .type("Hello, this is an edited test topic.");
        cy.get(".post-form button[type='submit']").click();

        cy.url().should("contain", "/forum/c/astrobin/announcements/test-topic");
        cy.get(".topic h1").contains("Edited test topic").should("exist");
        cy.get(".post-content").contains("Hello, this is an edited test topic.").should("exist");
    });

    it("should reply", () => {
        cy.get("#cke_id_body .cke_wysiwyg_div").type("This is a reply.");
        cy.get(".post-form button[type='submit']").click();

        cy.url().should("contain", "/forum/c/astrobin/announcements/test-topic");
        cy.get(".post-content").contains("This is a reply.").should("exist");
    });

    it("should quote", () => {
        cy.get(".post-related").last().contains("quote").click();
        cy.wait(1000);
        cy.get(".cke_button__sourcedialog").click();
        cy.get("textarea.cke_source")
            .should("contain.value", "[quote=\"astrobin_dev\"]This is a reply.[/quote]");
    });

    it("should like", () => {
        cy.login({
            next: "/forum/c/astrobin/announcements/test-topic",
            username: "astrobin_dev2",
            password: "<PASSWORD>"
        });

        let btn = cy.get(".post-related").first().find("button");

        btn.contains("Like").click();
        btn.contains("Unlike").should("be.visible");
    });

    it("should unlike", () => {
        let btn = cy.get(".post-related").first().find("button");

        btn.contains("Unlike").click();
        btn.contains("Like").should("be.visible");
    });

    it("should insert smiley", () => {
        cy.get(".cke_button__smiley").click();
        cy.get(".cke_dark_background a").first().click();
        cy.get("#cke_id_body .cke_wysiwyg_div").find(".smiley").should("be.visible");
    });

    it("should insert bold", () => { 
        cy.get(".cke_button__bold").click();
        cy.get("#cke_id_body .cke_wysiwyg_div strong");
    });

    it("should insert italic", () => {
        cy.get(".cke_button__italic").click();
        cy.get("#cke_id_body .cke_wysiwyg_div em");
    });

    it("should insert link", () => { 
        cy.get(".cke_button__simplelink").click();
        cy.get(".cke_dialog_ui_input_text input").first().type("https://astrobin.com");
        cy.get(".cke_dialog_ui_input_text input").last().type("Astrobin");
        cy.get(".cke_dialog_ui_button_ok").click();
        cy.get("#cke_id_body .cke_wysiwyg_div a").should("contain", "Astrobin");
    });
});
<commit_msg>(tests) Fix cypress test for forums (#1934)<commit_after>describe("Forums", () => {
    before(() => {
        cy.login({next: "/forum/"});
    });

    beforeEach(() => {
        Cypress.Cookies.preserveOnce("sessionid", "csrftoken", "astrobin_lang", "cookielaw_accepted");
    });

    it("should have default forum", () => {
        cy.get(".forum-name").contains("AstroBin Meta Forums").should("exist");
        cy.get(".forum-name a").contains("Announcements").should("exist");
    });

    it("should post", () => {
        cy.visit("/forum/c/astrobin/announcements/");
        cy.get("a").contains("New topic").click();
        cy.url().should("contain", "/topic/add/");

        cy.get('#i-have-read').click();
        cy.get('#forum-usage-modal .btn-primary').click();

        // Give the editor 10 seconds to appear
        cy.get(".post-form input[name='name']", {timeout: 10000}).should('be.visible');

        cy.get(".post-form input[name='name']").type("Test topic");
        cy.get("#cke_id_body .cke_wysiwyg_div").type("Hello, this is a test topic.");
        cy.get(".post-form button[type='submit']").click();

        cy.url().should("contain", "/forum/c/astrobin/announcements/test-topic");
        cy.get(".topic h1").contains("Test topic").should("exist");
        cy.get(".post-content").contains("Hello, this is a test topic.").should("exist");
    });

    it("should edit", () => {
        cy.get(".post-related a").contains("Edit").click();
        cy.url().should("match", /\/forum\/post\/\d+\/edit\//);

        // Give the editor 10 seconds to appear
        cy.get(".post-form input[name='name']", {timeout: 10000}).should('be.visible');

        cy.get(".post-form input[name='name']").clear().type("Edited test topic");
        cy.get("#cke_id_body .cke_wysiwyg_div")
            .clear()
            .type("Hello, this is an edited test topic.");
        cy.get(".post-form button[type='submit']").click();

        cy.url().should("contain", "/forum/c/astrobin/announcements/test-topic");
        cy.get(".topic h1").contains("Edited test topic").should("exist");
        cy.get(".post-content").contains("Hello, this is an edited test topic.").should("exist");
    });

    it("should reply", () => {
        cy.get("#cke_id_body .cke_wysiwyg_div").type("This is a reply.");
        cy.get(".post-form button[type='submit']").click();

        cy.url().should("contain", "/forum/c/astrobin/announcements/test-topic");
        cy.get(".post-content").contains("This is a reply.").should("exist");
    });

    it("should quote", () => {
        cy.get(".post-related").last().contains("quote").click();
        cy.wait(1000);
        cy.get(".cke_button__sourcedialog").click();
        cy.get("textarea.cke_source")
            .should("contain.value", "[quote=\"astrobin_dev\"]This is a reply.[/quote]");
    });

    it("should like", () => {
        cy.login({
            next: "/forum/c/astrobin/announcements/test-topic",
            username: "astrobin_dev2",
            password: "<PASSWORD>"
        });

        let btn = cy.get(".post-related").first().find("button");

        btn.contains("Like").click();
        btn.contains("Unlike").should("be.visible");
    });

    it("should unlike", () => {
        let btn = cy.get(".post-related").first().find("button");

        btn.contains("Unlike").click();
        btn.contains("Like").should("be.visible");
    });

    it("should insert smiley", () => {
        cy.get(".cke_button__smiley").click();
        cy.get(".cke_dark_background a").first().click();
        cy.get("#cke_id_body .cke_wysiwyg_div").find(".smiley").should("be.visible");
    });

    it("should insert bold", () => { 
        cy.get(".cke_button__bold").click();
        cy.get("#cke_id_body .cke_wysiwyg_div strong");
    });

    it("should insert italic", () => {
        cy.get(".cke_button__italic").click();
        cy.get("#cke_id_body .cke_wysiwyg_div em");
    });

    it("should insert link", () => { 
        cy.get(".cke_button__simplelink").click();
        cy.get(".cke_dialog_ui_input_text input").first().type("https://astrobin.com");
        cy.get(".cke_dialog_ui_input_text input").last().type("Astrobin");
        cy.get(".cke_dialog_ui_button_ok").click();
        cy.get("#cke_id_body .cke_wysiwyg_div a").should("contain", "Astrobin");
    });
});

{'fraction_non_alphanumeric': 0.22514484356894554, 'fraction_numerical': 0.005330243337195829, 'mean_word_length': 2.812279151943463, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 33, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, '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': '1658021', 'n_tokens_mistral': 2806, 'n_tokens_neox': 2671, 'n_words': 385}