<commit_before><?php

namespace Tests\Browser;

use Rogue\Models\Post;
use Tests\DuskTestCase;
use Rogue\Models\Signup;
use Laravel\Dusk\Browser;
use Tests\Browser\Pages\HomePage;
use Tests\Browser\Pages\CampaignInboxPage;
use Tests\Browser\Pages\CampaignSinglePage;

class ReviewPostTest extends DuskTestCase
{
    /**
     * Test user flow of approving a pending Post and tagging it as a Good Photo.
     *
     * @group ReviewPost
     * @return void
     */
    public function testApprovingAndTaggingAPost()
    {
        // Create a signup and an associated post with a 'pending' status
        // so there will be a post in the campaign inbox.
        $signup = factory(Signup::class)->create();
        $post = $this->createAssociatedPostWithStatus($signup, 'pending');

        $this->browse(function (Browser $browser) use ($signup) {
            $this->login($browser);

            $browser->assertAuthenticated()
                    ->visit('/campaigns/' . $signup->campaign_id)
                    ->on(new CampaignSinglePage($signup->campaign_id))
                    ->clickLink('Review')
                    ->assertPathIs('/campaigns/' . $signup->campaign_id . '/inbox')
                    ->on(new CampaignInboxPage($signup->campaign_id))
                    ->waitFor('@acceptButton')
                    ->press('Accept')
                    ->waitFor('@activeAcceptButton')
                    ->assertSeeIn('@activeAcceptButton', 'Accept')
                    ->press('Good Photo')
                    ->waitFor('@activeTagButton')
                    ->assertSeeIn('@activeTagButton', 'Good Photo');
        });
    }

    /**
     * Test user flow of rejecting a pending Post.
     *
     * @group ReviewPost
     * @return void
     */
    public function testRejectingAPost()
    {
        // Create a signup and an associated post with a 'pending' status
        // so there will be a post in the campaign inbox.
        $signup = factory(Signup::class)->create();
        $post = $this->createAssociatedPostWithStatus($signup, 'pending');

        $this->browse(function (Browser $browser) use ($signup) {
            $browser->visit(new HomePage)
                    // We're already logged in from the first test.
                    ->assertAuthenticated()
                    ->visit('/campaigns/' . $signup->campaign_id)
                    ->on(new CampaignSinglePage($signup->campaign_id))
                    ->clickLink('Review')
                    ->assertPathIs('/campaigns/' . $signup->campaign_id . '/inbox')
                    ->on(new CampaignInboxPage($signup->campaign_id))
                    ->waitFor('@rejectButton')
                    ->press('Reject')
                    ->waitFor('@activeRejectButton')
                    ->assertSeeIn('@activeRejectButton', 'Reject')
                    ->assertDontSee('@tagButton', 'Good Photo');
        });
    }<commit_msg>updates test to see disabled/enabled tags and ability to tag rejected post<commit_after><?php

namespace Tests\Browser;

use Rogue\Models\Post;
use Tests\DuskTestCase;
use Rogue\Models\Signup;
use Laravel\Dusk\Browser;
use Tests\Browser\Pages\HomePage;
use Tests\Browser\Pages\CampaignInboxPage;
use Tests\Browser\Pages\CampaignSinglePage;

class ReviewPostTest extends DuskTestCase
{
    /**
     * Test user flow of approving a pending Post and tagging it as a Good Photo.
     *
     * @group ReviewPost
     * @return void
     */
    public function testApprovingAndTaggingAPost()
    {
        // Create a signup and an associated post with a 'pending' status
        // so there will be a post in the campaign inbox.
        $signup = factory(Signup::class)->create();
        $post = $this->createAssociatedPostWithStatus($signup, 'pending');

        $this->browse(function (Browser $browser) use ($signup) {
            $this->login($browser);

            $browser->assertAuthenticated()
                    ->visit('/campaigns/' . $signup->campaign_id)
                    ->on(new CampaignSinglePage($signup->campaign_id))
                    ->clickLink('Review')
                    ->assertPathIs('/campaigns/' . $signup->campaign_id . '/inbox')
                    ->on(new CampaignInboxPage($signup->campaign_id))
                    ->waitFor('@acceptButton')
                    ->assertSeeIn('.disabled', 'Tags')
                    ->press('Accept')
                    ->waitFor('@activeAcceptButton')
                    ->assertSeeIn('@activeAcceptButton', 'Accept')
                    ->assertSeeIn('.enabled', 'Tags')
                    ->press('Good Photo')
                    ->waitFor('@activeTagButton')
                    ->assertSeeIn('@activeTagButton', 'Good Photo');
        });
    }

    /**
     * Test user flow of rejecting a pending Post and tagging it as a Test.
     *
     * @group ReviewPost
     * @return void
     */
    public function testRejectingAndTaggingAPost()
    {
        // Create a signup and an associated post with a 'pending' status
        // so there will be a post in the campaign inbox.
        $signup = factory(Signup::class)->create();
        $post = $this->createAssociatedPostWithStatus($signup, 'pending');

        $this->browse(function (Browser $browser) use ($signup) {
            $browser->visit(new HomePage)
                    // We're already logged in from the first test.
                    ->assertAuthenticated()
                    ->visit('/campaigns/' . $signup->campaign_id)
                    ->on(new CampaignSinglePage($signup->campaign_id))
                    ->clickLink('Review')
                    ->assertPathIs('/campaigns/' . $signup->campaign_id . '/inbox')
                    ->on(new CampaignInboxPage($signup->campaign_id))
                    ->waitFor('@rejectButton')
                    ->assertSeeIn('.disabled', 'Tags')
                    ->press('Reject')
                    ->waitFor('@activeRejectButton')
                    ->assertSeeIn('@activeRejectButton', 'Reject')
                    ->assertSeeIn('.enabled', 'Tags')
                    ->press('Test')
                    ->waitFor('@activeTagButton')
                    ->assertSeeIn('@activeTagButton', 'Test');
        });
    }
{'fraction_non_alphanumeric': 0.1288048702338994, 'fraction_numerical': 0.0, 'mean_word_length': 1.8929564411492121, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 89, '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': '342809', 'n_tokens_mistral': 1698, 'n_tokens_neox': 1595, 'n_words': 370}