Skip to content

Commit

Permalink
refactor(cypress): expose oidc helper from appshell/ssr bundle (#2437)
Browse files Browse the repository at this point in the history
  • Loading branch information
emmenko authored Dec 20, 2021
1 parent f8d7175 commit cc5c5f4
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 49 deletions.
6 changes: 6 additions & 0 deletions .changeset/giant-glasses-wash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@commercetools-frontend/application-shell': patch
'@commercetools-frontend/cypress': patch
---

Expose helper function from `@commercetools-frontend/application-shell/ssr`, clean up duplicate in `@commercetools-frontend/cypress`.
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import {
trimLeadingAndTrailingSlashes,
} from '@commercetools-frontend/url-utils';
import { LOGOUT_REASONS } from '@commercetools-frontend/constants';
import { buildOidcScope } from '../authenticated/helpers';
import useIsServedByProxy from '../../hooks/use-is-served-by-proxy';
import { OIDC_RESPONSE_TYPES } from '../../constants';
import { buildOidcScope } from '../../utils/oidc';
import * as oidcStorage from '../../utils/oidc-storage';
import Redirector from '../redirector';
import { getMcOrigin } from './helpers';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { ApplicationWindow } from '@commercetools-frontend/constants';

import { STORAGE_KEYS, OIDC_CLAIMS } from '../../constants';
import { buildOidcScope } from '../../utils/oidc';
import * as oidcStorage from '../../utils/oidc-storage';
import { buildOidcScope } from './helpers';

declare let window: ApplicationWindow;

Expand Down
1 change: 1 addition & 0 deletions packages/application-shell/src/ssr/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from '../utils/formatters';
export { buildOidcScope } from '../utils/oidc';
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ApplicationOidcForDevelopmentConfig } from '@commercetools-frontend/constants';

import { OIDC_CLAIMS } from '../../constants';
import { OIDC_CLAIMS } from '../constants';

type BuilOidcScopeOptions = {
projectKey?: ApplicationOidcForDevelopmentConfig['initialProjectKey'];
Expand Down
1 change: 1 addition & 0 deletions packages/cypress/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"@babel/runtime": "7.16.5",
"@babel/runtime-corejs3": "7.16.5",
"@commercetools-frontend/application-config": "20.12.1",
"@commercetools-frontend/application-shell": "20.12.2",
"@manypkg/get-packages": "1.1.3",
"uuid": "8.3.2"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/cypress/src/add-commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { ApplicationRuntimeConfig } from '@commercetools-frontend/applicati

import { v4 as uuidv4 } from 'uuid';
import { STORAGE_KEYS, OIDC_RESPONSE_TYPES } from '../constants';
import buildOidcScope from '../build-oidc-scope';
import { buildOidcScope } from '@commercetools-frontend/application-shell/ssr';

// eslint-disable-next-line @typescript-eslint/no-explicit-any
declare const Cypress: any;
Expand Down
38 changes: 0 additions & 38 deletions packages/cypress/src/build-oidc-scope.ts

This file was deleted.

7 changes: 0 additions & 7 deletions packages/cypress/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,3 @@ export const STORAGE_KEYS = {
} as const;

export const OIDC_RESPONSE_TYPES = { ID_TOKEN: 'id_token' };
export const OIDC_CLAIMS = {
OPEN_ID: 'openid',
PROJECT_KEY: 'project_key',
TEAM_ID: 'team_id',
VIEW: 'view',
MANAGE: 'manage',
};
1 change: 1 addition & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2893,6 +2893,7 @@ __metadata:
"@babel/runtime": 7.16.5
"@babel/runtime-corejs3": 7.16.5
"@commercetools-frontend/application-config": 20.12.1
"@commercetools-frontend/application-shell": 20.12.2
"@manypkg/get-packages": 1.1.3
cypress: 8.7.0
uuid: 8.3.2
Expand Down

1 comment on commit cc5c5f4

@vercel
Copy link

@vercel vercel bot commented on cc5c5f4 Dec 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.