Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add pill display settings #1184

Merged
merged 1 commit into from
Jun 6, 2024
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
1 change: 1 addition & 0 deletions src/__mocks__/state-mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,5 @@ export const mockSettings: SettingsState = {
markAsDoneOnOpen: false,
showAccountHostname: false,
delayNotificationState: false,
showPills: true,
};
144 changes: 121 additions & 23 deletions src/components/NotificationRow.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ describe('components/NotificationRow.tsx', () => {
hostname: 'github.com',
};

const tree = render(<NotificationRow {...props} />);
const tree = render(
<AppContext.Provider value={{ settings: mockSettings }}>
<NotificationRow {...props} />
</AppContext.Provider>,
);
expect(tree).toMatchSnapshot();
});

Expand All @@ -43,7 +47,11 @@ describe('components/NotificationRow.tsx', () => {
hostname: 'github.com',
};

const tree = render(<NotificationRow {...props} />);
const tree = render(
<AppContext.Provider value={{ settings: mockSettings }}>
<NotificationRow {...props} />
</AppContext.Provider>,
);
expect(tree).toMatchSnapshot();
});

Expand All @@ -60,11 +68,42 @@ describe('components/NotificationRow.tsx', () => {
hostname: 'github.com',
};

const tree = render(<NotificationRow {...props} />);
const tree = render(
<AppContext.Provider value={{ settings: mockSettings }}>
<NotificationRow {...props} />
</AppContext.Provider>,
);
expect(tree).toMatchSnapshot();
});

describe('notification pills / metrics', () => {
describe('showPills disabled', () => {
it('should not render any pills when showPills is disabled', async () => {
jest
.spyOn(global.Date, 'now')
.mockImplementation(() => new Date('2024').valueOf());

const mockNotification = mockSingleNotification;
mockNotification.subject.linkedIssues = ['#1'];

const props = {
notification: mockNotification,
hostname: 'github.com',
};

const tree = render(
<AppContext.Provider
value={{
settings: { ...mockSettings, showPills: false },
}}
>
<NotificationRow {...props} />
</AppContext.Provider>,
);
expect(tree).toMatchSnapshot();
});
});

describe('linked issue pills', () => {
it('should render issues pill when linked to one issue/pr', async () => {
jest
Expand All @@ -79,7 +118,15 @@ describe('components/NotificationRow.tsx', () => {
hostname: 'github.com',
};

const tree = render(<NotificationRow {...props} />);
const tree = render(
<AppContext.Provider
value={{
settings: mockSettings,
}}
>
<NotificationRow {...props} />
</AppContext.Provider>,
);
expect(tree).toMatchSnapshot();
});

Expand All @@ -96,7 +143,15 @@ describe('components/NotificationRow.tsx', () => {
hostname: 'github.com',
};

const tree = render(<NotificationRow {...props} />);
const tree = render(
<AppContext.Provider
value={{
settings: mockSettings,
}}
>
<NotificationRow {...props} />
</AppContext.Provider>,
);
expect(tree).toMatchSnapshot();
});
});
Expand All @@ -115,7 +170,15 @@ describe('components/NotificationRow.tsx', () => {
hostname: 'github.com',
};

const tree = render(<NotificationRow {...props} />);
const tree = render(
<AppContext.Provider
value={{
settings: mockSettings,
}}
>
<NotificationRow {...props} />
</AppContext.Provider>,
);
expect(tree).toMatchSnapshot();
});

Expand All @@ -132,7 +195,15 @@ describe('components/NotificationRow.tsx', () => {
hostname: 'github.com',
};

const tree = render(<NotificationRow {...props} />);
const tree = render(
<AppContext.Provider
value={{
settings: mockSettings,
}}
>
<NotificationRow {...props} />
</AppContext.Provider>,
);
expect(tree).toMatchSnapshot();
});

Expand All @@ -149,7 +220,15 @@ describe('components/NotificationRow.tsx', () => {
hostname: 'github.com',
};

const tree = render(<NotificationRow {...props} />);
const tree = render(
<AppContext.Provider
value={{
settings: mockSettings,
}}
>
<NotificationRow {...props} />
</AppContext.Provider>,
);
expect(tree).toMatchSnapshot();
});
});
Expand All @@ -168,7 +247,15 @@ describe('components/NotificationRow.tsx', () => {
hostname: 'github.com',
};

const tree = render(<NotificationRow {...props} />);
const tree = render(
<AppContext.Provider
value={{
settings: mockSettings,
}}
>
<NotificationRow {...props} />
</AppContext.Provider>,
);
expect(tree).toMatchSnapshot();
});
});
Expand All @@ -190,7 +277,15 @@ describe('components/NotificationRow.tsx', () => {
hostname: 'github.com',
};

const tree = render(<NotificationRow {...props} />);
const tree = render(
<AppContext.Provider
value={{
settings: mockSettings,
}}
>
<NotificationRow {...props} />
</AppContext.Provider>,
);
expect(tree).toMatchSnapshot();
});

Expand All @@ -210,7 +305,15 @@ describe('components/NotificationRow.tsx', () => {
hostname: 'github.com',
};

const tree = render(<NotificationRow {...props} />);
const tree = render(
<AppContext.Provider
value={{
settings: mockSettings,
}}
>
<NotificationRow {...props} />
</AppContext.Provider>,
);
expect(tree).toMatchSnapshot();
});
});
Expand Down Expand Up @@ -304,12 +407,10 @@ describe('components/NotificationRow.tsx', () => {
<AppContext.Provider
value={{
settings: { ...mockSettings, markAsDoneOnOpen: false },
auth: mockAuth,
markNotificationRead,
}}
>
<AppContext.Provider value={{ markNotificationRead }}>
<NotificationRow {...props} />
</AppContext.Provider>
<NotificationRow {...props} />
</AppContext.Provider>,
);

Expand All @@ -327,14 +428,9 @@ describe('components/NotificationRow.tsx', () => {

render(
<AppContext.Provider
value={{
settings: { ...mockSettings },
auth: mockAuth,
}}
value={{ settings: mockSettings, markNotificationDone }}
>
<AppContext.Provider value={{ markNotificationDone }}>
<NotificationRow {...props} />
</AppContext.Provider>
<NotificationRow {...props} />
</AppContext.Provider>,
);

Expand All @@ -352,7 +448,9 @@ describe('components/NotificationRow.tsx', () => {

render(
<AppContext.Provider value={{}}>
<AppContext.Provider value={{ unsubscribeNotification }}>
<AppContext.Provider
value={{ settings: mockSettings, unsubscribeNotification }}
>
<NotificationRow {...props} />
</AppContext.Provider>
</AppContext.Provider>,
Expand Down
Loading
Loading