Skip to content
Merged
Show file tree
Hide file tree
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
123 changes: 122 additions & 1 deletion playwright/repo.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import { Page } from '@playwright/test';
import { test, expect } from './fixtures';
import { mockBuildsByNumber, mockBuildsList } from './utils/buildMocks';
import { mockHooksListPaged } from './utils/hookMocks';
import { mockHooksList, mockHooksListPaged } from './utils/hookMocks';
import { mockSecretsList } from './utils/secretMocks';
import {
mockRepoDetail,
Expand Down Expand Up @@ -211,4 +211,125 @@ test.describe('Repo', () => {
});
});
});

test.describe('logged in with no builds', () => {
test('should show audit indicator when latest hook fails and there are no builds', async ({
page,
app,
}) => {
await mockRepoDetail(page, 'repository.json');
await mockBuildsList(page, []);
await mockHooksList(page, [
{
id: 1,
number: 1,
repo_id: 1,
build_id: 0,
source_id: 'source-id',
created: 200,
host: 'github.com',
event: 'push',
branch: 'main',
error: 'unable to process webhook',
status: 'failure',
link: 'https://github.com/github/octocat/settings/hooks',
},
]);

await app.login('/github/octocat');
await page.getByTestId('jump-bar-repo').waitFor();

await expect(page.getByTestId('jump-Audit')).toHaveClass(/alerting/);
});

test('should not show audit indicator when latest hook succeeds and there are no builds', async ({
page,
app,
}) => {
await mockRepoDetail(page, 'repository.json');
await mockBuildsList(page, []);
await mockHooksList(page, [
{
id: 1,
number: 1,
repo_id: 1,
build_id: 0,
source_id: 'source-id',
created: 200,
host: 'github.com',
event: 'push',
branch: 'main',
error: '',
status: 'success',
link: 'https://github.com/github/octocat/settings/hooks',
},
]);

await app.login('/github/octocat');
await page.getByTestId('jump-bar-repo').waitFor();

await expect(page.getByTestId('jump-Audit')).not.toHaveClass(/alerting/);
});

test('should not show audit indicator when latest hook is skipped and there are no builds', async ({
page,
app,
}) => {
await mockRepoDetail(page, 'repository.json');
await mockBuildsList(page, []);
await mockHooksList(page, [
{
id: 1,
number: 1,
repo_id: 1,
build_id: 0,
source_id: 'source-id',
created: 200,
host: 'github.com',
event: 'push',
branch: 'main',
error: 'no matching ruleset',
status: 'skipped',
link: 'https://github.com/github/octocat/settings/hooks',
},
]);

await app.login('/github/octocat');
await page.getByTestId('jump-bar-repo').waitFor();

await expect(page.getByTestId('jump-Audit')).not.toHaveClass(/alerting/);
});
});

test.describe('logged in with builds and failed latest hook', () => {
test('should show audit indicator when latest hook fails and is newer than latest build', async ({
page,
app,
}) => {
await mockRepoDetail(page, 'repository.json');
await mockBuildsList(page, 'builds_5.json');
await mockBuildsByNumber(page);
await mockHooksList(page, [
{
id: 1,
number: 1,
repo_id: 1,
build_id: 0,
source_id: 'source-id',
created: 9999999999,
host: 'github.com',
event: 'push',
branch: 'main',
error: 'unable to process webhook',
status: 'failure',
link: 'https://github.com/github/octocat/settings/hooks',
},
]);

await app.login('/github/octocat');
await page.getByTestId('jump-bar-repo').waitFor();

await expect(page.getByTestId('jump-Audit')).toHaveClass(/alerting/);
});
});
});
11 changes: 11 additions & 0 deletions src/elm/Components/Tabs.elm
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,17 @@ viewRepoTabs shared props =
_ ->
hook.created > build.created

( Just hook, Nothing ) ->
case hook.status of
"success" ->
False

"skipped" ->
False

_ ->
True

_ ->
False

Expand Down
Loading