From 761a519013fb34b894ec6af4d1025a4fa53da933 Mon Sep 17 00:00:00 2001 From: Diego2214 Date: Mon, 5 Apr 2021 16:01:10 -0700 Subject: [PATCH 01/45] Provided a dropdown list of crops,in alphabetical order, from the farmOS API to choose from. --- .../fd2_tabs/fd2_barn_kit/fd2_barn_kit.module | 10 +++++++ .../fd2_barn_kit/traySeedingReport.html | 30 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 farmdata2_modules/fd2_tabs/fd2_barn_kit/traySeedingReport.html diff --git a/farmdata2_modules/fd2_tabs/fd2_barn_kit/fd2_barn_kit.module b/farmdata2_modules/fd2_tabs/fd2_barn_kit/fd2_barn_kit.module index e61281f169..a1a46b2593 100644 --- a/farmdata2_modules/fd2_tabs/fd2_barn_kit/fd2_barn_kit.module +++ b/farmdata2_modules/fd2_tabs/fd2_barn_kit/fd2_barn_kit.module @@ -56,6 +56,16 @@ function fd2_barn_kit_menu() { 'weight' => -100, ); +! + $items['farm/fd2-barn-kit/traySeedingReport'] = array( + 'title' => 'Tray Seeding Report', + 'page callback' => 'fd2_barn_kit_view', + 'page arguments' => array('traySeedingReport.html'), + 'access arguments' => array('view fd2 barn kit'), + 'type' => MENU_LOCAL_TASK, + 'weight' => -10, + ); + return $items; }; diff --git a/farmdata2_modules/fd2_tabs/fd2_barn_kit/traySeedingReport.html b/farmdata2_modules/fd2_tabs/fd2_barn_kit/traySeedingReport.html new file mode 100644 index 0000000000..297ac9ff83 --- /dev/null +++ b/farmdata2_modules/fd2_tabs/fd2_barn_kit/traySeedingReport.html @@ -0,0 +1,30 @@ + +

Tray Seeding Report

+ + + +
+ + +
+ + + \ No newline at end of file From 7ddddf978da64e2e4af7d8a68873209942c58247 Mon Sep 17 00:00:00 2001 From: josieecook Date: Mon, 5 Apr 2021 20:28:06 -0400 Subject: [PATCH 02/45] Added start date and end date inputs to the tray seeding report tab, and set the default end date to the current day. --- .../fd2_tabs/fd2_barn_kit/fd2_barn_kit.module | 13 ++++++- .../fd2_barn_kit/traySeedingReport.html | 36 +++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 farmdata2_modules/fd2_tabs/fd2_barn_kit/traySeedingReport.html diff --git a/farmdata2_modules/fd2_tabs/fd2_barn_kit/fd2_barn_kit.module b/farmdata2_modules/fd2_tabs/fd2_barn_kit/fd2_barn_kit.module index e61281f169..63a8ef293c 100644 --- a/farmdata2_modules/fd2_tabs/fd2_barn_kit/fd2_barn_kit.module +++ b/farmdata2_modules/fd2_tabs/fd2_barn_kit/fd2_barn_kit.module @@ -53,9 +53,20 @@ function fd2_barn_kit_menu() { $items['farm/fd2-barn-kit/info'] = array( 'title' => 'Info', 'type' => MENU_DEFAULT_LOCAL_TASK, - 'weight' => -100, + 'weight' => -10, + ); + +! + $items['farm/fd2-barn-kit/traySeedingReport'] = array( + 'title' => 'Tray Seeding Report', + 'page callback' => 'fd2_barn_kit_view', + 'page arguments' => array('traySeedingReport.html'), + 'access arguments' => array('view fd2 barn kit'), + 'type' => MENU_LOCAL_TASK, + 'weight' => -10, ); + return $items; }; diff --git a/farmdata2_modules/fd2_tabs/fd2_barn_kit/traySeedingReport.html b/farmdata2_modules/fd2_tabs/fd2_barn_kit/traySeedingReport.html new file mode 100644 index 0000000000..f9791e197d --- /dev/null +++ b/farmdata2_modules/fd2_tabs/fd2_barn_kit/traySeedingReport.html @@ -0,0 +1,36 @@ + +
+ + + + + +
+ + + \ No newline at end of file From 496d4bc6296e8bb23964ec35e38bfd4a03e94e58 Mon Sep 17 00:00:00 2001 From: josieecook Date: Sat, 10 Apr 2021 22:13:17 -0400 Subject: [PATCH 03/45] Added comments to traySeedingReport.html for better readability --- .../fd2_tabs/fd2_barn_kit/traySeedingReport.html | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/farmdata2_modules/fd2_tabs/fd2_barn_kit/traySeedingReport.html b/farmdata2_modules/fd2_tabs/fd2_barn_kit/traySeedingReport.html index f9791e197d..7335f2863c 100644 --- a/farmdata2_modules/fd2_tabs/fd2_barn_kit/traySeedingReport.html +++ b/farmdata2_modules/fd2_tabs/fd2_barn_kit/traySeedingReport.html @@ -1,8 +1,10 @@
+ //Label and field for Start Date input + //Label and field for End Date input
@@ -13,6 +15,9 @@ data: { reportStart: '2018-05-01', reportEnd: '2018-07-31', + traySeedingLogs: [ + + ], }, methods: { timestampToYMD: function(timestamp) { From 04efe74ff5503ffe0b5f0e14eb7b895a47abab6d Mon Sep 17 00:00:00 2001 From: josieecook Date: Sat, 10 Apr 2021 23:24:35 -0400 Subject: [PATCH 04/45] Added a traySeedingLogRequest method that will make an API request to get seeding logs within the dates specified in the start and end date inputs. Also began to fill in table with appropriate variables from the request. --- .../fd2_barn_kit/traySeedingReport.html | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/farmdata2_modules/fd2_tabs/fd2_barn_kit/traySeedingReport.html b/farmdata2_modules/fd2_tabs/fd2_barn_kit/traySeedingReport.html index 8336cfad38..2eb6c5866a 100644 --- a/farmdata2_modules/fd2_tabs/fd2_barn_kit/traySeedingReport.html +++ b/farmdata2_modules/fd2_tabs/fd2_barn_kit/traySeedingReport.html @@ -49,10 +49,10 @@

Mock Report

Comments - - In Progress - - + + {{ timestampToYMD(log.date)}} + {{ log.crop }} + {{ log.numSeeds }} @@ -70,6 +70,9 @@

Mock Report

rptCrop: "Kale", reportStart: '2018-05-01', reportEnd: '2018-07-31', + traySeedingLogs: [ + + ], }, methods: { timestampToYMD: function(timestamp) { @@ -90,6 +93,20 @@

Mock Report

this.crops.push({rptCrop: 'Kale', reportStart: '2018-05-01', reportEnd: '2018-07-31'}); } }, + traySeedingLogRequest: function(field) { + let s = this.YMDToTimestamp(this.reportStart); + let e = this.YMDToTimestamp(this.reportEnd); + axios.get('/log.json?type=farm_seeding×tamp[ge]=' + s + '×tamp[le]=' + e) + .then(response => { + this.traySeedingLogs = response.data.list.map(t => { + return { + date:t.timestamp, + crop:t.name, + numSeeds:t.quantity, + }; + }); + }) + }, }, created() { //let today = new Date.now(); From 50e33644fdf612181021964da3b346dd8f8f48c3 Mon Sep 17 00:00:00 2001 From: josieecook Date: Sun, 11 Apr 2021 00:26:15 -0400 Subject: [PATCH 05/45] Added a traySeedingLogRequest method that sends an API request for tray seeding logs between the specified start and end dates. The dates of each log are added to the table, but all of the other details are currently blank. --- .../fd2_barn_kit/traySeedingReport.html | 98 ++++++++++--------- 1 file changed, 54 insertions(+), 44 deletions(-) diff --git a/farmdata2_modules/fd2_tabs/fd2_barn_kit/traySeedingReport.html b/farmdata2_modules/fd2_tabs/fd2_barn_kit/traySeedingReport.html index 2eb6c5866a..0295a8624e 100644 --- a/farmdata2_modules/fd2_tabs/fd2_barn_kit/traySeedingReport.html +++ b/farmdata2_modules/fd2_tabs/fd2_barn_kit/traySeedingReport.html @@ -10,56 +10,56 @@

Tray Seeding Report

- -
+ +
-
+ -
-
+ + -
- -
- -
-
-

Mock Report

-
-
    -
  • Start:{{}}
  • -
  • End:{{}}
  • -
  • Crop:{{}}
  • -
+ + + +
+
+

Mock Report

+
+
    +
  • Start:{{}}
  • +
  • End:{{}}
  • +
  • Crop:{{}}
  • +
-
- - - - - - - - - - - +
+
Date of Seeding Crop Number of Seeds Number of Trays Cells per Tray Variety User Comments
+ + + + + + + + + + - - - - - - - - - - -
Date of Seeding Crop Number of Seeds Number of Trays Cells per Tray Variety User Comments
{{ timestampToYMD(log.date)}}{{ log.crop }}{{ log.numSeeds }}
+ + {{ timestampToYMD(log.date) }} + {{ }} + {{ }} + + + + + + + +
+ \ No newline at end of file From ae7578665dc3769910d1d913bad6d6b1b13df13f Mon Sep 17 00:00:00 2001 From: Diego2214 Date: Mon, 12 Apr 2021 13:27:41 -0700 Subject: [PATCH 07/45] Added All option to crop downdown --- .../fd2_tabs/fd2_barn_kit/traySeedingReport.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/farmdata2_modules/fd2_tabs/fd2_barn_kit/traySeedingReport.html b/farmdata2_modules/fd2_tabs/fd2_barn_kit/traySeedingReport.html index 297ac9ff83..3e152937a5 100644 --- a/farmdata2_modules/fd2_tabs/fd2_barn_kit/traySeedingReport.html +++ b/farmdata2_modules/fd2_tabs/fd2_barn_kit/traySeedingReport.html @@ -22,7 +22,11 @@

Tray Seeding Report

created() { axios.get('/farm_asset.json?type=planting').then(response => { this.crops = response.data.list.map(f => f.name).sort(); + this.crops.splice(0,0,"All"); }); + // push all into crops array, make sure it goes to the top. Just incert on the top. + // once i get generate reort report, then get the API request to call all the crops. + // Make a API request, make sure to filter out the right things } }); Vue.config.devtools = true; From f58fcf923f97661d432f808542eb0a1acba57ffe Mon Sep 17 00:00:00 2001 From: Diego2214 Date: Tue, 13 Apr 2021 13:09:43 -0700 Subject: [PATCH 08/45] Cleaned Up code and made sure date/crops appear on table --- .../fd2_barn_kit/traySeedingReport.html | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/farmdata2_modules/fd2_tabs/fd2_barn_kit/traySeedingReport.html b/farmdata2_modules/fd2_tabs/fd2_barn_kit/traySeedingReport.html index 7d2e561423..c57f4c4ffb 100644 --- a/farmdata2_modules/fd2_tabs/fd2_barn_kit/traySeedingReport.html +++ b/farmdata2_modules/fd2_tabs/fd2_barn_kit/traySeedingReport.html @@ -9,30 +9,24 @@

Tray Seeding Report

-
- -
-

- -
-
-
+ +

Mock Report


    -
  • Start:{{}}
  • -
  • End:{{}}
  • -
  • Crop:{{}}
  • +
  • Start:{{reportStart}}
  • +
  • End:{{reportEnd}}
  • +
  • Crop:{{rptCrop}}

@@ -48,9 +42,9 @@

Mock Report

Comments - - In Progress - + + {{hlog.date}} + {{ hlog.crop }} @@ -60,15 +54,17 @@

Mock Report

- +
- \ No newline at end of file From d9ab6b6bdaf2d0d9a765d192c395ca9fe6f6c6c6 Mon Sep 17 00:00:00 2001 From: josieecook <60167626+josieecook@users.noreply.github.com> Date: Wed, 21 Apr 2021 09:02:52 -0400 Subject: [PATCH 17/45] Deleted traySeedingReport.html in main Returning main to original upstream code by removing file traySeedingReport.html. --- .../fd2_barn_kit/traySeedingReport.html | 172 ------------------ 1 file changed, 172 deletions(-) delete mode 100644 farmdata2_modules/fd2_tabs/fd2_barn_kit/traySeedingReport.html diff --git a/farmdata2_modules/fd2_tabs/fd2_barn_kit/traySeedingReport.html b/farmdata2_modules/fd2_tabs/fd2_barn_kit/traySeedingReport.html deleted file mode 100644 index 975314c6ff..0000000000 --- a/farmdata2_modules/fd2_tabs/fd2_barn_kit/traySeedingReport.html +++ /dev/null @@ -1,172 +0,0 @@ - -

Tray Seeding Report

- - -
- - - -
- - - - - - -
- - - -
-
-

Mock Report

-
-
    -
  • Start:{{reportStart}}
  • -
  • End:{{reportEnd}}
  • -
  • Crop:{{rptCrop}}
  • -
- -
- - - - - - - - - - - - - - - - - - - - - - - - - -
Date of Seeding Crop Number of Seeds Number of Trays Cells per Tray Variety User Comments Delete
{{ timestampToYMD(log.date) }}{{ log.crop }}{{ }}
-
-
- -

- - - \ No newline at end of file From b12c9682bdcefaf95b667376f1efd3a5bc20094a Mon Sep 17 00:00:00 2001 From: josie Date: Mon, 7 Jun 2021 09:17:44 -0400 Subject: [PATCH 18/45] Commiting progress in the cypress tests of the crop and field drop-down components --- .../cropAndFieldPickersTesting.html | 106 ++++++++++++++++++ .../integration/componentTesting.spec.js | 21 +++- .../fd2_tabs/fd2_example/fd2_example.module | 9 ++ 3 files changed, 131 insertions(+), 5 deletions(-) create mode 100644 farmdata2_modules/fd2_tabs/fd2_example/cropAndFieldPickersTesting.html diff --git a/farmdata2_modules/fd2_tabs/fd2_example/cropAndFieldPickersTesting.html b/farmdata2_modules/fd2_tabs/fd2_example/cropAndFieldPickersTesting.html new file mode 100644 index 0000000000..753911c1d3 --- /dev/null +++ b/farmdata2_modules/fd2_tabs/fd2_example/cropAndFieldPickersTesting.html @@ -0,0 +1,106 @@ + + + Crop Picker Component Testing + + + + +
+ Select a crop: + Select a field: +
+ + + + + + + + + diff --git a/farmdata2_modules/fd2_tabs/fd2_example/cypress/integration/componentTesting.spec.js b/farmdata2_modules/fd2_tabs/fd2_example/cypress/integration/componentTesting.spec.js index 5e1d0e3980..90737335af 100644 --- a/farmdata2_modules/fd2_tabs/fd2_example/cypress/integration/componentTesting.spec.js +++ b/farmdata2_modules/fd2_tabs/fd2_example/cypress/integration/componentTesting.spec.js @@ -1,13 +1,24 @@ describe('Field and Crop Dropdowns', () => { beforeEach(() => { - //cy.login('manager1', 'farmdata2') - cy.visit('/farm/fd2-example/componentTesting') + cy.login('manager1', 'farmdata2') + cy.visit('/farm/fd2-example/cropAndFieldPickersTesting') }) context('Crop Dropdown', () => { it('accepts input from search bar', () => { - cy.get('crop-picker-element') - .type('lettuce') - .should('have.value', 'lettuce') + cy.get('[data-cy=crop-picker-input]') + .type('lettuce') + .should('have.value', 'lettuce') + }) + + //create test to make sure that all crops are showing up in the drop-down menu before anything is typed in the search bar + //API request in the spec file??? + + it('displays only crops sorted out by the search term', () => { + cy.get('[data-cy=crop-picker-input]') + .type('lettuce') + .should('have.value', 'lettuce') + cy.get('[data-cy=crop-picker-dropdown]') + .should('have.value', ['placeholder']) }) }) }) diff --git a/farmdata2_modules/fd2_tabs/fd2_example/fd2_example.module b/farmdata2_modules/fd2_tabs/fd2_example/fd2_example.module index 61e253c47f..35f66937d5 100644 --- a/farmdata2_modules/fd2_tabs/fd2_example/fd2_example.module +++ b/farmdata2_modules/fd2_tabs/fd2_example/fd2_example.module @@ -72,6 +72,15 @@ function fd2_example_menu() { 'weight' => 100, ); + $items['farm/fd2-example/cropAndFieldPickersTesting'] = array( + 'title' => 'Crop and Field Pickers', + 'type' => MENU_LOCAL_TASK, + 'page callback' => 'fd2_example_view', + 'page arguments' => array('cropAndFieldPickersTesting.html'), + 'access arguments' => array('view fd2 example'), + 'weight' => 100, + ); + return $items; }; From 446b81f6dc51867e4f50efaa9157dd614c6f0994 Mon Sep 17 00:00:00 2001 From: josie Date: Tue, 8 Jun 2021 09:32:28 -0400 Subject: [PATCH 19/45] Crop and Field Picker component and cypress tests in progress --- .../cropAndFieldPickersTesting.html | 43 +++++++++--- .../integration/componentTesting.spec.js | 70 ++++++++++++++----- .../fd2_tabs/fd2_example/fd2_example.info | 3 +- .../resources/fieldOrCropDropdownComponent.js | 45 ++++++++++++ .../fieldOrCropDropdownComponent.spec.js | 26 +++++++ 5 files changed, 159 insertions(+), 28 deletions(-) create mode 100644 farmdata2_modules/fd2_tabs/resources/fieldOrCropDropdownComponent.js create mode 100644 farmdata2_modules/fd2_tabs/resources/fieldOrCropDropdownComponent.spec.js diff --git a/farmdata2_modules/fd2_tabs/fd2_example/cropAndFieldPickersTesting.html b/farmdata2_modules/fd2_tabs/fd2_example/cropAndFieldPickersTesting.html index 753911c1d3..1c3e69f915 100644 --- a/farmdata2_modules/fd2_tabs/fd2_example/cropAndFieldPickersTesting.html +++ b/farmdata2_modules/fd2_tabs/fd2_example/cropAndFieldPickersTesting.html @@ -6,8 +6,10 @@
- Select a crop: - Select a field: + Select a crop: + + + backup:
@@ -18,9 +20,9 @@ let CropPickerComponent = { template: `
- + - +
`, props: { @@ -39,6 +41,11 @@ selectedCrop: null, } }, + methods: { + cropChanged() { + this.$emit('cropChanged', this.selectedCrop) + } + }, computed: { fullDropDown: function() { let newList = this.dropDownList; @@ -53,9 +60,9 @@ let FieldPickerComponent = { template: `
- - - + + +
`, props: { @@ -88,15 +95,29 @@ new Vue({ el: '#app', components: { + 'field-or-crop-dropdown': FieldOrCropDropdownComponent, 'crop-picker': CropPickerComponent, - 'field-picker': FieldPickerComponent, - 'field-and-crop-picker': FieldAndCropPickerComponent }, data() { return { - cropsList: ["lettuce", "beans", "corn"], - fieldsList: ["Chuau", "Jasmine-1", "A"] + cropsList: [], + fieldsList: [] } + }, + created() { + /** + * axios.get('/farm_asset.json?type=planting').then(response => { + this.cropsList = response.data.list.map(f => f.name).sort(); + }); + axios.get('/taxonomy_term.json?bundle=farm_areas').then(response => { + this.fieldsList = response.data.list.map(f => f.name).sort(); + }); + */ + + //The lines below are added for the sake of testing + this.cropsList = ['Corn', 'Beans', 'Peas']; + this.fieldsList = ['Chuau', 'Jasmine-1', 'O']; + } }) diff --git a/farmdata2_modules/fd2_tabs/fd2_example/cypress/integration/componentTesting.spec.js b/farmdata2_modules/fd2_tabs/fd2_example/cypress/integration/componentTesting.spec.js index 90737335af..dfa4d34b40 100644 --- a/farmdata2_modules/fd2_tabs/fd2_example/cypress/integration/componentTesting.spec.js +++ b/farmdata2_modules/fd2_tabs/fd2_example/cypress/integration/componentTesting.spec.js @@ -1,24 +1,62 @@ describe('Field and Crop Dropdowns', () => { - beforeEach(() => { + beforeEach(() => { cy.login('manager1', 'farmdata2') cy.visit('/farm/fd2-example/cropAndFieldPickersTesting') - }) - context('Crop Dropdown', () => { - it('accepts input from search bar', () => { - cy.get('[data-cy=crop-picker-input]') - .type('lettuce') - .should('have.value', 'lettuce') + }) + context('Crop Dropdown', () => { + it('accepts input from search bar', () => { + cy.get('[data-cy=crop-picker-input]') + .type('Beans') + .should('have.value', 'Beans') + }) - //create test to make sure that all crops are showing up in the drop-down menu before anything is typed in the search bar - //API request in the spec file??? + it.only('contains the right crops', () => { + cy.get('[data-cy=crop-picker-options]') + .first().should('have.text', 'All') + .then().should('have.text', 'Corn') + .then().should('have.text', 'Beans') + .then().should('have.text', 'Peas') + }) - it('displays only crops sorted out by the search term', () => { - cy.get('[data-cy=crop-picker-input]') - .type('lettuce') - .should('have.value', 'lettuce') - cy.get('[data-cy=crop-picker-dropdown]') - .should('have.value', ['placeholder']) + it('includes the all option when the attribute is included', () => { + //test that it has the attribute 'includesAll' + cy.get('[data-cy=crop-picker-options]') + .first().should('have.text', 'All') + }) + + /** + * it('populates search bar when an option is selected', () => { + cy.get('[data-cy=crop-picker-input]') + .type('Beans') + cy.get('[data-cy=crop-picker-options]') + .first().should('have.text', 'Beans') + .next().should('have.text', 'Soybeans') + }) + */ + + /** + * it.only('updates the selectedCrop when an option is selected', () => { + cy.get('[data-cy=crop-picker-input]') + .type('Beans') + .should('have.value', 'Beans') + cy.get('[data-cy=crop-picker-component]') + .should('have.data', 'selectedCrop') + }) + */ + + }) + context('Field Dropdown', () => { + it('accepts input from search bar', () => { + cy.get('[data-cy=field-picker-input]') + .type('Jasmine-1') + .should('have.value', 'Jasmine-1') + }) + + it('includes "all" option when the attribute is included', () => { + //test that it has the attribute 'includesAll' + cy.get('[data-cy=crop-picker-options]') + .first().should('have.text', 'All') + }) }) - }) }) diff --git a/farmdata2_modules/fd2_tabs/fd2_example/fd2_example.info b/farmdata2_modules/fd2_tabs/fd2_example/fd2_example.info index 4c6bb1395d..ab99a3edd4 100644 --- a/farmdata2_modules/fd2_tabs/fd2_example/fd2_example.info +++ b/farmdata2_modules/fd2_tabs/fd2_example/fd2_example.info @@ -4,4 +4,5 @@ core = 7.x package = FarmData2 stylesheets[all][] = '../resources/fd2.css' -scripts[] = '../resources/fieldsDropdownComponent.js' \ No newline at end of file +scripts[] = '../resources/fieldsDropdownComponent.js' +scripts[] = '../resources/fieldOrCropDropdownComponent.js' \ No newline at end of file diff --git a/farmdata2_modules/fd2_tabs/resources/fieldOrCropDropdownComponent.js b/farmdata2_modules/fd2_tabs/resources/fieldOrCropDropdownComponent.js new file mode 100644 index 0000000000..94215270e3 --- /dev/null +++ b/farmdata2_modules/fd2_tabs/resources/fieldOrCropDropdownComponent.js @@ -0,0 +1,45 @@ +let FieldOrCropDropdownComponent = { + /** + *
+ + + + + +
` + */ + template: `
+ + + + + +
`, + props: { + dropDownList: { + type: Array + }, + includesAll: { + type: Boolean, + }, + }, + data() { + return { + selectedOption: null, + } + }, + methods: { + selectionChanged() { + this.$emit('selectionChanged', this.selectedOption) + } + }, + computed: { + fullDropDown: function() { + let newList = this.dropDownList; + if (this.includesAll == true) { + newList.splice(0,0,"All"); + } + return newList; + } + } +} \ No newline at end of file diff --git a/farmdata2_modules/fd2_tabs/resources/fieldOrCropDropdownComponent.spec.js b/farmdata2_modules/fd2_tabs/resources/fieldOrCropDropdownComponent.spec.js new file mode 100644 index 0000000000..71ee7e1203 --- /dev/null +++ b/farmdata2_modules/fd2_tabs/resources/fieldOrCropDropdownComponent.spec.js @@ -0,0 +1,26 @@ +describe('Field and Crop Dropdowns', () => { + beforeEach(() => { + cy.login('manager1', 'farmdata2') + cy.visit('/farm/fd2-example/cropAndFieldPickersTesting') + + }) + it('accepts input from search bar', () => { + cy.get('[data-cy=dropdown-input]') + .type('Beans') + .should('have.value', 'Beans') + }) + + it('contains the right crops', () => { + cy.get('[data-cy=singleOption]') + .first().should('have.text', 'All') + .next().should('have.text', 'Corn') + .next().should('have.text', 'Beans') + .next().should('have.text', 'Peas') + }) + + it('includes the all option when the attribute is included', () => { + //figure out how to include test that determines if it has the attribute 'includesAll' + cy.get('[data-cy=singleOption]') + .first().should('have.text', 'All') + }) +}) \ No newline at end of file From fd7a39f87442248d476885e69435874afe1815bc Mon Sep 17 00:00:00 2001 From: josie Date: Tue, 8 Jun 2021 10:55:51 -0400 Subject: [PATCH 20/45] Updated dropdown component with new name, more consistent labels, and a required dataList property --- .../cropAndFieldPickersTesting.html | 4 ++-- .../fd2_tabs/fd2_example/fd2_example.info | 2 +- ...mponent.js => dropdownWithAllComponent.js} | 22 ++++++------------- ...ec.js => dropdownWithAllComponent.spec.js} | 0 4 files changed, 10 insertions(+), 18 deletions(-) rename farmdata2_modules/fd2_tabs/resources/{fieldOrCropDropdownComponent.js => dropdownWithAllComponent.js} (58%) rename farmdata2_modules/fd2_tabs/resources/{fieldOrCropDropdownComponent.spec.js => dropdownWithAllComponent.spec.js} (100%) diff --git a/farmdata2_modules/fd2_tabs/fd2_example/cropAndFieldPickersTesting.html b/farmdata2_modules/fd2_tabs/fd2_example/cropAndFieldPickersTesting.html index 1c3e69f915..e673a5f176 100644 --- a/farmdata2_modules/fd2_tabs/fd2_example/cropAndFieldPickersTesting.html +++ b/farmdata2_modules/fd2_tabs/fd2_example/cropAndFieldPickersTesting.html @@ -6,7 +6,7 @@
- Select a crop: + Select a crop: backup: @@ -95,7 +95,7 @@ new Vue({ el: '#app', components: { - 'field-or-crop-dropdown': FieldOrCropDropdownComponent, + 'dropdown-with-all': DropdownWithAllComponent, 'crop-picker': CropPickerComponent, }, data() { diff --git a/farmdata2_modules/fd2_tabs/fd2_example/fd2_example.info b/farmdata2_modules/fd2_tabs/fd2_example/fd2_example.info index ab99a3edd4..531683749a 100644 --- a/farmdata2_modules/fd2_tabs/fd2_example/fd2_example.info +++ b/farmdata2_modules/fd2_tabs/fd2_example/fd2_example.info @@ -5,4 +5,4 @@ package = FarmData2 stylesheets[all][] = '../resources/fd2.css' scripts[] = '../resources/fieldsDropdownComponent.js' -scripts[] = '../resources/fieldOrCropDropdownComponent.js' \ No newline at end of file +scripts[] = '../resources/dropdownWithAllComponent.js' \ No newline at end of file diff --git a/farmdata2_modules/fd2_tabs/resources/fieldOrCropDropdownComponent.js b/farmdata2_modules/fd2_tabs/resources/dropdownWithAllComponent.js similarity index 58% rename from farmdata2_modules/fd2_tabs/resources/fieldOrCropDropdownComponent.js rename to farmdata2_modules/fd2_tabs/resources/dropdownWithAllComponent.js index 94215270e3..bcd656d934 100644 --- a/farmdata2_modules/fd2_tabs/resources/fieldOrCropDropdownComponent.js +++ b/farmdata2_modules/fd2_tabs/resources/dropdownWithAllComponent.js @@ -1,23 +1,15 @@ -let FieldOrCropDropdownComponent = { - /** - *
- - - - - -
` - */ +let DropdownWithAllComponent = { template: `
- - - + + +
`, props: { dropDownList: { - type: Array + type: Array, + required: true }, includesAll: { type: Boolean, @@ -34,7 +26,7 @@ let FieldOrCropDropdownComponent = { } }, computed: { - fullDropDown: function() { + fullDropdown: function() { let newList = this.dropDownList; if (this.includesAll == true) { newList.splice(0,0,"All"); diff --git a/farmdata2_modules/fd2_tabs/resources/fieldOrCropDropdownComponent.spec.js b/farmdata2_modules/fd2_tabs/resources/dropdownWithAllComponent.spec.js similarity index 100% rename from farmdata2_modules/fd2_tabs/resources/fieldOrCropDropdownComponent.spec.js rename to farmdata2_modules/fd2_tabs/resources/dropdownWithAllComponent.spec.js From 0177b75e4ea22f0f46b213602e14a46304e9eaaa Mon Sep 17 00:00:00 2001 From: josieecook Date: Tue, 8 Jun 2021 16:38:00 -0400 Subject: [PATCH 21/45] achieved functional dropdownWithAll component and component testing for it. --- .../cropAndFieldPickersTesting.html | 127 ------------------ .../integration/componentTesting.spec.js | 62 --------- .../resources/dropdownWithAllComponent.js | 22 ++- .../dropdownWithAllComponent.spec.comp.js | 48 +++++++ .../dropdownWithAllComponent.spec.js | 26 ---- .../resources/fieldsDropdownComponent.js | 2 +- 6 files changed, 66 insertions(+), 221 deletions(-) delete mode 100644 farmdata2_modules/fd2_tabs/fd2_example/cropAndFieldPickersTesting.html delete mode 100644 farmdata2_modules/fd2_tabs/fd2_example/cypress/integration/componentTesting.spec.js create mode 100644 farmdata2_modules/fd2_tabs/resources/dropdownWithAllComponent.spec.comp.js delete mode 100644 farmdata2_modules/fd2_tabs/resources/dropdownWithAllComponent.spec.js diff --git a/farmdata2_modules/fd2_tabs/fd2_example/cropAndFieldPickersTesting.html b/farmdata2_modules/fd2_tabs/fd2_example/cropAndFieldPickersTesting.html deleted file mode 100644 index e673a5f176..0000000000 --- a/farmdata2_modules/fd2_tabs/fd2_example/cropAndFieldPickersTesting.html +++ /dev/null @@ -1,127 +0,0 @@ - - - Crop Picker Component Testing - - - - -
- Select a crop: - - - backup: -
- - - - - - - - - diff --git a/farmdata2_modules/fd2_tabs/fd2_example/cypress/integration/componentTesting.spec.js b/farmdata2_modules/fd2_tabs/fd2_example/cypress/integration/componentTesting.spec.js deleted file mode 100644 index dfa4d34b40..0000000000 --- a/farmdata2_modules/fd2_tabs/fd2_example/cypress/integration/componentTesting.spec.js +++ /dev/null @@ -1,62 +0,0 @@ -describe('Field and Crop Dropdowns', () => { - beforeEach(() => { - cy.login('manager1', 'farmdata2') - cy.visit('/farm/fd2-example/cropAndFieldPickersTesting') - - }) - context('Crop Dropdown', () => { - it('accepts input from search bar', () => { - cy.get('[data-cy=crop-picker-input]') - .type('Beans') - .should('have.value', 'Beans') - }) - - it.only('contains the right crops', () => { - cy.get('[data-cy=crop-picker-options]') - .first().should('have.text', 'All') - .then().should('have.text', 'Corn') - .then().should('have.text', 'Beans') - .then().should('have.text', 'Peas') - }) - - it('includes the all option when the attribute is included', () => { - //test that it has the attribute 'includesAll' - cy.get('[data-cy=crop-picker-options]') - .first().should('have.text', 'All') - }) - - /** - * it('populates search bar when an option is selected', () => { - cy.get('[data-cy=crop-picker-input]') - .type('Beans') - cy.get('[data-cy=crop-picker-options]') - .first().should('have.text', 'Beans') - .next().should('have.text', 'Soybeans') - }) - */ - - /** - * it.only('updates the selectedCrop when an option is selected', () => { - cy.get('[data-cy=crop-picker-input]') - .type('Beans') - .should('have.value', 'Beans') - cy.get('[data-cy=crop-picker-component]') - .should('have.data', 'selectedCrop') - }) - */ - - }) - context('Field Dropdown', () => { - it('accepts input from search bar', () => { - cy.get('[data-cy=field-picker-input]') - .type('Jasmine-1') - .should('have.value', 'Jasmine-1') - }) - - it('includes "all" option when the attribute is included', () => { - //test that it has the attribute 'includesAll' - cy.get('[data-cy=crop-picker-options]') - .first().should('have.text', 'All') - }) - }) -}) diff --git a/farmdata2_modules/fd2_tabs/resources/dropdownWithAllComponent.js b/farmdata2_modules/fd2_tabs/resources/dropdownWithAllComponent.js index bcd656d934..31939ff029 100644 --- a/farmdata2_modules/fd2_tabs/resources/dropdownWithAllComponent.js +++ b/farmdata2_modules/fd2_tabs/resources/dropdownWithAllComponent.js @@ -1,13 +1,13 @@ let DropdownWithAllComponent = { - template: `
+ template: `
-
`, +
`, props: { - dropDownList: { + dropdownList: { type: Array, required: true }, @@ -27,11 +27,23 @@ let DropdownWithAllComponent = { }, computed: { fullDropdown: function() { - let newList = this.dropDownList; + let newList = this.dropdownList; if (this.includesAll == true) { newList.splice(0,0,"All"); } return newList; } } -} \ No newline at end of file +} +/* + * Export the fieldsDropdownComponent object as a CommonJS component + * so that it can be imported into the component test. This is + * wrapped in the try/catch to suppress the error that is generated + * in the browser when it is added to the Drupal page as a normal + * JavaScript file through a \ No newline at end of file diff --git a/farmdata2_modules/fd2_tabs/fd2_example/ex1.spec.js b/farmdata2_modules/fd2_tabs/fd2_example/ex1.spec.js index 03bd9cd97f..fccfbee856 100644 --- a/farmdata2_modules/fd2_tabs/fd2_example/ex1.spec.js +++ b/farmdata2_modules/fd2_tabs/fd2_example/ex1.spec.js @@ -1,31 +1,40 @@ describe('Tests for the example sub-tab', () => { - - it('Text field content is linked to header', () => { + beforeEach(() => { cy.login('worker1', 'farmdata2') cy.visit('/farm/fd2-example/ex1') + }) - cy.get('[data-cy=comment-field]').clear().type('Hello Farm!') + it('Text field content is linked to header', () => { + cy.get('[data-cy=comment-field]') + .clear() + .type('Hello Farm!') - cy.get('[data-cy=comment]').should('have.text','Hello Farm!') + cy.get('[data-cy=comment]') + .should('have.text','Hello Farm!') }) - + it('API call for farm name works', () => { - cy.login('worker1', 'farmdata2') - cy.visit('/farm/fd2-example/ex1') - - cy.get('[data-cy=get-name-button]').click() + cy.get('[data-cy=get-name-button]') + .click() - cy.get('[data-cy=farm-name]').should('have.text','Dickinson College Farm') + cy.get('[data-cy=farm-name]') + .should('have.text','Dickinson College Farm') }) - it('API call for fields works', () => { - cy.login('worker1', 'farmdata2') - cy.visit('/farm/fd2-example/ex1') - - cy.get('[data-cy=field-select]').select("All") - cy.get('[data-cy=selected-field]').should('have.text', "All") - - cy.get('[data-cy=field-select]').select("JASMINE-1") - cy.get('[data-cy=selected-field]').should('have.text', "JASMINE-1") + it.only('API call for fields works', () => { + cy.get('[data-cy=singleOption]') + .first().should('have.text', 'All') + .next().should('have.text', 'ALF 1') + + cy.get('[data-cy=dropdown-input]') + .type("All{enter}") + cy.get('[data-cy=selected-field]') + .should('have.text', "All") + + cy.get('[data-cy=dropdown-input]') + .clear() + .type("JASMINE-1{enter}") + cy.get('[data-cy=selected-field]') + .should('have.text', "JASMINE-1") }) }) diff --git a/farmdata2_modules/fd2_tabs/fd2_example/fd2_example.info b/farmdata2_modules/fd2_tabs/fd2_example/fd2_example.info index 5bd73c4b7a..c9dfa03580 100644 --- a/farmdata2_modules/fd2_tabs/fd2_example/fd2_example.info +++ b/farmdata2_modules/fd2_tabs/fd2_example/fd2_example.info @@ -5,4 +5,5 @@ package = FarmData2 stylesheets[all][] = '../resources/fd2.css' scripts[] = '../resources/fieldsDropdownComponent.js' -scripts[] = '../resources/customTableComponent.js' \ No newline at end of file +scripts[] = '../resources/customTableComponent.js' +scripts[] = '../resources/dropdownWithAllComponent.js' diff --git a/farmdata2_modules/fd2_tabs/resources/dropdownWithAllComponent.js b/farmdata2_modules/fd2_tabs/resources/dropdownWithAllComponent.js new file mode 100644 index 0000000000..2bf08889d9 --- /dev/null +++ b/farmdata2_modules/fd2_tabs/resources/dropdownWithAllComponent.js @@ -0,0 +1,58 @@ +/** + * Vue.js component that defines the dropdown menu. + */ +let DropdownWithAllComponent = { + template: `
+ + + + + +
`, + props: { + dropdownList: { + type: Array, + required: true + }, + includesAll: { + type: Boolean, + }, + }, + data() { + return { + selectedOption: null, + } + }, + methods: { + selectionChanged: function() { + this.$emit('selection-changed', this.selectedOption) + }, + checkInput: function() { + if (!this.fullDropdown.includes(this.selectedOption)) { + this.selectedOption = null; + } + } + }, + computed: { + fullDropdown: function() { + let newList = this.dropdownList; + if (this.includesAll == true) { + newList.splice(0,0,"All"); + //newList.push("All"); + } + return newList; + } + } +} +/* + * Export the fieldsDropdownComponent object as a CommonJS component + * so that it can be imported into the component test. This is + * wrapped in the try/catch to suppress the error that is generated + * in the browser when it is added to the Drupal page as a normal + * JavaScript file through a