Skip to content

Commit

Permalink
test(frontend): test sidebar components (#148)
Browse files Browse the repository at this point in the history
Some basic tests to check that sidebar sections render in the storybook.
  • Loading branch information
eatyourgreens authored Oct 3, 2024
1 parent 0f746a1 commit 66fc81a
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { StoryObj, Meta } from '@storybook/react';
import { expect, within } from '@storybook/test';

import { BuildingsSection } from './BuildingsSection';

Expand All @@ -23,4 +24,8 @@ export const Default: Story = {
args: {
view: 'exposure',
},
play: ({ canvasElement }) => {
const canvas = within(canvasElement);
expect(canvas.queryByText('Buildings')).toBeTruthy();
},
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { StoryObj, Meta } from '@storybook/react';
import { expect, within } from '@storybook/test';

import { DroughtsSection } from './DroughtsSection';

Expand All @@ -23,4 +24,8 @@ export const Default: Story = {
args: {
view: 'adaptation',
},
play: ({ canvasElement }) => {
const canvas = within(canvasElement);
expect(canvas.queryByText('Drought')).toBeTruthy();
},
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { StoryObj, Meta } from '@storybook/react';
import { expect, within } from '@storybook/test';

import { HazardsSection } from './HazardsSection';

Expand All @@ -23,10 +24,18 @@ export const Exposure: Story = {
args: {
view: 'exposure',
},
play: ({ canvasElement }) => {
const canvas = within(canvasElement);
expect(canvas.queryByText('Hazards')).toBeTruthy();
},
};

export const Risk: Story = {
args: {
view: 'risk',
},
play: ({ canvasElement }) => {
const canvas = within(canvasElement);
expect(canvas.queryByText('Hazards')).toBeTruthy();
},
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { StoryObj, Meta } from '@storybook/react';
import { expect, within } from '@storybook/test';

import { MarineSection } from './MarineSection';

Expand All @@ -23,4 +24,8 @@ export const Default: Story = {
args: {
view: 'nature-based-solutions',
},
play: ({ canvasElement }) => {
const canvas = within(canvasElement);
expect(canvas.queryByText('Marine')).toBeTruthy();
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const Exposure: Story = {
},
play: ({ canvasElement }) => {
const canvas = within(canvasElement);
expect(canvas.queryByText('Infrastructure')).toBeTruthy();
expect(
canvas.queryByText(
'Infrastructure layers are currently following the Adaptation Options selection',
Expand All @@ -48,6 +49,7 @@ export const Risk: Story = {
},
play: ({ canvasElement }) => {
const canvas = within(canvasElement);
expect(canvas.queryByText('Infrastructure')).toBeTruthy();
expect(
canvas.queryByText(
'Infrastructure layers are currently following the Adaptation Options selection',
Expand All @@ -62,6 +64,7 @@ export const Adaptation: Story = {
},
play: ({ canvasElement }) => {
const canvas = within(canvasElement);
expect(canvas.queryByText('Infrastructure')).toBeTruthy();
expect(
canvas.queryByText(
'Infrastructure layers are currently following the Adaptation Options selection',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { StoryObj, Meta } from '@storybook/react';
import { expect, within } from '@storybook/test';

import { RegionsSection } from './RegionsSection';

Expand All @@ -23,4 +24,8 @@ export const Default: Story = {
args: {
view: 'exposure',
},
play: ({ canvasElement }) => {
const canvas = within(canvasElement);
expect(canvas.queryByText('Regions')).toBeTruthy();
},
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { StoryObj, Meta } from '@storybook/react';
import { expect, within } from '@storybook/test';

import { TerrestrialSection } from './TerrestrialSection';

Expand All @@ -23,4 +24,8 @@ export const Default: Story = {
args: {
view: 'nature-based-solutions',
},
play: ({ canvasElement }) => {
const canvas = within(canvasElement);
expect(canvas.queryByText('Terrestrial')).toBeTruthy();
},
};

0 comments on commit 66fc81a

Please sign in to comment.