2020-07-15 01:29:15 +02:00
|
|
|
var common = require("../casper_lib/common.js");
|
2013-10-31 19:12:35 +01:00
|
|
|
|
|
|
|
// Test basic tab navigation.
|
|
|
|
|
|
|
|
common.start_and_log_in();
|
|
|
|
|
|
|
|
casper.then(function () {
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.test.info("Testing navigation");
|
2013-10-31 19:12:35 +01:00
|
|
|
});
|
|
|
|
|
2016-10-07 19:08:17 +02:00
|
|
|
function wait_for_tab(tab) {
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.waitForSelector("#" + tab + ".tab-pane.active", function () {
|
|
|
|
casper.test.assertExists("#" + tab + ".tab-pane.active", tab + " page is active");
|
2016-10-07 19:08:17 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2013-10-31 19:12:35 +01:00
|
|
|
function then_navigate_to(click_target, tab) {
|
|
|
|
casper.then(function () {
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.test.info("Visiting #" + click_target);
|
2016-12-03 01:12:52 +01:00
|
|
|
casper.click("a[href='#" + click_target + "']");
|
2016-10-07 19:08:17 +02:00
|
|
|
wait_for_tab(tab);
|
2013-10-31 19:12:35 +01:00
|
|
|
});
|
2016-10-07 19:08:17 +02:00
|
|
|
}
|
2013-10-31 19:12:35 +01:00
|
|
|
|
2016-10-07 19:08:17 +02:00
|
|
|
function then_navigate_to_settings() {
|
|
|
|
casper.then(function () {
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.test.info("Navigate to settings");
|
|
|
|
var menu_selector = "#settings-dropdown";
|
2016-10-07 19:08:17 +02:00
|
|
|
casper.waitUntilVisible(menu_selector, function () {
|
|
|
|
casper.click(menu_selector);
|
|
|
|
casper.waitUntilVisible('a[href^="#settings"]', function () {
|
|
|
|
casper.click('a[href^="#settings"]');
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.waitUntilVisible("#settings_page", function () {
|
|
|
|
casper.test.assertExists("#settings_page", "Settings page is active");
|
|
|
|
casper.click("#settings_page .exit");
|
2016-12-03 01:12:52 +01:00
|
|
|
});
|
2016-10-07 19:08:17 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function then_navigate_to_subscriptions() {
|
|
|
|
casper.then(function () {
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.test.info("Navigate to subscriptions");
|
2016-10-07 19:08:17 +02:00
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
var menu_selector = "#settings-dropdown";
|
2016-10-07 19:08:17 +02:00
|
|
|
casper.waitUntilVisible(menu_selector, function () {
|
|
|
|
casper.click(menu_selector);
|
2017-03-09 00:20:22 +01:00
|
|
|
casper.click('a[href^="#streams"]');
|
2017-02-10 07:55:26 +01:00
|
|
|
casper.waitUntilVisible("#subscription_overlay", function () {
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.test.assertExists("#subscriptions_table", "#subscriptions page is active");
|
|
|
|
casper.click("#subscription_overlay .exit");
|
2016-10-07 19:08:17 +02:00
|
|
|
});
|
|
|
|
});
|
2013-10-31 19:12:35 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Take a navigation tour of the app.
|
|
|
|
// Entries are (click target, tab that should be active after clicking).
|
2016-10-07 19:08:17 +02:00
|
|
|
then_navigate_to_settings();
|
2018-02-15 21:02:47 +01:00
|
|
|
|
|
|
|
var verona_narrow;
|
|
|
|
casper.then(function () {
|
|
|
|
var verona_id = casper.evaluate(function () {
|
2020-07-15 01:29:15 +02:00
|
|
|
return stream_data.get_stream_id("Verona");
|
2018-02-15 21:02:47 +01:00
|
|
|
});
|
2020-07-15 01:29:15 +02:00
|
|
|
verona_narrow = "narrow/stream/" + verona_id + "-Verona";
|
2018-02-15 21:02:47 +01:00
|
|
|
casper.test.info(verona_narrow);
|
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
then_navigate_to(verona_narrow, "home");
|
|
|
|
then_navigate_to("home", "home");
|
2018-02-15 21:02:47 +01:00
|
|
|
then_navigate_to_subscriptions();
|
2020-07-15 01:29:15 +02:00
|
|
|
then_navigate_to("", "home");
|
2018-02-15 21:02:47 +01:00
|
|
|
then_navigate_to_settings();
|
2020-07-15 01:29:15 +02:00
|
|
|
then_navigate_to("narrow/is/private", "home");
|
2018-02-15 21:02:47 +01:00
|
|
|
then_navigate_to_subscriptions();
|
2020-07-15 01:29:15 +02:00
|
|
|
then_navigate_to(verona_narrow, "home");
|
2018-02-15 21:02:47 +01:00
|
|
|
});
|
2017-03-23 07:05:36 +01:00
|
|
|
|
|
|
|
var initial_page_load_time;
|
|
|
|
var hash;
|
|
|
|
var orig_hash;
|
|
|
|
|
|
|
|
// Verify reload.js's server-initiated browser reload hash
|
|
|
|
// save/restore logic works.
|
|
|
|
casper.then(function () {
|
|
|
|
initial_page_load_time = casper.evaluate(function () {
|
|
|
|
return page_params.page_load_time;
|
|
|
|
});
|
|
|
|
casper.test.info(initial_page_load_time);
|
|
|
|
orig_hash = casper.evaluate(function () {
|
|
|
|
return window.location.hash;
|
|
|
|
});
|
|
|
|
casper.evaluate(function () {
|
|
|
|
reload.initiate({immediate: true});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
casper.then(function () {
|
|
|
|
// Confirm that's we've actually reloaded using the page load timestamp.
|
2020-07-15 00:34:28 +02:00
|
|
|
casper.waitFor(
|
|
|
|
function () {
|
|
|
|
return casper.evaluate(function (input) {
|
|
|
|
return page_params.page_load_time > input;
|
|
|
|
}, initial_page_load_time);
|
|
|
|
},
|
|
|
|
function () {
|
|
|
|
// Verify the hash was preserved
|
|
|
|
hash = casper.evaluate(function () {
|
|
|
|
return window.location.hash;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
);
|
2017-03-23 21:56:59 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
casper.then(function () {
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.waitUntilVisible("#zfilt", function () {
|
2017-03-23 07:05:36 +01:00
|
|
|
// Verify that we're narrowed to the target stream
|
|
|
|
casper.test.assertEquals(orig_hash, hash);
|
|
|
|
casper.test.assertVisible("#zfilt");
|
|
|
|
casper.test.assertNotVisible("#zhome");
|
|
|
|
});
|
|
|
|
});
|
2013-10-31 19:12:35 +01:00
|
|
|
|
|
|
|
common.then_log_out();
|
|
|
|
|
|
|
|
// Run the above queued actions.
|
|
|
|
casper.run(function () {
|
|
|
|
casper.test.done();
|
|
|
|
});
|