UNPKG

@cloudquery/plugin-config-ui-lib

Version:

Plugin configuration UI library for CloudQuery Cloud App

3 lines (2 loc) 6.07 kB
import{expect as e,test as t,devices as i}from"@playwright/test";function o(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 d(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,d)}a((o=o.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const n=()=>{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 l(e){return{email:`e2e-test-${process.env.GITHUB_JOB_ID}-${e}@cloudquery.io`,newPassword:"A87654321a",password:"12345678Aa"}}function r(e,t){return o(this,void 0,void 0,(function*(){yield e.waitForTimeout(500),yield e.waitForURL((e=>e.pathname===t))}))}function d(e,t,i){return o(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:t,value:i})}))}function a(t,i,n){return o(this,void 0,void 0,(function*(){const o="string"==typeof i?t.locator(i):i;yield e(o).toBeVisible(),yield o.focus(),yield o.clear(),n&&(yield"keyboard"in t?t.keyboard.type(n):o.fill(n)),yield e("string"==typeof i?t.locator(i):i).toHaveValue(n)}))}function s(e,t){return o(this,void 0,void 0,(function*(){yield e.goto(t),yield e.waitForTimeout(1e3),yield function(e){return o(this,void 0,void 0,(function*(){yield e.waitForLoadState("domcontentloaded",{timeout:15e3}),yield e.waitForLoadState("load",{timeout:15e3})}))}(e)}))}function u(t,i){return o(this,void 0,void 0,(function*(){yield e(i).toBeVisible(),yield i.focus(),yield i.click()}))}const y=()=>`name-${Math.random().toString(36).slice(2,12)}`,c=e=>o(void 0,void 0,void 0,(function*(){return yield u(0,e.locator(String.raw`button[type="submit"]`))})),m=t=>o(void 0,void 0,void 0,(function*(){yield t.goto("https://cloud.cloudquery.io/auth/login");const{email:i,password:o}=n();yield a(t,t.getByLabel("Email Address"),i),yield c(t),yield a(t,t.getByLabel("Password"),o),yield c(t),yield e(t.getByRole("heading",{name:"Overview"})).toBeVisible()})),g=i=>o(void 0,[i],void 0,(function*({page:i,kind:o,pluginNewName:n,pluginLabel:l,fillFieldsSteps:r}){t.setTimeout(3e5),yield i.goto(v()),yield e(i.getByRole("heading",{name:`Create a ${o}`})).toBeVisible(),yield a(i,'input[type="text"]',l),yield u(0,i.getByRole("button",{name:l}).first()),yield e(i.getByText(l)).toBeTruthy(),yield e(i.locator('iframe[name="Plugin UI"]')).toBeVisible({timeout:3e4}),yield e(i.getByText("Previewing")).toBeVisible();const d=i.frame({name:"Plugin UI"});if(!d)throw new Error("iframe not found");return yield a(d,'[name="displayName"]',n),yield null==r?void 0:r(d),yield c(d),yield e(d.locator('button:has-text("Cancel test")')).toBeTruthy(),yield e(i.getByText(`Edit ${o}`)).toBeVisible({timeout:3e4}),i.url()})),p=i=>o(void 0,[i],void 0,(function*({page:i,kind:o,pluginNewName:n,pluginLabel:l,fillFieldsSteps:r,pluginUrl:d}){t.setTimeout(3e5),yield i.goto(v()),yield e(i.getByRole("heading",{name:`Create a ${o}`})).toBeVisible(),yield a(i,'input[type="text"]',l),yield u(0,i.getByRole("button",{name:l}).first()),yield e(i.getByText("Previewing")).toBeVisible(),yield i.goto(B(d)),yield e(i.getByText(n)).toBeTruthy(),yield i.getByRole("tab",{name:`Edit ${o}`}).click(),yield e(i.locator('iframe[name="Plugin UI"]')).toBeVisible({timeout:3e4}),yield e(i.getByText("Previewing")).toBeVisible();const s=i.frame({name:"Plugin UI"});if(!s)throw new Error("iframe not found");yield e(s.getByRole("textbox",{name:("destination"===o?"Destination":"Source")+" name"})).toHaveValue(n),yield null==r?void 0:r(s),yield c(s),yield e(s.locator('button:has-text("Cancel test")')).toBeTruthy(),yield e(i.getByText(`Edit ${o}`)).toBeVisible({timeout:3e4})})),f=i=>o(void 0,[i],void 0,(function*({page:i,kind:o,pluginNewName:n,pluginLabel:l,pluginUrl:r}){t.setTimeout(3e5),yield i.goto(v()),yield e(i.getByRole("heading",{name:`Create a ${o}`})).toBeVisible(),yield a(i,'input[type="text"]',l),yield u(0,i.getByRole("button",{name:l}).first()),yield e(i.getByText("Previewing")).toBeVisible(),yield i.goto(B(r)),yield e(i.getByText(n)).toBeTruthy(),yield i.getByRole("tab",{name:`Edit ${o}`}).click(),yield e(i.locator('iframe[name="Plugin UI"]')).toBeVisible({timeout:3e4}),yield e(i.getByText("Previewing")).toBeVisible();const d=i.frame({name:"Plugin UI"});if(!d)throw new Error("iframe not found");yield e(d.getByRole("textbox",{name:("destination"===o?"Destination":"Source")+" name"})).toHaveValue(n),yield d.getByRole("button",{name:`Delete ${o}`}).click(),yield u(0,i.getByText(`Delete ${o}`)),yield e(i.getByText(n)).toHaveCount(0,{timeout:15e3})}));function v(){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 B(e){return process.env.CQ_CI_PLAYWRIGHT_PREVIEW_LINK?`${e}?${process.env.CQ_CI_PLAYWRIGHT_PREVIEW_LINK.split("?")[1]}`:e}const _={forbidOnly:!0,fullyParallel:!1,projects:[{name:"chromium",use:Object.assign({},i["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"}};export{d as assertUrlParam,r as assertUrlPathname,u as click,c as clickSubmit,g as createPlugin,f as deletePlugin,p as editPlugin,a as fillInput,n as getMainTestUser,y as getPersistentName,B as getPluginUrl,l as getRandomTestUser,v as getRootUrl,s as goTo,m as login,_ as playwrightConfig}; //# sourceMappingURL=index.esm.js.map