mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 10:20:58 -06:00
FIX: flaky flags specs when moving up or down (#28272)
Those are the steps to move the flag: 1. open menu; 2. click move up - `saving` CSS class is added; 3. request to backend; 4. `saving` CSS class is removed. To check if the action was finished we are using this method: ``` def move_up(key) open_flag_menu(key) find(".admin-flag-item__move-up").click has_saved_flag?(key) self end def has_saved_flag?(key) has_css?(".admin-flag-item.#{key}.saving") has_no_css?(".admin-flag-item.#{key}.saving") end ``` However, sometimes specs were failing with `expected to find CSS ".admin-flag-item.spam.saving" but there were no matches` I think that the problem is with those 2 lines: ``` find(".admin-flag-item__move-up").click has_closed_flag_menu? ``` If the save action is very fast, then the `saving` class is removed before the first check. Therefore, to determine that the move action is finished, I am checking if the menu is closed.
This commit is contained in:
parent
9d00871a67
commit
db4395d70c
@ -74,18 +74,18 @@ export default class AdminFlagItem extends Component {
|
||||
@action
|
||||
moveUp() {
|
||||
this.isSaving = true;
|
||||
this.dMenu.close();
|
||||
this.args.moveFlagCallback(this.args.flag, "up").finally(() => {
|
||||
this.isSaving = false;
|
||||
this.dMenu.close();
|
||||
});
|
||||
}
|
||||
|
||||
@action
|
||||
moveDown() {
|
||||
this.isSaving = true;
|
||||
this.dMenu.close();
|
||||
this.args.moveFlagCallback(this.args.flag, "down").finally(() => {
|
||||
this.isSaving = false;
|
||||
this.dMenu.close();
|
||||
});
|
||||
}
|
||||
@action
|
||||
|
@ -68,17 +68,21 @@ module PageObjects
|
||||
has_no_css?(".admin-flag-item.#{key}.saving")
|
||||
end
|
||||
|
||||
def has_closed_flag_menu?
|
||||
has_no_css?(".flag-menu-content")
|
||||
end
|
||||
|
||||
def move_down(key)
|
||||
open_flag_menu(key)
|
||||
find(".admin-flag-item__move-down").click
|
||||
has_saved_flag?(key)
|
||||
has_closed_flag_menu?
|
||||
self
|
||||
end
|
||||
|
||||
def move_up(key)
|
||||
open_flag_menu(key)
|
||||
find(".admin-flag-item__move-up").click
|
||||
has_saved_flag?(key)
|
||||
has_closed_flag_menu?
|
||||
self
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user