<commit_before>
import { By, until } from "selenium-webdriver";

import {
    waitForElement,
    waitForElementText,
    waitForElementRemoved,
    findElement,
    waitForElementAndClick,
    waitForElementAndSendKeys,
    waitForUrl,
    screenshot,
    loginMetabase,
    ensureLoggedIn,
    describeE2E
} from "../support/utils";

jasmine.DEFAULT_TIMEOUT_INTERVAL = 600000;

describeE2E("admin/datamodel", () => {
    beforeEach(() =>
        ensureLoggedIn(server, driver, "<EMAIL>", "12341234")
    );

    describe("data model editor", () => {
        it("should allow admin to edit data model", async () => {
            await driver.get(`${server.host}/admin/datamodel/database`);

            // hide orders table
            await waitForElementAndClick(driver, ".AdminList-items li:nth-child(2)");
            await screenshot(driver, "screenshots/admin-datamodel-orders.png");

            await waitForElementAndClick(driver, "#VisibilityTypes span:nth-child(2)");
            await waitForElementAndClick(driver, "#VisibilitySubTypes span:nth-child(3)");

            // unhide
            await waitForElementAndClick(driver, "#VisibilityTypes span:first-child");

            // hide fields from people table
            await waitForElementAndClick(driver, ".AdminList-items li:nth-child(3)");

            await waitForElementAndClick(driver, "#ColumnsList li:first-child .TableEditor-field-visibility");
            await waitForElementAndClick(driver, ".ColumnarSelector-rows li:nth-child(2) .ColumnarSelector-row");

            await waitForElementAndClick(driver, "#ColumnsList li:nth-child(2) .TableEditor-field-visibility");
            await waitForElementAndClick(driver, ".ColumnarSelector-rows li:nth-child(3) .ColumnarSelector-row");

            // modify special type for address field
            await waitForElementAndClick(driver, "#ColumnsList li:first-child .TableEditor-field-special-type");
            await waitForElementAndClick(driver, ".ColumnarSelector-rows li:nth-child(2) .ColumnarSelector-row");

            //TODO: verify tables and fields are hidden in query builder
        });

        it("should allow admin to create segments and metrics", async () => {
            await driver.get(`${server.host}/admin/datamodel/database/1/table/2`);

            // add a segment
            await waitForElementAndClick(driver, "#SegmentsList a.text-brand");

            await waitForElementAndClick(driver, ".GuiBuilder-filtered-by a");
            await waitForElementAndClick(driver, "#FilterPopover .List-item:nth-child(4)>a");
            const addFilterButton = findElement(driver, "#FilterPopover .Button.disabled");
            await waitForElementAndClick(driver, "#OperatorSelector .Button.Button-normal.Button--medium:nth-child(3)");
            await waitForElementAndSendKeys(driver, "#FilterPopover input.border-purple", 'gmail');
            expect(await addFilterButton.isEnabled()).toBe(true);
            await addFilterButton.click();

            await waitForElementAndSendKeys(driver, "input[name='name']", 'Gmail users');
            await waitForElementAndSendKeys(driver, "textarea[name='description']", 'All people using Gmail for email');

            await findElement(driver, "button.Button.Button--primary").click();

            expect(await waitForElementText(driver, "#SegmentsList tr:first-child td:first-child")).toEqual("Gmail users");

            // add a metric
            await waitForElementAndClick(driver, "#MetricsList a.text-brand");

            await waitForElementAndClick(driver, "#Query-section-aggregation");
            await waitForElementAndClick(driver, "#AggregationPopover .List-item:nth-child(2)>a");

            await waitForElementAndSendKeys(driver, "input[name='name']", 'User count');
            await waitForElementAndSendKeys(driver, "textarea[name='description']", 'Total number of users');

            await findElement(driver, "button.Button.Button--primary").click();

            expect(await waitForElementText(driver, "#MetricsList tr:first-child td:first-child")).toEqual("User count");
        });
    });
});<commit_msg>Fix E2E test [ci e2e]<commit_after>
import { By, until } from "selenium-webdriver";

import {
    waitForElement,
    waitForElementText,
    waitForElementRemoved,
    findElement,
    waitForElementAndClick,
    waitForElementAndSendKeys,
    waitForUrl,
    screenshot,
    loginMetabase,
    ensureLoggedIn,
    describeE2E
} from "../support/utils";

jasmine.DEFAULT_TIMEOUT_INTERVAL = 600000;

describeE2E("admin/datamodel", () => {
    beforeEach(() =>
        ensureLoggedIn(server, driver, "<EMAIL>", "12341234")
    );

    describe("data model editor", () => {
        it("should allow admin to edit data model", async () => {
            await driver.get(`${server.host}/admin/datamodel/database`);

            // hide orders table
            await waitForElementAndClick(driver, ".AdminList-items li:nth-child(2)");
            await screenshot(driver, "screenshots/admin-datamodel-orders.png");

            await waitForElementAndClick(driver, "#VisibilityTypes span:nth-child(2)");
            await waitForElementAndClick(driver, "#VisibilitySubTypes span:nth-child(3)");

            // unhide
            await waitForElementAndClick(driver, "#VisibilityTypes span:first-child");

            // hide fields from people table
            await waitForElementAndClick(driver, ".AdminList-items li:nth-child(3)");

            await waitForElementAndClick(driver, "#ColumnsList li:first-child .TableEditor-field-visibility");
            await waitForElementAndClick(driver, ".ColumnarSelector-rows li:nth-child(2) .ColumnarSelector-row");

            await waitForElementAndClick(driver, "#ColumnsList li:nth-child(2) .TableEditor-field-visibility");
            await waitForElementAndClick(driver, ".ColumnarSelector-rows li:nth-child(3) .ColumnarSelector-row");

            // modify special type for address field
            await waitForElementAndClick(driver, "#ColumnsList li:first-child .TableEditor-field-special-type");
            await waitForElementAndClick(driver, ".ColumnarSelector-rows li:nth-child(2) .ColumnarSelector-row");

            //TODO: verify tables and fields are hidden in query builder
        });

        it("should allow admin to create segments and metrics", async () => {
            await driver.get(`${server.host}/admin/datamodel/database/1/table/2`);

            // add a segment
            await waitForElementAndClick(driver, "#SegmentsList a.text-brand");

            await waitForElementAndClick(driver, ".GuiBuilder-filtered-by a");
            await waitForElementAndClick(driver, "#FilterPopover .List-item:nth-child(4)>a");
            const addFilterButton = findElement(driver, "#FilterPopover .Button.disabled");
            await waitForElementAndClick(driver, "#OperatorSelector .Button.Button-normal.Button--medium:nth-child(3)");
            await waitForElementAndSendKeys(driver, "#FilterPopover input.border-purple", 'gmail');
            expect(await addFilterButton.isEnabled()).toBe(true);
            await addFilterButton.click();

            await waitForElementAndSendKeys(driver, "input[name='name']", 'Gmail users');
            await waitForElementAndSendKeys(driver, "textarea[name='description']", 'All people using Gmail for email');

            await findElement(driver, "button.Button.Button--primary").click();

            expect(await waitForElementText(driver, "#SegmentsList tr:first-child td:first-child")).toEqual("Gmail users");

            // add a metric
            await waitForElementAndClick(driver, "#MetricsList a.text-brand");

            await waitForElementAndClick(driver, "#Query-section-aggregation");
            await waitForElementAndClick(driver, "#AggregationPopover .List-item:nth-child(1)>a");

            await waitForElementAndSendKeys(driver, "input[name='name']", 'User count');
            await waitForElementAndSendKeys(driver, "textarea[name='description']", 'Total number of users');

            await findElement(driver, "button.Button.Button--primary").click();

            expect(await waitForElementText(driver, "#MetricsList tr:first-child td:first-child")).toEqual("User count");
        });
    });
});
{'fraction_non_alphanumeric': 0.12626506024096384, 'fraction_numerical': 0.007228915662650603, 'mean_word_length': 3.254741158380318, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, 'https://': 0, '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': '5204625', 'n_tokens_mistral': 2298, 'n_tokens_neox': 2293, 'n_words': 446}