<commit_before>import loginAsRole from '../../helpers/login-as-role';
import {currentURL} from '@ember/test-helpers';
import {expect} from 'chai';
import {setupApplicationTest} from 'ember-mocha';
import {setupMirage} from 'ember-cli-mirage/test-support';
import {visit} from '../../helpers/visit';

describe('Acceptance: Lexical editor', function () {
    let hooks = setupApplicationTest();
    setupMirage(hooks);

    beforeEach(async function () {
        this.server.loadFixtures();
    });

    it('redirects to signin when not authenticated', async function () {
        await visit('/lexical-editor/post/');
        expect(currentURL(), 'currentURL').to.equal('/signin');
    });

    it('redirects to posts screen if editor.lexicalUrl config is missing', async function () {
        await loginAsRole('Administrator', this.server);
        await visit('/lexical-editor/post/');

        expect(currentURL(), 'currentURL').to.equal('/posts');
    });

    it('loads when editor.lexicalUrl is present', async function () {
        const config = this.server.schema.configs.find(1);
        config.attrs.editor = {lexicalUrl: 'https://cdn.pkg/editor.js'};
        config.save();

        // stub loaded external module
        window.KoenigLexical = {
            KoenigComposer: () => null,
            KoenigEditor: () => null
        };

        await loginAsRole('Administrator', this.server);
        await visit('/lexical-editor/post/');
        expect(currentURL(), 'currentURL').to.equal('/lexical-editor/post/');
    });
});
<commit_msg>Updated lexical editor acceptance test to match new behaviour<commit_after>import loginAsRole from '../../helpers/login-as-role';
import {currentURL} from '@ember/test-helpers';
import {expect} from 'chai';
import {setupApplicationTest} from 'ember-mocha';
import {setupMirage} from 'ember-cli-mirage/test-support';
import {visit} from '../../helpers/visit';

describe('Acceptance: Lexical editor', function () {
    let hooks = setupApplicationTest();
    setupMirage(hooks);

    beforeEach(async function () {
        this.server.loadFixtures();
    });

    it('redirects to signin when not authenticated', async function () {
        await visit('/lexical-editor/post/');
        expect(currentURL(), 'currentURL').to.equal('/signin');
    });

    it('redirects to posts screen if editor.url config is missing', async function () {
        await loginAsRole('Administrator', this.server);
        await visit('/lexical-editor/post/');

        expect(currentURL(), 'currentURL').to.equal('/posts');
    });

    it('loads when editor.url is present', async function () {
        const config = this.server.schema.configs.find(1);
        config.attrs.editor = {url: 'https://cdn.pkg/editor.js'};
        config.save();

        // stub loaded external module
        window.KoenigLexical = {
            KoenigComposer: () => null,
            KoenigEditor: () => null
        };

        await loginAsRole('Administrator', this.server);
        await visit('/lexical-editor/post/');
        expect(currentURL(), 'currentURL').to.equal('/lexical-editor/post/');
    });
});

{'fraction_non_alphanumeric': 0.16022981168209385, 'fraction_numerical': 0.0006383657835939994, 'mean_word_length': 3.06485084306096, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '4734509', 'n_tokens_mistral': 897, 'n_tokens_neox': 885, 'n_words': 198}