@cloudquery/plugin-config-ui-lib
Version:
Plugin configuration UI library for CloudQuery Cloud App
3 lines (2 loc) • 6.29 kB
JavaScript
;var e=require("@playwright/test");function t(e,t,i,o){return new(i||(i=Promise))((function(n,l){function r(e){try{a(o.next(e))}catch(e){l(e)}}function s(e){try{a(o.throw(e))}catch(e){l(e)}}function a(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(r,s)}a((o=o.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const i=()=>{if(!process.env.CQ_CI_PLAYWRIGHT_TEST_USER_EMAIL)throw new Error("CQ_CI_PLAYWRIGHT_TEST_USER_EMAIL is not set");if(!process.env.CQ_CI_PLAYWRIGHT_TEST_USER_PASSWORD)throw new Error("CQ_CI_PLAYWRIGHT_TEST_USER_PASSWORD is not set");return{email:process.env.CQ_CI_PLAYWRIGHT_TEST_USER_EMAIL,password:process.env.CQ_CI_PLAYWRIGHT_TEST_USER_PASSWORD}};function o(i,o,n){return t(this,void 0,void 0,(function*(){const t="string"==typeof o?i.locator(o):o;yield e.expect(t).toBeVisible(),yield t.focus(),yield t.clear(),n&&(yield"keyboard"in i?i.keyboard.type(n):t.fill(n)),yield e.expect("string"==typeof o?i.locator(o):o).toHaveValue(n)}))}function n(i,o){return t(this,void 0,void 0,(function*(){yield e.expect(o).toBeVisible(),yield o.focus(),yield o.click()}))}const l=e=>t(void 0,void 0,void 0,(function*(){return yield n(0,e.locator(String.raw`button[type="submit"]`))}));function r(){return process.env.CQ_CI_PLAYWRIGHT_PREVIEW_LINK?process.env.CQ_CI_PLAYWRIGHT_PREVIEW_LINK.replace("cloudquery-test","cq-bot-team"):"https://cloud.cloudquery.io"}function s(e){return process.env.CQ_CI_PLAYWRIGHT_PREVIEW_LINK?`${e}?${process.env.CQ_CI_PLAYWRIGHT_PREVIEW_LINK.split("?")[1]}`:e}const a={forbidOnly:!0,fullyParallel:!1,projects:[{name:"chromium",use:Object.assign({},e.devices["Desktop Chrome"])}],reporter:"html",retries:0,testDir:"./e2e-tests",timeout:12e4,use:{baseURL:"http://localhost:3000",headless:!!process.env.CI,trace:"retain-on-failure",video:{mode:"retain-on-failure",size:{height:480,width:640}}},workers:1,webServer:{command:"http-server ./build -p 3000 --silent",reuseExistingServer:!process.env.CI,stderr:"pipe",stdout:"pipe",url:"http://localhost:3000"}};exports.assertUrlParam=function(e,i,o){return t(this,void 0,void 0,(function*(){yield e.waitForTimeout(500),yield e.waitForFunction((({key:e,value:t})=>new URL(document.location.href).searchParams.get(e)===t),{key:i,value:o})}))},exports.assertUrlPathname=function(e,i){return t(this,void 0,void 0,(function*(){yield e.waitForTimeout(500),yield e.waitForURL((e=>e.pathname===i))}))},exports.click=n,exports.clickSubmit=l,exports.createPlugin=i=>t(void 0,[i],void 0,(function*({page:t,kind:i,pluginNewName:s,pluginLabel:a,fillFieldsSteps:d}){e.test.setTimeout(3e5),yield t.goto(r()),yield e.expect(t.getByRole("heading",{name:`Create a ${i}`})).toBeVisible(),yield o(t,'input[type="text"]',a),yield n(0,t.getByRole("button",{name:a}).first()),yield e.expect(t.getByText(a)).toBeTruthy(),yield e.expect(t.locator('iframe[name="Plugin UI"]')).toBeVisible({timeout:3e4}),yield e.expect(t.getByText("Previewing")).toBeVisible();const u=t.frame({name:"Plugin UI"});if(!u)throw new Error("iframe not found");return yield o(u,'[name="displayName"]',s),yield null==d?void 0:d(u),yield l(u),yield e.expect(u.locator('button:has-text("Cancel test")')).toBeTruthy(),yield e.expect(t.getByText(`Edit ${i}`)).toBeVisible({timeout:3e4}),t.url()})),exports.deletePlugin=i=>t(void 0,[i],void 0,(function*({page:t,kind:i,pluginNewName:l,pluginLabel:a,pluginUrl:d}){e.test.setTimeout(3e5),yield t.goto(r()),yield e.expect(t.getByRole("heading",{name:`Create a ${i}`})).toBeVisible(),yield o(t,'input[type="text"]',a),yield n(0,t.getByRole("button",{name:a}).first()),yield e.expect(t.getByText("Previewing")).toBeVisible(),yield t.goto(s(d)),yield e.expect(t.getByText(l)).toBeTruthy(),yield t.getByRole("tab",{name:`Edit ${i}`}).click(),yield e.expect(t.locator('iframe[name="Plugin UI"]')).toBeVisible({timeout:3e4}),yield e.expect(t.getByText("Previewing")).toBeVisible();const u=t.frame({name:"Plugin UI"});if(!u)throw new Error("iframe not found");yield e.expect(u.getByRole("textbox",{name:("destination"===i?"Destination":"Source")+" name"})).toHaveValue(l),yield u.getByRole("button",{name:`Delete ${i}`}).click(),yield n(0,t.getByText(`Delete ${i}`)),yield e.expect(t.getByText(l)).toHaveCount(0,{timeout:15e3})})),exports.editPlugin=i=>t(void 0,[i],void 0,(function*({page:t,kind:i,pluginNewName:a,pluginLabel:d,fillFieldsSteps:u,pluginUrl:c}){e.test.setTimeout(3e5),yield t.goto(r()),yield e.expect(t.getByRole("heading",{name:`Create a ${i}`})).toBeVisible(),yield o(t,'input[type="text"]',d),yield n(0,t.getByRole("button",{name:d}).first()),yield e.expect(t.getByText("Previewing")).toBeVisible(),yield t.goto(s(c)),yield e.expect(t.getByText(a)).toBeTruthy(),yield t.getByRole("tab",{name:`Edit ${i}`}).click(),yield e.expect(t.locator('iframe[name="Plugin UI"]')).toBeVisible({timeout:3e4}),yield e.expect(t.getByText("Previewing")).toBeVisible();const y=t.frame({name:"Plugin UI"});if(!y)throw new Error("iframe not found");yield e.expect(y.getByRole("textbox",{name:("destination"===i?"Destination":"Source")+" name"})).toHaveValue(a),yield null==u?void 0:u(y),yield l(y),yield e.expect(y.locator('button:has-text("Cancel test")')).toBeTruthy(),yield e.expect(t.getByText(`Edit ${i}`)).toBeVisible({timeout:3e4})})),exports.fillInput=o,exports.getMainTestUser=i,exports.getPersistentName=()=>`name-${Math.random().toString(36).slice(2,12)}`,exports.getPluginUrl=s,exports.getRandomTestUser=function(e){return{email:`e2e-test-${process.env.GITHUB_JOB_ID}-${e}@cloudquery.io`,newPassword:"A87654321a",password:"12345678Aa"}},exports.getRootUrl=r,exports.goTo=function(e,i){return t(this,void 0,void 0,(function*(){yield e.goto(i),yield e.waitForTimeout(1e3),yield function(e){return t(this,void 0,void 0,(function*(){yield e.waitForLoadState("domcontentloaded",{timeout:15e3}),yield e.waitForLoadState("load",{timeout:15e3})}))}(e)}))},exports.login=n=>t(void 0,void 0,void 0,(function*(){yield n.goto("https://cloud.cloudquery.io/auth/login");const{email:t,password:r}=i();yield o(n,n.getByLabel("Email Address"),t),yield l(n),yield o(n,n.getByLabel("Password"),r),yield l(n),yield e.expect(n.getByRole("heading",{name:"Overview"})).toBeVisible()})),exports.playwrightConfig=a;
//# sourceMappingURL=index.cjs.js.map