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
Original file line number Diff line number Diff line change
Expand Up @@ -188,15 +188,17 @@ describe('notification list in a browser', () => {
});
await page.getByTestId(`${kind}-mark-as-read`).first().click();
await waitFor(() =>
expect(document.getElementById('notification-0')?.classList.contains('opacity-0')).toBe(
expect(document.getElementById('notification-0')?.hasAttribute('data-animating-exit')).toBe(
true,
),
);
await scrollToEnd();
await waitFor(() => expect(document.getElementById('notification-0')).toBeNull());
await scrollToStart();
await waitFor(() => expect(document.getElementById('notification-0')).not.toBeNull());
expect(document.getElementById('notification-0')?.classList.contains('opacity-0')).toBe(true);
expect(document.getElementById('notification-0')?.hasAttribute('data-animating-exit')).toBe(
true,
);
expect(
document
.getElementById('notification-0')
Expand All @@ -207,7 +209,7 @@ describe('notification list in a browser', () => {
await pending;
});
await waitFor(() =>
expect(document.getElementById('notification-0')?.classList.contains('opacity-0')).toBe(
expect(document.getElementById('notification-0')?.hasAttribute('data-animating-exit')).toBe(
false,
),
);
Expand Down Expand Up @@ -245,7 +247,7 @@ describe('notification list in a browser', () => {
const original = getMockedNotificationsState().notifications;
await page.getByTestId(`${kind}-mark-as-read`).first().click();
await waitFor(() =>
expect(document.getElementById('notification-0')?.classList.contains('opacity-0')).toBe(
expect(document.getElementById('notification-0')?.hasAttribute('data-animating-exit')).toBe(
true,
),
);
Expand All @@ -270,7 +272,7 @@ describe('notification list in a browser', () => {
await scrollToStart();
await waitFor(() => expect(document.getElementById('notification-0')).not.toBeNull());
expect(scrollContainer()).toBe(scroller);
expect(document.getElementById('notification-0')?.classList.contains('opacity-0')).toBe(
expect(document.getElementById('notification-0')?.hasAttribute('data-animating-exit')).toBe(
false,
);
expect(
Expand Down Expand Up @@ -303,8 +305,10 @@ describe('notification list in a browser', () => {
});
await waitFor(() => expect(document.getElementById('new-notification')).not.toBeNull());
expect(scrollContainer()).toBe(scroller);
expect(document.getElementById('notification-0')?.classList.contains('opacity-0')).toBe(true);
expect(document.getElementById('new-notification')?.classList.contains('opacity-0')).toBe(
expect(document.getElementById('notification-0')?.hasAttribute('data-animating-exit')).toBe(
true,
);
expect(document.getElementById('new-notification')?.hasAttribute('data-animating-exit')).toBe(
false,
);
await act(async () => {
Expand All @@ -316,7 +320,7 @@ describe('notification list in a browser', () => {
// oxlint-disable-next-line typescript/await-thenable -- Vitest types omit `expect.element`'s poll promise
await expect.element(page.getByTestId('repository-mark-as-read')).toBeVisible();
expect(scrollContainer()).toBe(scroller);
expect(document.getElementById('new-notification')?.classList.contains('opacity-0')).toBe(
expect(document.getElementById('new-notification')?.hasAttribute('data-animating-exit')).toBe(
false,
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export function NotificationRow({
isAnimatingExit && 'translate-x-full opacity-0 transition duration-350 ease-in-out',
isNotificationRead && Opacity.READ,
)}
data-animating-exit={isAnimatingExit || undefined}
id={notification.id}
>
<Stack align="center" className="gitify-row-content" direction="horizontal" gap="condensed">
Expand Down
55 changes: 24 additions & 31 deletions src/renderer/routes/Accounts.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import {

import { useAccountsStore } from '../stores';

import { IconColor } from '../types';

import {
getAlternateScopeNames,
getRecommendedScopeNames,
Expand Down Expand Up @@ -74,55 +72,41 @@ describe('renderer/routes/Accounts.tsx', () => {
{
name: 'recommended scopes',
scopes: getRecommendedScopeNames(),
color: IconColor.GREEN,
variant: 'default',
},
{
name: 'alternate scopes only',
scopes: getAlternateScopeNames(),
color: 'text-gitify-warning',
variant: 'default',
},
{
name: 'neither scope set',
scopes: getRequiredScopeNames(),
color: null,
variant: 'danger',
},
{
name: 'both scope sets',
scopes: [...new Set([...getRecommendedScopeNames(), ...getAlternateScopeNames()])],
color: IconColor.GREEN,
variant: 'default',
},
];

it.each(scopeCases)(
'preserves the icon color and button variant for $name',
async ({ scopes, color, variant }) => {
async ({ scopes, variant }) => {
const account = { ...mockPersonalAccessTokenAccount, scopes };

await act(async () => {
renderWithProviders(<AccountsRoute />, {
accounts: [{ ...mockPersonalAccessTokenAccount, scopes }],
});
renderWithProviders(<AccountsRoute />, { accounts: [account] });
});

const button = screen.getByTestId('account-view-scopes');
const icon = button.querySelector('svg');
const button = screen.getByRole('button', {
name: `View scopes for ${account.user?.login}`,
});

expect(icon).toHaveClass('octicon-shield-check');
expect(button.querySelector('svg')).toHaveClass('octicon-shield-check');
expect(button).toHaveAttribute('data-variant', variant);
expect(button).toHaveAttribute('data-size', 'small');
expect(button).toHaveAccessibleName(
`View scopes for ${mockPersonalAccessTokenAccount.user?.login}`,
);
if (color) {
expect(icon).toHaveClass(color);
}
for (const scopeColor of [IconColor.GREEN, 'text-gitify-warning']) {
if (scopeColor !== color) {
expect(icon).not.toHaveClass(scopeColor);
}
}
},
);

Expand All @@ -135,7 +119,9 @@ describe('renderer/routes/Accounts.tsx', () => {
renderWithProviders(<AccountsRoute />, { accounts: [account] });
});

const icon = screen.getByTestId('account-view-scopes').querySelector('svg');
const icon = screen
.getByRole('button', { name: `View scopes for ${account.user?.login}` })
.querySelector('svg');
expect(icon).toBeInTheDocument();

const updatedAccount = {
Expand All @@ -149,7 +135,11 @@ describe('renderer/routes/Accounts.tsx', () => {
});

expect(screen.getByText('Updated account name')).toBeInTheDocument();
expect(screen.getByTestId('account-view-scopes').querySelector('svg')).toBe(icon);
expect(
screen
.getByRole('button', { name: `View scopes for ${account.user?.login}` })
.querySelector('svg'),
).toBe(icon);
},
);

Expand All @@ -163,9 +153,11 @@ describe('renderer/routes/Accounts.tsx', () => {
renderWithProviders(<AccountsRoute />, { accounts: [account] });
});

const button = screen.getByTestId('account-view-scopes');
const button = screen.getByRole('button', {
name: `View scopes for ${account.user?.login}`,
});

expect(button).toHaveAttribute('data-variant', 'danger');
expect(button.querySelector('svg')).not.toHaveClass(IconColor.GREEN, 'text-gitify-warning');

const updatedAccount = { ...account, scopes: getRecommendedScopeNames() };
expect(getAccountUUID(updatedAccount)).toBe(getAccountUUID(account));
Expand All @@ -174,9 +166,10 @@ describe('renderer/routes/Accounts.tsx', () => {
useAccountsStore.setState({ accounts: [updatedAccount] });
});

const updatedButton = screen.getByTestId('account-view-scopes');
expect(updatedButton.querySelector('svg')).toHaveClass(IconColor.GREEN);
expect(updatedButton.querySelector('svg')).not.toHaveClass('text-gitify-warning');
const updatedButton = screen.getByRole('button', {
name: `View scopes for ${updatedAccount.user?.login}`,
});

expect(updatedButton).toHaveAttribute('data-variant', 'default');

await userEvent.click(updatedButton);
Expand Down
Loading