@cloudquery/plugin-config-ui-lib
Version:
Plugin configuration UI library for CloudQuery Cloud App
3 lines (2 loc) • 9.77 kB
JavaScript
import{expect as e,test as t,devices as n}from"@playwright/test";var r=function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)};function o(e,t,n,r){return new(n||(n=Promise))((function(o,s){function a(e){try{u(r.next(e))}catch(e){s(e)}}function i(e){try{u(r.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,i)}u((r=r.apply(e,t||[])).next())}))}function s(e,t){var n,r,o,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=i(0),a.throw=i(1),a.return=i(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function i(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,i[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}"function"==typeof SuppressedError&&SuppressedError;var a=function(){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 i(e){return{email:"e2e-test-".concat(process.env.GITHUB_JOB_ID,"-").concat(e,"@cloudquery.io"),newPassword:"A87654321a",password:"12345678Aa"}}function u(e,t){return o(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,e.waitForTimeout(500)];case 1:return n.sent(),[4,e.waitForURL((function(e){return e.pathname===t}))];case 2:return n.sent(),[2]}}))}))}function c(e,t,n){return o(this,void 0,void 0,(function(){return s(this,(function(r){switch(r.label){case 0:return[4,e.waitForTimeout(500)];case 1:return r.sent(),[4,e.waitForFunction((function(e){var t=e.key,n=e.value;return new URL(document.location.href).searchParams.get(t)===n}),{key:t,value:n})];case 2:return r.sent(),[2]}}))}))}function l(t,n,r){return o(this,void 0,void 0,(function(){var o;return s(this,(function(s){switch(s.label){case 0:return o="string"==typeof n?t.locator(n):n,[4,e(o).toBeVisible()];case 1:return s.sent(),[4,o.focus()];case 2:return s.sent(),[4,o.clear()];case 3:return s.sent(),r?[4,"keyboard"in t?t.keyboard.type(r):o.fill(r)]:[3,5];case 4:s.sent(),s.label=5;case 5:return[4,e("string"==typeof n?t.locator(n):n).toHaveValue(r)];case 6:return s.sent(),[2]}}))}))}function f(e){return o(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,e.waitForLoadState("domcontentloaded",{timeout:15e3})];case 1:return t.sent(),[4,e.waitForLoadState("load",{timeout:15e3})];case 2:return t.sent(),[2]}}))}))}function p(e,t){return o(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,e.goto(t)];case 1:return n.sent(),[4,e.waitForTimeout(1e3)];case 2:return n.sent(),[4,f(e)];case 3:return n.sent(),[2]}}))}))}function d(t,n){return o(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,e(n).toBeVisible()];case 1:return t.sent(),[4,n.focus()];case 2:return t.sent(),[4,n.click()];case 3:return t.sent(),[2]}}))}))}var h,m=function(){return"name-".concat(Math.random().toString(36).slice(2,12))},v=function(e){return o(void 0,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,d(0,e.locator(String.raw(h||(n=['button[type="submit"]'],r=['button[type="submit"]'],Object.defineProperty?Object.defineProperty(n,"raw",{value:r}):n.raw=r,h=n))))];case 1:return[2,t.sent()]}var n,r}))}))},b=function(t){return o(void 0,void 0,void 0,(function(){var n,r,o;return s(this,(function(s){switch(s.label){case 0:return[4,t.goto("https://cloud.cloudquery.io/auth/login")];case 1:return s.sent(),n=a(),r=n.email,o=n.password,[4,l(t,t.getByLabel("Email Address"),r)];case 2:case 4:return s.sent(),[4,v(t)];case 3:return s.sent(),[4,l(t,t.getByLabel("Password"),o)];case 5:return s.sent(),[4,e(t.getByRole("heading",{name:"Overview"})).toBeVisible()];case 6:return s.sent(),[2]}}))}))},y=function(n){return o(void 0,[n],void 0,(function(n){var r,o=n.page,a=n.kind,i=n.pluginNewName,u=n.pluginLabel,c=n.fillFieldsSteps;return s(this,(function(n){switch(n.label){case 0:return t.setTimeout(3e5),[4,o.goto(_())];case 1:return n.sent(),[4,e(o.getByRole("heading",{name:"Create a ".concat(a)})).toBeVisible()];case 2:return n.sent(),[4,l(o,'input[type="text"]',u)];case 3:return n.sent(),[4,d(0,o.getByRole("button",{name:u}).first())];case 4:return n.sent(),[4,e(o.getByText(u)).toBeTruthy()];case 5:return n.sent(),[4,e(o.locator('iframe[name="Plugin UI"]')).toBeVisible({timeout:3e4})];case 6:return n.sent(),[4,e(o.getByText("Previewing")).toBeVisible()];case 7:if(n.sent(),!(r=o.frame({name:"Plugin UI"})))throw new Error("iframe not found");return[4,l(r,'[name="displayName"]',i)];case 8:return n.sent(),[4,null==c?void 0:c(r)];case 9:return n.sent(),[4,v(r)];case 10:return n.sent(),[4,e(r.locator('button:has-text("Cancel test")')).toBeTruthy()];case 11:return n.sent(),[4,e(o.getByText("Edit ".concat(a))).toBeVisible({timeout:3e4})];case 12:return n.sent(),[2,o.url()]}}))}))},g=function(n){return o(void 0,[n],void 0,(function(n){var r,o=n.page,a=n.kind,i=n.pluginNewName,u=n.pluginLabel,c=n.fillFieldsSteps,f=n.pluginUrl;return s(this,(function(n){switch(n.label){case 0:return t.setTimeout(3e5),[4,o.goto(_())];case 1:return n.sent(),[4,e(o.getByRole("heading",{name:"Create a ".concat(a)})).toBeVisible()];case 2:return n.sent(),[4,l(o,'input[type="text"]',u)];case 3:return n.sent(),[4,d(0,o.getByRole("button",{name:u}).first())];case 4:case 9:return n.sent(),[4,e(o.getByText("Previewing")).toBeVisible()];case 5:return n.sent(),[4,o.goto(B(f))];case 6:return n.sent(),[4,e(o.getByText(i)).toBeTruthy()];case 7:return n.sent(),[4,o.getByRole("tab",{name:"Edit ".concat(a)}).click()];case 8:return n.sent(),[4,e(o.locator('iframe[name="Plugin UI"]')).toBeVisible({timeout:3e4})];case 10:if(n.sent(),!(r=o.frame({name:"Plugin UI"})))throw new Error("iframe not found");return[4,e(r.getByRole("textbox",{name:"".concat("destination"===a?"Destination":"Source"," name")})).toHaveValue(i)];case 11:return n.sent(),[4,null==c?void 0:c(r)];case 12:return n.sent(),[4,v(r)];case 13:return n.sent(),[4,e(r.locator('button:has-text("Cancel test")')).toBeTruthy()];case 14:return n.sent(),[4,e(o.getByText("Edit ".concat(a))).toBeVisible({timeout:3e4})];case 15:return n.sent(),[2]}}))}))},w=function(n){return o(void 0,[n],void 0,(function(n){var r,o=n.page,a=n.kind,i=n.pluginNewName,u=n.pluginLabel,c=n.pluginUrl;return s(this,(function(n){switch(n.label){case 0:return t.setTimeout(3e5),[4,o.goto(_())];case 1:return n.sent(),[4,e(o.getByRole("heading",{name:"Create a ".concat(a)})).toBeVisible()];case 2:return n.sent(),[4,l(o,'input[type="text"]',u)];case 3:return n.sent(),[4,d(0,o.getByRole("button",{name:u}).first())];case 4:case 9:return n.sent(),[4,e(o.getByText("Previewing")).toBeVisible()];case 5:return n.sent(),[4,o.goto(B(c))];case 6:return n.sent(),[4,e(o.getByText(i)).toBeTruthy()];case 7:return n.sent(),[4,o.getByRole("tab",{name:"Edit ".concat(a)}).click()];case 8:return n.sent(),[4,e(o.locator('iframe[name="Plugin UI"]')).toBeVisible({timeout:3e4})];case 10:if(n.sent(),!(r=o.frame({name:"Plugin UI"})))throw new Error("iframe not found");return[4,e(r.getByRole("textbox",{name:"".concat("destination"===a?"Destination":"Source"," name")})).toHaveValue(i)];case 11:return n.sent(),[4,r.getByRole("button",{name:"Delete ".concat(a)}).click()];case 12:return n.sent(),[4,d(0,o.getByText("Delete ".concat(a)))];case 13:return n.sent(),[4,e(o.getByText(i)).toHaveCount(0,{timeout:15e3})];case 14:return n.sent(),[2]}}))}))};function _(){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?"".concat(e,"?").concat(process.env.CQ_CI_PLAYWRIGHT_PREVIEW_LINK.split("?")[1]):e}var T={forbidOnly:!0,fullyParallel:!1,projects:[{name:"chromium",use:r({},n["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{c as assertUrlParam,u as assertUrlPathname,d as click,v as clickSubmit,y as createPlugin,w as deletePlugin,g as editPlugin,l as fillInput,a as getMainTestUser,m as getPersistentName,B as getPluginUrl,i as getRandomTestUser,_ as getRootUrl,p as goTo,b as login,T as playwrightConfig};
//# sourceMappingURL=index.esm.js.map