Skip to content

Commit

Permalink
feat: add pill display settings (#1184)
Browse files Browse the repository at this point in the history
  • Loading branch information
setchy committed Jun 6, 2024
1 parent 811cc2d commit a342c17
Show file tree
Hide file tree
Showing 10 changed files with 675 additions and 106 deletions.
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

0 comments on commit a342c17

Please sign in to comment.