From 93a0db448b0f4ba99c994666ad0f57eafa0d6766 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atte=20Kein=C3=A4nen?= <atte.keinanen@gmail.com> Date: Wed, 9 Aug 2017 09:11:57 -0700 Subject: [PATCH] Convert Admin General Settings test to Jest --- .../admin/settings/settings.integ.spec.js | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 frontend/test/admin/settings/settings.integ.spec.js diff --git a/frontend/test/admin/settings/settings.integ.spec.js b/frontend/test/admin/settings/settings.integ.spec.js new file mode 100644 index 00000000000..b4b86dcb49f --- /dev/null +++ b/frontend/test/admin/settings/settings.integ.spec.js @@ -0,0 +1,54 @@ +// Converted from an old Selenium E2E test +import { + login, + createTestStore, +} from "__support__/integrated_tests"; +import { mount } from "enzyme"; +import SettingInput from "metabase/admin/settings/components/widgets/SettingInput"; +import { INITIALIZE_SETTINGS, UPDATE_SETTING } from "metabase/admin/settings/settings"; +import { LOAD_CURRENT_USER } from "metabase/redux/user"; + +jasmine.DEFAULT_TIMEOUT_INTERVAL = 600000; + +describe("admin/settings", () => { + beforeAll(async () => + await login() + ); + + // TODO Atte Keinänen 6/22/17: Disabled because we already have converted this to Jest&Enzyme in other branch + describe("admin settings", () => { + // pick a random site name to try updating it to + const siteName = "Metabase" + Math.random(); + + it("should save the setting", async () => { + const store = await createTestStore(); + + store.pushPath('/admin/settings/general'); + const app = mount(store.getAppContainer()) + + await store.waitForActions([LOAD_CURRENT_USER, INITIALIZE_SETTINGS]) + + // first just make sure the site name isn't already set (it shouldn't since we're using a random name) + const input = app.find(SettingInput).first().find("input"); + expect(input.prop("value")).not.toBe(siteName) + + // clear the site name input, send the keys corresponding to the site name, then blur to trigger the update + input.simulate('change', { target: { value: siteName } }) + input.simulate('blur') + + await store.waitForActions([UPDATE_SETTING]) + }); + + it("should show the updated name after page reload", async () => { + const store = await createTestStore(); + + store.pushPath('/admin/settings/general'); + const app = mount(store.getAppContainer()) + + await store.waitForActions([LOAD_CURRENT_USER, INITIALIZE_SETTINGS]) + + const input = app.find(SettingInput).first().find("input"); + expect(input.prop("value")).toBe(siteName) + }) + }); +}); -- GitLab