mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	We now specifically wait for the length to decrease by one. This seems like a more deterministic condition to wait on. Previously we were waiting till the id of the deleted message remained visible; intuitively, this should have worked but it seems that there is some race condition that was causing the test to fail sporadically.
		
			
				
	
	
		
			46 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			46 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
var common = require('../casper_lib/common.js').common;
 | 
						|
 | 
						|
common.start_and_log_in();
 | 
						|
 | 
						|
var last_message_id;
 | 
						|
var msgs_qty;
 | 
						|
 | 
						|
 | 
						|
casper.then(function () {
 | 
						|
    casper.waitUntilVisible("#zhome");
 | 
						|
});
 | 
						|
 | 
						|
casper.then(function () {
 | 
						|
    msgs_qty = this.evaluate(function () {
 | 
						|
        return $('#zhome .message_row').length;
 | 
						|
    });
 | 
						|
    last_message_id = this.evaluate(function () {
 | 
						|
        var msg = $('#zhome .message_row:last');
 | 
						|
        msg.find('.info').click();
 | 
						|
        $('.delete_message').click();
 | 
						|
        return msg.attr('id');
 | 
						|
    });
 | 
						|
});
 | 
						|
 | 
						|
casper.then(function () {
 | 
						|
    casper.waitUntilVisible("#delete_message_modal", function () {
 | 
						|
        casper.click('#do_delete_message_button');
 | 
						|
    });
 | 
						|
});
 | 
						|
 | 
						|
casper.then(function () {
 | 
						|
    casper.waitFor(function check_length() {
 | 
						|
        return casper.evaluate(function (expected_length) {
 | 
						|
            return $('#zhome .message_row').length === expected_length;
 | 
						|
        }, msgs_qty - 1);
 | 
						|
    });
 | 
						|
});
 | 
						|
 | 
						|
casper.then(function () {
 | 
						|
    casper.test.assertDoesntExist(last_message_id);
 | 
						|
});
 | 
						|
 | 
						|
casper.run(function () {
 | 
						|
    casper.test.done();
 | 
						|
});
 |