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

Prevent calls to getMe from embed #417

Merged
merged 3 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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 .storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const config: StorybookConfig = {
"@storybook/addon-essentials",
"@storybook/addon-interactions",
"@storybook/addon-svelte-csf",
"storybook-addon-cookie",
],
framework: {
name: "@storybook/svelte-webpack5",
Expand Down
24 changes: 24 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
"react-dom": "^18.2.0",
"serve": "^14.2.0",
"storybook": "7.6.10",
"storybook-addon-cookie": "^3.2.0",
"storybook-mock-date-decorator": "^1.0.1",
"svelte-jester": "^3.0.0",
"tape": "^5.7.2",
Expand Down
5 changes: 4 additions & 1 deletion src/api/orgAndUser.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import session from "./session.js";
import session, { cookiesEnabled, getCsrfToken } from "./session.js";
import { USER_EXPAND, ORG_EXPAND, DEFAULT_EXPAND } from "./common.js";
import { queryBuilder } from "@/util/url.js";
import { grabAllPages } from "@/util/paginate.js";
import { apiUrl } from "./base.js";

export async function getMe(expand = DEFAULT_EXPAND) {
// Check that the user is logged in via cookies
if (cookiesEnabled && !getCsrfToken()) return null;

Check warning on line 9 in src/api/orgAndUser.js

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 9 in src/api/orgAndUser.js

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 9 in src/api/orgAndUser.js

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch

Check warning on line 9 in src/api/orgAndUser.js

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch

Check warning on line 9 in src/api/orgAndUser.js

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
// Check that the user is logged in via network request
const { status, data } = await session.get(
queryBuilder(apiUrl(`users/me/`), { expand }),
);
Expand Down
15 changes: 15 additions & 0 deletions src/common/dialog/stories/RevisionsDialog.stories.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,14 @@
title: "Dialogs / Revision",
component: RevisionsDialog,
parameters: {
layout: "centered",
chromatic: { delay: 1000 },
cookie: {

Check warning on line 41 in src/common/dialog/stories/RevisionsDialog.stories.svelte

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
csrftoken: "mockToken",
},
cookiePreserve: true,
},
argTypes: {

Check warning on line 46 in src/common/dialog/stories/RevisionsDialog.stories.svelte

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
enabled: {
control: {
type: "boolean",
Expand Down Expand Up @@ -135,11 +139,22 @@
name="With GetMe Error"
{args}
parameters={{ msw: { handlers: [revisionControl.success, mockGetMe.error] } }}
/>
<Story
name="With Loading"
{args}
parameters={{
msw: { handlers: [revisionControl.loading, mockGetMe.loading] },
}}
/>
<Story
name="Without CSRF Token"
{args}
parameters={{

Check warning on line 153 in src/common/dialog/stories/RevisionsDialog.stories.svelte

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
msw: { handlers: [revisionControl.success, mockGetMe.data] },
cookie: {
csrftoken: "",
},
cookiePreserve: false,
}}
/>
Loading