Skip to content

Commit

Permalink
tests: update to use proper find syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
JRJurman committed Oct 22, 2023
1 parent d4db40c commit 4b22194
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 44 deletions.
22 changes: 11 additions & 11 deletions examples/export/export.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ describe('Tram-Lite Example Components (via export)', () => {
cy.visit('../examples/export/index.html');

/* copied from inline tests */
cy.get('ex-temperature').get('input#f').type('19');
cy.get('ex-temperature').get('input#c').should('have.value', '-7');
cy.get('ex-temperature').get('input#f').should('have.value', '19');
cy.get('ex-temperature').find('input#f').type('19');
cy.get('ex-temperature').find('input#c').should('have.value', '-7');
cy.get('ex-temperature').find('input#f').should('have.value', '19');

/* copied from inline tests */
cy.get('ex-progressbar').should('not.have.attr', 'warning');
cy.get('ex-progressbar').get('input#value').clear().type('12');
cy.get('ex-progressbar').find('input#value').clear().type('12');
cy.get('ex-progressbar').should('have.attr', 'warning');
cy.get('ex-progressbar').get('input#max').clear().type('15');
cy.get('ex-progressbar').find('input#max').clear().type('15');
cy.get('ex-progressbar').should('not.have.attr', 'warning');

/* copied from inline tests */
cy.get('ex-colorpicker').invoke('attr', 'hue', '120');
cy.get('ex-colorpicker').get('input#hue-range-input').should('have.value', '120');
cy.get('ex-colorpicker').get('input#hue-text-input').should('have.value', '120');
cy.get('ex-colorpicker').find('input#hue-range-input').should('have.value', '120');
cy.get('ex-colorpicker').find('input#hue-text-input').should('have.value', '120');
cy.get('ex-colorpicker')
.get('rect')
.then(($element) => {
Expand All @@ -30,15 +30,15 @@ describe('Tram-Lite Example Components (via export)', () => {
cy.get('ex-todoitem').contains('Example Initial Item');
cy.get('ex-todoitem').contains('Learning Tram-Lite');

cy.get('ex-todolist').get('form input').type('Cypress Test'); // create new todo item
cy.get('ex-todolist').get('form').submit();
cy.get('ex-todolist').find('form input').type('Cypress Test'); // create new todo item
cy.get('ex-todolist').find('form').submit();

cy.get('ex-todoitem').contains('Cypress Test'); // verify it exists

cy.get('ex-todoitem').contains('Cypress Test').click(); // click it, and verify that the top label updates
cy.get('ex-todolist').get('span').contains('(1/3)');
cy.get('ex-todolist').find('span').contains('(1/3)');

cy.get('ex-todoitem').contains('Cypress Test').click();
cy.get('ex-todolist').get('span').contains('(0/3)');
cy.get('ex-todolist').find('span').contains('(0/3)');
});
});
14 changes: 7 additions & 7 deletions examples/hybrid/hybrid.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ describe('Tram-Lite Example Components (via import and inline)', () => {
cy.visit('../examples/hybrid/index.html');

/* copied from inline tests, verify inline defined element */
cy.get('in-temperature').get('input#f').type('19');
cy.get('in-temperature').get('input#c').should('have.value', '-7');
cy.get('in-temperature').get('input#f').should('have.value', '19');
cy.get('in-temperature').find('input#f').type('19');
cy.get('in-temperature').find('input#c').should('have.value', '-7');
cy.get('in-temperature').find('input#f').should('have.value', '19');

/* copied from inline tests, verify the external component imported works */
cy.get('ex-progressbar').should('not.have.attr', 'warning');
cy.get('ex-progressbar').get('input#value').clear().type('12');
cy.get('ex-progressbar').find('input#value').clear().type('12');
cy.get('ex-progressbar').should('have.attr', 'warning');
cy.get('ex-progressbar').get('input#max').clear().type('15');
cy.get('ex-progressbar').find('input#max').clear().type('15');
cy.get('ex-progressbar').should('not.have.attr', 'warning');

/* copied from inline tests, verify that external component exported works */
cy.get('ex-colorpicker').invoke('attr', 'hue', '120');
cy.get('ex-colorpicker').get('input#hue-range-input').should('have.value', '120');
cy.get('ex-colorpicker').get('input#hue-text-input').should('have.value', '120');
cy.get('ex-colorpicker').find('input#hue-range-input').should('have.value', '120');
cy.get('ex-colorpicker').find('input#hue-text-input').should('have.value', '120');
cy.get('ex-colorpicker')
.get('rect')
.then(($element) => {
Expand Down
22 changes: 11 additions & 11 deletions examples/import/import.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ describe('Tram-Lite Example Components (via import)', () => {
cy.visit('../examples/import/index.html');

/* copied from inline tests - verifies that multiple components in a single import works */
cy.get('ex-temperature').get('input#f').type('19');
cy.get('ex-temperature').get('input#c').should('have.value', '-7');
cy.get('ex-temperature').get('input#f').should('have.value', '19');
cy.get('ex-temperature').find('input#f').type('19');
cy.get('ex-temperature').find('input#c').should('have.value', '-7');
cy.get('ex-temperature').find('input#f').should('have.value', '19');

/* copied from inline tests - verifies that multiple components in a single import works */
cy.get('ex-progressbar').should('not.have.attr', 'warning');
cy.get('ex-progressbar').get('input#value').clear().type('12');
cy.get('ex-progressbar').find('input#value').clear().type('12');
cy.get('ex-progressbar').should('have.attr', 'warning');
cy.get('ex-progressbar').get('input#max').clear().type('15');
cy.get('ex-progressbar').find('input#max').clear().type('15');
cy.get('ex-progressbar').should('not.have.attr', 'warning');

/* copied from inline tests - verifies that multiple call of import-component works */
cy.get('ex-colorpicker').invoke('attr', 'hue', '120');
cy.get('ex-colorpicker').get('input#hue-range-input').should('have.value', '120');
cy.get('ex-colorpicker').get('input#hue-text-input').should('have.value', '120');
cy.get('ex-colorpicker').find('input#hue-range-input').should('have.value', '120');
cy.get('ex-colorpicker').find('input#hue-text-input').should('have.value', '120');
cy.get('ex-colorpicker')
.get('rect')
.then(($element) => {
Expand All @@ -30,15 +30,15 @@ describe('Tram-Lite Example Components (via import)', () => {
cy.get('ex-todoitem').contains('Example Initial Item');
cy.get('ex-todoitem').contains('Learning Tram-Lite');

cy.get('ex-todolist').get('form input').type('Cypress Test'); // create new todo item
cy.get('ex-todolist').get('form').submit();
cy.get('ex-todolist').find('form input').type('Cypress Test'); // create new todo item
cy.get('ex-todolist').find('form').submit();

cy.get('ex-todoitem').contains('Cypress Test'); // verify it exists

cy.get('ex-todoitem').contains('Cypress Test').click(); // click it, and verify that the top label updates
cy.get('ex-todolist').get('span').contains('(1/3)');
cy.get('ex-todolist').find('span').contains('(1/3)');

cy.get('ex-todoitem').contains('Cypress Test').click();
cy.get('ex-todolist').get('span').contains('(0/3)');
cy.get('ex-todolist').find('span').contains('(0/3)');
});
});
30 changes: 15 additions & 15 deletions examples/inline/inline.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ describe('Tram-Lite Example Components', () => {
cy.get('in-counter#red').contains(/Red: 1/);

/* verify that updating inputs updates attributes as expected (tl-controlled) */
cy.get('in-mirror').get('input#source').type('Hello, World');
cy.get('in-mirror').get('input#reflection').should('have.value', 'Hello, World');
cy.get('in-mirror').find('input#source').type('Hello, World');
cy.get('in-mirror').find('input#reflection').should('have.value', 'Hello, World');
cy.get('in-mirror').should('have.attr', 'value', 'Hello, World');
cy.get('in-mirror').should('have.attr', 'is-mirrored', '');

/* verify that updating an attribute copies to multiple elements and attributes */
cy.get('in-colorpicker').invoke('attr', 'hue', '120');
cy.get('in-colorpicker').get('input#hue-range-input').should('have.value', '120');
cy.get('in-colorpicker').get('input#hue-text-input').should('have.value', '120');
cy.get('in-colorpicker').find('input#hue-range-input').should('have.value', '120');
cy.get('in-colorpicker').find('input#hue-text-input').should('have.value', '120');
cy.get('in-colorpicker')
.get('rect')
.then(($element) => {
Expand All @@ -38,32 +38,32 @@ describe('Tram-Lite Example Components', () => {
cy.get('in-todoitem').contains('Learning Tram-Lite');

/* verify that creating elements works as expected */
cy.get('in-todolist').get('form input').type('Cypress Test'); // create new todo item
cy.get('in-todolist').get('form').submit();
cy.get('in-todolist').find('form input').type('Cypress Test'); // create new todo item
cy.get('in-todolist').find('form').submit();

cy.get('in-todoitem').contains('Cypress Test'); // verify it exists

cy.get('in-todoitem').contains('Cypress Test').click(); // click it, and verify that the top label updates
cy.get('in-todolist').get('span').contains('(1/3)');
cy.get('in-todolist').find('span').contains('(1/3)');

/* verify that updating an input with a false value unsets the attribute value */
cy.get('in-todoitem').contains('Cypress Test').click();
cy.get('in-todolist').get('span').contains('(0/3)');
cy.get('in-todolist').find('span').contains('(0/3)');

/* verify that boolean attributes on controlled elements update when host attributes update */
cy.get('in-todolist').get('button#select-all').click();
cy.get('in-todoitem').get('input').should('be.checked');
cy.get('in-todolist').find('button#select-all').click();
cy.get('in-todoitem').find('input').should('be.checked');

/* verify that component effects trigger on dependency updates */
cy.get('in-temperature').get('input#f').type('19');
cy.get('in-temperature').get('input#c').should('have.value', '-7');
cy.get('in-temperature').get('input#f').should('have.value', '19');
cy.get('in-temperature').find('input#f').type('19');
cy.get('in-temperature').find('input#c').should('have.value', '-7');
cy.get('in-temperature').find('input#f').should('have.value', '19');

/* verify that an element with multiple dependencies triggers on either dependency */
cy.get('in-progressbar').should('not.have.attr', 'warning');
cy.get('in-progressbar').get('input#value').clear().type('12');
cy.get('in-progressbar').find('input#value').clear().type('12');
cy.get('in-progressbar').should('have.attr', 'warning');
cy.get('in-progressbar').get('input#max').clear().type('15');
cy.get('in-progressbar').find('input#max').clear().type('15');
cy.get('in-progressbar').should('not.have.attr', 'warning');
});
});

0 comments on commit 4b22194

Please sign in to comment.