Skip to content

Commit

Permalink
Merge pull request #80 from marmelab/openAPI-guessers
Browse files Browse the repository at this point in the history
Add Guessers based on the OpenAPI Schema
  • Loading branch information
djhi authored Nov 7, 2024
2 parents a2e3d4a + 9fc8c78 commit c9578ec
Show file tree
Hide file tree
Showing 96 changed files with 3,765 additions and 5,164 deletions.
19 changes: 19 additions & 0 deletions cypress/e2e/adminGuesser.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { login } from './login';

const getPaginationText = () =>
cy.findByText(/\d+-\d+ of \d+/, { timeout: 10000 });

describe('AdminGuesser', () => {
it('should render one menu item per resource', () => {
cy.visit('/');
login();
cy.findByText('Companies').should('exist');
cy.findByText('Contacts').should('exist');
cy.findByText('Deals').should('exist');
cy.findByText('Tags').should('exist');
cy.findByText('Tasks').should('exist');
cy.findByText('Dealnotes').should('exist');
cy.findByText('Contactnotes').should('exist');
cy.findByText('Sales').should('exist');
});
});
17 changes: 0 additions & 17 deletions cypress/e2e/dashboard.cy.ts

This file was deleted.

71 changes: 4 additions & 67 deletions cypress/e2e/lists.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,57 +11,6 @@ describe('Lists', () => {
getPaginationText();
});

it('should allow to filter by date', () => {
cy.visit('/');
login();
cy.findByText('Contacts').click();
getPaginationText().then(el => {
const count = parseInt(el.text().split('of')[1].trim());

cy.findByText('Earlier').click();
// Use should here to allow built-in retry as it may take a few ms for the list to update
getPaginationText().should(el => {
const countFiltered = parseInt(el.text().split('of')[1].trim());
expect(countFiltered).to.be.lessThan(count);
});
});
});

it('should allow to filter by status', () => {
cy.visit('/');
login();
cy.findByText('Contacts').click();
getPaginationText().then(el => {
const count = parseInt(el.text().split('of')[1].trim());

cy.findByText('Cold').click();
// Use should here to allow built-in retry as it may take a few ms for the list to update
getPaginationText().should(el => {
const countFiltered = parseInt(el.text().split('of')[1].trim());
expect(countFiltered).to.be.lessThan(count);
});
});
});

it('should allow to filter by tag', () => {
cy.visit('/');
login();
cy.findByText('Contacts').click();
getPaginationText().then(el => {
const count = parseInt(el.text().split('of')[1].trim());

cy.findByText('football-fan', {
selector: '[role=button] *',
}).click();

// Use should here to allow built-in retry as it may take a few ms for the list to update
getPaginationText().should(el => {
const countFiltered = parseInt(el.text().split('of')[1].trim());
expect(countFiltered).to.be.lessThan(count);
});
});
});

it('should allow to move through pages', () => {
cy.visit('/');
login();
Expand Down Expand Up @@ -92,23 +41,11 @@ describe('Lists', () => {
cy.visit('/');
login();
cy.findByText('Contacts').click();
cy.findAllByText(/\d+ days? ago/, { timeout: 10000 }).should(
'have.length.greaterThan',
0
);
cy.findAllByText(/\d+ years? ago/, { timeout: 10000 }).should(
'have.length',
0
);
cy.findByText('Sort by Last seen descending').click();
cy.findByText('Last seen ascending').click();
cy.findAllByText(/\d+ days? ago/, { timeout: 10000 }).should(
cy.findByLabelText('Sort by Gender descending').click();
cy.findAllByText('female', { timeout: 10000 }).should(
'have.length',
0
);
cy.findAllByText(/\d+ years? ago/, { timeout: 10000 }).should(
'have.length.greaterThan',
0
10
);
cy.findByText('male').should('not.exist');
});
});
2 changes: 1 addition & 1 deletion packages/demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<meta name="theme-color" content="#000000" />
<link rel="manifest" href="./manifest.json" />
<link rel="shortcut icon" href="./favicon.ico" />
<title>Atomic CRM</title>
<title>CRM Demo</title>
<style>
body {
margin: 0;
Expand Down
20 changes: 0 additions & 20 deletions packages/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,18 @@
"version": "3.2.1",
"private": true,
"dependencies": {
"@hello-pangea/dnd": "^16.3.0",
"@mui/icons-material": "^5.0.1",
"@mui/material": "^5.15.20",
"@nivo/bar": "^0.80.0",
"@nivo/core": "^0.80.0",
"@tanstack/react-query": "^5.45.1",
"@vitejs/plugin-react": "^2.2.0",
"clsx": "^1.1.1",
"date-fns": "^2.19.0",
"faker": "~5.4.0",
"lodash": "~4.17.5",
"prop-types": "^15.7.2",
"ra-data-fakerest": "^5.0.0",
"ra-supabase": "^3.2.1",
"react": "^18.2.0",
"react-admin": "^5.0.0",
"react-beautiful-dnd": "^13.0.0",
"react-dom": "^18.2.0",
"react-error-boundary": "^3.1.4",
"react-router": "^6.23.1",
"react-router-dom": "^6.23.1",
"vite": "^3.2.0"
},
"devDependencies": {
"@testing-library/jest-dom": "^6.4.5",
"@testing-library/react": "^15.0.7",
"@testing-library/user-event": "^14.4.3",
"@types/faker": "~5.1.7",
"@types/jest": "^26.0.19",
"@types/lodash": "~4.14.168",
"@types/react": "^18.0.0",
"@types/react-beautiful-dnd": "^13.0.0",
"@types/react-dom": "^18.0.0",
"source-map-explorer": "^2.0.0",
"tsx": "^3.12.2",
Expand Down
78 changes: 5 additions & 73 deletions packages/demo/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,78 +1,10 @@
import * as React from 'react';
import {
Admin,
Resource,
ListGuesser,
defaultTheme,
mergeTranslations,
CustomRoutes,
} from 'react-admin';
import polyglotI18nProvider from 'ra-i18n-polyglot';
import englishMessages from 'ra-language-english';
import { BrowserRouter, Route } from 'react-router-dom';
import {
LoginPage,
raSupabaseEnglishMessages,
SetPasswordPage,
ForgotPasswordPage,
} from 'ra-supabase';
import { QueryClient } from '@tanstack/react-query';
import { authProvider } from './authProvider';
import Layout from './Layout';
import contacts from './contacts';
import companies from './companies';
import deals from './deals';
import { Dashboard } from './dashboard/Dashboard';
import { dataProvider } from './dataProvider';

const queryClient = new QueryClient();
const i18nProvider = polyglotI18nProvider(() => {
return mergeTranslations(englishMessages, raSupabaseEnglishMessages);
}, 'en');
import { AdminGuesser } from 'ra-supabase';

const App = () => (
<BrowserRouter>
<Admin
dataProvider={dataProvider}
authProvider={authProvider}
i18nProvider={i18nProvider}
layout={Layout}
dashboard={Dashboard}
loginPage={LoginPage}
queryClient={queryClient}
theme={{
...defaultTheme,
palette: {
background: {
default: '#fafafb',
},
},
}}
>
<CustomRoutes noLayout>
<Route
path={SetPasswordPage.path}
element={<SetPasswordPage />}
/>
<Route
path={ForgotPasswordPage.path}
element={<ForgotPasswordPage />}
/>
</CustomRoutes>
<Resource name="deals" {...deals} />
<Resource name="contacts" {...contacts} />
<Resource name="companies" {...companies} />
<Resource name="tasks" list={ListGuesser} />
<Resource
name="sales"
list={ListGuesser}
recordRepresentation={(record: any) =>
`${record.first_name} ${record.last_name}`
}
/>
<Resource name="tags" list={ListGuesser} />
</Admin>
</BrowserRouter>
<AdminGuesser
instanceUrl={import.meta.env.VITE_SUPABASE_URL}
apiKey={import.meta.env.VITE_SUPABASE_ANON_KEY}
/>
);

export default App;
82 changes: 0 additions & 82 deletions packages/demo/src/Header.tsx

This file was deleted.

29 changes: 0 additions & 29 deletions packages/demo/src/Layout.tsx

This file was deleted.

20 changes: 0 additions & 20 deletions packages/demo/src/authProvider.ts

This file was deleted.

Loading

0 comments on commit c9578ec

Please sign in to comment.