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

#29 - FieldKit Tab: Test for FieldKit Sub-Tabs #192

Open
wants to merge 17 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
Expand Up @@ -37,6 +37,5 @@ describe('Check the JS vars defined by the BarnKit module', () => {
cy.window().its('fd2UserID').should('equal',5);
cy.window().its('fd2UserName').should('equal','worker1');
})

// Currently guest users cannot see any FD2 tabs so no check for them.
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
describe("Testing for Area Filter", () => {
beforeEach(() => {
cy.login("manager1", "farmdata2")
cy.visit("/farm/fd2-barn-kit/seedingReport")
})

it("Check when if when All is selected table will contain seeding logs for multiple different areas", () => {

cy.get('[data-cy=start-date-select] > [data-cy=date-select]').type('2020-05-05').blur()
cy.get('[data-cy=end-date-select] > [data-cy=date-select]').type('2020-05-15').blur()

cy.get('[data-cy=generate-rpt-btn]').click()

cy.get('[data-cy=area-dropdown] > [data-cy=dropdown-input]').should('have.value', 'All')

cy.get('[data-cy=td-r0c2]').contains('K')
cy.get('[data-cy=td-r6c2]').contains('J')
cy.get('[data-cy=td-r10c2]').contains('ALF-1')
cy.get('[data-cy=td-r11c2]').contains('SEEDING BENCH')
cy.get('[data-cy=td-r66c2]').contains('ALF-3')
})

//Test #2
it("Check when specific area is selected that table only contains seeding logs for that area", () => {
cy.get('[data-cy=start-date-select] > [data-cy=date-select]').type('2020-01-01').blur()
cy.get('[data-cy=end-date-select] > [data-cy=date-select]').type('2020-05-01').blur()
cy.get('[data-cy=generate-rpt-btn]').click()
//we are selecting area M for testing
cy.get('[data-cy=area-dropdown] > [data-cy=dropdown-input] > [data-cy=option1]')

//Checking if each row displays the correct area
cy.get("[data-cy=td-r0c2]").contains("M")

})
//Test #3
it("Check that area filter only contains areas where there are seeding logs", () => {
cy.get('[data-cy=start-date-select] > [data-cy=date-select]').type('2020-05-05').blur();
cy.get('[data-cy=end-date-select] > [data-cy=date-select]').type('2020-05-15').blur();

cy.get('[data-cy=generate-rpt-btn]').click();

cy.get('[data-cy=area-dropdown] > [data-cy=dropdown-input]')
.children()
.should('have.length.gte', 1)
.then(($children) => {
// Asserting that at least one child element exists
expect($children).to.have.length.gte(1);

// Checking if the child elements contain specific values
cy.wrap($children.eq(0)).should('have.value', 'All');
});
});


})
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,54 @@ describe('Testing for the transplanting report page', () => {
cy.waitForPage()
})

//Test #1
it('Contains header "Transplanting Report"', () => {
cy.contains("Transplanting Report").should("be.visible");
})

//Test #2
it('Contains section called "Set Dates"', () => {
cy.get('legend:contains("Set Dates")').should("be.visible");
})

//Test 3
it('Check if button is enabled and has label "Generate Report"', () => {
cy.get('[data-cy=generate-rpt-btn]')
.should('have.text', 'Generate Report')
.should('be.enabled')
})
// Test 4 fixed
it("Checks if default start date is the first day of current year ", () => {
cy.get('[data-cy=date-select]')
.each(($el, index, $all) => {
if (index == 0) {
expect($el).to.have.value('2023-01-01')
}
})
})
//Test 5
it("Checks if default end date is the current date", () => {
let currentDate = dayjs().format("YYYY-MM-DD")
cy.get("[data-cy=end-date-select]")
.each(($el, index, $all) => {
if (index == 1) {
expect($el).to.have.value(currentDate)
}
})
})

//Test 6
it("Checks if the remainder of the report is not visible or does not exist", () => {
cy.get("[data-cy=filters-panel]").should("not.exist")
cy.get("[data-cy=report-table").should("not.exist")
cy.get("[data-cy=direct-summary").should("not.exist")
cy.get("[data-cy=tray-summary").should("not.exist")
})


context('can set dates and then render the report', () => {


it('allows user input of the start and end dates', () => {
cy.get('[data-cy=date-range-selection]')
.should('exist')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
describe("Testing for Field-kit Sub-tabs", () => {
beforeEach(() => {
cy.login("manager1", "farmdata2")
cy.visit("/farm/fd2-field-kit")
})

//Test 1
it("Check that the FieldKit tab contains sub-tabs for “Info” and “Seeding Input", () => {
cy.get('.tabs--secondary').should("have.contain","Info")
cy.get('.tabs--secondary').should("have.contain","Seeding Input")
})

//Test 2
it("Check that the order of the tabs is “Info” and then “Seeding Input", () => {
cy.get('.tabs--secondary > :nth-child(1) > a').should("have.contain","Info")
cy.get('.tabs--secondary > :nth-child(2) > a').should("have.contain","Seeding Input")

})

//Test 3
it("Check that there are the correct number of sub-tabs (2 at this time)", () => {
cy.get('.tabs--secondary').children().should("have.length",2)
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,12 @@ <h1 style='text-align:center;'>Seeding Input Log</h1>
if (this.submitInProgress == true){
return true
}
if (this.selectedDate === null || this.selectedDate === dayjs().format('YYYY-MM-DD').toString()) {
return true;
}
if (!dayjs(this.selectedDate, 'YYYY-MM-DD', true).isValid()) {
return true;
}
if(this.selectedCrop == null){
return true
}
Expand Down