scouting: Convert actions to stats when submitted
Now that actions are submitted, we need to convert them into stats.
This patch does that by calling the correct conversion function and
then inserting the result into the database.
I had to adjust the scouting_test slightly because the behaviour
changed slightly. The test doesn't clear the database between test
cases. So the one test case submitting scout data means it can't be
scouted again. The button is now disabled.
Signed-off-by: Philipp Schrader <philipp.schrader@gmail.com>
Change-Id: Ib3e68103c8064c61e628711c9fe375919372e18c
diff --git a/scouting/scouting_test.cy.js b/scouting/scouting_test.cy.js
index 1d7620a..365b19e 100644
--- a/scouting/scouting_test.cy.js
+++ b/scouting/scouting_test.cy.js
@@ -1,5 +1,13 @@
/// <reference types="cypress" />
+// On the 87th row of matches (index 86) click on the second team
+// (index 1) which resolves to team 5254 in semi final 2 match 3.
+const SEMI_FINAL_2_MATCH_3_TEAM_5254 = 86 * 6 + 1;
+
+// On the 1st row of matches (index 0) click on the fourth team
+// (index 3) which resolves to team 3990 in quals match 1.
+const QUALS_MATCH_1_TEAM_3990 = 0 * 6 + 3;
+
function disableAlerts() {
cy.get('#block_alerts').check({force: true}).should('be.checked');
}
@@ -20,17 +28,6 @@
cy.get(fieldSelector).type('{selectAll}' + value);
}
-// Click on a random team in the Match list. The exact details here are not
-// important, but we need to know what they are. This could as well be any
-// other team from any other match.
-function clickSemiFinal2Match3Team5254() {
- // On the 87th row of matches (index 86) click on the second team
- // (index 1) which resolves to team 5254 in semi final 2 match 3.
- cy.get('button.match-item')
- .eq(86 * 6 + 1)
- .click();
-}
-
// Moves the nth slider left or right. A positive "adjustBy" value moves the
// slider to the right. A negative value moves the slider to the left.
//
@@ -115,7 +112,10 @@
//TODO(FILIP): Verify last action when the last action header gets added.
it('should: be able to submit data scouting.', () => {
- clickSemiFinal2Match3Team5254();
+ // Click on a random team in the Match list. The exact details here are not
+ // important, but we need to know what they are. This could as well be any
+ // other team from any other match.
+ cy.get('button.match-item').eq(SEMI_FINAL_2_MATCH_3_TEAM_5254).click();
// Select Starting Position.
headerShouldBe('5254 Init ');
@@ -135,7 +135,7 @@
clickButton('DEAD');
clickButton('Revive');
- // Engame.
+ // Endgame.
clickButton('Endgame');
cy.get('[type="checkbox"]').check();
@@ -144,10 +144,16 @@
clickButton('Submit');
headerShouldBe('5254 Success ');
+
+ // Now that the data is submitted, the button should be disabled.
+ switchToTab('Match List');
+ cy.get('button.match-item')
+ .eq(SEMI_FINAL_2_MATCH_3_TEAM_5254)
+ .should('be.disabled');
});
it('should: be able to return to correct screen with undo for pick and place.', () => {
- clickSemiFinal2Match3Team5254();
+ cy.get('button.match-item').eq(QUALS_MATCH_1_TEAM_3990).click();
// Select Starting Position.
cy.get('[type="radio"]').first().check();
@@ -160,13 +166,13 @@
clickButton('UNDO');
// User should be back on pickup screen.
- headerShouldBe('5254 Pickup ');
+ headerShouldBe('3990 Pickup ');
// Check the same thing but for undoing place.
clickButton('CUBE');
clickButton('MID');
clickButton('UNDO');
- headerShouldBe('5254 Place ');
+ headerShouldBe('3990 Place ');
});
it('should: submit note scouting for multiple teams', () => {