Skip to content

Commit 6015670

Browse files
authored
Merge pull request #2107 from marmelab/next
Prepare 2.2.0
2 parents c3a8f25 + 5e088e5 commit 6015670

File tree

126 files changed

+2848
-986
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+2848
-986
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ dist: trusty
1212
cache:
1313
yarn: true
1414
directories:
15-
- node_modules
15+
- ~/.cache
1616
before_install:
1717
- "/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1280x1024x16"
18-
- curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 1.3.2
18+
- curl -o- -L https://yarnpkg.com/install.sh | bash
1919
- source ~/.bashrc
2020
- sh -e /etc/init.d/xvfb start
2121
- sleep 3

CHANGELOG.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
11
# Changelog
22

3+
## v2.2.0
4+
5+
* Add Export feature ([fzaninotto](https://github.com/fzaninotto))
6+
* Add the `callback` side effect ([fzaninotto](https://github.com/fzaninotto))
7+
* Add Error Page ([fzaninotto](https://github.com/fzaninotto))
8+
* Add clear button on inputs ([djhi](https://github.com/djhi))
9+
* Add ability to clone a record ([fzaninotto](https://github.com/fzaninotto))
10+
* Add validation for `dataProvider` response format ([djhi](https://github.com/djhi), [fzaninotto](https://github.com/fzaninotto))
11+
* Add Tooltips To Icon Buttons ([fzaninotto](https://github.com/fzaninotto))
12+
* Add ability to alter values after submission and before saving them ([djhi](https://github.com/djhi))
13+
* Add support for forms in lists ([djhi](https://github.com/djhi))
14+
* Add support for `asyncBlurFields` in forms ([fzaninotto](https://github.com/fzaninotto))
15+
* Add redirection to the previous page when a `FETCH_ERROR` occurs ([djhi](https://github.com/djhi))
16+
* Add `<CreateActions>` and `<RecordTitle>` components ([djhi](https://github.com/djhi))
17+
* Update the UI to make the `<AppBar>` dense ([fzaninotto](https://github.com/fzaninotto))
18+
* Update the UI to make the page heading smaller ([fzaninotto](https://github.com/fzaninotto))
19+
* Update the `<ListView>` implementation to make it easier to override ([fzaninotto](https://github.com/fzaninotto))
20+
* Fix bug with `defaultValues` and `<TabbedForm>` ([djhi](https://github.com/djhi))
21+
* Fix bug with `defaultValues` and `<FormDataConsumer>` ([djhi](https://github.com/djhi))
22+
* Fix bug with Form state being persisted between resources ([djhi](https://github.com/djhi))
23+
* Fix `defaultValue` for `<ArrayInput>` ([djhi](https://github.com/djhi))
24+
325
## v2.1.5
426

527
* Fix `NumberField` style regression in Show views ([djhi](https://github.com/djhi))

cypress/integration/create.js

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import loginPageFactory from '../support/LoginPage';
44

55
describe('Create Page', () => {
66
const CreatePage = createPageFactory('/#/posts/create');
7+
const UserCreatePage = createPageFactory('/#/users/create');
78
const ShowPage = showPageFactory('/#/posts/14/show');
89
const LoginPage = loginPageFactory('/#/login');
910

@@ -21,7 +22,18 @@ describe('Create Page', () => {
2122
);
2223
});
2324

24-
it('should have a working array input with references', () => {
25+
it('should put the ArrayInput default value', () => {
26+
const currentDate = new Date();
27+
const currentDateString = currentDate.toISOString().slice(0, 10);
28+
cy.get(CreatePage.elements.input('backlinks[0].date')).should(el =>
29+
expect(el).to.have.value(currentDateString)
30+
);
31+
cy.get(CreatePage.elements.input('backlinks[0].url')).should(el =>
32+
expect(el).to.have.value('http://google.com')
33+
);
34+
});
35+
36+
it('should have a working array input with references', () => {
2537
cy.get(CreatePage.elements.addAuthor).click();
2638
cy.get(CreatePage.elements.input('authors[0].user_id')).should(
2739
el => expect(el).to.exist
@@ -75,6 +87,33 @@ describe('Create Page', () => {
7587
ShowPage.delete();
7688
});
7789

90+
it('should allow to call a custom action updating values before submit', () => {
91+
const values = [
92+
{
93+
type: 'input',
94+
name: 'title',
95+
value: 'Test title',
96+
},
97+
{
98+
type: 'textarea',
99+
name: 'teaser',
100+
value: 'Test teaser',
101+
},
102+
{
103+
type: 'checkbox',
104+
name: 'commentable',
105+
value: false,
106+
},
107+
];
108+
109+
CreatePage.setValues(values);
110+
CreatePage.submitWithAverageNote();
111+
ShowPage.waitUntilVisible();
112+
ShowPage.gotoTab(3);
113+
cy.contains('10');
114+
ShowPage.delete();
115+
});
116+
78117
it('should not accept creation without required fields', () => {
79118
const values = [
80119
{
@@ -87,4 +126,40 @@ describe('Create Page', () => {
87126
CreatePage.submit();
88127
cy.contains('Required field');
89128
});
129+
130+
it('should not reset form values when an input with defaultValue is dynamically added', () => {
131+
const values = [
132+
{
133+
type: 'input',
134+
name: 'title',
135+
value: 'Test title',
136+
},
137+
];
138+
CreatePage.setValues(values);
139+
cy.get(CreatePage.elements.input('average_note')).should(el =>
140+
expect(el).to.have.value('5')
141+
);
142+
cy.get(CreatePage.elements.input('title')).should(el =>
143+
expect(el).to.have.value('Test title')
144+
);
145+
});
146+
147+
it('should not reset the form value when switching tabs', () => {
148+
LoginPage.navigate();
149+
LoginPage.login('admin', 'password');
150+
UserCreatePage.navigate();
151+
152+
CreatePage.setValues([
153+
{
154+
type: 'input',
155+
name: 'name',
156+
value: 'The real Slim Shady!',
157+
},
158+
]);
159+
CreatePage.gotoTab(2);
160+
CreatePage.gotoTab(1);
161+
cy.get(CreatePage.elements.input('name')).should(el =>
162+
expect(el).to.have.value('The real Slim Shady!')
163+
);
164+
});
90165
});

cypress/support/CreatePage.js

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@ export default url => ({
77
snackbar: 'div[role="alertdialog"]',
88
submitButton: ".create-page button[type='submit']",
99
submitAndAddButton:
10-
".create-page form>div:last-child button[type='button']",
10+
".create-page form>div:last-child button[type='button']:nth-child(2)",
11+
submitCommentable:
12+
".create-page form>div:last-child button[type='button']:last-child",
1113
descInput: '.ql-editor',
14+
tab: index => `.form-tab:nth-of-type(${index})`,
1215
},
1316

1417
navigate() {
@@ -20,6 +23,12 @@ export default url => ({
2023
},
2124

2225
setInputValue(type, name, value, clearPreviousValue = true) {
26+
if (type === 'checkbox') {
27+
if (value === true) {
28+
return cy.get(this.elements.input(name, 'input')).check();
29+
}
30+
return cy.get(this.elements.input(name, 'input')).check();
31+
}
2332
if (clearPreviousValue) {
2433
cy.get(this.elements.input(name, type)).clear();
2534
}
@@ -28,10 +37,12 @@ export default url => ({
2837

2938
setValues(values, clearPreviousValue = true) {
3039
values.forEach(val => {
31-
if (clearPreviousValue) {
32-
cy.get(this.elements.input(val.name, val.type)).clear();
33-
}
34-
cy.get(this.elements.input(val.name, val.type)).type(val.value);
40+
this.setInputValue(
41+
val.type,
42+
val.name,
43+
val.value,
44+
clearPreviousValue
45+
);
3546
});
3647
},
3748

@@ -48,4 +59,15 @@ export default url => ({
4859
cy.get(this.elements.body).click(); // dismiss notification
4960
cy.wait(200); // let the notification disappear (could block further submits)
5061
},
62+
63+
submitWithAverageNote() {
64+
cy.get(this.elements.submitCommentable).click();
65+
cy.get(this.elements.snackbar);
66+
cy.get(this.elements.body).click(); // dismiss notification
67+
cy.wait(200); // let the notification disappear (could block further submits)
68+
},
69+
70+
gotoTab(index) {
71+
cy.get(this.elements.tab(index)).click();
72+
},
5173
});

0 commit comments

Comments
 (0)