diff --git a/pantheon-bundle/frontend/src/app/Constants.tsx b/pantheon-bundle/frontend/src/app/Constants.tsx index c774707ee..812b95678 100644 --- a/pantheon-bundle/frontend/src/app/Constants.tsx +++ b/pantheon-bundle/frontend/src/app/Constants.tsx @@ -1,40 +1,40 @@ export class Fields { - public static JCR_DESCRIPTION = 'jcr:description' - public static JCR_PRIMARYTYPE = 'jcr:primaryType' - public static JCR_TITLE = 'jcr:title' - public static JCR_UUID = 'jcr:uuid' - public static PANT_MODULE_TYPE = 'moduleType' - public static NAME = 'name' - public static PANT_PUBLISHED_DATE = 'pant:publishedDate' - public static PANT_DATE_UPLOADED = 'pant:dateUploaded' - public static SLING_RESOURCETYPE = 'sling:resourceType' - public static PANT_PRODUCT_VERSION_REF = 'productVersion' - public static URL_FRAGMENT = 'urlFragment' + public static JCR_DESCRIPTION = "jcr:description" + public static JCR_PRIMARYTYPE = "jcr:primaryType" + public static JCR_TITLE = "jcr:title" + public static JCR_UUID = "jcr:uuid" + public static PANT_MODULE_TYPE = "moduleType" + public static NAME = "name" + public static PANT_PUBLISHED_DATE = "pant:publishedDate" + public static PANT_DATE_UPLOADED = "pant:dateUploaded" + public static SLING_RESOURCETYPE = "sling:resourceType" + public static PANT_PRODUCT_VERSION_REF = "productVersion" + public static URL_FRAGMENT = "urlFragment" } // tslint:disable-next-line: max-classes-per-file export class JcrTypes { - public static PRODUCT_VERSION = 'pant:productVersion' + public static PRODUCT_VERSION = "pant:productVersion" } // tslint:disable-next-line: max-classes-per-file export class SlingTypes { - public static PRODUCT_VERSION = 'pantheon/productVersion' + public static PRODUCT_VERSION = "pantheon/productVersion" } // tslint:disable-next-line: max-classes-per-file export class SlingTypesPrefixes { - public static PANTHEON = 'pantheon' + public static PANTHEON = "pantheon" } // tslint:disable-next-line: max-classes-per-file export class PathPrefixes { - public static MODULE_PATH_PREFIX = '/module' - public static ASSEBMLY_PATH_PREFIX = '/assembly' + public static MODULE_PATH_PREFIX = "/module" + public static ASSEBMLY_PATH_PREFIX = "/assembly" } // tslint:disable-next-line: max-classes-per-file export class PantheonContentTypes { - public static MODULE = 'module' - public static ASSEMBLY = 'assembly' + public static MODULE = "module" + public static ASSEMBLY = "assembly" } \ No newline at end of file diff --git a/pantheon-bundle/frontend/src/app/Dropdown.test.tsx b/pantheon-bundle/frontend/src/app/Dropdown.test.tsx index 013463d28..05400f0c6 100644 --- a/pantheon-bundle/frontend/src/app/Dropdown.test.tsx +++ b/pantheon-bundle/frontend/src/app/Dropdown.test.tsx @@ -1,13 +1,13 @@ -import React from 'react' -import { Dropdown } from '@app/Dropdown' -import '@app/fetchMock' -import { mount, shallow } from 'enzyme' -import sinon from 'sinon' -import renderer from 'react-test-renderer' +import React from "react" +import { Dropdown } from "@app/Dropdown" +import "@app/fetchMock" +import { mount, shallow } from "enzyme" +import sinon from "sinon" +import renderer from "react-test-renderer" -describe('Tests for Dropdown', () => { +describe("Tests for Dropdown", () => { - test('should render Dropdown component', () => { + test("should render Dropdown component", () => { const view = shallow( { expect(view).toMatchSnapshot() }) - it('should render dropdown list', () => { + it("should render dropdown list", () => { const wrapper = mount( { ) }) - it('test changeSelection function', () => { + it("test changeSelection function", () => { const wrapper = renderer.create() const inst = wrapper.getInstance() - const spy = sinon.spy(inst, 'changeSelection') + const spy = sinon.spy(inst, "changeSelection") inst.changeSelection(wrapper) sinon.assert.called(spy) - const spy2 = sinon.spy(inst, 'changeExpandState') + const spy2 = sinon.spy(inst, "changeExpandState") inst.changeExpandState() sinon.assert.called(spy2) }) diff --git a/pantheon-bundle/frontend/src/app/Dropdown.tsx b/pantheon-bundle/frontend/src/app/Dropdown.tsx index 84f7eeae4..6686c14d3 100644 --- a/pantheon-bundle/frontend/src/app/Dropdown.tsx +++ b/pantheon-bundle/frontend/src/app/Dropdown.tsx @@ -1,5 +1,5 @@ -import React, { Component } from 'react'; -import '@app/app.css'; +import React, { Component } from "react"; +import "@app/app.css"; export interface IProps { perPageValue: (itemsPerPage) => any @@ -9,10 +9,10 @@ export interface IProps { class Dropdown extends Component { public dropdownItems = [ - '25 items per page', - '50 items per page', - '75 items per page', - '100 items per page' + "25 items per page", + "50 items per page", + "75 items per page", + "100 items per page" ]; public state = { diff --git a/pantheon-bundle/frontend/src/app/Pagination.test.tsx b/pantheon-bundle/frontend/src/app/Pagination.test.tsx index 95f75470a..0d92dc76d 100644 --- a/pantheon-bundle/frontend/src/app/Pagination.test.tsx +++ b/pantheon-bundle/frontend/src/app/Pagination.test.tsx @@ -1,13 +1,13 @@ -import React from 'react' -import { Pagination } from '@app/Pagination' -import '@app/fetchMock' +import React from "react" +import { Pagination } from "@app/Pagination" +import "@app/fetchMock" -import { mount, shallow } from 'enzyme' -import { LevelItem } from '@patternfly/react-core' +import { mount, shallow } from "enzyme" +import { LevelItem } from "@patternfly/react-core" -describe('Tests for Pagination', () => { +describe("Tests for Pagination", () => { - test('should render Pagination component', () => { + test("should render Pagination component", () => { const view = shallow( { expect(view).toMatchSnapshot() }) - it('should render Badge for displaying page number', () => { + it("should render Badge for displaying page number", () => { const wrapper = mount( any @@ -18,10 +18,10 @@ export interface IProps { class Pagination extends React.Component { public dropdownItems = [ - '25 items per page', - '50 items per page', - '75 items per page', - '100 items per page' + "25 items per page", + "50 items per page", + "75 items per page", + "100 items per page" ]; public state = { @@ -30,7 +30,7 @@ class Pagination extends React.Component { isOpen: false, itemsPerPage: 25, renderSearch: false, - searchValue: '', + searchValue: "", selected: this.dropdownItems[0] }; @@ -117,7 +117,7 @@ class Pagination extends React.Component { private dropDownValue = (value) => { this.setState({ isOpen: !this.state.isOpen, - itemsPerPage: Number(value.substr(0,value.indexOf(' '))), + itemsPerPage: Number(value.substr(0,value.indexOf(" "))), selected: value },()=>{ this.props.handlePerPageLimit(this.state.itemsPerPage) diff --git a/pantheon-bundle/frontend/src/app/TestResources.tsx b/pantheon-bundle/frontend/src/app/TestResources.tsx index 9d8c55948..4476b2c84 100644 --- a/pantheon-bundle/frontend/src/app/TestResources.tsx +++ b/pantheon-bundle/frontend/src/app/TestResources.tsx @@ -1,4 +1,4 @@ -import { IAppState } from './app'; +import { IAppState } from "./app"; const mockStateUser: IAppState = { isAdmin: false, diff --git a/pantheon-bundle/frontend/src/app/__snapshots__/moduleDisplay.test.tsx.snap b/pantheon-bundle/frontend/src/app/__snapshots__/moduleDisplay.test.tsx.snap index 19d557f16..f265bc33a 100644 --- a/pantheon-bundle/frontend/src/app/__snapshots__/moduleDisplay.test.tsx.snap +++ b/pantheon-bundle/frontend/src/app/__snapshots__/moduleDisplay.test.tsx.snap @@ -153,6 +153,7 @@ exports[`ModuleDisplay tests should render ModuleDisplay component 1`] = `
{ - public static ANON_USER = 'anonymous' - public static ADMIN_USER = 'admin' + public static ANON_USER = "anonymous" + public static ADMIN_USER = "admin" public static thisApp: App @@ -49,7 +49,7 @@ class App extends Component { public onNavToggle() { // No idea why this roundabout setState is necessary, but if we replace this with the simpler "this.setState", - // then we get a console error saying "`this` is undefined" - which I don't even understand how that's + // then we get a console error saying "`this` is undefined" - which I don"t even understand how that"s // possible - but this works around it. App.thisApp.setState({ isNavOpen: !App.thisApp.state.isNavOpen diff --git a/pantheon-bundle/frontend/src/app/assemblyDisplay.test.tsx b/pantheon-bundle/frontend/src/app/assemblyDisplay.test.tsx index aacd6bc24..6ba65b3c1 100644 --- a/pantheon-bundle/frontend/src/app/assemblyDisplay.test.tsx +++ b/pantheon-bundle/frontend/src/app/assemblyDisplay.test.tsx @@ -1,217 +1,217 @@ -import React from 'react' -import { AssemblyDisplay } from '@app/assemblyDisplay' -import '@app/fetchMock' +import React from "react" +import { AssemblyDisplay } from "@app/assemblyDisplay" +import "@app/fetchMock" -import { mount, shallow } from 'enzyme' -import { Button, Card, TextContent, Level, LevelItem, Title, Divider } from '@patternfly/react-core' -import renderer from 'react-test-renderer' -import sinon from 'sinon' -import { Versions } from '@app/versions' -const anymatch = require('anymatch') +import { mount, shallow } from "enzyme" +import { Button, Card, TextContent, Level, LevelItem, Title, Divider } from "@patternfly/react-core" +import renderer from "react-test-renderer" +import sinon from "sinon" +import { Versions } from "@app/versions" +const anymatch = require("anymatch") const props = { location: { pathname: "assembly/test" } } -describe('AssemblyDisplay tests', () => { - test('should render AssemblyDisplay component', () => { +describe("AssemblyDisplay tests", () => { + test("should render AssemblyDisplay component", () => { const view = shallow() expect(view).toMatchSnapshot() }) - it('should render a Button', () => { + it("should render a Button", () => { const wrapper = mount() const button = wrapper.find(Button) expect(button.exists()).toBe(true) }) - it('should render a Card', () => { + it("should render a Card", () => { const wrapper = mount() const card = wrapper.find(Card) expect(card.exists()).toBe(true) }) - it('should render a TextContent Element', () => { + it("should render a TextContent Element", () => { const wrapper = mount() const textContent = wrapper.find(TextContent) expect(textContent.exists()).toBe(true) }) - it('should render a Level Element', () => { + it("should render a Level Element", () => { const wrapper = mount() const level = wrapper.find(Level) expect(level.exists()).toBe(true) }) - it('should render a LevelItem', () => { + it("should render a LevelItem", () => { const wrapper = mount() const levelItem = wrapper.find(LevelItem) expect(levelItem.exists()).toBe(true) }) - it('should render a Versions Element', () => { + it("should render a Versions Element", () => { const wrapper = mount() const versions = wrapper.find(Versions) expect(versions.exists()).toBe(true) }) - it('should render a Divider Element', () => { + it("should render a Divider Element", () => { const wrapper = mount() const divider = wrapper.find(Divider) expect(divider.exists()).toBe(true) }) - it('test fetchModuleDetails function', () => { + it("test fetchModuleDetails function", () => { const wrapper = renderer.create() const inst = wrapper.getInstance() expect(inst.fetchModuleDetails(props)).toMatchSnapshot() }) - it('test getVersionUUID function', () => { + it("test getVersionUUID function", () => { const wrapper = renderer.create() const inst = wrapper.getInstance() expect(inst.getVersionUUID("/modules/test")).toMatchSnapshot() }) - it('test getProductInitialLoad function', () => { + it("test getProductInitialLoad function", () => { const wrapper = renderer.create() const inst = wrapper.getInstance() expect(inst.getProductInitialLoad()).toMatchSnapshot() }) - it('test componentDidMount function', () => { + it("test componentDidMount function", () => { const wrapper = renderer.create() const inst = wrapper.getInstance() expect(inst.componentDidMount()).toMatchSnapshot() }) - it('test getPortalUrl function', () => { + it("test getPortalUrl function", () => { const wrapper = renderer.create() const inst = wrapper.getInstance() expect(inst.getPortalUrl()).toMatchSnapshot() }) - it('has a props', () => { + it("has a props", () => { const assemblyDisplay = mount().matchesElement expect(assemblyDisplay.length === 1) }) // Value testing with Enzyme. - it('renders Product heading', () => { + it("renders Product heading", () => { const wrapper = mount() - const sourceTypeText = wrapper.find('#span-source-type-product').first().text() + const sourceTypeText = wrapper.find("#span-source-type-product").first().text() // ensure it matches what is expected expect(sourceTypeText).toEqual("Product") }) - it('renders Published heading', () => { + it("renders Published heading", () => { const wrapper = mount() - const sourceTypeText = wrapper.find('#span-source-type-draft-published').first().text() + const sourceTypeText = wrapper.find("#span-source-type-draft-published").first().text() // ensure it matches what is expected expect(sourceTypeText).toEqual("Published") }) - it('renders Draft Uploaded heading', () => { + it("renders Draft Uploaded heading", () => { const wrapper = mount() - const sourceTypeText = wrapper.find('#span-source-type-draft-uploaded').first().text() + const sourceTypeText = wrapper.find("#span-source-type-draft-uploaded").first().text() // ensure it matches what is expected expect(sourceTypeText).toEqual("Draft uploaded") }) - it('renders View on Customer Portal hotlink', () => { + it("renders View on Customer Portal hotlink", () => { const wrapper = mount() - wrapper.setState({ 'login': true }) - wrapper.setState({ 'releaseUpdateDate': "Fri Oct 18 2019 17:35:50 GMT-0400" }) - wrapper.setState({ 'variantUUID': "123" }) - wrapper.setState({ 'portalHost': "https://example.com" }) - const sourceTypeText = wrapper.find('a').at(0).text() + wrapper.setState({ "login": true }) + wrapper.setState({ "releaseUpdateDate": "Fri Oct 18 2019 17:35:50 GMT-0400" }) + wrapper.setState({ "variantUUID": "123" }) + wrapper.setState({ "portalHost": "https://example.com" }) + const sourceTypeText = wrapper.find("a").at(0).text() // ensure it matches what is expected expect(sourceTypeText).toContain("View on Customer Portal") }) - it('should check if draftUpdateDate exists', () => { + it("should check if draftUpdateDate exists", () => { const wrapper = shallow() - wrapper.setState({ 'login': true }) + wrapper.setState({ "login": true }) wrapper.setState({ "draftUpdateDate": "abcd" }) - expect(wrapper.state('draftUpdateDate')).toBeDefined() + expect(wrapper.state("draftUpdateDate")).toBeDefined() }) - it('should check if releaseUpdateDate exists', () => { + it("should check if releaseUpdateDate exists", () => { const wrapper = shallow() - wrapper.setState({ 'login': true }) + wrapper.setState({ "login": true }) wrapper.setState({ "releaseUpdateDate": "abcd" }) - expect(wrapper.state('releaseUpdateDate')).toBeDefined() + expect(wrapper.state("releaseUpdateDate")).toBeDefined() }) - it('should have a Title', () => { + it("should have a Title", () => { const wrapper = shallow() - wrapper.setState({ 'login': true }) + wrapper.setState({ "login": true }) wrapper.setState({ "moduleTitle": "test title" }) const sourceText = wrapper.find(Title).first().html() // ensure it matches what is expected - expect(wrapper.state('moduleTitle')).toBeDefined() + expect(wrapper.state("moduleTitle")).toBeDefined() expect(sourceText).toContain("test title") }) - it('should have a Text component of TextVariant.small', () => { + it("should have a Text component of TextVariant.small", () => { const wrapper = shallow() - wrapper.setState({ 'login': true }) + wrapper.setState({ "login": true }) expect(wrapper.find('[component="small"]').exists()); }) - it('should have a versionUUID', () => { + it("should have a versionUUID", () => { const wrapper = shallow() - wrapper.setState({ 'login': true }) + wrapper.setState({ "login": true }) wrapper.setState({ "versionUUID": "122234-1234-1234T" }) - expect(wrapper.state('versionUUID')).toBeDefined() + expect(wrapper.state("versionUUID")).toBeDefined() }) - it('should have a productValue', () => { + it("should have a productValue", () => { const wrapper = shallow() - wrapper.setState({ 'login': true }) + wrapper.setState({ "login": true }) const len = wrapper.setState({ "productValue": "Red Hat Enterprise Linux" }) - expect(wrapper.state('productValue')).toBeDefined() + expect(wrapper.state("productValue")).toBeDefined() }) - it('should have a versionValue', () => { + it("should have a versionValue", () => { const wrapper = shallow() - wrapper.setState({ 'login': true }) + wrapper.setState({ "login": true }) const len = wrapper.setState({ "versionValue": "8.x" }) - expect(wrapper.state('versionValue')).toBeDefined() + expect(wrapper.state("versionValue")).toBeDefined() }) - it('renders Copy permanent URL', () => { + it("renders Copy permanent URL", () => { const wrapper = shallow() - wrapper.setState({ 'login': true }) - wrapper.setState({ 'variantUUID': "somepath" }) - const permanentURL = wrapper.find('a#permanentURL').first() + wrapper.setState({ "login": true }) + wrapper.setState({ "variantUUID": "somepath" }) + const permanentURL = wrapper.find("a#permanentURL").first() expect(permanentURL.exists).toBeTruthy() }) - it('renders copySuccess Message', () => { + it("renders copySuccess Message", () => { const wrapper = shallow() - wrapper.setState({ 'login': true }) - wrapper.setState({ 'releasePath': "somepath" }) - wrapper.setState({ 'variantUUID': "1234" }) + wrapper.setState({ "login": true }) + wrapper.setState({ "releasePath": "somepath" }) + wrapper.setState({ "variantUUID": "1234" }) wrapper.setState({ "copySuccess": "Copied!" }) - expect(wrapper.state('copySuccess')).toContain("Copied!") + expect(wrapper.state("copySuccess")).toContain("Copied!") }) - test('copyToClipboard click event', () => { + test("copyToClipboard click event", () => { const wrapper = shallow() const instance = wrapper.instance() - const spy = sinon.spy(instance, 'copyToClipboard') + const spy = sinon.spy(instance, "copyToClipboard") - wrapper.setState({ variantUUID: '1234', releasePath: 'yarn' }) - expect(wrapper.find('#permanentURL').exists()) + wrapper.setState({ variantUUID: "1234", releasePath: "yarn" }) + expect(wrapper.find("#permanentURL").exists()) }) - it('test fetch api call for portalUrl', async () => { + it("test fetch api call for portalUrl", async () => { window.fetch = jest.fn().mockImplementation(async () => { return new Promise((resolve, reject) => { resolve({ @@ -226,7 +226,7 @@ describe('AssemblyDisplay tests', () => { }) const wrapper = await shallow() await wrapper.update() - expect(wrapper.state('portalHost')).toBe("https://example.com") + expect(wrapper.state("portalHost")).toBe("https://example.com") }) }) }) diff --git a/pantheon-bundle/frontend/src/app/assemblyDisplay.tsx b/pantheon-bundle/frontend/src/app/assemblyDisplay.tsx index 0c2c4ff97..832d8ea8f 100644 --- a/pantheon-bundle/frontend/src/app/assemblyDisplay.tsx +++ b/pantheon-bundle/frontend/src/app/assemblyDisplay.tsx @@ -1,34 +1,34 @@ -import React, { Component } from 'react' -import { CopyIcon } from '@patternfly/react-icons'; +import React, { Component } from "react" +import { CopyIcon } from "@patternfly/react-icons"; import { Level, LevelItem, Button, Divider, Title, Card, Text, TextContent, TextVariants -} from '@patternfly/react-core' -import { Versions } from '@app/versions' -import { Fields, PathPrefixes, PantheonContentTypes } from '@app/Constants' -// import { continueStatement } from '@babel/types'; +} from "@patternfly/react-core" +import { Versions } from "@app/versions" +import { Fields, PathPrefixes, PantheonContentTypes } from "@app/Constants" +// import { continueStatement } from "@babel/types"; class AssemblyDisplay extends Component { constructor(props) { super(props) this.state = { - attributesFilePath: '', - copySuccess: '', - draftPath: '', - draftUpdateDate: '', - modulePath: '', + attributesFilePath: "", + copySuccess: "", + draftPath: "", + draftUpdateDate: "", + modulePath: "", moduleTitle: "", - moduleType: '', - portalHost: '', + moduleType: "", + portalHost: "", productValue: "", productUrlFragment: "", versionUrlFragment: "", - releasePath: '', - releaseUpdateDate: '', - releaseVersion: '', + releasePath: "", + releaseUpdateDate: "", + releaseVersion: "", results: {}, - variant: 'DEFAULT', - variantUUID: '', + variant: "DEFAULT", + variantUUID: "", versionValue: "" } } @@ -41,7 +41,7 @@ class AssemblyDisplay extends Component { } public render() { - // console.log('Props: ', this.props) + // console.log("Props: ", this.props) return (
@@ -68,20 +68,20 @@ class AssemblyDisplay extends Component { - {this.state.releaseUpdateDate.trim() !== "" && this.state.releaseUpdateDate !== '-' + {this.state.releaseUpdateDate.trim() !== "" && this.state.releaseUpdateDate !== "-" && this.state.variantUUID !== "" && this.state.portalHost !== "" - && View on Customer Portal + && View on Customer Portal } - {this.state.releaseUpdateDate.trim() !== "" && this.state.releaseUpdateDate !== '-' + {this.state.releaseUpdateDate.trim() !== "" && this.state.releaseUpdateDate !== "-" && this.state.variantUUID !== "" && this.state.portalHost !== "" && Copy permanent URL } -  {this.state.copySuccess !== '' && this.state.copySuccess} +  {this.state.copySuccess !== "" && this.state.copySuccess} @@ -109,7 +109,7 @@ class AssemblyDisplay extends Component { - {this.state.productValue + ' ' + this.state.versionValue} + {this.state.productValue + " " + this.state.versionValue} @@ -120,7 +120,7 @@ class AssemblyDisplay extends Component { {this.state.draftUpdateDate.trim() !== "" && this.state.draftUpdateDate.length >= 15 ? - new Intl.DateTimeFormat('en-GB', { year: 'numeric', month: 'long', day: 'numeric' }).format(new Date(this.state.draftUpdateDate)) : "--"} + new Intl.DateTimeFormat("en-GB", { year: "numeric", month: "long", day: "numeric" }).format(new Date(this.state.draftUpdateDate)) : "--"} @@ -131,7 +131,7 @@ class AssemblyDisplay extends Component { {this.state.releaseUpdateDate.trim() !== "" && this.state.releaseUpdateDate.length >= 15 ? - new Intl.DateTimeFormat('en-GB', { year: 'numeric', month: 'long', day: 'numeric' }).format(new Date(this.state.releaseUpdateDate)) : "--"} + new Intl.DateTimeFormat("en-GB", { year: "numeric", month: "long", day: "numeric" }).format(new Date(this.state.releaseUpdateDate)) : "--"} @@ -143,7 +143,7 @@ class AssemblyDisplay extends Component { {} {} - {' '} + {" "}
@@ -172,9 +172,9 @@ class AssemblyDisplay extends Component { ) } private generateDraftHtml = (pathname: any) => { - const docPath = '/pantheon/preview/latest/' + this.state.variantUUID + '?rerender=true' + const docPath = "/pantheon/preview/latest/" + this.state.variantUUID + "?rerender=true" - // console.log('Preview path: ', docPath) + // console.log("Preview path: ", docPath) return window.open(docPath) } @@ -195,10 +195,10 @@ class AssemblyDisplay extends Component { releasePath: "/content" + path + ".preview?variant=" + this.state.variant }) - fetch(path + '/en_US.harray.4.json') + fetch(path + "/en_US.harray.4.json") .then(response => response.json()) .then(responseJSON => { - // console.log('fetch results:', responseJSON) + // console.log("fetch results:", responseJSON) // TODO: refactor for loops for (const sourceVariant of responseJSON.__children__) { if (!sourceVariant.__children__) { @@ -209,7 +209,7 @@ class AssemblyDisplay extends Component { if (!myChild.__children__) { continue } - if (myChild.__name__ === 'draft') { + if (myChild.__name__ === "draft") { this.setState({ draftUpdateDate: myChild["jcr:created"] }) } @@ -219,7 +219,7 @@ class AssemblyDisplay extends Component { } for (const offspring of myGrandchild.__children__) { - if (offspring.__name__ === 'metadata') { + if (offspring.__name__ === "metadata") { if (offspring[Fields.JCR_TITLE] !== undefined) { @@ -279,7 +279,7 @@ class AssemblyDisplay extends Component { } for (const offspring of variant.__children__) { - if (offspring.__name__ === 'metadata') { + if (offspring.__name__ === "metadata") { if (offspring[Fields.PANT_PRODUCT_VERSION_REF] !== undefined) { @@ -295,7 +295,7 @@ class AssemblyDisplay extends Component { } private getProductInitialLoad = (uuid) => { - const path = '/content/products.harray.3.json' + const path = "/content/products.harray.3.json" fetch(path) .then(response => response.json()) .then(responseJSON => { @@ -304,7 +304,7 @@ class AssemblyDisplay extends Component { continue } for (const productChild of product.__children__) { - if (productChild.__name__ !== 'versions') { + if (productChild.__name__ !== "versions") { continue } if (productChild.__children__) { @@ -321,23 +321,23 @@ class AssemblyDisplay extends Component { } private copyToClipboard = () => { - const textField = document.createElement('textarea') - if (this.state.variantUUID.trim() !== '') { - textField.value = this.state.portalHost + '/documentation/en-us/guide/' + this.state.productUrlFragment + '/' + this.state.versionUrlFragment + '/' + this.state.variantUUID + const textField = document.createElement("textarea") + if (this.state.variantUUID.trim() !== "") { + textField.value = this.state.portalHost + "/documentation/en-us/guide/" + this.state.productUrlFragment + "/" + this.state.versionUrlFragment + "/" + this.state.variantUUID document.body.appendChild(textField) textField.select() - document.execCommand('copy') + document.execCommand("copy") textField.remove() - this.setState({ copySuccess: 'Copied!' }) + this.setState({ copySuccess: "Copied!" }) } } private mouseLeave = () => { - this.setState({ copySuccess: '' }) + this.setState({ copySuccess: "" }) } private getPortalUrl = () => { - fetch('/conf/pantheon/pant:portalUrl') + fetch("/conf/pantheon/pant:portalUrl") .then(resp => { if (resp.ok) { resp.text().then(text => { @@ -350,9 +350,9 @@ class AssemblyDisplay extends Component { private async getVariantParam() { const query = new URLSearchParams(this.props.location.search); - const variantParam = query.get('variant') + const variantParam = query.get("variant") // console.log("[getVariantparam] variantParam => ", variantParam) - if (variantParam !== 'undefined') { + if (variantParam !== "undefined") { this.setState({ variant: variantParam }) } } @@ -360,12 +360,12 @@ class AssemblyDisplay extends Component { private fetchAttributesFilePath = async (data) => { await this.getVariantParam() const path = data.location.pathname.substring(PathPrefixes.ASSEBMLY_PATH_PREFIX.length) - // path = '/repositories/test-repo/entities/.../assembly_access-control-list.adoc' - let repo = '' + // path = "/repositories/test-repo/entities/.../assembly_access-control-list.adoc" + let repo = "" const group = path.split("/") repo = group[2] - fetch('/content/repositories/' + repo + '/module_variants/' + this.state.variant + '.harray.json') + fetch("/content/repositories/" + repo + "/module_variants/" + this.state.variant + ".harray.json") .then((response) => { if (response.ok) { return response.json() diff --git a/pantheon-bundle/frontend/src/app/components/Chrome/Chrome.tsx b/pantheon-bundle/frontend/src/app/components/Chrome/Chrome.tsx index f01de5dd3..0fc404407 100644 --- a/pantheon-bundle/frontend/src/app/components/Chrome/Chrome.tsx +++ b/pantheon-bundle/frontend/src/app/components/Chrome/Chrome.tsx @@ -1,4 +1,4 @@ -import * as React from 'react'; +import * as React from "react"; interface IChrome { header: React.ReactNode; diff --git a/pantheon-bundle/frontend/src/app/components/Chrome/Header/Brand/Brand.test.tsx b/pantheon-bundle/frontend/src/app/components/Chrome/Header/Brand/Brand.test.tsx index 890d9982d..ef7072fa3 100644 --- a/pantheon-bundle/frontend/src/app/components/Chrome/Header/Brand/Brand.test.tsx +++ b/pantheon-bundle/frontend/src/app/components/Chrome/Header/Brand/Brand.test.tsx @@ -1,11 +1,11 @@ -import React from 'react' -import { Brand } from './Brand' -import '@app/fetchMock' +import React from "react" +import { Brand } from "./Brand" +import "@app/fetchMock" -import { shallow } from 'enzyme' +import { shallow } from "enzyme" -describe('Brand tests', () => { - test('should render Brand component', () => { +describe("Brand tests", () => { + test("should render Brand component", () => { const view = shallow() expect(view).toMatchSnapshot() }) diff --git a/pantheon-bundle/frontend/src/app/components/Chrome/Header/Brand/Brand.tsx b/pantheon-bundle/frontend/src/app/components/Chrome/Header/Brand/Brand.tsx index 9982cd523..e50195ed1 100644 --- a/pantheon-bundle/frontend/src/app/components/Chrome/Header/Brand/Brand.tsx +++ b/pantheon-bundle/frontend/src/app/components/Chrome/Header/Brand/Brand.tsx @@ -1,10 +1,10 @@ -import React, { Component } from 'react'; +import React, { Component } from "react"; import { Link } from "react-router-dom"; -import logo from '../../../../images/Pantheon2-logo-white.png'; +import logo from "../../../../images/Pantheon2-logo-white.png"; class Brand extends Component { public state = { - linkText: 'Pantheon', + linkText: "Pantheon", logoWidth: 220 }; @@ -12,7 +12,7 @@ class Brand extends Component { return ( - +
{this.state.linkText}
diff --git a/pantheon-bundle/frontend/src/app/components/Chrome/Header/BuildInfo.test.tsx b/pantheon-bundle/frontend/src/app/components/Chrome/Header/BuildInfo.test.tsx index d6563519b..f7dd32391 100644 --- a/pantheon-bundle/frontend/src/app/components/Chrome/Header/BuildInfo.test.tsx +++ b/pantheon-bundle/frontend/src/app/components/Chrome/Header/BuildInfo.test.tsx @@ -1,17 +1,17 @@ -import React from 'react' -import { BuildInfo } from './BuildInfo' -import '@app/fetchMock' +import React from "react" +import { BuildInfo } from "./BuildInfo" +import "@app/fetchMock" -import { shallow } from 'enzyme' +import { shallow } from "enzyme" -describe('BuildInfo tests', () => { - test('should render NavLinks component', () => { +describe("BuildInfo tests", () => { + test("should render NavLinks component", () => { const view = shallow() expect(view).toMatchSnapshot() }) - test('getBuildInfo call', () => { - const spy = jest.spyOn(BuildInfo.prototype, 'getBuildInfo') + test("getBuildInfo call", () => { + const spy = jest.spyOn(BuildInfo.prototype, "getBuildInfo") shallow() expect(spy).toHaveBeenCalled() diff --git a/pantheon-bundle/frontend/src/app/components/Chrome/Header/BuildInfo.tsx b/pantheon-bundle/frontend/src/app/components/Chrome/Header/BuildInfo.tsx index df633fe2f..e97792efa 100644 --- a/pantheon-bundle/frontend/src/app/components/Chrome/Header/BuildInfo.tsx +++ b/pantheon-bundle/frontend/src/app/components/Chrome/Header/BuildInfo.tsx @@ -1,11 +1,11 @@ -import React, { Component } from 'react'; +import React, { Component } from "react"; import { Link } from "react-router-dom"; class BuildInfo extends Component { public state = { - buildDate: '', - commitHash: '', - commitText: '' + buildDate: "", + commitHash: "", + commitText: "" }; public componentDidMount() { @@ -28,7 +28,7 @@ class BuildInfo extends Component { public getBuildInfo() { const backend = "/pantheon/builddate.json" - if (this.state.buildDate === '') { + if (this.state.buildDate === "") { fetch(backend) .then(response => response.json()) .then(responseJSON => this.setState({ buildDate: "Build Date: " + responseJSON.buildDate, commitHash: responseJSON.commitHash })) diff --git a/pantheon-bundle/frontend/src/app/components/Chrome/Header/Header.tsx b/pantheon-bundle/frontend/src/app/components/Chrome/Header/Header.tsx index 598702ed6..7e0cf9213 100644 --- a/pantheon-bundle/frontend/src/app/components/Chrome/Header/Header.tsx +++ b/pantheon-bundle/frontend/src/app/components/Chrome/Header/Header.tsx @@ -1,9 +1,9 @@ -import React from 'react' -import { PageHeader, Brand } from '@patternfly/react-core' -// import { Brand } from '../Header/Brand/Brand' -import { User } from '../Header/User' -import { IAppState } from '@app/app' -import logo from '../../../images/Pantheon2-logo-white.png'; +import React from "react" +import { PageHeader, Brand } from "@patternfly/react-core" +// import { Brand } from "../Header/Brand/Brand" +import { User } from "../Header/User" +import { IAppState } from "@app/app" +import logo from "../../../images/Pantheon2-logo-white.png"; export interface IHeaderProps { isNavOpen: boolean @@ -21,9 +21,9 @@ export const Header: React.FunctionComponent = ({ logo={} logoProps={ { - 'href': '/', + "href": "/", // @todo Replace in CSS file when a project stylesheet has been setup - 'style': {'maxWidth': '220px'} + "style": {"maxWidth": "220px"} } } headerTools={} diff --git a/pantheon-bundle/frontend/src/app/components/Chrome/Header/User.test.tsx b/pantheon-bundle/frontend/src/app/components/Chrome/Header/User.test.tsx index 7a3721bb6..ba00a04a5 100644 --- a/pantheon-bundle/frontend/src/app/components/Chrome/Header/User.test.tsx +++ b/pantheon-bundle/frontend/src/app/components/Chrome/Header/User.test.tsx @@ -1,37 +1,37 @@ -import React from 'react' -import { User } from './User' -import '@app/fetchMock' +import React from "react" +import { User } from "./User" +import "@app/fetchMock" import { Link } from "react-router-dom" -import { HashRouter as Router } from 'react-router-dom' -import { shallow, mount } from 'enzyme' -import renderer from 'react-test-renderer' -import { mockStateUser } from '@app/TestResources' +import { HashRouter as Router } from "react-router-dom" +import { shallow, mount } from "enzyme" +import renderer from "react-test-renderer" +import { mockStateUser } from "@app/TestResources" -describe('User tests', () => { - test('should render User component', () => { +describe("User tests", () => { + test("should render User component", () => { const view = shallow() expect(view).toMatchSnapshot() }) - it('should render a Link component', () => { + it("should render a Link component", () => { const wrapper = mount() const navLinks = wrapper.find(Link) expect(navLinks.exists()).toBe(true) }) - it('test render function', () => { + it("test render function", () => { const wrapper = renderer.create() const inst = wrapper.getInstance() expect(inst.render).toMatchSnapshot() }) - it('test conditionalRedirect function', () => { + it("test conditionalRedirect function", () => { const wrapper = renderer.create() const inst = wrapper.getInstance() expect(inst.conditionalRedirect).toMatchSnapshot() }) - it('test componentDidMount function', () => { + it("test componentDidMount function", () => { const wrapper = renderer.create() const inst = wrapper.getInstance() expect(inst.componentDidMount).toMatchSnapshot() diff --git a/pantheon-bundle/frontend/src/app/components/Chrome/Header/User.tsx b/pantheon-bundle/frontend/src/app/components/Chrome/Header/User.tsx index 746cfc706..75ac69037 100644 --- a/pantheon-bundle/frontend/src/app/components/Chrome/Header/User.tsx +++ b/pantheon-bundle/frontend/src/app/components/Chrome/Header/User.tsx @@ -1,13 +1,13 @@ -import React, { Component } from 'react' -import { Link } from 'react-router-dom' +import React, { Component } from "react" +import { Link } from "react-router-dom" import { Button, Dropdown, DropdownToggle, DropdownItem, Modal, DropdownPosition -} from '@patternfly/react-core' -import { HelpIcon } from '@patternfly/react-icons' +} from "@patternfly/react-core" +import { HelpIcon } from "@patternfly/react-icons" -import { IAppState } from '@app/app' +import { IAppState } from "@app/app" interface IState { helpDropdownOpen: boolean @@ -25,16 +25,16 @@ class User extends Component { public render() { const dropdownItems = [ - Help, - Contribute to Pantheon + Help, + Contribute to Pantheon ] const placeHolderModalButtons = [ - + ] return ( - @@ -51,9 +51,9 @@ class User extends Component { dropdownItems={dropdownItems} position={DropdownPosition.right} /> - - {this.props.userAuthenticated ? 'Log Out [' + this.props.username + ']' : 'Log In'} + {this.props.userAuthenticated ? "Log Out [" + this.props.username + "]" : "Log In"} ) @@ -79,8 +79,8 @@ class User extends Component { private conditionalRedirect = () => { if (this.props.userAuthenticated) { - fetch('/system/sling/logout') - .then(response => window.location.href = '/pantheon') + fetch("/system/sling/logout") + .then(response => window.location.href = "/pantheon") } } } diff --git a/pantheon-bundle/frontend/src/app/components/Chrome/Sidebar/NavLinks.test.tsx b/pantheon-bundle/frontend/src/app/components/Chrome/Sidebar/NavLinks.test.tsx index 3fd542ca3..828a26bea 100644 --- a/pantheon-bundle/frontend/src/app/components/Chrome/Sidebar/NavLinks.test.tsx +++ b/pantheon-bundle/frontend/src/app/components/Chrome/Sidebar/NavLinks.test.tsx @@ -1,51 +1,51 @@ -import React from 'react' -import { NavLinks } from './NavLinks' -import { NavList, NavItem, NavExpandable } from '@patternfly/react-core' -import { HashRouter as Router } from 'react-router-dom' - -import { mount, shallow } from 'enzyme' -import { Link } from 'react-router-dom' -import renderer from 'react-test-renderer' -import { mockStateUser, mockStateGuest, mockStateAdmin } from '@app/TestResources' - -describe('NavLinks tests', () => { - test('should render NavLinks component', () => { +import React from "react" +import { NavLinks } from "./NavLinks" +import { NavList, NavItem, NavExpandable } from "@patternfly/react-core" +import { HashRouter as Router } from "react-router-dom" + +import { mount, shallow } from "enzyme" +import { Link } from "react-router-dom" +import renderer from "react-test-renderer" +import { mockStateUser, mockStateGuest, mockStateAdmin } from "@app/TestResources" + +describe("NavLinks tests", () => { + test("should render NavLinks component", () => { const view = shallow() expect(view).toMatchSnapshot() }) - it('should render a NavList', () => { + it("should render a NavList", () => { const wrapper = shallow() const navList = wrapper.find(NavList) expect(navList.exists()).toBe(true) }) - it('should render a NavItem', () => { + it("should render a NavItem", () => { const wrapper = shallow() const navItem = wrapper.find(NavItem) expect(navItem.exists()).toBe(true) }) - it('should render a Link component', () => { + it("should render a Link component", () => { const wrapper = shallow() const navLinks = wrapper.find(Link) expect(navLinks.exists()).toBe(true) }) - it('should render an Expandable component', () => { + it("should render an Expandable component", () => { const wrapper = shallow() const expandable = wrapper.find(NavExpandable) expect(expandable.exists()).toBe(true) }) - it('should contain 1 NavItem without authentication', () => { + it("should contain 1 NavItem without authentication", () => { const wrapper = shallow() const items = wrapper.find(NavItem) expect(items).toHaveLength(1) }) - it('should handle state changes for isLoggedIn', () => { + it("should handle state changes for isLoggedIn", () => { const wrapper = shallow() const navGroup1 = wrapper.find('[groupId="grp-1"]') expect(navGroup1.length).toBe(3) @@ -53,58 +53,58 @@ describe('NavLinks tests', () => { expect(navGroup2.length).toBe(3) }) - it('should handle state changes for isAdmin', () => { + it("should handle state changes for isAdmin", () => { const wrapper = shallow() const navGroup3 = wrapper.find('[groupId="grp-3"]') expect(navGroup3.length).toBe(4) }) - it('test browserLink function', () => { + it("test browserLink function", () => { const wrapper = renderer.create() const inst = wrapper.getInstance() expect(inst.browserLink).toMatchSnapshot() }) - it('test welcomeLink function', () => { + it("test welcomeLink function", () => { const wrapper = renderer.create() const inst = wrapper.getInstance() expect(inst.welcomeLink).toMatchSnapshot() }) - it('test webConsole function', () => { + it("test webConsole function", () => { const wrapper = renderer.create() const inst = wrapper.getInstance() expect(inst.consoleLink).toMatchSnapshot() }) - it('test render function', () => { + it("test render function", () => { const wrapper = renderer.create() const inst = wrapper.getInstance() expect(inst.render).toMatchSnapshot() }) - it('test checkAuth function', () => { + it("test checkAuth function", () => { const wrapper = renderer.create() const inst = wrapper.getInstance() expect(inst.checkAuth).toMatchSnapshot() }) - it('test onExpandableSelect function', () => { + it("test onExpandableSelect function", () => { const wrapper = renderer.create() const inst = wrapper.getInstance() expect(inst.onExpandableSelect).toMatchSnapshot() }) - it('test handleItemOnclick function', () => { + it("test handleItemOnclick function", () => { const wrapper = renderer.create() const inst = wrapper.getInstance() expect(inst.handleItemOnclick).toMatchSnapshot() }) - it('test Admin Panel links', () => { - jest.mock('./NavLinks', () => { + it("test Admin Panel links", () => { + jest.mock("./NavLinks", () => { // Require the original module to not be mocked... - const originalModule = jest.requireActual('./NavLinks') + const originalModule = jest.requireActual("./NavLinks") return { __esModule: true, // Use it when dealing with esModules @@ -116,9 +116,9 @@ describe('NavLinks tests', () => { } }) - const browserLink = require('./NavLinks').browserLink - const consoleLink = require('./NavLinks').consoleLink - const welcomeLink = require('./NavLinks').welcomeLink + const browserLink = require("./NavLinks").browserLink + const consoleLink = require("./NavLinks").consoleLink + const welcomeLink = require("./NavLinks").welcomeLink expect(browserLink()).toBe('window.open("/bin/browser.html")') expect(consoleLink()).toBe('window.open("/system/console/bundles.html")') @@ -126,13 +126,13 @@ describe('NavLinks tests', () => { jest.resetAllMocks() }) - it('calls render function', () => { + it("calls render function", () => { const render = jest.fn() render() expect(render).toHaveBeenCalled() }) - it('test fetch api call', async () => { + it("test fetch api call", async () => { window.fetch = jest.fn().mockImplementation(async () => { return new Promise((resolve, reject) => { resolve({ @@ -149,9 +149,9 @@ describe('NavLinks tests', () => { }) const wrapper = await shallow() await wrapper.update() - expect(wrapper.state('getUserInfo')).toBe(true) - expect(wrapper.state('isLoggedIn')).toBe(true) - expect(wrapper.state('isAdmin')).toBe(false) + expect(wrapper.state("getUserInfo")).toBe(true) + expect(wrapper.state("isLoggedIn")).toBe(true) + expect(wrapper.state("isAdmin")).toBe(false) }) }) }) \ No newline at end of file diff --git a/pantheon-bundle/frontend/src/app/components/Chrome/Sidebar/NavLinks.tsx b/pantheon-bundle/frontend/src/app/components/Chrome/Sidebar/NavLinks.tsx index ed1cc7908..a147eafde 100644 --- a/pantheon-bundle/frontend/src/app/components/Chrome/Sidebar/NavLinks.tsx +++ b/pantheon-bundle/frontend/src/app/components/Chrome/Sidebar/NavLinks.tsx @@ -1,105 +1,105 @@ -import React, { Component } from 'react' -import { NavItem, NavExpandable, NavList } from '@patternfly/react-core' +import React, { Component } from "react" +import { NavItem, NavExpandable, NavList } from "@patternfly/react-core" import { Link } from "react-router-dom" -import { IAppState } from '@app/app' +import { IAppState } from "@app/app" // BASE is used in the fetch call to check if isLoggedIn or isAdmin. It currently breaks the Navlinks. // only search is displayed when BASE is consumed. -// const BASE = process.env.BROWSER? '': `http://localhost`; +// const BASE = process.env.BROWSER? "": `http://localhost`; class NavLinks extends Component { constructor(props) { super(props) this.state = { - activeGroup: '', - activeItem: '', - expandableClickedGroup: '', - expandableClickedItem: '', + activeGroup: "", + activeItem: "", + expandableClickedGroup: "", + expandableClickedItem: "", gotUserInfo: false, isDropdownOpen: false, isKebabDropdownOpen: false } } public render() { - const browserText = 'Content Browser' - const consoleText = 'Web Console' - const gitText = 'Git Import' - const productText = 'New Product' - const productsText = 'Product Listing' - const searchText = 'Search' - const slingHomeText = 'Sling Welcome' + const browserText = "Content Browser" + const consoleText = "Web Console" + const gitText = "Git Import" + const productText = "New Product" + const productsText = "Product Listing" + const searchText = "Search" + const slingHomeText = "Sling Welcome" return ( - + - {searchText} + {searchText} {(this.props.userAuthenticated) && ( - {gitText} + {gitText} )} - {(this.props.userAuthenticated) && ( + {(this.props.userAuthenticated) && ( - {productsText} + {productsText} {(productText.length > 0) && ( - {productText} + {productText} )} )} - {(this.props.userAuthenticated) && this.props.isAdmin && ( + {(this.props.userAuthenticated) && this.props.isAdmin && ( - {slingHomeText} + {slingHomeText} - {browserText} + {browserText} - {consoleText} + {consoleText} )} diff --git a/pantheon-bundle/frontend/src/app/components/Chrome/Sidebar/Sidebar.test.tsx b/pantheon-bundle/frontend/src/app/components/Chrome/Sidebar/Sidebar.test.tsx index cb01086e5..24a3771cc 100644 --- a/pantheon-bundle/frontend/src/app/components/Chrome/Sidebar/Sidebar.test.tsx +++ b/pantheon-bundle/frontend/src/app/components/Chrome/Sidebar/Sidebar.test.tsx @@ -1,26 +1,26 @@ -import React from 'react' -import { Sidebar } from './Sidebar' -import { NavList } from '@patternfly/react-core' -import { NavLinks } from './NavLinks' -import { BuildInfo } from '../Header/BuildInfo' -import { mount, shallow } from 'enzyme' -import { HashRouter as Router } from 'react-router-dom' -import '@app/fetchMock' -import { mockStateUser } from '@app/TestResources' +import React from "react" +import { Sidebar } from "./Sidebar" +import { NavList } from "@patternfly/react-core" +import { NavLinks } from "./NavLinks" +import { BuildInfo } from "../Header/BuildInfo" +import { mount, shallow } from "enzyme" +import { HashRouter as Router } from "react-router-dom" +import "@app/fetchMock" +import { mockStateUser } from "@app/TestResources" -describe('Sidebar tests', () => { - test('should render Sidebar component', () => { +describe("Sidebar tests", () => { + test("should render Sidebar component", () => { const view = shallow() expect(view).toMatchSnapshot() }) - it('should render a NavList', () => { + it("should render a NavList", () => { const wrapper = mount() const navList = wrapper.find(NavList) expect(navList.exists()).toBe(true) }) - it('should render a NavLinks component', () => { + it("should render a NavLinks component", () => { const wrapper = mount() const navLinks = wrapper.find(NavLinks) expect(navLinks.exists()).toBe(true) diff --git a/pantheon-bundle/frontend/src/app/components/Chrome/Sidebar/Sidebar.tsx b/pantheon-bundle/frontend/src/app/components/Chrome/Sidebar/Sidebar.tsx index b607e3acc..3da15339f 100644 --- a/pantheon-bundle/frontend/src/app/components/Chrome/Sidebar/Sidebar.tsx +++ b/pantheon-bundle/frontend/src/app/components/Chrome/Sidebar/Sidebar.tsx @@ -1,7 +1,7 @@ -import * as React from 'react' -import { PageSidebar, Nav, NavList } from '@patternfly/react-core' -import { NavLinks } from './NavLinks' -import { IAppState } from '@app/app' +import * as React from "react" +import { PageSidebar, Nav, NavList } from "@patternfly/react-core" +import { NavLinks } from "./NavLinks" +import { IAppState } from "@app/app" export interface ISideBarProps { isNavOpen: boolean diff --git a/pantheon-bundle/frontend/src/app/gitImport.test.tsx b/pantheon-bundle/frontend/src/app/gitImport.test.tsx index 337f48fa1..fe8ea5835 100644 --- a/pantheon-bundle/frontend/src/app/gitImport.test.tsx +++ b/pantheon-bundle/frontend/src/app/gitImport.test.tsx @@ -8,40 +8,40 @@ import { Bullseye, TextInput, FormGroup, Button } from '@patternfly/react-core' import sinon from 'sinon' import renderer from 'react-test-renderer' -describe('Login tests', () => { - test('should render Login component', () => { +describe("Login tests", () => { + test("should render Login component", () => { const view = shallow() expect(view).toMatchSnapshot() }) - it('should render a Bullseye layout', () => { + it("should render a Bullseye layout", () => { const wrapper = mount() const bullseyeLayout = wrapper.find(Bullseye) expect(bullseyeLayout.exists()).toBe(true) }) - it('should render a form group', () => { + it("should render a form group", () => { const wrapper = mount() const formGroup = wrapper.find(FormGroup) expect(formGroup.exists()).toBe(true) }) - it('should render a text input', () => { + it("should render a text input", () => { const wrapper = mount() const textInput = wrapper.find(TextInput) expect(textInput.exists()).toBe(true) }) - it('should render a Button', () => { + it("should render a Button", () => { const wrapper = mount() const button = wrapper.find(Button) expect(button.exists()).toBe(true) }) - it('test onChangeSort function', () => { + it("test onChangeSort function", () => { const wrapper = renderer.create() const inst = wrapper.getInstance() - const spy = sinon.spy(inst, 'cloneRepo') + const spy = sinon.spy(inst, "cloneRepo") inst.cloneRepo() sinon.assert.called(spy) inst.setState({ repository: "http" }) diff --git a/pantheon-bundle/frontend/src/app/gitImport.tsx b/pantheon-bundle/frontend/src/app/gitImport.tsx index e82ee3110..88778c39e 100644 --- a/pantheon-bundle/frontend/src/app/gitImport.tsx +++ b/pantheon-bundle/frontend/src/app/gitImport.tsx @@ -1,18 +1,18 @@ -import React, { Component } from 'react'; -import { Bullseye, Button, Alert, Modal, AlertActionCloseButton, FormGroup, TextInput, ModalVariant } from '@patternfly/react-core'; -import '@app/app.css'; -import { Redirect } from 'react-router-dom' +import React, { Component } from "react"; +import { Bullseye, Button, Alert, Modal, AlertActionCloseButton, FormGroup, TextInput, ModalVariant } from "@patternfly/react-core"; +import "@app/app.css"; +import { Redirect } from "react-router-dom" class GitImport extends Component { public state = { - branch: '', - git2pantheonURL: '', + branch: "", + git2pantheonURL: "", isFormSubmitted: false, isMissingFields: false, isSucess: false, redirect: false, - repository: '', - submitMsg: '' + repository: "", + submitMsg: "" }; public render() { @@ -91,7 +91,7 @@ class GitImport extends Component { if (this.state.repository === "") { this.setState({ isMissingFields: true }) } else { - fetch('/conf/pantheon/pant:syncServiceUrl') + fetch("/conf/pantheon/pant:syncServiceUrl") .then((resp => { if (!resp.ok) { this.setState({ isFormSubmitted: true, isSucess: false, msgType: "danger", submitMsg: "Error occurred, could not find the git2pantheon URL configuration." }) @@ -143,7 +143,7 @@ class GitImport extends Component { private renderRedirect = () => { if (this.state.redirect) { - return + return } else { return "" } diff --git a/pantheon-bundle/frontend/src/app/login.test.tsx b/pantheon-bundle/frontend/src/app/login.test.tsx index 3599bfeaf..8e59f0ea0 100644 --- a/pantheon-bundle/frontend/src/app/login.test.tsx +++ b/pantheon-bundle/frontend/src/app/login.test.tsx @@ -1,47 +1,47 @@ -import React from 'react' -import { Login } from '@app/login' -import '@app/fetchMock' +import React from "react" +import { Login } from "@app/login" +import "@app/fetchMock" -import { mount, shallow } from 'enzyme' -import { Bullseye, TextInput, FormGroup, Button } from '@patternfly/react-core' +import { mount, shallow } from "enzyme" +import { Bullseye, TextInput, FormGroup, Button } from "@patternfly/react-core" -import renderer from 'react-test-renderer' -import sinon from 'sinon' +import renderer from "react-test-renderer" +import sinon from "sinon" -describe('Login tests', () => { - test('should render Login component', () => { +describe("Login tests", () => { + test("should render Login component", () => { const view = shallow() expect(view).toMatchSnapshot() }) - it('should render a form group', () => { + it("should render a form group", () => { const wrapper = mount() const formGroup = wrapper.find(FormGroup) expect(formGroup.exists()).toBe(true) }) - it('should render a text input', () => { + it("should render a text input", () => { const wrapper = mount() const textInput = wrapper.find(TextInput) expect(textInput.exists()).toBe(true) }) - it('should render a Button', () => { + it("should render a Button", () => { const wrapper = mount() const button = wrapper.find(Button) expect(button.exists()).toBe(true) }) - it('should render a Bullseye layout', () => { + it("should render a Bullseye layout", () => { const wrapper = mount() const bullseyeLayout = wrapper.find(Bullseye) expect(bullseyeLayout.exists()).toBe(true) }) - it('test login function', () => { + it("test login function", () => { const wrapper = renderer.create() const inst = wrapper.getInstance() - const spy = sinon.spy(inst, 'login') + const spy = sinon.spy(inst, "login") inst.login() sinon.assert.called(spy) }) diff --git a/pantheon-bundle/frontend/src/app/login.tsx b/pantheon-bundle/frontend/src/app/login.tsx index ba66a01e5..56df95040 100644 --- a/pantheon-bundle/frontend/src/app/login.tsx +++ b/pantheon-bundle/frontend/src/app/login.tsx @@ -1,14 +1,14 @@ -import React, { Component } from 'react'; -import { Bullseye, Button, Alert, AlertActionCloseButton, FormGroup, TextInput } from '@patternfly/react-core'; -import '@app/app.css'; +import React, { Component } from "react"; +import { Bullseye, Button, Alert, AlertActionCloseButton, FormGroup, TextInput } from "@patternfly/react-core"; +import "@app/app.css"; class Login extends Component { constructor(props) { super(props) this.state = { - authMessage: '', - password: '', - username: '' + authMessage: "", + password: "", + username: "" }; } @@ -44,7 +44,7 @@ class Login extends Component { } private onLoginKeyPress = (event) => { - if (event.key === 'Enter') { + if (event.key === "Enter") { this.login() } } @@ -58,7 +58,7 @@ class Login extends Component { } private resetAuthMessage = () => { - this.setState({ authMessage: '' }) + this.setState({ authMessage: "" }) } private onUsernameChange = username => { @@ -74,9 +74,9 @@ class Login extends Component { formData.append("j_username", this.state.username) formData.append("j_password", this.state.password) - fetch('/j_security_check', { + fetch("/j_security_check", { body: formData, - method: 'post', + method: "post", }).then(response => { if (response.status === 200) { console.log(" Works " + response.status) diff --git a/pantheon-bundle/frontend/src/app/moduleDisplay.test.tsx b/pantheon-bundle/frontend/src/app/moduleDisplay.test.tsx index 62b4d1cf9..f691d7e62 100644 --- a/pantheon-bundle/frontend/src/app/moduleDisplay.test.tsx +++ b/pantheon-bundle/frontend/src/app/moduleDisplay.test.tsx @@ -1,250 +1,250 @@ -import React from 'react' -import { ModuleDisplay } from '@app/moduleDisplay' -import '@app/fetchMock' +import React from "react" +import { ModuleDisplay } from "@app/moduleDisplay" +import "@app/fetchMock" -import { mount, shallow } from 'enzyme' -import { Button, Card, DataList, DataListItem, DataListItemCells, DataListItemRow, DataListCell, TextContent, Level, LevelItem, Breadcrumb, BreadcrumbItem, Title, Divider } from '@patternfly/react-core' -import renderer from 'react-test-renderer' -import sinon from 'sinon' -import { Versions } from '@app/versions' -const anymatch = require('anymatch') +import { mount, shallow } from "enzyme" +import { Button, Card, DataList, DataListItem, DataListItemCells, DataListItemRow, DataListCell, TextContent, Level, LevelItem, Breadcrumb, BreadcrumbItem, Title, Divider } from "@patternfly/react-core" +import renderer from "react-test-renderer" +import sinon from "sinon" +import { Versions } from "@app/versions" +const anymatch = require("anymatch") const props = { location: { pathname: "module/test" } } -describe('ModuleDisplay tests', () => { - test('should render ModuleDisplay component', () => { +describe("ModuleDisplay tests", () => { + test("should render ModuleDisplay component", () => { const view = shallow() expect(view).toMatchSnapshot() }) - it('should render a Button', () => { + it("should render a Button", () => { const wrapper = mount() const button = wrapper.find(Button) expect(button.exists()).toBe(true) }) - it('should render a Card', () => { + it("should render a Card", () => { const wrapper = mount() const card = wrapper.find(Card) expect(card.exists()).toBe(true) }) - it('should render a TextContent Element', () => { + it("should render a TextContent Element", () => { const wrapper = mount() const textContent = wrapper.find(TextContent) expect(textContent.exists()).toBe(true) }) - it('should render a Level Element', () => { + it("should render a Level Element", () => { const wrapper = mount() const level = wrapper.find(Level) expect(level.exists()).toBe(true) }) - it('should render a LevelItem', () => { + it("should render a LevelItem", () => { const wrapper = mount() const levelItem = wrapper.find(LevelItem) expect(levelItem.exists()).toBe(true) }) - it('should render a Versions Element', () => { + it("should render a Versions Element", () => { const wrapper = mount() const versions = wrapper.find(Versions) expect(versions.exists()).toBe(true) }) - it('should render a Divider Element', () => { + it("should render a Divider Element", () => { const wrapper = mount() const divider = wrapper.find(Divider) expect(divider.exists()).toBe(true) }) - it('test fetchModuleDetails function', () => { + it("test fetchModuleDetails function", () => { const wrapper = renderer.create() const inst = wrapper.getInstance() expect(inst.fetchModuleDetails(props)).toMatchSnapshot() }) - // it('test getProduct function', () => { + // it("test getProduct function", () => { // const wrapper = renderer.create() // const inst = wrapper.getInstance() // expect(inst.getProduct()).toMatchSnapshot() // }) - // it('test getVersion function', () => { + // it("test getVersion function", () => { // const wrapper = renderer.create() // const inst = wrapper.getInstance() // expect(inst.getVersion()).toMatchSnapshot() // }) - it('test getVersionUUID function', () => { + it("test getVersionUUID function", () => { const wrapper = renderer.create() const inst = wrapper.getInstance() expect(inst.getVersionUUID("/modules/test")).toMatchSnapshot() }) - it('test getProductInitialLoad function', () => { + it("test getProductInitialLoad function", () => { const wrapper = renderer.create() const inst = wrapper.getInstance() expect(inst.getProductInitialLoad()).toMatchSnapshot() }) - it('test componentDidMount function', () => { + it("test componentDidMount function", () => { const wrapper = renderer.create() const inst = wrapper.getInstance() expect(inst.componentDidMount()).toMatchSnapshot() }) - it('test getPortalUrl function', () => { + it("test getPortalUrl function", () => { const wrapper = renderer.create() const inst = wrapper.getInstance() expect(inst.getPortalUrl()).toMatchSnapshot() }) - it('has a props', () => { + it("has a props", () => { const moduleDisplay = mount().matchesElement expect(moduleDisplay.length === 1) }) // Value testing with Enzyme. - it('renders Product heading', () => { + it("renders Product heading", () => { const wrapper = mount() - const sourceTypeText = wrapper.find('#span-source-type-product').first().text() + const sourceTypeText = wrapper.find("#span-source-type-product").first().text() // ensure it matches what is expected expect(sourceTypeText).toEqual("Product") }) - it('renders Published heading', () => { + it("renders Published heading", () => { const wrapper = mount() - const sourceTypeText = wrapper.find('#span-source-type-published').first().text() + const sourceTypeText = wrapper.find("#span-source-type-published").first().text() // ensure it matches what is expected expect(sourceTypeText).toEqual("Published") }) - it('renders Draft Uploaded heading', () => { + it("renders Draft Uploaded heading", () => { const wrapper = mount() - const sourceTypeText = wrapper.find('#span-source-type-draft-uploaded').first().text() + const sourceTypeText = wrapper.find("#span-source-type-draft-uploaded").first().text() // ensure it matches what is expected expect(sourceTypeText).toEqual("Draft uploaded") }) - it('renders Module Type heading', () => { + it("renders Module Type heading", () => { const wrapper = mount() - const sourceTypeText = wrapper.find('#span-source-name-module-type').first().text() + const sourceTypeText = wrapper.find("#span-source-name-module-type").first().text() // ensure it matches what is expected expect(sourceTypeText).toEqual("Module type") }) - it('renders View on Customer Portal hotlink', () => { + it("renders View on Customer Portal hotlink", () => { const wrapper = mount() - wrapper.setState({ 'login': true }) - wrapper.setState({ 'releaseUpdateDate': "Fri Oct 18 2019 17:35:50 GMT-0400" }) - wrapper.setState({ 'variantUUID': "123" }) - wrapper.setState({ 'portalUrl': "https://example.com" }) - const sourceTypeText = wrapper.find('a').at(0).text() + wrapper.setState({ "login": true }) + wrapper.setState({ "releaseUpdateDate": "Fri Oct 18 2019 17:35:50 GMT-0400" }) + wrapper.setState({ "variantUUID": "123" }) + wrapper.setState({ "portalUrl": "https://example.com" }) + const sourceTypeText = wrapper.find("a").at(0).text() // ensure it matches what is expected expect(sourceTypeText).toContain("View on Customer Portal") }) - it('should check if draftUpdateDate exists', () => { + it("should check if draftUpdateDate exists", () => { const wrapper = shallow() - wrapper.setState({ 'login': true }) + wrapper.setState({ "login": true }) wrapper.setState({ "draftUpdateDate": "abcd" }) - expect(wrapper.state('draftUpdateDate')).toBeDefined() + expect(wrapper.state("draftUpdateDate")).toBeDefined() }) - it('should check if releaseUpdateDate exists', () => { + it("should check if releaseUpdateDate exists", () => { const wrapper = shallow() - wrapper.setState({ 'login': true }) + wrapper.setState({ "login": true }) wrapper.setState({ "releaseUpdateDate": "abcd" }) - expect(wrapper.state('releaseUpdateDate')).toBeDefined() + expect(wrapper.state("releaseUpdateDate")).toBeDefined() }) - it('should check if moduleType exists', () => { + it("should check if moduleType exists", () => { const wrapper = shallow() - wrapper.setState({ 'moduleType': '' }) + wrapper.setState({ "moduleType": "" }) wrapper.setState({ "moduleType": "module" }) - expect(wrapper.state('moduleType')).toBeDefined() + expect(wrapper.state("moduleType")).toBeDefined() }) - it('should have a Title', () => { + it("should have a Title", () => { const wrapper = shallow() - wrapper.setState({ 'login': true }) + wrapper.setState({ "login": true }) wrapper.setState({ "moduleTitle": "test title" }) const sourceText = wrapper.find(Title).first().html() // ensure it matches what is expected - expect(wrapper.state('moduleTitle')).toBeDefined() + expect(wrapper.state("moduleTitle")).toBeDefined() expect(sourceText).toContain("test title") }) - it('should have a Text component of TextVariant.small', () => { + it("should have a Text component of TextVariant.small", () => { const wrapper = shallow() - wrapper.setState({ 'login': true }) - expect(wrapper.find('[component="small"]').exists()); + wrapper.setState({ "login": true }) + expect(wrapper.find("[component='small']").exists()); }) - it('should have a versionUUID', () => { + it("should have a versionUUID", () => { const wrapper = shallow() - wrapper.setState({ 'login': true }) + wrapper.setState({ "login": true }) wrapper.setState({ "versionUUID": "122234-1234-1234T" }) - expect(wrapper.state('versionUUID')).toBeDefined() + expect(wrapper.state("versionUUID")).toBeDefined() }) - it('should have a productValue', () => { + it("should have a productValue", () => { const wrapper = shallow() - wrapper.setState({ 'login': true }) + wrapper.setState({ "login": true }) const len = wrapper.setState({ "productValue": "Red Hat Enterprise Linux" }) - expect(wrapper.state('productValue')).toBeDefined() + expect(wrapper.state("productValue")).toBeDefined() }) - it('should have a versionValue', () => { + it("should have a versionValue", () => { const wrapper = shallow() - wrapper.setState({ 'login': true }) + wrapper.setState({ "login": true }) const len = wrapper.setState({ "versionValue": "8.x" }) - expect(wrapper.state('versionValue')).toBeDefined() + expect(wrapper.state("versionValue")).toBeDefined() }) - it('renders Copy permanent URL', () => { + it("renders Copy permanent URL", () => { const wrapper = shallow() - wrapper.setState({ 'login': true }) - wrapper.setState({ 'variantUUID': "somepath" }) - const permanentURL = wrapper.find('a#permanentURL').first() + wrapper.setState({ "login": true }) + wrapper.setState({ "variantUUID": "somepath" }) + const permanentURL = wrapper.find("a#permanentURL").first() expect(permanentURL.exists).toBeTruthy() }) - it('renders copySuccess Message', () => { + it("renders copySuccess Message", () => { const wrapper = shallow() - wrapper.setState({ 'login': true }) - wrapper.setState({ 'releasePath': "somepath" }) - wrapper.setState({ 'variantUUID': "1234" }) + wrapper.setState({ "login": true }) + wrapper.setState({ "releasePath": "somepath" }) + wrapper.setState({ "variantUUID": "1234" }) wrapper.setState({ "copySuccess": "Copied!" }) - expect(wrapper.state('copySuccess')).toContain("Copied!") + expect(wrapper.state("copySuccess")).toContain("Copied!") }) - test('copyToClipboard click event', () => { + test("copyToClipboard click event", () => { const wrapper = shallow() const instance = wrapper.instance() - const spy = sinon.spy(instance, 'copyToClipboard') + const spy = sinon.spy(instance, "copyToClipboard") - wrapper.setState({ variantUUID: '1234', releasePath: 'yarn' }) - expect(wrapper.find('#permanentURL').exists()) + wrapper.setState({ variantUUID: "1234", releasePath: "yarn" }) + expect(wrapper.find("#permanentURL").exists()) }) - // it('test mouseLeave function', () => { + // it("test mouseLeave function", () => { // const wrapper = renderer.create() // const inst = wrapper.getInstance() // expect(inst.mouseLeave()).toMatchSnapshot() // }) - it('test fetch api call for portalUrl', async () => { + it("test fetch api call for portalUrl", async () => { window.fetch = jest.fn().mockImplementation(async () => { return new Promise((resolve, reject) => { resolve({ @@ -259,7 +259,7 @@ describe('ModuleDisplay tests', () => { }) const wrapper = await shallow() await wrapper.update() - expect(wrapper.state('portalHost')).toBe("https://example.com") + expect(wrapper.state("portalHost")).toBe("https://example.com") }) }) }) diff --git a/pantheon-bundle/frontend/src/app/moduleDisplay.tsx b/pantheon-bundle/frontend/src/app/moduleDisplay.tsx index 94cb12c33..6a5ff2e7a 100644 --- a/pantheon-bundle/frontend/src/app/moduleDisplay.tsx +++ b/pantheon-bundle/frontend/src/app/moduleDisplay.tsx @@ -1,14 +1,17 @@ -import React, { Component } from 'react' -import { CopyIcon } from '@patternfly/react-icons'; +import React, { Component } from "react" +import { CopyIcon } from "@patternfly/react-icons"; import { Card, Text, TextContent, TextVariants, Level, LevelItem, Button, Divider, Title -} from '@patternfly/react-core' +} from "@patternfly/react-core" -import { Versions } from '@app/versions' -import { Fields, PathPrefixes, PantheonContentTypes } from '@app/Constants' -// import { continueStatement } from '@babel/types'; +import { Versions } from "@app/versions" +import { Fields, PathPrefixes, PantheonContentTypes } from "@app/Constants" +// import { continueStatement } from "@babel/types"; export interface IModuleDisplayState { + assemblyData: any + assemblyTitle: string + assemblyPath: string attributesFilePath: string copySuccess: string draftPath: string @@ -34,24 +37,27 @@ class ModuleDisplay extends Component { constructor(props) { super(props) this.state = { - attributesFilePath: '', - copySuccess: '', - draftPath: '', - draftUpdateDate: '', - modulePath: '', - moduleTitle: '', - moduleType: '', - portalUrl: '', - productValue: '', - productUrlFragment: '', - versionUrlFragment: '', - releasePath: '', - releaseUpdateDate: '', - releaseVersion: '', + attributesFilePath: "", + copySuccess: "", + draftPath: "", + draftUpdateDate: "", + modulePath: "", + moduleTitle: "", + moduleType: "", + portalUrl: "", + productValue: "", + productUrlFragment: "", + versionUrlFragment: "", + releasePath: "", + releaseUpdateDate: "", + releaseVersion: "", results: {}, - variant: 'DEFAULT', - variantUUID: '', - versionValue: '' + variant: "DEFAULT", + variantUUID: "", + versionValue: "", + assemblyData: [], + assemblyTitle: "", + assemblyPath: "" } } @@ -59,16 +65,17 @@ class ModuleDisplay extends Component { this.fetchModuleDetails(this.props) this.getVersionUUID(this.props.location.pathname) this.fetchAttributesFilePath(this.props) + } public render() { - // console.log('Props: ', this.props) + // console.log("Props: ", this.props) return ( - {this.state.moduleTitle} + {this.state.moduleTitle} @@ -89,20 +96,20 @@ class ModuleDisplay extends Component {
- {this.state.releaseUpdateDate.trim() !== '' && this.state.releaseUpdateDate !== '-' - && this.state.variantUUID !== '' - && this.state.portalUrl !== '' - && View on Customer Portal + {this.state.releaseUpdateDate.trim() !== "" && this.state.releaseUpdateDate !== "-" + && this.state.variantUUID !== "" + && this.state.portalUrl !== "" + && View on Customer Portal } - {this.state.releaseUpdateDate.trim() !== '' && this.state.releaseUpdateDate !== '-' - && this.state.variantUUID !== '' - && this.state.portalUrl !== '' - && Copy permanent URL + {this.state.releaseUpdateDate.trim() !== "" && this.state.releaseUpdateDate !== "-" + && this.state.variantUUID !== "" + && this.state.portalUrl !== "" + && Copy permanent URL } -  {this.state.copySuccess !== '' && this.state.copySuccess} +  {this.state.copySuccess !== "" && this.state.copySuccess} @@ -110,23 +117,23 @@ class ModuleDisplay extends Component { - Product + Product {} - Module type + Module type - Draft uploaded + Draft uploaded - Published + Published @@ -134,7 +141,7 @@ class ModuleDisplay extends Component { - {this.state.productValue + ' ' + this.state.versionValue} + {this.state.productValue + " " + this.state.versionValue} {} @@ -142,8 +149,8 @@ class ModuleDisplay extends Component { - {this.state.moduleType.trim() !== '' ? - this.state.moduleType : ''} + {this.state.moduleType.trim() !== "" ? + this.state.moduleType : ""} @@ -152,9 +159,9 @@ class ModuleDisplay extends Component { - {this.state.draftUpdateDate.trim() !== '' + {this.state.draftUpdateDate.trim() !== "" && this.state.draftUpdateDate.length >= 15 ? - new Intl.DateTimeFormat('en-GB', { year: 'numeric', month: 'long', day: 'numeric' }).format(new Date(this.state.draftUpdateDate)) : '--'} + new Intl.DateTimeFormat("en-GB", { year: "numeric", month: "long", day: "numeric" }).format(new Date(this.state.draftUpdateDate)) : "--"} @@ -163,9 +170,9 @@ class ModuleDisplay extends Component { - {this.state.releaseUpdateDate.trim() !== '' + {this.state.releaseUpdateDate.trim() !== "" && this.state.releaseUpdateDate.length >= 15 ? - new Intl.DateTimeFormat('en-GB', { year: 'numeric', month: 'long', day: 'numeric' }).format(new Date(this.state.releaseUpdateDate)) : '--'} + new Intl.DateTimeFormat("en-GB", { year: "numeric", month: "long", day: "numeric" }).format(new Date(this.state.releaseUpdateDate)) : "--"} @@ -177,7 +184,7 @@ class ModuleDisplay extends Component { {} {} - {' '} + {" "}
@@ -194,6 +201,7 @@ class ModuleDisplay extends Component { variant={this.state.variant} variantUUID={this.state.variantUUID} attributesFilePath={this.state.attributesFilePath} + assemblies={this.state.assemblyData} updateDate={this.updateDate} onGetProduct={this.getProduct} onGetVersion={this.getVersion} @@ -206,7 +214,7 @@ class ModuleDisplay extends Component { ) } private generateDraftHtml = (pathname: any) => { - const docPath = '/pantheon/preview/latest/' + this.state.variantUUID + '?rerender=true' + const docPath = "/pantheon/preview/latest/" + this.state.variantUUID + "?rerender=true" return window.open(docPath) } @@ -225,15 +233,15 @@ class ModuleDisplay extends Component { const path = data.location.pathname.substring(PathPrefixes.MODULE_PATH_PREFIX.length) this.setState({ modulePath: path, - releasePath: '/content' + path + '.preview?variant=' + this.state.variant + releasePath: "/content" + path + ".preview?variant=" + this.state.variant }) this.getPortalUrl(path, this.state.variant) - fetch(path + '/en_US.harray.4.json') + fetch(path + "/en_US.harray.4.json") .then(response => response.json()) .then(responseJSON => { - // console.log('fetch results:', responseJSON) + // console.log("fetch results:", responseJSON) // TODO: refactor for loops for (const sourceVariant of responseJSON.__children__) { if (!sourceVariant.__children__) { @@ -244,16 +252,17 @@ class ModuleDisplay extends Component { if (!myChild.__children__) { continue } - if (myChild.__name__ === 'draft') { - this.setState({ draftUpdateDate: myChild['jcr:created'] }) + if (myChild.__name__ === "draft") { + this.setState({ draftUpdateDate: myChild["jcr:created"] }) } + for (const myGrandchild of myChild.__children__) { if (!myGrandchild.__children__) { continue } for (const offspring of myGrandchild.__children__) { - if (offspring.__name__ === 'metadata') { + if (offspring.__name__ === "metadata") { if (offspring[Fields.JCR_TITLE] !== undefined) { @@ -261,10 +270,10 @@ class ModuleDisplay extends Component { moduleTitle: offspring[Fields.JCR_TITLE], }) } - if (offspring['pant:moduleType'] !== undefined) { + if (offspring["pant:moduleType"] !== undefined) { this.setState({ - moduleType: offspring['pant:moduleType'], + moduleType: offspring["pant:moduleType"], }) } @@ -273,6 +282,15 @@ class ModuleDisplay extends Component { } } + + } + // get the variant UUID + for (const variants of responseJSON.__children__){ + if(variants.__name__ === "variants"){ + for (const variant of variants.__children__){ + this.fetchIncludedInAssembliesDetails(variant[Fields.JCR_UUID]) + } + } } }) @@ -293,8 +311,8 @@ class ModuleDisplay extends Component { private getVersionUUID = (path) => { // remove /module from path path = path.substring(PathPrefixes.MODULE_PATH_PREFIX.length) - // path = '/content' + path + '/en_US/1/metadata.json' - path = '/content' + path + '/en_US.harray.4.json' + // path = "/content" + path + "/en_US/1/metadata.json" + path = "/content" + path + "/en_US.harray.4.json" fetch(path) .then(response => response.json()) .then((responseJSON) => { @@ -313,7 +331,7 @@ class ModuleDisplay extends Component { } for (const offspring of variant.__children__) { - if (offspring.__name__ === 'metadata') { + if (offspring.__name__ === "metadata") { if (offspring[Fields.PANT_PRODUCT_VERSION_REF] !== undefined) { @@ -329,7 +347,7 @@ class ModuleDisplay extends Component { } private getProductInitialLoad = (uuid) => { - const path = '/content/products.harray.3.json' + const path = "/content/products.harray.3.json" fetch(path) .then(response => response.json()) .then(responseJSON => { @@ -338,7 +356,7 @@ class ModuleDisplay extends Component { continue } for (const productChild of product.__children__) { - if (productChild.__name__ !== 'versions') { + if (productChild.__name__ !== "versions") { continue } if (productChild.__children__) { @@ -355,23 +373,23 @@ class ModuleDisplay extends Component { } private copyToClipboard = () => { - const textField = document.createElement('textarea') - if (this.state.variantUUID.trim() !== '') { + const textField = document.createElement("textarea") + if (this.state.variantUUID.trim() !== "") { textField.value = this.state.portalUrl document.body.appendChild(textField) textField.select() - document.execCommand('copy') + document.execCommand("copy") textField.remove() - this.setState({ copySuccess: 'Copied!' }) + this.setState({ copySuccess: "Copied!" }) } } private mouseLeave = () => { - this.setState({ copySuccess: '' }) + this.setState({ copySuccess: "" }) } private getPortalUrl = (path, variant) => { - const variantPath = '/content' + path + '/en_US/variants/' + variant + '.url.txt' + const variantPath = "/content" + path + "/en_US/variants/" + variant + ".url.txt" fetch(variantPath) .then(resp => { if (resp.ok) { @@ -384,9 +402,9 @@ class ModuleDisplay extends Component { private async getVariantParam() { const query = new URLSearchParams(this.props.location.search); - const variantParam = query.get('variant') - // console.log('[moduleDisplay] variantParam => ', variantParam) - if (variantParam !== 'undefined' && variantParam !== null) { + const variantParam = query.get("variant") + // console.log("[moduleDisplay] variantParam => "", variantParam) + if (variantParam !== "undefined" && variantParam !== null) { this.setState({ variant: variantParam }) } } @@ -394,11 +412,11 @@ class ModuleDisplay extends Component { private fetchAttributesFilePath = async (data) => { await this.getVariantParam() const path = data.location.pathname.substring(PathPrefixes.MODULE_PATH_PREFIX.length) - // console.log('[fetchAttributesFilePath] path =>', path) - let repo = '' - const group = path.split('/') + // console.log("[fetchAttributesFilePath] path =>", path) + let repo = "" + const group = path.split("/") repo = group[2] - fetch('/content/repositories/' + repo + '/module_variants/' + this.state.variant + '.harray.json') + fetch("/content/repositories/" + repo + "/module_variants/" + this.state.variant + ".harray.json") .then((response) => { if (response.ok) { return response.json() @@ -407,8 +425,8 @@ class ModuleDisplay extends Component { } }) .then(responseJSON => { - if (responseJSON['pant:attributesFilePath'] !== undefined) { - this.setState({ attributesFilePath: responseJSON['pant:attributesFilePath'] }) + if (responseJSON["pant:attributesFilePath"] !== undefined) { + this.setState({ attributesFilePath: responseJSON["pant:attributesFilePath"] }) } }) .catch((error) => { @@ -416,6 +434,22 @@ class ModuleDisplay extends Component { }) } + private fetchIncludedInAssembliesDetails = (data) => { + fetch("/module/assemblies.json/"+data) + .then((response) => { + if (response.ok) { + return response.json() + }else { + throw new Error(response.statusText) + } + }) + .then(responseJSON => { + this.setState({assemblyData: responseJSON.assemblies}) + } + + ) + } + } export { ModuleDisplay } diff --git a/pantheon-bundle/frontend/src/app/product.test.tsx b/pantheon-bundle/frontend/src/app/product.test.tsx index 29ce59394..6b63829ce 100644 --- a/pantheon-bundle/frontend/src/app/product.test.tsx +++ b/pantheon-bundle/frontend/src/app/product.test.tsx @@ -1,85 +1,85 @@ -import React from 'react' -import { Product } from '@app/product' -import '@app/fetchMock' +import React from "react" +import { Product } from "@app/product" +import "@app/fetchMock" -import { mount, shallow } from 'enzyme' -import { Bullseye, TextInput, FormGroup, Button } from '@patternfly/react-core' -import renderer from 'react-test-renderer' +import { mount, shallow } from "enzyme" +import { Bullseye, TextInput, FormGroup, Button } from "@patternfly/react-core" +import renderer from "react-test-renderer" -describe('Product tests', () => { - test('should render Product component', () => { +describe("Product tests", () => { + test("should render Product component", () => { const view = shallow() expect(view).toMatchSnapshot() }) - it('should render a Bullseye layout', () => { + it("should render a Bullseye layout", () => { const wrapper = mount() const bullseyeLayout = wrapper.find(Bullseye) expect(bullseyeLayout.exists()).toBe(true) }) - it('should render a form group', () => { + it("should render a form group", () => { const wrapper = mount() const formGroup = wrapper.find(FormGroup) expect(formGroup.exists()).toBe(true) }) - it('should render a text input', () => { + it("should render a text input", () => { const wrapper = mount() const textInput = wrapper.find(TextInput) expect(textInput.exists()).toBe(true) }) - it('should render a Button', () => { + it("should render a Button", () => { const wrapper = mount() const button = wrapper.find(Button) expect(button.exists()).toBe(true) }) - it('test renderRedirect function', () => { + it("test renderRedirect function", () => { const wrapper = renderer.create() const inst = wrapper.getInstance() expect(inst.renderRedirect).toMatchSnapshot() }) - it('test loginRedirect function', () => { + it("test loginRedirect function", () => { const wrapper = renderer.create() const inst = wrapper.getInstance() expect(inst.loginRedirect).toMatchSnapshot() }) - it('test checkAuth function', () => { + it("test checkAuth function", () => { const wrapper = renderer.create() const inst = wrapper.getInstance() expect(inst.checkAuth).toMatchSnapshot() }) - it('test dismissNotification function', () => { + it("test dismissNotification function", () => { const wrapper = renderer.create() const inst = wrapper.getInstance() expect(inst.dismissNotification).toMatchSnapshot() }) - it('test productExist function', () => { + it("test productExist function", () => { const wrapper = renderer.create() const inst = wrapper.getInstance() expect(inst.productExist("Red Hat Enterprise Linux")).toMatchSnapshot() }) - it('test handleNameInput function', () => { + it("test handleNameInput function", () => { const wrapper = renderer.create() const inst = wrapper.getInstance() expect(inst.handleNameInput("Red Hat Enterprise Linux")).toMatchSnapshot() }) - it('test handleProductInput function', () => { + it("test handleProductInput function", () => { const wrapper = renderer.create() const inst = wrapper.getInstance() expect(inst.handleProductInput("Linux Platform")).toMatchSnapshot() }) - it('test handleUrlInput function', () => { + it("test handleUrlInput function", () => { const wrapper = renderer.create() const inst = wrapper.getInstance() expect(inst.handleUrlInput("red_hat")).toMatchSnapshot() diff --git a/pantheon-bundle/frontend/src/app/product.tsx b/pantheon-bundle/frontend/src/app/product.tsx index c6f459381..f3918ea79 100644 --- a/pantheon-bundle/frontend/src/app/product.tsx +++ b/pantheon-bundle/frontend/src/app/product.tsx @@ -1,8 +1,8 @@ -import React, { Component } from 'react' -import { Bullseye, Button, Alert, AlertActionCloseButton, Form, FormGroup, TextInput, ActionGroup } from '@patternfly/react-core' -import '@app/app.css' -import { Redirect } from 'react-router-dom' -import { Fields } from './Constants' +import React, { Component } from "react" +import { Bullseye, Button, Alert, AlertActionCloseButton, Form, FormGroup, TextInput, ActionGroup } from "@patternfly/react-core" +import "@app/app.css" +import { Redirect } from "react-router-dom" +import { Fields } from "./Constants" interface IState { failedPost: boolean @@ -23,9 +23,9 @@ class Product extends Component { isDup: false, isMissingFields: false, isUrlFragmentValid: true, - productDescription: '', - productName: '', - productUrlFragment: '', + productDescription: "", + productName: "", + productUrlFragment: "", redirect: false } @@ -126,14 +126,14 @@ class Product extends Component { } private saveProduct = () => { - if (this.state.productName === ''|| this.state.productUrlFragment === '') { + if (this.state.productName === ""|| this.state.productUrlFragment === "") { this.setState({ isMissingFields: true }) } else { this.productExist().then(exist => { if (!exist) { const hdrs = { - 'Accept': 'application/json', - 'cache-control': 'no-cache' + "Accept": "application/json", + "cache-control": "no-cache" } // setup url fragment const urlFragment = this.state.productName.toString().toLowerCase().replace(/[^A-Z0-9]+/ig, "_") @@ -141,16 +141,16 @@ class Product extends Component { formData.append("name", this.state.productName) formData.append("description", this.state.productDescription) formData.append("sling:resourceType", "pantheon/product") - formData.append("jcr:primaryType", 'pant:product') - // currently we don't translate products in Customer Portal. + formData.append("jcr:primaryType", "pant:product") + // currently we don"t translate products in Customer Portal. formData.append("locale", "en-US") formData.append(Fields.URL_FRAGMENT, this.state.productUrlFragment) // fetch makes the request to create a new product. // transfor productName to lower case and replace special chars with _. - fetch(encodeURI('/content/products/' + urlFragment), { + fetch(encodeURI("/content/products/" + urlFragment), { body: formData, headers: hdrs, - method: 'post' + method: "post" }).then(response => { if (response.status === 201 || response.status === 200) { this.setState({ redirect: true }) @@ -166,7 +166,7 @@ class Product extends Component { private renderRedirect = () => { if (this.state.redirect) { - return + return } else { return "" } @@ -182,7 +182,7 @@ class Product extends Component { private productExist = () => { let exists = false - const backend = '/content/products/' + this.state.productName.toString().toLowerCase().replace(/[^A-Z0-9]+/ig, "_") + '.json' + const backend = "/content/products/" + this.state.productName.toString().toLowerCase().replace(/[^A-Z0-9]+/ig, "_") + ".json" return fetch(backend) .then(response => { if (response.status === 200) { diff --git a/pantheon-bundle/frontend/src/app/productDetails.test.tsx b/pantheon-bundle/frontend/src/app/productDetails.test.tsx index 1997ee611..0d93dce01 100644 --- a/pantheon-bundle/frontend/src/app/productDetails.test.tsx +++ b/pantheon-bundle/frontend/src/app/productDetails.test.tsx @@ -1,88 +1,88 @@ -import React from 'react' -import { ProductDetails, IProps } from '@app/productDetails' -import '@app/fetchMock' +import React from "react" +import { ProductDetails, IProps } from "@app/productDetails" +import "@app/fetchMock" -import { mount, shallow } from 'enzyme' -import { Breadcrumb, Button, Form, FormGroup, Level, LevelItem, TextContent, TextInput, Text } from '@patternfly/react-core' -import renderer from 'react-test-renderer' -import sinon from 'sinon' +import { mount, shallow } from "enzyme" +import { Breadcrumb, Button, Form, FormGroup, Level, LevelItem, TextContent, TextInput, Text } from "@patternfly/react-core" +import renderer from "react-test-renderer" +import sinon from "sinon" const props = { productName: "Red Hat Enterprise Linux" } -describe('ProductDetails tests', () => { - test('should render ProductDetails component', () => { +describe("ProductDetails tests", () => { + test("should render ProductDetails component", () => { const view = shallow() expect(view).toMatchSnapshot() }) - it('should render a form', () => { + it("should render a form", () => { const wrapper = mount() const form = wrapper.find(Form) expect(form.exists()).toBe(true) }) - it('should render a form group', () => { + it("should render a form group", () => { const wrapper = mount() const formGroup = wrapper.find(FormGroup) expect(formGroup.exists()).toBe(true) }) - it('should render a text input', () => { + it("should render a text input", () => { const wrapper = mount() const textInput = wrapper.find(TextInput) expect(textInput.exists()).toBe(true) }) - it('should render a Button', () => { + it("should render a Button", () => { const wrapper = mount() const button = wrapper.find(Button) expect(button.exists()).toBe(true) }) - it('should render a breadcrumb', () => { + it("should render a breadcrumb", () => { const wrapper = mount() const breadCrumb = wrapper.find(Breadcrumb) expect(breadCrumb.exists()).toBe(true) }) - it('should render a Level element', () => { + it("should render a Level element", () => { const wrapper = mount() const level = wrapper.find(Level) expect(level.exists()).toBe(true) }) - it('should render a LevelItem', () => { + it("should render a LevelItem", () => { const wrapper = mount() const levelItem = wrapper.find(LevelItem) expect(levelItem.exists()).toBe(true) }) - it('should render a TextContent element', () => { + it("should render a TextContent element", () => { const wrapper = mount() const textContent = wrapper.find(TextContent) expect(textContent.exists()).toBe(true) }) - it('should render a Text element', () => { + it("should render a Text element", () => { const wrapper = mount() const text = wrapper.find(Text) expect(text.exists()).toBe(true) }) - it('test props', () => { + it("test props", () => { const productDetails = mount().text expect(productDetails.length === 1) }) - it('test fetchProductDetails function', () => { + it("test fetchProductDetails function", () => { const wrapper = renderer.create() const inst = wrapper.getInstance() expect(inst.fetchProductDetails([])).toMatchSnapshot() }) - it('test handleTextInputChange function', () => { + it("test handleTextInputChange function", () => { const wrapper = renderer.create() const inst = wrapper.getInstance() // @todo Test was failing because componentDidUpdate calls window.location.reldoad() which Jest can't support @@ -91,38 +91,38 @@ describe('ProductDetails tests', () => { // expect(inst.handleTextInputChange("1.1")).toMatchSnapshot() }) - it('test handleUrlInputChange function', () => { + it("test handleUrlInputChange function", () => { const wrapper = renderer.create() const inst = wrapper.getInstance() expect(inst.handleUrlInputChange()).toMatchSnapshot() }) - it('test saveVersion function', () => { + it("test saveVersion function", () => { const wrapper = renderer.create() const inst = wrapper.getInstance() expect(inst.saveVersion).toMatchSnapshot() }) - it('test createVersionsPath function', () => { + it("test createVersionsPath function", () => { const wrapper = renderer.create() const inst = wrapper.getInstance() expect(inst.createVersionsPath).toMatchSnapshot() }) // @todo This test is triggering reload which breaks Jest tests, adding the fix from "test handleInputChange function" doesn't fix this one - // test('newSearch() click event', () => { + // test("newSearch() click event", () => { // const wrapper = shallow() // const instance = wrapper.instance() - // const spy = sinon.spy(instance, 'saveVersion') + // const spy = sinon.spy(instance, "saveVersion") // wrapper.setState({ "newVersion": "1.1" }) - // wrapper.find(Button).simulate('click') + // wrapper.find(Button).simulate("click") // sinon.assert.called(spy) // }) // @todo componentWillReceiveProps is deprecated https://reactjs.org/docs/react-component.html#unsafe_componentwillreceivepropscomponentWillReceiveProps // @todo This test is triggering reload which breaks Jest tests, adding the fix from "test handleInputChange function" doesn't fix this one - it('test componentWillReceiveProps function', () => { + it("test componentWillReceiveProps function", () => { const wrapper = renderer.create() const inst = wrapper.getInstance() expect(inst.componentWillReceiveProps({ ...props })).toMatchSnapshot() @@ -132,6 +132,6 @@ describe('ProductDetails tests', () => { const state: IProps = { productName: "Red Hat Enterprise Linux" } - expect(state.productName).toEqual('Red Hat Enterprise Linux') + expect(state.productName).toEqual("Red Hat Enterprise Linux") }) }) diff --git a/pantheon-bundle/frontend/src/app/productDetails.tsx b/pantheon-bundle/frontend/src/app/productDetails.tsx index 6e6b2d833..dad25f42f 100644 --- a/pantheon-bundle/frontend/src/app/productDetails.tsx +++ b/pantheon-bundle/frontend/src/app/productDetails.tsx @@ -1,10 +1,10 @@ -import React, { Component } from 'react' +import React, { Component } from "react" import { ActionGroup, Alert, AlertActionCloseButton, Breadcrumb, BreadcrumbItem, Button, Form, FormGroup, Level, LevelItem, List, ListItem, Text, TextContent, TextVariants, TextInput, InputGroup -} from '@patternfly/react-core' -import { Fields, JcrTypes, SlingTypes } from '@app/Constants' -import { tsObjectKeyword } from '@babel/types'; +} from "@patternfly/react-core" +import { Fields, JcrTypes, SlingTypes } from "@app/Constants" +import { tsObjectKeyword } from "@babel/types"; export interface IProps { productName: string @@ -29,14 +29,14 @@ class ProductDetails extends Component { failedPost: false, isMissingFields: false, isUrlFragmentValid: true, - newVersion: '', - urlFragment: '', + newVersion: "", + urlFragment: "", } } public componentWillReceiveProps(nextProps) { // allow page load from productDetails to products listing - if (nextProps.productName !== undefined && nextProps.productName.trim() !== '') { + if (nextProps.productName !== undefined && nextProps.productName.trim() !== "") { return window.location.reload(false) } } @@ -58,7 +58,7 @@ class ProductDetails extends Component { - {this.props.productName}{' '} + {this.props.productName}{" "} @@ -136,7 +136,7 @@ class ProductDetails extends Component { private fetchProductDetails = (versionNames) => { // setup url fragment const urlFragment = this.props.productName.toString().toLowerCase().replace(/[^A-Z0-9]+/ig, "_") - const path = '/content/products/' + urlFragment + '/versions.2.json' + const path = "/content/products/" + urlFragment + "/versions.2.json" let key versionNames = [] @@ -185,7 +185,7 @@ class ProductDetails extends Component { } private saveVersion = () => { - if (this.state.newVersion === '' || this.state.urlFragment === '') { + if (this.state.newVersion === "" || this.state.urlFragment === "") { this.setState({ isMissingFields: true }) } else { const formData = new FormData() @@ -196,16 +196,16 @@ class ProductDetails extends Component { const productUrlFragment = this.props.productName.toString().toLowerCase().replace(/[^A-Z0-9]+/ig, "_") const encodedVersion = this.state.newVersion.toString().toLowerCase().replace(/[^A-Z0-9]+/ig, "_") - fetch(encodeURI('/content/products/' + productUrlFragment + '/versions/' + encodedVersion), { + fetch(encodeURI("/content/products/" + productUrlFragment + "/versions/" + encodedVersion), { body: formData, - method: 'post', + method: "post", }).then(response => { if (response.status === 200 || response.status === 201) { - this.setState({ newVersion: '', urlFragment: '' }) + this.setState({ newVersion: "", urlFragment: "" }) this.fetchProductDetails(this.state.allVersionNames) } else { this.setState({ failedPost: true, isMissingFields: false }) - console.log('Version adding failure') + console.log("Version adding failure") } }) } @@ -215,14 +215,14 @@ class ProductDetails extends Component { private createVersionsPath = () => { const formData = new FormData() const urlFragment = this.props.productName.toString().toLowerCase().replace(/[^A-Z0-9]+/ig, "_") - fetch(encodeURI('/content/products/' + urlFragment + '/versions'), { + fetch(encodeURI("/content/products/" + urlFragment + "/versions"), { body: formData, - method: 'post', + method: "post", }).then(response => { if (response.status === 200 || response.status === 201) { console.log(" Created versions path " + response.status) } else { - console.log(' Created versions path failed!') + console.log(" Created versions path failed!") } }) diff --git a/pantheon-bundle/frontend/src/app/productListing.test.tsx b/pantheon-bundle/frontend/src/app/productListing.test.tsx index bddc4d45f..e0338d5d6 100644 --- a/pantheon-bundle/frontend/src/app/productListing.test.tsx +++ b/pantheon-bundle/frontend/src/app/productListing.test.tsx @@ -1,94 +1,94 @@ -import React from 'react' -import { ProductListing } from '@app/productListing' -import '@app/fetchMock' +import React from "react" +import { ProductListing } from "@app/productListing" +import "@app/fetchMock" -import { mount, shallow } from 'enzyme' -import { DataList, DataListItem, DataListItemCells, DataListItemRow, FormGroup, TextInput } from '@patternfly/react-core' -import renderer from 'react-test-renderer' +import { mount, shallow } from "enzyme" +import { DataList, DataListItem, DataListItemCells, DataListItemRow, FormGroup, TextInput } from "@patternfly/react-core" +import renderer from "react-test-renderer" const props = { match: exact => true } -describe('ProductListing tests', () => { - test('should render ProductListing component', () => { +describe("ProductListing tests", () => { + test("should render ProductListing component", () => { const view = shallow() expect(view).toMatchSnapshot() }) - it('should render a Data List', () => { + it("should render a Data List", () => { const wrapper = mount() const dataList = wrapper.find(DataList) expect(dataList.exists()).toBe(true) }) - it('should render a DataListItem', () => { + it("should render a DataListItem", () => { const wrapper = mount() const dataListItem = wrapper.find(DataListItem) expect(dataListItem.exists()).toBe(true) }) - it('should render a DataListItemCells Element', () => { + it("should render a DataListItemCells Element", () => { const wrapper = mount() const dataListItemCells = wrapper.find(DataListItemCells) expect(dataListItemCells.exists()).toBe(true) }) - it('should render a DataListItemRow element', () => { + it("should render a DataListItemRow element", () => { const wrapper = mount() const dataListItemRow = wrapper.find(DataListItemRow) expect(dataListItemRow.exists()).toBe(true) }) - it('should render a form group', () => { + it("should render a form group", () => { const wrapper = mount() const formGroup = wrapper.find(FormGroup) expect(formGroup.exists()).toBe(true) }) - it('should render a text input', () => { + it("should render a text input", () => { const wrapper = mount() const textInput = wrapper.find(TextInput) expect(textInput.exists()).toBe(true) }) - it('test props', () => { + it("test props", () => { const productListing = mount().matchesElement expect(productListing.length === 1) }) - it('test getProducts function', () => { + it("test getProducts function", () => { const wrapper = renderer.create() const inst = wrapper.getInstance() expect(inst.getProducts([{"product1": "product1 name"}])).toMatchSnapshot() }) - it('test getProductsUrl function', () => { + it("test getProductsUrl function", () => { const wrapper = renderer.create() const inst = wrapper.getInstance() expect(inst.getProductsUrl("/content/products.query.json?nodeType=pant:product&orderby=name")).toMatchSnapshot() }) - it('test setInput function', () => { + it("test setInput function", () => { const wrapper = renderer.create() const inst = wrapper.getInstance() expect(inst.setInput("test input")).toMatchSnapshot() }) - it('test loginRedirect function', () => { + it("test loginRedirect function", () => { const wrapper = renderer.create() const inst = wrapper.getInstance() expect(inst.loginRedirect).toMatchSnapshot() }) - it('test checkAuth function', () => { + it("test checkAuth function", () => { const wrapper = renderer.create() const inst = wrapper.getInstance() expect(inst.checkAuth).toMatchSnapshot() }) - it('test componentDidMount function', () => { + it("test componentDidMount function", () => { const wrapper = renderer.create() const inst = wrapper.getInstance() expect(inst.componentDidMount).toMatchSnapshot() diff --git a/pantheon-bundle/frontend/src/app/productListing.tsx b/pantheon-bundle/frontend/src/app/productListing.tsx index bfdebed3b..e044787f0 100644 --- a/pantheon-bundle/frontend/src/app/productListing.tsx +++ b/pantheon-bundle/frontend/src/app/productListing.tsx @@ -1,11 +1,11 @@ -import React, { Component } from 'react'; +import React, { Component } from "react"; import { DataList, DataListItem, DataListCell, DataListItemRow, DataListItemCells, DataListAction, FormGroup, OptionsMenu, OptionsMenuItem, OptionsMenuToggle, TextInput -} from '@patternfly/react-core'; -import '@app/app.css'; -import { ProductDetails } from '@app/productDetails'; -import { CaretDownIcon } from '@patternfly/react-icons'; +} from "@patternfly/react-core"; +import "@app/app.css"; +import { ProductDetails } from "@app/productDetails"; +import { CaretDownIcon } from "@patternfly/react-icons"; class ProductListing extends Component { @@ -13,11 +13,11 @@ class ProductListing extends Component { super(props); this.state = { allProducts: [], - input: '', + input: "", isEmptyResults: false, isOpen: false, isProductDetails: false, - productName: '', + productName: "", redirect: false, results: [] }; @@ -94,11 +94,11 @@ class ProductListing extends Component { > Product Details]} isOpen={data.isOpen} - toggle={