Skip to content
This repository has been archived by the owner on Aug 26, 2024. It is now read-only.

TEST 44 RESOLVED: Testing to create Direct Seeding Log in Seeding Input #174

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
e2e: {
setupNodeEvents(on, config) {
// implement node event listeners here
},
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "[email protected]",
"body": "Fixtures are a great way to mock data for responses to routes"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add('login', (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// ***********************************************************
// This example support/e2e.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands'

// Alternatively you can use CommonJS syntax:
// require('./commands')
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/**The file is to ensure that the "Submit" button is enabled and disabled as appropriate.*/


describe("Seeding Input: Test Submit", () => {

beforeEach(() => {
cy.login("manager1","farmdata2");
cy.visit("/farm/fd2-field-kit/seedingInput");
cy.waitForPage();

//selectDate
cy.get('[data-cy="date-selection"] > [data-cy="date-select"]').click()
.type('2024-04-24');
//select crop
cy.get('[data-cy="crop-selection"] > [data-cy="dropdown-input"]')
.select('ARUGULA');

//select area
cy.get('[data-cy="direct-seedings"]')
.click();
//Choose type of area
cy.get('[data-cy="direct-area-selection"] > [data-cy="dropdown-input"]')
.select('CHUAU-1')
//Input num/rows
cy.get('[data-cy="num-rowbed-input"] > [data-cy="text-input"]')
.type(5);
//input feet area
cy.get('[data-cy="num-feet-input"] > [data-cy="text-input"]')
.type(124);

//Input workers
cy.get('[data-cy="num-worker-input"] > [data-cy="text-input"]')
.type(20);
//Input minutes
cy.get('[data-cy="minute-input"] > [data-cy="text-input"]')
.type(35);

cy.get('[data-cy="comments"]').type("Testing");
cy.get('[data-cy="submit-button"]').click();
});

it('Testing comfirm', () => {
cy.get('[data-cy="confirm-button"]').should('be.visible');
});

it('Cancel comfirm', () => {
cy.get('[data-cy="cancel-button"]').should('be.visible');
});

context("Direct seeding is being created", () => {
beforeEach(() => {
cy.get('[data-cy="confirm-button"]').click();
})

it('Testing the log has been submitted', () => {
cy.request('GET','http://fd2_farmdata2/log.json?type=farm_seeding&timestamp[ge]=1713931200&timestamp[le]=1713931200').then((response) => {
expect(response.body.list[0].movement.data.name).to.equal("{\"crop_tid\":\"102\"}"); //get the Crop
expect(response.body.list[0].movement.area[0].name).to.eq("CHUAU-1"); //area name
expect(response.body.list[0].quantity[0].value).to.eq('124'); //row feed
expect(response.data.list[0].quantity[1].value).to.equal("5"); //rows/bed check
expect(response.data.list[0].quantity[2].value).to.equal("20"); // workers
expect(response.data.list[0].quantity[3].value).to.equal("0.58"); // hours
expect(response.data.list[0].timestamp).to.equal("1713931200"); // teimstanp
expect(response.data.list[0].notes.value).to.equal("Testing"); // comments
expect(response.data.list[0].name).to.equal("2021-04-10 ARUGULA CHUAU-1"); //name of the transaction
});
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/**The file is to ensure that the "Submit" button is enabled and disabled as appropriate.*/

describe("Seeding Input: Test Submit", () => {
beforeEach(() => {
cy.login("manager1","farmdata2");
cy.visit("/farm/fd2-field-kit/seedingInput");
cy.waitForPage();
});

//testing
//submit button enabled
it("Submit should be disabled", () => {
cy.get("[data-cy='submit-button']").should('be.disabled');
});

//enabled by tray seedings
context("Button enabled only when all required field have valid values (Tray)", () => {
beforeEach(() => {
//selectDate
cy.get('[data-cy="date-selection"] > [data-cy="date-select"]').click()
.type('2021-04-10');
//select crop
cy.get('[data-cy="crop-selection"] > [data-cy="dropdown-input"]')
.select('ARUGULA');
//select tray seeding
cy.get('[data-cy="tray-seedings"]')
.click();
//Choose crop area
cy.get('[data-cy="tray-area-selection"] > [data-cy="dropdown-input"]')
.select('CHUAU');
//Input Cells/Tray
cy.get('[data-cy="num-cell-input"] > [data-cy="text-input"]')
.type(5);
//Input Trays
cy.get('[data-cy="num-tray-input"] > [data-cy="text-input"]')
.type(10);
//Input Seeds
cy.get('[data-cy="num-seed-input"] > [data-cy="text-input"]')
.type(15);
//Input workers
cy.get('[data-cy="num-worker-input"] > [data-cy="text-input"]')
.type(20);
//Input minutes
cy.get('[data-cy="minute-input"] > [data-cy="text-input"]')
.type(35);

cy.get('[data-cy="comments"]').type("Testing");
});

it('Test submit button is enabled', () => {
cy.get('[data-cy="submit-button"]').should('be.enabled');
});
});

//enabled by direct seedings
context("Button enabled only when all required field have valid values (Direct)", () => {
beforeEach(() => {
//reload page
cy.reload();
//selectDate
cy.get('[data-cy="date-selection"] > [data-cy="date-select"]').click()
.type('2021-04-10');
//select crop
cy.get('[data-cy="crop-selection"] > [data-cy="dropdown-input"]')
.select('ARUGULA');

//select area
cy.get('[data-cy="direct-seedings"]')
.click();
//Choose type of area
cy.get('[data-cy="direct-area-selection"] > [data-cy="dropdown-input"]')
.select('CHUAU-1')
//Input num/rows
cy.get('[data-cy="num-rowbed-input"] > [data-cy="text-input"]')
.type(5);
//input feet area
cy.get('[data-cy="num-feet-input"] > [data-cy="text-input"]')
.type(124);

//Input workers
cy.get('[data-cy="num-worker-input"] > [data-cy="text-input"]')
.type(20);
//Input minutes
cy.get('[data-cy="minute-input"] > [data-cy="text-input"]')
.type(35);

cy.get('[data-cy="comments"]').type("Testing");
});

it('Test submit button is enabled', () => {
cy.get('[data-cy="submit-button"]').should('be.enabled');
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/**
* This file tests the default contents of the
* "Seeding Type" (Tray/Direct) section of the Seeding
* Input Form in the FieldKit.
*/

describe("Test Seeding Input Default Type", () => {
beforeEach(() => {
cy.login("manager1","farmdata2");
cy.visit("/farm/fd2-field-kit/seedingInput");

});

/** Check elements for "Tray" is enabled.
* binding with submitInProgress Value
*/
it("1) Tray seeding is enabled", () => {
cy.get("[data-cy='tray-seedings']").should('be.enabled')
})
/** Check elements for "Direct" is enabled.
* binding with submitInProgress Value
*/
it("2) Direct seeding is enabled", () => {
cy.get("[data-cy='direct-seedings']").should('be.enabled')
})

/** Check neither Tray nor Direct is selected */
it("3) Tray and Direct elements not selected", () => {
cy.get("[data-cy='tray-seedings']").should('not.be.checked')
cy.get("[data-cy='direct-seedings']").should('not.be.checked')
})

/** Check neither Tray nor Direct is selected */
it("4) message visible when tray and direct not selected", () => {
cy.get("[data-cy='tray-seedings']").should('not.be.checked')
cy.get("[data-cy='direct-seedings']").should('not.be.checked')
cy.contains("Please Select Tray Seeding or Direct Seeding")
})

/** Check the form elements for either the "Tray" and
"Direct" seedings are not visible or do not exist. */

it("5) Check form elements of Tray is not visible or not exist", () => {
cy.get("[data-cy=tray-area-selection]").should("not.be.visible")
cy.get("[data-cy=num-cell-input]").should("not.be.visible")
cy.get("[data-cy=num-tray-input]").should("not.be.visible")
cy.get("[data-cy=num-seed-input]").should("not.be.visible")
})
it("5) Check form elements of Direct is not visible or not exist", () => {
cy.get("[data-cy=direct-area-selection]").should("not.be.visible")
cy.get("[data-cy=num-rowbed-input]").should("not.be.visible")
cy.get("[data-cy=unit-feet]").should("not.be.visible")
cy.get("[data-cy=num-feet-input]").should("not.be.visible")
})

});