-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adding form with actions example
- Loading branch information
1 parent
18c2006
commit b11929a
Showing
6 changed files
with
228 additions
and
8 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
206 changes: 206 additions & 0 deletions
206
...ges/test-generator/integration-test-templates/cypress/integration/two-way-binding-spec.ts
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,206 @@ | ||
/* | ||
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"). | ||
You may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
describe('Workflow', () => { | ||
before(() => { | ||
cy.visit('http://localhost:3000/two-way-binding-tests'); | ||
}); | ||
|
||
describe('CheckboxField', () => { | ||
it('updates on ui interaction', () => { | ||
cy.get('#checkbox-field-section').within(() => { | ||
cy.get('.amplify-checkbox__button').invoke('attr', 'data-checked').should('eq', 'false'); | ||
cy.contains('Subscribe').click(); | ||
cy.get('.amplify-checkbox__button').invoke('attr', 'data-checked').should('eq', 'true'); | ||
}); | ||
}); | ||
|
||
it('updates on state mutation', () => { | ||
cy.get('#checkbox-field-section').within(() => { | ||
cy.get('.amplify-checkbox__button').invoke('attr', 'data-checked').should('eq', 'true'); | ||
cy.contains('Set CheckboxFieldValue').click(); | ||
cy.get('.amplify-checkbox__button').invoke('attr', 'data-checked').should('eq', 'false'); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('PasswordField', () => { | ||
it('updates on ui interaction', () => { | ||
cy.get('#password-field-section').within(() => { | ||
cy.contains('Entered Value').should('not.exist'); | ||
cy.get('input').type('Entered Value'); | ||
cy.contains('Entered Value'); | ||
}); | ||
}); | ||
|
||
it('updates on state mutation', () => { | ||
cy.get('#password-field-section').within(() => { | ||
cy.contains('admin123').should('not.exist'); | ||
cy.contains('Set PasswordFieldValue').click(); | ||
cy.contains('admin123'); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('PhoneNumberField', () => { | ||
it('updates on ui interaction', () => { | ||
cy.get('#phone-number-field-section').within(() => { | ||
cy.contains('Entered Value').should('not.exist'); | ||
cy.get('input').type('Entered Value'); | ||
cy.contains('Entered Value'); | ||
}); | ||
}); | ||
|
||
it('updates on state mutation', () => { | ||
cy.get('#phone-number-field-section').within(() => { | ||
cy.contains('8675309').should('not.exist'); | ||
cy.contains('Set PhoneNumberFieldValue').click(); | ||
cy.contains('8675309'); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('RadioGroupField', () => { | ||
it('updates on ui interaction', () => { | ||
cy.get('#radio-group-field-section').within(() => { | ||
cy.get('#radio-group-field-value').contains('css').should('not.exist'); | ||
cy.contains('css').click(); | ||
cy.get('#radio-group-field-value').contains('css'); | ||
}); | ||
}); | ||
|
||
it('updates on state mutation', () => { | ||
cy.get('#radio-group-field-section').within(() => { | ||
cy.get('#radio-group-field-value').contains('javascript').should('not.exist'); | ||
cy.contains('Set RadioGroupField').click(); | ||
cy.get('#radio-group-field-value').contains('javascript'); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('SearchField', () => { | ||
it('updates on ui interaction', () => { | ||
cy.get('#search-field-section').within(() => { | ||
cy.contains('Entered Value').should('not.exist'); | ||
cy.get('input').type('Entered Value'); | ||
cy.contains('Entered Value'); | ||
}); | ||
}); | ||
|
||
it('updates on state mutation', () => { | ||
cy.get('#search-field-section').within(() => { | ||
cy.contains('UI Docs').should('not.exist'); | ||
cy.contains('Set SearchFieldValue').click(); | ||
cy.contains('UI Docs'); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('SelectField', () => { | ||
it('updates on ui interaction', () => { | ||
cy.get('#select-field-section').within(() => { | ||
cy.contains('banana').should('not.exist'); | ||
cy.get('select').select('banana'); | ||
cy.contains('banana'); | ||
}); | ||
}); | ||
|
||
it('updates on state mutation', () => { | ||
cy.get('#select-field-section').within(() => { | ||
cy.contains('orange').should('not.exist'); | ||
cy.contains('Set SelectFieldValue').click(); | ||
cy.contains('orange'); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('SliderField', () => { | ||
// Disabling ui interaction test, moving thumb slider is failing. | ||
it.skip('updates on ui interaction', () => { | ||
cy.get('#slider-field-section').within(() => { | ||
// cy.contains('90').should('not.exist'); | ||
cy.get('.amplify-sliderfield__thumb').trigger('mousedown'); | ||
cy.get('.amplify-sliderfield__thumb').trigger('mousemove', -20); | ||
cy.get('.amplify-sliderfield__thumb').trigger('mouseup'); | ||
cy.contains('90'); | ||
}); | ||
}); | ||
|
||
it('updates on state mutation', () => { | ||
cy.get('#slider-field-section').within(() => { | ||
cy.contains('90').should('not.exist'); | ||
cy.contains('Set SliderFieldValue').click(); | ||
cy.contains('90'); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('StepperField', () => { | ||
it('updates on ui interaction', () => { | ||
cy.get('#stepper-field-section').within(() => { | ||
cy.contains('1').should('not.exist'); | ||
cy.get('.amplify-stepperfield__button--increase').click(); | ||
cy.contains('1'); | ||
}); | ||
}); | ||
|
||
it('updates on state mutation', () => { | ||
cy.get('#stepper-field-section').within(() => { | ||
cy.contains('9').should('not.exist'); | ||
cy.contains('Set StepperFieldValue').click(); | ||
cy.contains('9'); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('SwitchField', () => { | ||
it('updates on ui interaction', () => { | ||
cy.get('#switch-field-section').within(() => { | ||
cy.get('.amplify-switch-thumb').invoke('attr', 'data-checked').should('eq', 'false'); | ||
cy.contains('Subscribe').click(); | ||
cy.get('.amplify-switch-thumb').invoke('attr', 'data-checked').should('eq', 'true'); | ||
cy.contains('Subscribe').click(); | ||
cy.get('.amplify-switch-thumb').invoke('attr', 'data-checked').should('eq', 'false'); | ||
}); | ||
}); | ||
|
||
it('updates on state mutation', () => { | ||
cy.get('#switch-field-section').within(() => { | ||
cy.get('.amplify-switch-thumb').invoke('attr', 'data-checked').should('eq', 'false'); | ||
cy.contains('Set SwitchFieldValue').click(); | ||
cy.get('.amplify-switch-thumb').invoke('attr', 'data-checked').should('eq', 'true'); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('TextField', () => { | ||
it('updates on ui interaction', () => { | ||
cy.get('#text-field-section').within(() => { | ||
cy.contains('Entered Value').should('not.exist'); | ||
cy.get('input').type('Entered Value'); | ||
cy.contains('Entered Value'); | ||
}); | ||
}); | ||
|
||
it('updates on state mutation', () => { | ||
cy.get('#text-field-section').within(() => { | ||
cy.contains('Hardcoded Value').should('not.exist'); | ||
cy.contains('Set TextFieldValue').click(); | ||
cy.contains('Hardcoded Value'); | ||
}); | ||
}); | ||
}); | ||
}); |
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
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