Skip to content

Commit

Permalink
wip: replace
Browse files Browse the repository at this point in the history
  • Loading branch information
cuserox committed Aug 22, 2024
1 parent ffd6297 commit 62b14f8
Show file tree
Hide file tree
Showing 70 changed files with 309 additions and 367 deletions.
8 changes: 3 additions & 5 deletions packages/tokens-studio-for-figma/cypress/e2e/branches.cy.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import {
StorageProviderType
} from '@/constants/StorageProviderType';
import { AVAILABLE_PROVIDERS } from '@sync-providers/constants';
import { UpdateMode } from '@/constants/UpdateMode';
import MockEnv from '../support/mockEnv'
import { fillTokenForm } from './helpers/utils';

describe('Branch switcher', () => {
const provider = {
provider: StorageProviderType.GITHUB,
provider: AVAILABLE_PROVIDERS.GITHUB,
id: '122/figma-tokens',
secret: '456',
name: 'dummy 2',
Expand Down Expand Up @@ -157,4 +155,4 @@ describe('Branch switcher', () => {
cy.get('[data-testid=push-dialog-button-push-changes]').click();
cy.get('[data-testid=push-dialog-success-heading]').should('have.length', 1);
});
});
});
8 changes: 3 additions & 5 deletions packages/tokens-studio-for-figma/cypress/e2e/inspector.cy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import {
StorageProviderType
} from '@/constants/StorageProviderType';
import { AVAILABLE_PROVIDERS } from '@sync-providers/constants';
import { UpdateMode } from '@/constants/UpdateMode';
import MockEnv from '../support/mockEnv';

Expand Down Expand Up @@ -28,7 +26,7 @@ describe('Inspector tokens', () => {
updateRemote: true,
updateStyles: true,
},
storageType: { provider: StorageProviderType.LOCAL },
storageType: { provider: AVAILABLE_PROVIDERS.LOCAL },
user: {
figmaId: 'figma:1234',
userId: 'uid:1234',
Expand Down Expand Up @@ -253,4 +251,4 @@ describe('Inspector tokens', () => {
cy.contains('opacity.50').should('not.exist');
cy.contains('opacity.100');
});
});
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import {
StorageProviderType
} from '@/constants/StorageProviderType';
import { AVAILABLE_PROVIDERS } from '@sync-providers/constants';
import { UpdateMode } from '@/constants/UpdateMode';
import MockEnv from '../support/mockEnv';

Expand Down Expand Up @@ -33,7 +31,7 @@ describe('TokenListing', () => {
updateRemote: true,
updateStyles: true,
},
storageType: { provider: StorageProviderType.LOCAL },
storageType: { provider: AVAILABLE_PROVIDERS.LOCAL },
user: {
figmaId: 'figma:1234',
userId: 'uid:1234',
Expand Down
6 changes: 2 additions & 4 deletions packages/tokens-studio-for-figma/cypress/e2e/startup.cy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import {
StorageProviderType
} from '@/constants/StorageProviderType';
import { AVAILABLE_PROVIDERS } from '@sync-providers/constants';
import {
TokenTypes
} from '@/constants/TokenTypes';
Expand Down Expand Up @@ -29,7 +27,7 @@ describe('Loads application', () => {
updateRemote: true,
updateStyles: true,
},
storageType: { provider: StorageProviderType.LOCAL },
storageType: { provider: AVAILABLE_PROVIDERS.LOCAL },
user: {
figmaId: 'figma:1234',
userId: 'uid:1234',
Expand Down
8 changes: 3 additions & 5 deletions packages/tokens-studio-for-figma/cypress/e2e/themes.cy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import {
StorageProviderType
} from '@/constants/StorageProviderType';
import { AVAILABLE_PROVIDERS } from '@sync-providers/constants';
import { UpdateMode } from '@/constants/UpdateMode';
import MockEnv from '../support/mockEnv';

Expand All @@ -27,7 +25,7 @@ describe('Themes', () => {
updateRemote: true,
updateStyles: true,
},
storageType: { provider: StorageProviderType.LOCAL },
storageType: { provider: AVAILABLE_PROVIDERS.LOCAL },
user: {
figmaId: 'figma:1234',
userId: 'uid:1234',
Expand Down Expand Up @@ -121,4 +119,4 @@ describe('Themes', () => {
cy.get('[data-testid="button-manage-themes-modal-delete-theme"]').click();
cy.get('[data-testid="singlethemeentry"]').should('have.length', 0)
});
});
});
8 changes: 3 additions & 5 deletions packages/tokens-studio-for-figma/cypress/e2e/tokens.cy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import {
StorageProviderType
} from '@/constants/StorageProviderType';
import { AVAILABLE_PROVIDERS } from '@sync-providers/constants';
import { UpdateMode } from '@/constants/UpdateMode';
import MockEnv from '../support/mockEnv';
import { fillTokenForm, fillInputNth, fillValueInput, fillInput } from './helpers/utils';
Expand Down Expand Up @@ -28,7 +26,7 @@ describe('TokenListing', () => {
updateRemote: true,
updateStyles: true,
},
storageType: { provider: StorageProviderType.LOCAL },
storageType: { provider: AVAILABLE_PROVIDERS.LOCAL },
user: {
figmaId: 'figma:1234',
userId: 'uid:1234',
Expand Down Expand Up @@ -464,7 +462,7 @@ describe('TokenListing', () => {
cy.get('span:contains("minWidth")').parent().should('be.visible');
cy.get('span:contains("minWidth")').parent().click();
cy.get('[data-testid="composition-token-dropdown"]').click();


cy.get('body').type('{esc}');

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from 'react';
import { Provider } from 'react-redux';
import type { StorageProviderType } from '@sync-providers/types';
import { AVAILABLE_PROVIDERS } from '@sync-providers/constants';
import { Entitlements } from '@/app/store/models/userState';
import { StorageProviderType } from '@/constants/StorageProviderType';
import { TokenSetStatus } from '@/constants/TokenSetStatus';
import { TokenTypes } from '@/constants/TokenTypes';
import {
Expand Down Expand Up @@ -86,7 +87,7 @@ const mockValues: Record<string, AnyTokenList> = {
};

const mockGithubStoragetype: StorageType = {
provider: StorageProviderType.GITHUB,
provider: AVAILABLE_PROVIDERS.GITHUB as StorageProviderType.GITHUB,
id: 'github',
internalId: 'github',
name: 'Github',
Expand All @@ -96,7 +97,7 @@ const mockGithubStoragetype: StorageType = {

const mockGithubApiProviders: StorageTypeCredentials[] = [
{
provider: StorageProviderType.GITHUB,
provider: AVAILABLE_PROVIDERS.GITHUB as StorageProviderType.GITHUB,
id: 'github',
internalId: 'github',
name: 'Github',
Expand Down Expand Up @@ -128,7 +129,7 @@ const mockStartupParams: Omit<StartupMessage, 'licenseKey'> = {
localApiProviders: [],
settings: mockSettings,
storageType: {
provider: StorageProviderType.LOCAL,
provider: AVAILABLE_PROVIDERS.LOCAL as StorageProviderType.LOCAL,
},
user: mockUser,
localTokenData: {
Expand Down Expand Up @@ -405,7 +406,7 @@ describe('AppContainer (integration)', () => {
checkForChanges: false,
},
storageType: {
provider: StorageProviderType.GITHUB,
provider: AVAILABLE_PROVIDERS.GITHUB,
branch: 'main',
filePath: 'data/tokens.json',
id: 'github',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { StorageProviderType } from '@/constants/StorageProviderType';
import type { StorageProviderType } from '@sync-providers/types';
import { AVAILABLE_PROVIDERS } from '@sync-providers/constants';
import { createMockStore } from '../../../../../../tests/config/setupTest';
import type { StartupMessage } from '@/types/AsyncMessages';
import { TokenTypes } from '@/constants/TokenTypes';
Expand All @@ -21,7 +22,7 @@ describe('pullTokensFactory', () => {
id: 'github',
internalId: 'github',
name: 'Github',
provider: StorageProviderType.GITHUB,
provider: AVAILABLE_PROVIDERS.GITHUB as StorageProviderType.GITHUB,
branch: 'main',
filePath: 'data/tokens.json',
};
Expand All @@ -39,7 +40,7 @@ describe('pullTokensFactory', () => {
const mockStore = createMockStore({
uiState: {
storageType: {
provider: StorageProviderType.LOCAL,
provider: AVAILABLE_PROVIDERS.LOCAL as StorageProviderType.LOCAL,
},
},
});
Expand Down Expand Up @@ -83,7 +84,7 @@ describe('pullTokensFactory', () => {
const mockStore = createMockStore({
uiState: {
storageType: {
provider: StorageProviderType.LOCAL,
provider: AVAILABLE_PROVIDERS.LOCAL as StorageProviderType.LOCAL,
},
},
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { StorageProviderType } from '@/constants/StorageProviderType';
import { AVAILABLE_PROVIDERS } from '@sync-providers/constants';
import { StartupMessage } from '@/types/AsyncMessages';
import { createMockStore } from '../../../../../../tests/config/setupTest';
import { saveStorageInformationFactory } from '../saveStorageInformationFactory';
Expand All @@ -7,10 +7,10 @@ describe('saveStorageInformationFactory', () => {
it('should work', async () => {
const mockStore = createMockStore({});
const mockParams = {
storageType: StorageProviderType.GITHUB,
storageType: AVAILABLE_PROVIDERS.GITHUB,
localApiProviders: [
{
provider: StorageProviderType.GITHUB,
provider: AVAILABLE_PROVIDERS.GITHUB,
},
],
} as unknown as StartupMessage;
Expand All @@ -23,7 +23,7 @@ describe('saveStorageInformationFactory', () => {

expect(mockSetStorageFn).toBeCalledTimes(1);
expect(mockSetStorageFn).toBeCalledWith({
provider: StorageProviderType.GITHUB,
provider: AVAILABLE_PROVIDERS.GITHUB,
});
expect(mockStore.getState().uiState.apiProviders).toEqual(mockParams.localApiProviders);
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import * as Sentry from '@sentry/react';
import type { LDFlagSet } from 'launchdarkly-js-client-sdk';
import { Store } from 'redux';
import { AVAILABLE_PROVIDERS } from '@sync-providers/constants';
import { INTERNAL_THEMES_NO_GROUP } from '../../../../constants/InternalTokenGroup';
import type { StartupMessage } from '@/types/AsyncMessages';
import type { Dispatch, RootState } from '@/app/store';
import { Tabs } from '@/constants/Tabs';
import { storageTypeSelector } from '@/selectors';
import { StorageProviderType } from '@/constants/StorageProviderType';
import useConfirm from '@/app/hooks/useConfirm';
import isSameCredentials from '@/utils/isSameCredentials';
import { track } from '@/utils/analytics';
Expand Down Expand Up @@ -37,15 +37,15 @@ export function pullTokensFactory(
const state = store.getState();
const storageType = storageTypeSelector(state);
const isRemoteStorage = [
StorageProviderType.ADO,
StorageProviderType.GITHUB,
StorageProviderType.GITLAB,
StorageProviderType.BITBUCKET,
StorageProviderType.JSONBIN,
StorageProviderType.GENERIC_VERSIONED_STORAGE,
StorageProviderType.URL,
StorageProviderType.SUPERNOVA,
StorageProviderType.TOKENS_STUDIO,
AVAILABLE_PROVIDERS.ADO,
AVAILABLE_PROVIDERS.GITHUB,
AVAILABLE_PROVIDERS.GITLAB,
AVAILABLE_PROVIDERS.BITBUCKET,
AVAILABLE_PROVIDERS.JSONBIN,
AVAILABLE_PROVIDERS.GENERIC_VERSIONED_STORAGE,
AVAILABLE_PROVIDERS.URL,
AVAILABLE_PROVIDERS.SUPERNOVA,
AVAILABLE_PROVIDERS.TOKENS_STUDIO,
].includes(storageType.provider);

if (isRemoteStorage) {
Expand All @@ -63,10 +63,10 @@ export function pullTokensFactory(
}

if (
matchingSet.provider === StorageProviderType.GITHUB
|| matchingSet.provider === StorageProviderType.GITLAB
|| matchingSet.provider === StorageProviderType.ADO
|| matchingSet.provider === StorageProviderType.BITBUCKET
matchingSet.provider === AVAILABLE_PROVIDERS.GITHUB
|| matchingSet.provider === AVAILABLE_PROVIDERS.GITLAB
|| matchingSet.provider === AVAILABLE_PROVIDERS.ADO
|| matchingSet.provider === AVAILABLE_PROVIDERS.BITBUCKET
) {
const branches = await useRemoteTokensResult.fetchBranches(matchingSet);
if (branches) dispatch.branchState.setBranches(branches);
Expand Down Expand Up @@ -136,7 +136,7 @@ export function pullTokensFactory(
if (
!checkForChanges
|| (
(storageType && storageType.provider !== StorageProviderType.LOCAL)
(storageType && storageType.provider !== AVAILABLE_PROVIDERS.LOCAL)
&& checkForChanges && (!await askUserIfRecoverLocalChanges())
)
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
import React from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { useTranslation } from 'react-i18next';
import { AVAILABLE_PROVIDERS } from '@sync-providers/constants';
import Modal from './Modal';
import { Dispatch } from '../store';
import { TokenFormatOptions } from '@/plugin/TokenFormatStoreClass';
Expand All @@ -15,7 +16,6 @@ import useRemoteTokens from '../store/remoteTokens';
import w3cConvertImage from '@/app/assets/hints/w3cformat.png';
import legacyConvertImage from '@/app/assets/hints/legacyformat.png';
import { storageTypeSelector } from '@/selectors';
import { StorageProviderType } from '@/constants/StorageProviderType';

export function ConvertToDTCGModal() {
const dispatch = useDispatch<Dispatch>();
Expand All @@ -35,7 +35,7 @@ export function ConvertToDTCGModal() {
const handleConvert = React.useCallback(() => {
dispatch.tokenState.setTokenFormat(isDTCG ? TokenFormatOptions.Legacy : TokenFormatOptions.DTCG);
dispatch.uiState.setShowConvertTokenFormatModal(false);
if (storageType.provider === StorageProviderType.LOCAL) return;
if (storageType.provider === AVAILABLE_PROVIDERS.LOCAL) return;
pushTokens({
overrides: isDTCG ? {
branch: 'w3c-dtcg-conversion-revert',
Expand All @@ -47,7 +47,7 @@ export function ConvertToDTCGModal() {
});
}, [dispatch, pushTokens, isDTCG, storageType]);

const hasRemoteChanges = hasChanges && storageType.provider !== StorageProviderType.LOCAL;
const hasRemoteChanges = hasChanges && storageType.provider !== AVAILABLE_PROVIDERS.LOCAL;

return (
<Modal title={isDTCG ? t('w3cformatmodaltitle') : t('w3cconverttitle')} isOpen={showConvertTokenFormatModal} close={handleClose} showClose>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';
import { AVAILABLE_PROVIDERS } from '@sync-providers/constants';
import { render, waitFor } from '../../../tests/config/setupTest';
import { store } from '../store';
import Footer from './Footer';
import * as pjs from '../../../package.json';
import { StorageProviderType } from '@/constants/StorageProviderType';

describe('Footer', () => {
it('displays current version number', () => {
Expand All @@ -13,15 +13,15 @@ describe('Footer', () => {

it('shows branch selector for users on a free plan', () => {
const { getByText } = render(<Footer />, { store });
store.dispatch.uiState.setLocalApiState({ provider: StorageProviderType.GITHUB, branch: 'test-branch' });
store.dispatch.uiState.setLocalApiState({ provider: AVAILABLE_PROVIDERS.GITHUB, branch: 'test-branch' });
waitFor(() => {
expect(getByText('test-branch')).toBeInTheDocument();
});
});

it('shows push button when user is able to push', () => {
const { getByTestId } = render(<Footer />, { store });
store.dispatch.uiState.setLocalApiState({ provider: StorageProviderType.GITHUB, branch: 'test-branch', filePath: 'tokens.json' });
store.dispatch.uiState.setLocalApiState({ provider: AVAILABLE_PROVIDERS.GITHUB, branch: 'test-branch', filePath: 'tokens.json' });

waitFor(() => {
const pushButton = getByTestId('footer-push-button');
Expand All @@ -33,7 +33,7 @@ describe('Footer', () => {

it('disables push button when user is not able to push', () => {
const { getByTestId } = render(<Footer />, { store });
store.dispatch.uiState.setLocalApiState({ provider: StorageProviderType.GITHUB, branch: 'test-branch' });
store.dispatch.uiState.setLocalApiState({ provider: AVAILABLE_PROVIDERS.GITHUB, branch: 'test-branch' });
store.dispatch.tokenState.setEditProhibited(true);

waitFor(() => {
Expand All @@ -46,7 +46,7 @@ describe('Footer', () => {

it('shows pull button when user is able to pull', () => {
const { getByTestId } = render(<Footer />, { store });
store.dispatch.uiState.setLocalApiState({ provider: StorageProviderType.GITHUB, branch: 'test-branch' });
store.dispatch.uiState.setLocalApiState({ provider: AVAILABLE_PROVIDERS.GITHUB, branch: 'test-branch' });
waitFor(() => {
const pullButton = getByTestId('footer-pull-button');

Expand Down
Loading

0 comments on commit 62b14f8

Please sign in to comment.