-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
158 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
id,first_name,last_name,email,address,zipcode,city,stateAbbr,avatar,birthday,first_seen,last_seen,has_ordered,latest_purchase,has_newsletter,nb_commands,total_spent,groups | ||
470,Kaela,Nolan,[email protected],19270 Schinner Fork,15063-7481,Shanahanport,OH,https://marmelab.com/posters/avatar-124.jpeg,2011-09-03T18:19:06.601Z,2021-04-23T08:50:21.272Z,2021-04-23T13:00:16.355Z,true,,false,0,0 | ||
123,Mallie,Labadie,[email protected],313 Jaclyn Manor,63546-3960,Maceyfort,AL,https://marmelab.com/posters/avatar-38.jpeg,2010-07-23T09:17:28.279Z,2021-04-22T02:07:21.103Z,2021-04-23T12:44:34.152Z,true,2019-08-19T10:29:33.863Z,true,1,93.25,ordered_once;regular;reviewer | ||
431,Marcelino,Steuber,[email protected],,,,,,,2020-10-30T03:50:30.265Z,2021-04-23T12:29:41.586Z,false,,true,0,0, | ||
441,Francis,Smitham,[email protected],,,,,,,2021-04-22T22:28:58.884Z,2021-04-23T11:14:07.539Z,false,,true,0,0, | ||
191,Micheal,Bogisich,[email protected],,,,,,,2021-04-22T23:55:07.778Z,2021-04-23T10:29:16.721Z,false,,true,0,0, | ||
187,Emmy,Murray,[email protected],,,,,,,2021-03-13T02:46:35.106Z,2021-04-23T08:40:55.366Z,false,,true,0,0, | ||
623,Rick,Dach,[email protected],,,,,,,2021-02-08T12:10:39.046Z,2021-04-23T04:29:09.293Z,false,,true,0,0, | ||
343,Mortimer,Jones,[email protected],,,,,,,2021-04-04T06:04:49.627Z,2021-04-23T01:40:51.884Z,false,,true,0,0, | ||
723,Wilfredo,Renner,[email protected],,,,,,,2019-08-01T06:25:59.666Z,2021-04-22T23:30:43.699Z,false,,true,0,0,regular | ||
803,Kellen,Schoen,[email protected],,,,,,,2020-01-24T19:43:18.566Z,2021-04-22T23:28:44.813Z,false,,true,0,0, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
id,reference,date,customer_id,basket.product_id,basket.quantity,total_ex_taxes,delivery_fees,tax_rate,taxes,total,status,returned | ||
408,5TFGTA,2021-04-23T02:07:38.273Z,17,87,1,108.28,5.38,0.2,22.73,136.39,ordered,false | ||
,,,,10,2,,,,,,, | ||
93,M2GL49,2021-04-19T23:49:46.313Z,750,87,5,92.4,5.61,0.12,11.76,109.77,ordered,false | ||
413,JTI3CU,2021-04-18T02:56:46.786Z,879,28,2,81.12,6.19,0.12,10.48,97.79,ordered,false | ||
,,,,35,2,,,,,,, | ||
421,80EPRZ,2021-04-14T19:53:26.605Z,362,20,1,141.78,3.14,0.17,24.64,169.56,ordered,false | ||
,,,,97,1,,,,,,, | ||
,,,,84,2,,,,,,, | ||
386,WREQLW,2021-04-13T23:33:12.169Z,265,109,1,76.94999999999999,4.25,0.12,9.74,90.94,ordered,false | ||
,,,,98,1,,,,,,, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
id,reference,date,customer_id,basket.product_id,basket.quantity,total_ex_taxes,delivery_fees,tax_rate,taxes,total,status,returned | ||
12,MHWV4O,2021-04-20T21:10:35.516Z,520,83,1,23.01,3.88,0.17,4.57,31.46,delivered,false | ||
18,GYYHGX,2021-04-20T06:59:34.831Z,543,105,1,68.77,7.49,0.12,9.15,85.41,delivered,false | ||
174,XAH660,2021-04-13T20:06:44.191Z,165,90,3,54,3.54,0.12,6.9,64.44,delivered,false | ||
453,5W2ST6,2021-04-12T20:26:11.626Z,608,75,3,243.12,7.68,0.12,30.1,280.9,delivered,false | ||
270,KGDZ3F,2021-04-09T04:11:23.181Z,711,115,1,110.13,5.96,0.17,19.74,135.83,delivered,false | ||
,,,,119,2,,,,,,, | ||
468,OFA1OP,2021-04-08T06:58:34.635Z,272,66,3,334.08,5.99,0.12,40.81,380.88,delivered,false | ||
,,,,11,3,,,,,,, | ||
,,,,71,3,,,,,,, | ||
68,K9TZVO,2021-04-05T17:20:16.741Z,65,4,2,91.14,4.09,0.17,16.19,111.42,delivered,false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
import * as React from 'react'; | ||
import { fireEvent, render, waitFor } from '@testing-library/react'; | ||
import userEvents from '@testing-library/user-event'; | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
import { Admin } from './Admin'; | ||
|
||
describe('Admin', () => { | ||
test('should be functional', async () => { | ||
const customers = fs.readFileSync( | ||
path.resolve(__dirname, '../assets/ra-customers.csv'), | ||
{ | ||
encoding: 'utf-8', | ||
} | ||
); | ||
const orders1 = fs.readFileSync( | ||
path.resolve(__dirname, '../assets/ra-orders-1.csv'), | ||
{ | ||
encoding: 'utf-8', | ||
} | ||
); | ||
const orders2 = fs.readFileSync( | ||
path.resolve(__dirname, '../assets/ra-orders-2.csv'), | ||
{ | ||
encoding: 'utf-8', | ||
} | ||
); | ||
// jest.setTimeout(31000); | ||
let file = new File([customers], 'customers.csv', { | ||
type: 'text/csv', | ||
}); | ||
const { getByLabelText, getByText, getByDisplayValue } = render( | ||
<Admin /> | ||
); | ||
|
||
userEvents.upload(getByLabelText('CSV File'), file); | ||
|
||
await waitFor(() => { | ||
getByDisplayValue('customers'); | ||
}); | ||
|
||
fireEvent.click(getByText('Import')); | ||
|
||
await waitFor(() => { | ||
getByText('Customers', { selector: '#react-admin-title *' }); | ||
getByText('Id', { selector: 'th *' }); | ||
getByText('First name', { selector: 'th *' }); | ||
getByText('Last name', { selector: 'th *' }); | ||
getByText('Email', { selector: 'th *' }); | ||
getByText('Address', { selector: 'th *' }); | ||
getByText('Zipcode', { selector: 'th *' }); | ||
getByText('City', { selector: 'th *' }); | ||
getByText('State abbr', { selector: 'th *' }); | ||
getByText('Avatar', { selector: 'th *' }); | ||
getByText('Birthday', { selector: 'th *' }); | ||
getByText('First seen', { selector: 'th *' }); | ||
getByText('Last seen', { selector: 'th *' }); | ||
getByText('Has ordered', { selector: 'th *' }); | ||
getByText('Latest purchase', { selector: 'th *' }); | ||
getByText('Has newsletter', { selector: 'th *' }); | ||
getByText('Nb commands', { selector: 'th *' }); | ||
getByText('Total spent', { selector: 'th *' }); | ||
getByText('Groups', { selector: 'th *' }); | ||
getByText('1-10 of 10'); | ||
}); | ||
|
||
fireEvent.click(getByText('New resource', { selector: 'button *' })); | ||
|
||
file = new File([orders1], 'orders.csv', { | ||
type: 'text/csv', | ||
}); | ||
userEvents.upload(getByLabelText('CSV File'), file); | ||
|
||
await waitFor(() => { | ||
getByDisplayValue('orders'); | ||
}); | ||
fireEvent.click(getByText('Import')); | ||
|
||
await waitFor(() => { | ||
getByText('Orders', { selector: '#react-admin-title *' }); | ||
getByText('Id', { selector: 'th *' }); | ||
getByText('Reference', { selector: 'th *' }); | ||
getByText('Date', { selector: 'th *' }); | ||
getByText('Customer', { selector: 'th *' }); | ||
getByText('Basket.product', { selector: 'th *' }); | ||
getByText('Basket.quantity', { selector: 'th *' }); | ||
getByText('Total ex taxes', { selector: 'th *' }); | ||
getByText('Delivery fees', { selector: 'th *' }); | ||
getByText('Tax rate', { selector: 'th *' }); | ||
getByText('Taxes', { selector: 'th *' }); | ||
getByText('Total', { selector: 'th *' }); | ||
getByText('Status', { selector: 'th *' }); | ||
getByText('Returned', { selector: 'th *' }); | ||
getByText('1-5 of 5'); | ||
}); | ||
|
||
fireEvent.click(getByText('New resource', { selector: 'button *' })); | ||
|
||
file = new File([orders2], 'orders2.csv', { | ||
type: 'text/csv', | ||
}); | ||
userEvents.upload(getByLabelText('CSV File'), file); | ||
|
||
await waitFor(() => { | ||
getByDisplayValue('orders2'); | ||
}); | ||
fireEvent.change(getByDisplayValue('orders2'), { | ||
target: { value: 'orders' }, | ||
}); | ||
fireEvent.click(getByText('Import')); | ||
|
||
await waitFor(() => { | ||
getByText('Orders', { selector: '#react-admin-title *' }); | ||
getByText('1-10 of 12'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters