UNPKG

@cloudquery/plugin-config-ui-lib

Version:

Plugin configuration UI library for CloudQuery Cloud App

3 lines (2 loc) 9.97 kB
"use strict";var e=require("@playwright/test"),t=function(){return t=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},t.apply(this,arguments)};function n(e,t,n,r){return new(n||(n=Promise))((function(o,s){function a(e){try{c(r.next(e))}catch(e){s(e)}}function i(e){try{c(r.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,i)}c((r=r.apply(e,t||[])).next())}))}function r(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(c){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,c])}}}"function"==typeof SuppressedError&&SuppressedError;var o=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 s(t,o,s){return n(this,void 0,void 0,(function(){var n;return r(this,(function(r){switch(r.label){case 0:return n="string"==typeof o?t.locator(o):o,[4,e.expect(n).toBeVisible()];case 1:return r.sent(),[4,n.focus()];case 2:return r.sent(),[4,n.clear()];case 3:return r.sent(),s?[4,"keyboard"in t?t.keyboard.type(s):n.fill(s)]:[3,5];case 4:r.sent(),r.label=5;case 5:return[4,e.expect("string"==typeof o?t.locator(o):o).toHaveValue(s)];case 6:return r.sent(),[2]}}))}))}function a(e){return n(this,void 0,void 0,(function(){return r(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 i(t,o){return n(this,void 0,void 0,(function(){return r(this,(function(t){switch(t.label){case 0:return[4,e.expect(o).toBeVisible()];case 1:return t.sent(),[4,o.focus()];case 2:return t.sent(),[4,o.click()];case 3:return t.sent(),[2]}}))}))}var c,u=function(e){return n(void 0,void 0,void 0,(function(){return r(this,(function(t){switch(t.label){case 0:return[4,i(0,e.locator(String.raw(c||(n=['button[type="submit"]'],r=['button[type="submit"]'],Object.defineProperty?Object.defineProperty(n,"raw",{value:r}):n.raw=r,c=n))))];case 1:return[2,t.sent()]}var n,r}))}))};function l(){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 p(e){return process.env.CQ_CI_PLAYWRIGHT_PREVIEW_LINK?"".concat(e,"?").concat(process.env.CQ_CI_PLAYWRIGHT_PREVIEW_LINK.split("?")[1]):e}var f={forbidOnly:!0,fullyParallel:!1,projects:[{name:"chromium",use:t({},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,t,o){return n(this,void 0,void 0,(function(){return r(this,(function(n){switch(n.label){case 0:return[4,e.waitForTimeout(500)];case 1:return n.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:o})];case 2:return n.sent(),[2]}}))}))},exports.assertUrlPathname=function(e,t){return n(this,void 0,void 0,(function(){return r(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]}}))}))},exports.click=i,exports.clickSubmit=u,exports.createPlugin=function(t){return n(void 0,[t],void 0,(function(t){var n,o=t.page,a=t.kind,c=t.pluginNewName,p=t.pluginLabel,f=t.fillFieldsSteps;return r(this,(function(t){switch(t.label){case 0:return e.test.setTimeout(3e5),[4,o.goto(l())];case 1:return t.sent(),[4,e.expect(o.getByRole("heading",{name:"Create a ".concat(a)})).toBeVisible()];case 2:return t.sent(),[4,s(o,'input[type="text"]',p)];case 3:return t.sent(),[4,i(0,o.getByRole("button",{name:p}).first())];case 4:return t.sent(),[4,e.expect(o.getByText(p)).toBeTruthy()];case 5:return t.sent(),[4,e.expect(o.locator('iframe[name="Plugin UI"]')).toBeVisible({timeout:3e4})];case 6:return t.sent(),[4,e.expect(o.getByText("Previewing")).toBeVisible()];case 7:if(t.sent(),!(n=o.frame({name:"Plugin UI"})))throw new Error("iframe not found");return[4,s(n,'[name="displayName"]',c)];case 8:return t.sent(),[4,null==f?void 0:f(n)];case 9:return t.sent(),[4,u(n)];case 10:return t.sent(),[4,e.expect(n.locator('button:has-text("Cancel test")')).toBeTruthy()];case 11:return t.sent(),[4,e.expect(o.getByText("Edit ".concat(a))).toBeVisible({timeout:3e4})];case 12:return t.sent(),[2,o.url()]}}))}))},exports.deletePlugin=function(t){return n(void 0,[t],void 0,(function(t){var n,o=t.page,a=t.kind,c=t.pluginNewName,u=t.pluginLabel,f=t.pluginUrl;return r(this,(function(t){switch(t.label){case 0:return e.test.setTimeout(3e5),[4,o.goto(l())];case 1:return t.sent(),[4,e.expect(o.getByRole("heading",{name:"Create a ".concat(a)})).toBeVisible()];case 2:return t.sent(),[4,s(o,'input[type="text"]',u)];case 3:return t.sent(),[4,i(0,o.getByRole("button",{name:u}).first())];case 4:case 9:return t.sent(),[4,e.expect(o.getByText("Previewing")).toBeVisible()];case 5:return t.sent(),[4,o.goto(p(f))];case 6:return t.sent(),[4,e.expect(o.getByText(c)).toBeTruthy()];case 7:return t.sent(),[4,o.getByRole("tab",{name:"Edit ".concat(a)}).click()];case 8:return t.sent(),[4,e.expect(o.locator('iframe[name="Plugin UI"]')).toBeVisible({timeout:3e4})];case 10:if(t.sent(),!(n=o.frame({name:"Plugin UI"})))throw new Error("iframe not found");return[4,e.expect(n.getByRole("textbox",{name:"".concat("destination"===a?"Destination":"Source"," name")})).toHaveValue(c)];case 11:return t.sent(),[4,n.getByRole("button",{name:"Delete ".concat(a)}).click()];case 12:return t.sent(),[4,i(0,o.getByText("Delete ".concat(a)))];case 13:return t.sent(),[4,e.expect(o.getByText(c)).toHaveCount(0,{timeout:15e3})];case 14:return t.sent(),[2]}}))}))},exports.editPlugin=function(t){return n(void 0,[t],void 0,(function(t){var n,o=t.page,a=t.kind,c=t.pluginNewName,f=t.pluginLabel,d=t.fillFieldsSteps,h=t.pluginUrl;return r(this,(function(t){switch(t.label){case 0:return e.test.setTimeout(3e5),[4,o.goto(l())];case 1:return t.sent(),[4,e.expect(o.getByRole("heading",{name:"Create a ".concat(a)})).toBeVisible()];case 2:return t.sent(),[4,s(o,'input[type="text"]',f)];case 3:return t.sent(),[4,i(0,o.getByRole("button",{name:f}).first())];case 4:case 9:return t.sent(),[4,e.expect(o.getByText("Previewing")).toBeVisible()];case 5:return t.sent(),[4,o.goto(p(h))];case 6:return t.sent(),[4,e.expect(o.getByText(c)).toBeTruthy()];case 7:return t.sent(),[4,o.getByRole("tab",{name:"Edit ".concat(a)}).click()];case 8:return t.sent(),[4,e.expect(o.locator('iframe[name="Plugin UI"]')).toBeVisible({timeout:3e4})];case 10:if(t.sent(),!(n=o.frame({name:"Plugin UI"})))throw new Error("iframe not found");return[4,e.expect(n.getByRole("textbox",{name:"".concat("destination"===a?"Destination":"Source"," name")})).toHaveValue(c)];case 11:return t.sent(),[4,null==d?void 0:d(n)];case 12:return t.sent(),[4,u(n)];case 13:return t.sent(),[4,e.expect(n.locator('button:has-text("Cancel test")')).toBeTruthy()];case 14:return t.sent(),[4,e.expect(o.getByText("Edit ".concat(a))).toBeVisible({timeout:3e4})];case 15:return t.sent(),[2]}}))}))},exports.fillInput=s,exports.getMainTestUser=o,exports.getPersistentName=function(){return"name-".concat(Math.random().toString(36).slice(2,12))},exports.getPluginUrl=p,exports.getRandomTestUser=function(e){return{email:"e2e-test-".concat(process.env.GITHUB_JOB_ID,"-").concat(e,"@cloudquery.io"),newPassword:"A87654321a",password:"12345678Aa"}},exports.getRootUrl=l,exports.goTo=function(e,t){return n(this,void 0,void 0,(function(){return r(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,a(e)];case 3:return n.sent(),[2]}}))}))},exports.login=function(t){return n(void 0,void 0,void 0,(function(){var n,a,i;return r(this,(function(r){switch(r.label){case 0:return[4,t.goto("https://cloud.cloudquery.io/auth/login")];case 1:return r.sent(),n=o(),a=n.email,i=n.password,[4,s(t,t.getByLabel("Email Address"),a)];case 2:case 4:return r.sent(),[4,u(t)];case 3:return r.sent(),[4,s(t,t.getByLabel("Password"),i)];case 5:return r.sent(),[4,e.expect(t.getByRole("heading",{name:"Overview"})).toBeVisible()];case 6:return r.sent(),[2]}}))}))},exports.playwrightConfig=f; //# sourceMappingURL=index.cjs.js.map