Skip to content
Snippets Groups Projects
Commit a5cffebd authored by Tom Robinson's avatar Tom Robinson
Browse files

Misc e2e fixes [ci e2e]

parent 3a8cb268
No related branches found
No related tags found
No related merge requests found
......@@ -25,14 +25,14 @@ describeE2E("auth/login", () => {
await driver.manage().deleteAllCookies();
});
it ("should take you to the login page", async () => {
it("should take you to the login page", async () => {
await driver.get(`${server.host}/`);
await waitForUrl(driver, `${server.host}/auth/login?redirect=%2F`);
expect(await driver.isElementPresent(By.css("[name=email]"))).toEqual(true);
await screenshot(driver, "screenshots/auth-login.png");
});
it ("should log you in", async () => {
it("should log you in", async () => {
await driver.get(`${server.host}/`);
await loginMetabase(driver, "bob@metabase.com", "12341234");
await waitForUrl(driver, `${server.host}/`);
......@@ -40,7 +40,7 @@ describeE2E("auth/login", () => {
sessionId = sessionCookie.value;
});
it ("should redirect you after logging in", async () => {
it("should redirect you after logging in", async () => {
await driver.get(`${server.host}/questions`);
await waitForUrl(driver, `${server.host}/auth/login?redirect=%2Fquestions`);
await loginMetabase(driver, "bob@metabase.com", "12341234");
......@@ -55,13 +55,13 @@ describeE2E("auth/login", () => {
await driver.manage().addCookie("metabase.SESSION_ID", sessionId);
});
it ("is logged in", async () => {
it("is logged in", async () => {
await driver.get(`${server.host}/`);
await waitForUrl(driver, `${server.host}/`);
await screenshot(driver, "screenshots/loggedin.png");
});
it ("loads the qb", async () => {
it("loads the qb", async () => {
await driver.get(`${server.host}/q#eyJuYW1lIjpudWxsLCJkYXRhc2V0X3F1ZXJ5Ijp7ImRhdGFiYXNlIjoxLCJ0eXBlIjoibmF0aXZlIiwibmF0aXZlIjp7InF1ZXJ5Ijoic2VsZWN0ICdvaCBoYWkgZ3Vpc2Ug8J-QsScifSwicGFyYW1ldGVycyI6W119LCJkaXNwbGF5Ijoic2NhbGFyIiwidmlzdWFsaXphdGlvbl9zZXR0aW5ncyI6e319`);
await waitForUrl(driver, `${server.host}/q#eyJuYW1lIjpudWxsLCJkYXRhc2V0X3F1ZXJ5Ijp7ImRhdGFiYXNlIjoxLCJ0eXBlIjoibmF0aXZlIiwibmF0aXZlIjp7InF1ZXJ5Ijoic2VsZWN0ICdvaCBoYWkgZ3Vpc2Ug8J-QsScifSwicGFyYW1ldGVycyI6W119LCJkaXNwbGF5Ijoic2NhbGFyIiwidmlzdWFsaXphdGlvbl9zZXR0aW5ncyI6e319`);
await screenshot(driver, "screenshots/qb.png");
......
......@@ -72,7 +72,7 @@ export const waitForElementAndClick = async (driver, selector, timeout = DEFAULT
};
export const waitForElementAndSendKeys = async (driver, selector, keys, timeout = DEFAULT_TIMEOUT) => {
log(`waiting for element to send ${keys}: ${selector}`);
log(`waiting for element to send "${keys}": ${selector}`);
const element = await waitForElement(driver, selector, timeout);
await element.clear();
return await element.sendKeys(keys);
......@@ -151,6 +151,7 @@ export const ensureLoggedIn = async (server, driver, email, password) => {
console.log("logging in");
await driver.get(`${server.host}/`);
await driver.manage().deleteAllCookies();
await driver.get(`${server.host}/`);
await loginMetabase(driver, email, password);
await waitForUrl(driver, `${server.host}/`);
}
......@@ -226,13 +227,32 @@ function jasmineMultipleSetupTeardown(fn) {
const handlers = { beforeAll: [], beforeEach: [], afterEach: [], afterAll: [] }
const originals = {};
let originalDescribe = global.describe;
let innerDescribe = false;
global.describe = (...args) => {
innerDescribe = true;
try {
return originalDescribe.apply(this, args);
} finally {
innerDescribe = false;
}
}
Object.keys(handlers).map((name) => {
originals[name] = global[name];
global[name] = (fn) => handlers[name].push(fn);
global[name] = (fn) => {
if (innerDescribe) {
return originals[name](fn);
} else {
return handlers[name].push(fn);
}
};
});
fn.apply(this, args);
global.describe = originalDescribe;
// restore and register actual handler
Object.keys(handlers).map((name) => {
global[name] = originals[name];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment