Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions tests/Feature/Screens/OrgMembersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function serveOrg(array $thread, array $writes = [], array $candidates = []): vo
});
}

function writesSent(): array
function memberWritesSent(): array
{
return collect(Http::recorded())
->filter(fn (array $sent): bool => $sent[0]->method() !== 'GET')
Expand Down Expand Up @@ -139,7 +139,7 @@ function writesSent(): array
->call('addPeople')
->assertNoNavigation();

expect(writesSent())->toBe([]);
expect(memberWritesSent())->toBe([]);
});

it('renames the org at once, and takes the name away when the field is empty', function () {
Expand Down Expand Up @@ -195,7 +195,7 @@ function writesSent(): array
finishRefreshes($screen);

expect($screen->instance()->members[1]['role'])->toBe('maintainer')
->and(writesSent())->toBe(['PUT remotes/orgs/org-1/members/ada'])
->and(memberWritesSent())->toBe(['PUT remotes/orgs/org-1/members/ada'])
->and(json_decode(sentTo('PUT', 'remotes/orgs/org-1/members/ada')[0], true))->toBe(['role' => 'maintainer']);
})->with(['ios', 'android']);

Expand Down Expand Up @@ -226,7 +226,7 @@ function writesSent(): array
$screen->call('makeContributor', 'grace')
->assertNativeCalled('ToastKit.Show', fn (array $params): bool => $params['message'] === 'An org needs at least one maintainer.');

expect(writesSent())->toBe([]);
expect(memberWritesSent())->toBe([]);
});

it('asks before removing someone, and removes them only once you say so', function () {
Expand All @@ -240,15 +240,15 @@ function writesSent(): array
->emitNative(ButtonPressed::class, ['index' => 0, 'label' => 'Cancel', 'id' => 'remove-member:org-1:ada'])
->assertSee('Ada Lovelace');

expect(writesSent())->toBe([]);
expect(memberWritesSent())->toBe([]);

$screen->emitNative(ButtonPressed::class, ['index' => 1, 'label' => 'Remove', 'id' => 'remove-member:org-1:ada'])
->assertDontSee('Ada Lovelace');

serveOrg(orgJson(members: [orgJson()['data']['members'][0], orgJson()['data']['members'][2]]));
finishRefreshes($screen)->assertDontSee('Ada Lovelace');

expect(writesSent())->toBe(['DELETE remotes/orgs/org-1/members/ada']);
expect(memberWritesSent())->toBe(['DELETE remotes/orgs/org-1/members/ada']);
});

it('puts someone back where they were when devnull won’t remove them', function () {
Expand All @@ -271,7 +271,7 @@ function writesSent(): array
->emitNative(ButtonPressed::class, ['index' => 0, 'label' => 'Cancel', 'id' => 'leave-org:org-1'])
->assertNoNavigation();

expect(writesSent())->toBe([]);
expect(memberWritesSent())->toBe([]);
});

it('leaves the org, takes it out of the kept inbox, and goes back past its thread to the inbox', function () {
Expand All @@ -284,7 +284,7 @@ function writesSent(): array
finishRefreshes($members)->emitNative(ButtonPressed::class, ['index' => 1, 'label' => 'Leave', 'id' => 'leave-org:org-1']);
finishRefreshes($members)->assertWentBack();

expect(writesSent())->toContain('DELETE remotes/orgs/org-1/members/local_dev')
expect(memberWritesSent())->toContain('DELETE remotes/orgs/org-1/members/local_dev')
->and(array_column(kept('remotes')['data'], 'id'))->toBe(['conv-1'])
->and(kept('remotes/orgs/org-1/messages'))->toBeNull();

Expand Down
Loading