Skip to content

Commit

Permalink
Merge pull request #58 from robinmetral/disable-hydrate-on-client-only
Browse files Browse the repository at this point in the history
Disable the Hydrate task on client only configs
  • Loading branch information
AndrewOCC authored Jan 14, 2021
2 parents 92263a0 + 4dfc439 commit 6a9876f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/tasks/get-groups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@ export function getGroups({
result.push(server);
}
if (allowedGroups.includes('client')) {
result.push(client);
const tasks = allowedGroups.includes('server')
? client.tasks
: client.tasks.filter((task) => task.name !== 'Hydrate');
result.push({
...client,
tasks,
});
}

result.push(getInteractionGroup(interactions));
Expand Down
13 changes: 12 additions & 1 deletion test/panel/group-filtering.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import server from '../../src/tasks/preset/server';
it('should allow filtering of tasks (client only)', () => {
// 1: Initial render
const channel: Channel = new Channel({ async: false });
const { container, queryByText } = render(
const { container, queryByText, debug } = render(
<WithStorybookTheme>
<Panel interactions={[]} channel={channel} allowedGroups={['client']} />
</WithStorybookTheme>,
Expand All @@ -37,6 +37,14 @@ it('should allow filtering of tasks (client only)', () => {

expect(queryByText(client.name)).toBeTruthy();
expect(queryByText(server.name)).toBeFalsy();

// All tasks should be rendered except Hydrate (see #57)
expect(queryByText('Hydrate')).toBeFalsy();
client.tasks.forEach((task) => {
if (task.name !== 'Hydrate') {
expect(queryByText(task.name)).toBeTruthy();
}
});
});

it('should allow filtering of tasks (server only)', () => {
Expand Down Expand Up @@ -64,4 +72,7 @@ it('should allow filtering of tasks (server only)', () => {

expect(queryByText(client.name)).toBeFalsy();
expect(queryByText(server.name)).toBeTruthy();
server.tasks.forEach((task) => {
expect(queryByText(task.name)).toBeTruthy();
});
});

0 comments on commit 6a9876f

Please sign in to comment.