-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(demos): add "Feature App in Feature App" demo (#313)
- Loading branch information
1 parent
793bf05
commit 2fcecf6
Showing
6 changed files
with
101 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
packages/demos/src/feature-app-in-feature-app/feature-app-inner.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import {Label} from '@blueprintjs/core'; | ||
import {ReactFeatureApp} from '@feature-hub/react'; | ||
import * as React from 'react'; | ||
|
||
export default { | ||
id: 'test:hello-world-inner', | ||
|
||
create(): ReactFeatureApp { | ||
return { | ||
render: () => <Label>Hello, World!</Label> | ||
}; | ||
} | ||
}; |
18 changes: 18 additions & 0 deletions
18
packages/demos/src/feature-app-in-feature-app/feature-app-outer.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import {Card} from '@blueprintjs/core'; | ||
import {FeatureAppContainer, ReactFeatureApp} from '@feature-hub/react'; | ||
import * as React from 'react'; | ||
import featureAppDefinition from './feature-app-inner'; | ||
|
||
export default { | ||
id: 'test:hello-world-outer', | ||
|
||
create(): ReactFeatureApp { | ||
return { | ||
render: () => ( | ||
<Card style={{margin: '20px'}}> | ||
<FeatureAppContainer featureAppDefinition={featureAppDefinition} /> | ||
</Card> | ||
) | ||
}; | ||
} | ||
}; |
31 changes: 31 additions & 0 deletions
31
packages/demos/src/feature-app-in-feature-app/index.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* @jest-environment puppeteer | ||
*/ | ||
|
||
import {Server} from 'http'; | ||
import {AddressInfo} from 'net'; | ||
import {Browser} from '../browser'; | ||
import {startServer} from '../start-server'; | ||
import webpackConfigs from './webpack-config'; | ||
|
||
jest.setTimeout(60000); | ||
|
||
describe('integration test: "Feature App in Feature App"', () => { | ||
const browser = new Browser(5000); | ||
|
||
let server: Server; | ||
|
||
beforeAll(async () => { | ||
server = await startServer(webpackConfigs, undefined); | ||
|
||
const {port} = server.address() as AddressInfo; | ||
|
||
await browser.goto(`http://localhost:${port}`, 60000); | ||
}); | ||
|
||
afterAll(done => server.close(done)); | ||
|
||
it('renders a Feature App with another nested Feature App', async () => { | ||
await expect(page).toMatch('Hello, World!'); | ||
}); | ||
}); |
21 changes: 21 additions & 0 deletions
21
packages/demos/src/feature-app-in-feature-app/integrator.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import {FeatureAppManager, FeatureServiceRegistry} from '@feature-hub/core'; | ||
import { | ||
FeatureAppContainer, | ||
FeatureHubContextProvider | ||
} from '@feature-hub/react'; | ||
import * as React from 'react'; | ||
import * as ReactDOM from 'react-dom'; | ||
import '../blueprint-css'; | ||
import featureAppDefinition from './feature-app-outer'; | ||
|
||
const featureServiceRegistry = new FeatureServiceRegistry(); | ||
|
||
const featureAppManager = new FeatureAppManager(featureServiceRegistry); | ||
|
||
ReactDOM.render( | ||
<FeatureHubContextProvider value={{featureAppManager}}> | ||
<FeatureAppContainer featureAppDefinition={featureAppDefinition} /> | ||
</FeatureHubContextProvider>, | ||
|
||
document.querySelector('main') | ||
); |
14 changes: 14 additions & 0 deletions
14
packages/demos/src/feature-app-in-feature-app/webpack-config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import {join} from 'path'; | ||
import {Configuration} from 'webpack'; | ||
import {webpackBaseConfig} from '../webpack-base-config'; | ||
|
||
export default [ | ||
{ | ||
...webpackBaseConfig, | ||
entry: join(__dirname, './integrator.tsx'), | ||
output: { | ||
filename: 'integrator.js', | ||
publicPath: '/' | ||
} | ||
} | ||
] as Configuration[]; |