• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

CBIIT / crdc-datahub-ui / 13768297073

10 Mar 2025 03:20PM UTC coverage: 59.96% (-0.3%) from 60.271%
13768297073

Pull #642

github

web-flow
Merge ccb08cb24 into 922b0b29f
Pull Request #642: CRDCDH-2458 Setup Storybook

3139 of 5627 branches covered (55.78%)

Branch coverage included in aggregate %.

3 of 69 new or added lines in 16 files covered. (4.35%)

4374 of 6903 relevant lines covered (63.36%)

145.82 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/components/AccessRequest/index.stories.tsx
1
import type { Meta, StoryObj } from "@storybook/react";
2
import { MockedResponse } from "@apollo/client/testing";
3
import { within } from "@storybook/testing-library";
4
import Dialog from "./index";
5
import {
6
  LIST_APPROVED_STUDIES,
7
  ListApprovedStudiesInput,
8
  ListApprovedStudiesResp,
9
} from "../../graphql";
10
import { Context as AuthContext, ContextState as AuthCtxState } from "../Contexts/AuthContext";
11
import { Roles } from "../../config/AuthRoles";
12

NEW
13
const meta: Meta<typeof Dialog> = {
×
14
  title: "Dialogs / Access Request",
15
  component: Dialog,
16
  parameters: {
17
    layout: "fullscreen",
18
  },
19
  tags: ["autodocs"],
20
} satisfies Meta<typeof Dialog>;
21

22
export default meta;
23
type Story = StoryObj<typeof meta>;
24

NEW
25
const studiesMock: MockedResponse<ListApprovedStudiesResp, ListApprovedStudiesInput> = {
×
26
  request: {
27
    query: LIST_APPROVED_STUDIES,
28
  },
29
  result: {
30
    data: {
31
      listApprovedStudies: {
32
        total: 2,
33
        studies: [
34
          {
35
            _id: "study-1",
36
            studyName: "Study-1",
37
            studyAbbreviation: "S1",
38
            controlledAccess: false,
39
            openAccess: false,
40
            dbGaPID: null,
41
            ORCID: "",
42
            originalOrg: null,
43
            PI: "",
44
            primaryContact: null,
45
            programs: [],
46
            createdAt: "",
47
          },
48
          {
49
            _id: "study-2",
50
            studyName: "Study-2",
51
            studyAbbreviation: "S2",
52
            controlledAccess: false,
53
            openAccess: false,
54
            dbGaPID: null,
55
            ORCID: "",
56
            originalOrg: null,
57
            PI: "",
58
            primaryContact: null,
59
            programs: [],
60
            createdAt: "",
61
          },
62
        ],
63
      },
64
    },
65
  },
NEW
66
  variableMatcher: () => true,
×
67
};
68

NEW
69
export const Default: Story = {
×
70
  args: {
71
    role: "Submitter",
72
    permissions: ["access:request"],
73
  },
74
  argTypes: {
75
    role: {
76
      name: "Role",
77
      options: Roles,
78
      control: {
79
        type: "radio",
80
      },
81
    },
82
    permissions: {
83
      name: "Permissions",
84
      options: ["access:request"],
85
      control: {
86
        type: "check",
87
      },
88
    },
89
  },
90
  parameters: {
91
    apolloClient: {
92
      mocks: [studiesMock],
93
    },
94
  },
95
  play: async ({ canvasElement }) => {
NEW
96
    const canvas = within(canvasElement);
×
97

NEW
98
    canvas.getByText("Request Access").click();
×
99

NEW
100
    await canvas.findByText("Request Access");
×
101
  },
102
  decorators: [
103
    (Story, context) => (
NEW
104
      <AuthContext.Provider
×
105
        value={
106
          {
107
            isLoggedIn: true,
108
            user: {
109
              firstName: "Example",
110
              role: context.args.role,
111
              permissions: context.args.permissions,
112
            } as User,
113
          } as AuthCtxState
114
        }
115
      >
116
        <Story />
117
      </AuthContext.Provider>
118
    ),
119
  ],
120
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc