<commit_before>"use strict";

var shared = require("./core/shared.js");
var MercatorProposalFormPage = require("./MercatorProposalFormPage.js");
var MercatorProposalListing = require("./MercatorProposalListing.js");


describe("mercator proposal form", function() {
    afterEach(function() {
        shared.logout();
    });

    it("is validated correctly", function() {
        shared.loginAnnotator();

        var page = new MercatorProposalFormPage().create();
        expect(page.isValid()).toBe(false);

        // make all good
        page.fillValid();
        expect(page.isValid()).toBe(true);

        // experience is optional
        page.experience.clear();
        expect(page.isValid()).toBe(true);

        // location is required
        page.locationLocationIsSpecific.click();
        page.locationLocationIsLinkedToRuhr.click();
        expect(page.isValid()).toBe(false);
        page.locationLocationIsLinkedToRuhr.click();
        expect(page.isValid()).toBe(true);

        // name is required
        page.userInfoFirstName.clear();
        expect(page.isValid()).toBe(false);
        page.userInfoFirstName.sendKeys("pizza");
        expect(page.isValid()).toBe(true);

        // heard_from is required
        page.heardFromColleague.click();
        expect(page.isValid()).toBe(false);
        page.heardFromColleague.click();
        expect(page.isValid()).toBe(true);

        // image has min width
        page.setImage("./proposalImageTooSmall.png");
        expect(shared.hasClass(page.form, "ng-invalid-too-narrow"));
        expect(page.isValid()).toBe(false);
        page.setImage("./proposalImageValid.png");
        expect(page.isValid()).toBe(true);
    });

    it("is submitted properly", function() {
        shared.loginAnnotator();

        var page = new MercatorProposalFormPage().create();
        page.fillValid();
        page.submitButton.click();
        expect(browser.getCurrentUrl()).not.toContain("@create");
        expect(element(by.css("adh-mercator-proposal-detail-view .mercator-proposal-cover-header"))
            .getText()).toContain("protitle");
    });

    xit("allows creator to edit existing proposals (depends on submit) - fails due to #679", function() {
        shared.loginAnnotator();

        var list = new MercatorProposalListing().get();
        browser.waitForAngular();
        var form = list.getDetailPage(0).getEditPage();
        form.userInfoLastName.clear();
        expect(form.isValid()).toBe(false);
        form.userInfoLastName.sendKeys("rasta");

        form.acceptDisclaimer.click();
        form.submitButton.click();
        expect(browser.getCurrentUrl()).not.toContain("@edit");
        browser.waitForAngular();
        expect(element(by.tagName("adh-mercator-proposal-detail-view")).element(by.tagName("adh-user-meta")).getText()).toContain("pita rasta");
    });

    it("disallows anonymous to edit existing proposals (depends on submit)", function() {
        var list = new MercatorProposalListing().get();
        var editButton = list.getDetailPage(0).editButton;
        expect(editButton.isPresent()).toBe(false);
    });

    it("disallows other users to edit existing proposals (depends on submit)", function() {
        shared.loginContributor();
        var list = new MercatorProposalListing().get();
        var editButton = list.getDetailPage(0).editButton;
        expect(editButton.isPresent()).toBe(false);
    });<commit_msg>Mark proposal edit acceptance test as fixed<commit_after>"use strict";

var shared = require("./core/shared.js");
var MercatorProposalFormPage = require("./MercatorProposalFormPage.js");
var MercatorProposalListing = require("./MercatorProposalListing.js");


describe("mercator proposal form", function() {
    afterEach(function() {
        shared.logout();
    });

    it("is validated correctly", function() {
        shared.loginAnnotator();

        var page = new MercatorProposalFormPage().create();
        expect(page.isValid()).toBe(false);

        // make all good
        page.fillValid();
        expect(page.isValid()).toBe(true);

        // experience is optional
        page.experience.clear();
        expect(page.isValid()).toBe(true);

        // location is required
        page.locationLocationIsSpecific.click();
        page.locationLocationIsLinkedToRuhr.click();
        expect(page.isValid()).toBe(false);
        page.locationLocationIsLinkedToRuhr.click();
        expect(page.isValid()).toBe(true);

        // name is required
        page.userInfoFirstName.clear();
        expect(page.isValid()).toBe(false);
        page.userInfoFirstName.sendKeys("pizza");
        expect(page.isValid()).toBe(true);

        // heard_from is required
        page.heardFromColleague.click();
        expect(page.isValid()).toBe(false);
        page.heardFromColleague.click();
        expect(page.isValid()).toBe(true);

        // image has min width
        page.setImage("./proposalImageTooSmall.png");
        expect(shared.hasClass(page.form, "ng-invalid-too-narrow"));
        expect(page.isValid()).toBe(false);
        page.setImage("./proposalImageValid.png");
        expect(page.isValid()).toBe(true);
    });

    it("is submitted properly", function() {
        shared.loginAnnotator();

        var page = new MercatorProposalFormPage().create();
        page.fillValid();
        page.submitButton.click();
        expect(browser.getCurrentUrl()).not.toContain("@create");
        expect(element(by.css("adh-mercator-proposal-detail-view .mercator-proposal-cover-header"))
            .getText()).toContain("protitle");
    });

    it("allows creator to edit existing proposals (depends on submit)", function() {
        shared.loginAnnotator();

        var list = new MercatorProposalListing().get();
        browser.waitForAngular();
        var form = list.getDetailPage(0).getEditPage();
        form.userInfoLastName.clear();
        expect(form.isValid()).toBe(false);
        form.userInfoLastName.sendKeys("rasta");

        form.acceptDisclaimer.click();
        form.submitButton.click();
        expect(browser.getCurrentUrl()).not.toContain("@edit");
        browser.waitForAngular();
        expect(element(by.tagName("adh-mercator-proposal-detail-view")).element(by.tagName("adh-user-meta")).getText()).toContain("pita rasta");
    });

    it("disallows anonymous to edit existing proposals (depends on submit)", function() {
        var list = new MercatorProposalListing().get();
        var editButton = list.getDetailPage(0).editButton;
        expect(editButton.isPresent()).toBe(false);
    });

    it("disallows other users to edit existing proposals (depends on submit)", function() {
        shared.loginContributor();
        var list = new MercatorProposalListing().get();
        var editButton = list.getDetailPage(0).editButton;
        expect(editButton.isPresent()).toBe(false);
    });
{'fraction_non_alphanumeric': 0.14994934143870314, 'fraction_numerical': 0.0013026487190620929, 'mean_word_length': 3.0338587273788673, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5103169', 'n_tokens_mistral': 1955, 'n_tokens_neox': 1911, 'n_words': 310}