diff options
| author | Joseph Caburnay <jcb@odoo.com> | 2020-06-22 09:44:36 +0000 |
|---|---|---|
| committer | Joseph Caburnay <jcb@odoo.com> | 2020-08-19 07:34:04 +0000 |
| commit | 96e27f09006046aae75655386eddbca9feba31b5 (patch) | |
| tree | de74d01572485c54b6f3de016ea0486729ddebcf /addons/pos_restaurant/static | |
| parent | 18651864dd3bf27fd1c910888f5dbbed4046d42b (diff) | |
[FIX] point_of_sale,pos_*: indeterministic tour tests failures
closes odoo/odoo#56062
Related: odoo/enterprise#12487
Signed-off-by: pimodoo <pimodoo@users.noreply.github.com>
Diffstat (limited to 'addons/pos_restaurant/static')
4 files changed, 38 insertions, 19 deletions
diff --git a/addons/pos_restaurant/static/src/js/Screens/FloorScreen/FloorScreen.js b/addons/pos_restaurant/static/src/js/Screens/FloorScreen/FloorScreen.js index 587fe6e2d7c..87b599c9428 100644 --- a/addons/pos_restaurant/static/src/js/Screens/FloorScreen/FloorScreen.js +++ b/addons/pos_restaurant/static/src/js/Screens/FloorScreen/FloorScreen.js @@ -153,15 +153,24 @@ odoo.define('pos_restaurant.FloorScreen', function (require) { }); if (!confirmed) return; try { + const originalSelectedTableId = this.state.selectedTableId; await this.rpc({ model: 'restaurant.table', method: 'create_from_ui', - args: [{ active: false, id: this.state.selectedTableId }], + args: [{ active: false, id: originalSelectedTableId }], }); this.activeFloor.tables = this.activeTables.filter( - (table) => table.id !== this.state.selectedTableId + (table) => table.id !== originalSelectedTableId ); - this.state.selectedTableId = null; + // Value of an object can change inside async function call. + // Which means that in this code block, the value of `state.selectedTableId` + // before the await call can be different after the finishing the await call. + // Since we wanted to disable the selected table after deletion, we should be + // setting the selectedTableId to null. However, we only do this if nothing + // else is selected during the rpc call. + if (this.state.selectedTableId === originalSelectedTableId) { + this.state.selectedTableId = null; + } } catch (error) { if (error.message.code < 0) { await this.showPopup('OfflineErrorPopup', { diff --git a/addons/pos_restaurant/static/tests/tours/ControlButtons.tour.js b/addons/pos_restaurant/static/tests/tours/ControlButtons.tour.js index 102ff280977..f26d4f79b29 100644 --- a/addons/pos_restaurant/static/tests/tours/ControlButtons.tour.js +++ b/addons/pos_restaurant/static/tests/tours/ControlButtons.tour.js @@ -16,16 +16,16 @@ odoo.define('pos_restaurant.tour.ControlButtons', function (require) { // Test TransferOrderButton FloorScreen.do.clickTable('T2'); - ProductScreen.exec.addOrderline('Water', '5.0', '2.0'); + ProductScreen.exec.addOrderline('Water', '5', '2', '10.0'); ProductScreen.do.clickTransferButton(); FloorScreen.do.clickTable('T4'); - ProductScreen.do.clickOrderline('Water', '5.0', '2.0'); + ProductScreen.do.clickOrderline('Water', '5', '2'); Chrome.do.backToFloor(); FloorScreen.do.clickTable('T2'); ProductScreen.check.orderIsEmpty(); Chrome.do.backToFloor(); FloorScreen.do.clickTable('T4'); - ProductScreen.do.clickOrderline('Water', '5.0', '2.0'); + ProductScreen.do.clickOrderline('Water', '5', '2'); // Test SplitBillButton ProductScreen.do.clickSplitBillButton(); @@ -36,9 +36,8 @@ odoo.define('pos_restaurant.tour.ControlButtons', function (require) { TextAreaPopup.check.isShown(); TextAreaPopup.do.inputText('test note'); TextAreaPopup.do.clickConfirm(); - ProductScreen.check.orderlineHasNote('Water', '5.0', 'test note'); - ProductScreen.exec.addOrderline('Water', '8', '1.1'); - ProductScreen.check.selectedOrderlineHas('Water', '8', '8.80'); + ProductScreen.check.orderlineHasNote('Water', '5', 'test note'); + ProductScreen.exec.addOrderline('Water', '8', '1', '8.0'); // Test PrintBillButton ProductScreen.do.clickPrintBillButton(); diff --git a/addons/pos_restaurant/static/tests/tours/FloorScreen.tour.js b/addons/pos_restaurant/static/tests/tours/FloorScreen.tour.js index 4ece19fec4b..93a7a2c8ea6 100644 --- a/addons/pos_restaurant/static/tests/tours/FloorScreen.tour.js +++ b/addons/pos_restaurant/static/tests/tours/FloorScreen.tour.js @@ -35,6 +35,7 @@ odoo.define('pos_restaurant.tour.FloorScreen', function (require) { FloorScreen.do.clickFloor('Main Floor'); FloorScreen.check.editModeIsActive(false); FloorScreen.do.clickEdit(); + FloorScreen.check.editModeIsActive(true); // test add table FloorScreen.do.clickAddTable(); @@ -47,13 +48,18 @@ odoo.define('pos_restaurant.tour.FloorScreen', function (require) { // test duplicate table FloorScreen.do.clickDuplicate(); - FloorScreen.do.clickRename(); - TextInputPopup.do.inputText('T101'); + // new table is already named T101 FloorScreen.check.selectedTableIs('T101'); + FloorScreen.do.clickRename(); + TextInputPopup.check.isShown(); + TextInputPopup.do.inputText('T1111'); + TextInputPopup.do.clickConfirm(); + FloorScreen.check.selectedTableIs('T1111'); // switch floor, switch back and check if // the new tables are still there FloorScreen.do.clickFloor('Second Floor'); + FloorScreen.check.editModeIsActive(false); FloorScreen.check.hasTable('T3'); FloorScreen.check.hasTable('T1'); @@ -62,26 +68,31 @@ odoo.define('pos_restaurant.tour.FloorScreen', function (require) { FloorScreen.check.hasTable('T4'); FloorScreen.check.hasTable('T5'); FloorScreen.check.hasTable('T100'); - FloorScreen.check.hasTable('T101'); + FloorScreen.check.hasTable('T1111'); // test delete table FloorScreen.do.clickEdit(); + FloorScreen.check.editModeIsActive(true); FloorScreen.do.clickTable('T2'); + FloorScreen.check.selectedTableIs('T2'); FloorScreen.do.clickTrash(); Chrome.do.confirmPopup(); // change number of seats FloorScreen.do.clickTable('T4'); + FloorScreen.check.selectedTableIs('T4'); FloorScreen.do.clickSeats(); - NumberPopup.do.pressNumpad('Backspace 1 0'); + NumberPopup.do.pressNumpad('Backspace 9'); + NumberPopup.check.inputShownIs('9'); NumberPopup.do.clickConfirm(); - FloorScreen.check.tableSeatIs('T4', '10'); + FloorScreen.check.tableSeatIs('T4', '9'); // change shape FloorScreen.do.changeShapeTo('round'); // Opening product screen in main floor should go back to main floor FloorScreen.do.clickEdit(); + FloorScreen.check.editModeIsActive(false); FloorScreen.check.hasTable('T4'); FloorScreen.do.clickTable('T4'); ProductScreen.check.isShown(); diff --git a/addons/pos_restaurant/static/tests/tours/SplitBillScreen.tour.js b/addons/pos_restaurant/static/tests/tours/SplitBillScreen.tour.js index 9eb138bbb9b..cf09ebf0a4b 100644 --- a/addons/pos_restaurant/static/tests/tours/SplitBillScreen.tour.js +++ b/addons/pos_restaurant/static/tests/tours/SplitBillScreen.tour.js @@ -15,9 +15,9 @@ odoo.define('pos_restaurant.tour.SplitBillScreen', function (require) { startSteps(); FloorScreen.do.clickTable('T2'); - ProductScreen.exec.addOrderline('Water', '5', '1.2'); - ProductScreen.exec.addOrderline('Minute Maid', '3', '1.2'); - ProductScreen.exec.addOrderline('Coca-Cola', '1', '1.2'); + ProductScreen.exec.addOrderline('Water', '5', '2', '10.0'); + ProductScreen.exec.addOrderline('Minute Maid', '3', '2', '6.0'); + ProductScreen.exec.addOrderline('Coca-Cola', '1', '2', '2.0'); ProductScreen.do.clickSplitBillButton(); // Check if the screen contains all the orderlines @@ -31,10 +31,10 @@ odoo.define('pos_restaurant.tour.SplitBillScreen', function (require) { SplitBillScreen.do.clickOrderline('Water'); SplitBillScreen.do.clickOrderline('Water'); SplitBillScreen.check.orderlineHas('Water', '5', '3'); - SplitBillScreen.check.subtotalIs('3.60') + SplitBillScreen.check.subtotalIs('6.0') SplitBillScreen.do.clickOrderline('Coca-Cola'); SplitBillScreen.check.orderlineHas('Coca-Cola', '1', '1'); - SplitBillScreen.check.subtotalIs('4.80') + SplitBillScreen.check.subtotalIs('8.0') // click pay to split, go back to check the lines SplitBillScreen.do.clickPay(); |
