-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/app wrappers registry (#249)
* feat: App Wrappers support for Registry API & UI * chore: seeds adjustment for new demo page with App Wrappers * chore: E2E tests updated to new Demo apps * chore: E2E tests for home page & appWrapper
- Loading branch information
Showing
21 changed files
with
301 additions
and
45 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
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,44 @@ | ||
Feature('App Wrapper'); | ||
|
||
Scenario('Renders App Wrapper (SSR) & mounts target app on click', (I) => { | ||
I.amOnPage('/wrapper/'); | ||
I.waitForText('Hello from wrapper!', 10, '#body'); | ||
|
||
I.click('Mount actual app', '#body'); | ||
I.waitForText('Welcome to target app', 10, '#body'); | ||
I.see('propFromWrapper', '#body') | ||
I.see('fromClick', '#body') | ||
}); | ||
|
||
Scenario('Renders App Wrapper (CSR) & mounts target app on click', (I) => { | ||
I.amOnPage('/'); | ||
I.click(`a[href="/wrapper/"]`); | ||
I.waitForText('Hello from wrapper!', 10, '#body'); | ||
|
||
I.click('Mount actual app', '#body'); | ||
I.waitForText('Welcome to target app', 10, '#body'); | ||
I.see('propFromWrapper', '#body') | ||
I.see('fromClick', '#body') | ||
}); | ||
|
||
Scenario('Renders Target App (SSR)', (I) => { | ||
I.amOnPage('/wrapper/?showApp=1'); | ||
I.waitForText('Welcome to target app', 10, '#body'); | ||
I.see('propFromWrapper', '#body') | ||
I.see('fromLocation', '#body') | ||
}); | ||
|
||
Scenario('Renders Target App (CSR)', (I) => { | ||
I.amOnPage('/wrapper/'); | ||
I.waitForText('Hello from wrapper!', 10, '#body'); | ||
I.click('Mount actual app', '#body'); | ||
|
||
I.waitForText('Welcome to target app', 10, '#body'); | ||
I.click(`a[href="/nosuchpath"]`); | ||
I.waitForText('404', 10, '#body'); | ||
I.executeScript('window.history.back();'); | ||
|
||
I.waitForText('Welcome to target app', 10, '#body'); | ||
I.see('propFromWrapper', '#body') | ||
I.see('fromLocation', '#body') | ||
}); |
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,6 @@ | ||
Feature('Home page'); | ||
|
||
Scenario('Renders home page', (I) => { | ||
I.amOnPage('/'); | ||
I.waitForText('Hi! Welcome to our Demo website', 10, '#body'); | ||
}); |
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
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
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
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
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
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
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
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
67 changes: 67 additions & 0 deletions
67
registry/server/migrations/20210125185210_app_wrapper_kind.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,67 @@ | ||
import * as Knex from 'knex'; | ||
|
||
export async function up(knex: Knex): Promise<void> { | ||
if (isMySQL(knex)) { | ||
return knex.raw("ALTER TABLE `apps` " + | ||
"MODIFY COLUMN `kind` " + | ||
"enum('primary', 'essential','essential','wrapper') " + | ||
"NOT NULL DEFAULT 'regular';"); | ||
} else { | ||
await alterSqliteTable(knex, 'apps', ` | ||
name varchar(50) not null primary key, | ||
spaBundle varchar(255) not null, | ||
cssBundle varchar(255), | ||
dependencies json, | ||
ssr json, | ||
props json, | ||
assetsDiscoveryUrl varchar(255), | ||
assetsDiscoveryUpdatedAt integer, | ||
kind text default 'regular', | ||
configSelector varchar(255), | ||
check (\`kind\` in ('primary', 'essential', 'regular', 'wrapper')) | ||
`); | ||
} | ||
} | ||
|
||
|
||
export async function down(knex: Knex): Promise<void> { | ||
if (isMySQL(knex)) { | ||
return knex.raw("ALTER TABLE `apps` " + | ||
"MODIFY COLUMN `kind` " + | ||
"enum('primary', 'essential','essential') " + | ||
"NOT NULL DEFAULT 'regular';"); | ||
} else { | ||
await alterSqliteTable(knex,'apps', ` | ||
name varchar(50) not null primary key, | ||
spaBundle varchar(255) not null, | ||
cssBundle varchar(255), | ||
dependencies json, | ||
ssr json, | ||
props json, | ||
assetsDiscoveryUrl varchar(255), | ||
assetsDiscoveryUpdatedAt integer, | ||
kind text default 'regular', | ||
configSelector varchar(255), | ||
check (\`kind\` in ('primary', 'essential', 'regular')) | ||
`); | ||
} | ||
} | ||
|
||
async function alterSqliteTable(knex: Knex, tableName: string, columnsSql: string):Promise<void> { | ||
try { | ||
await knex.schema.raw(`PRAGMA foreign_keys=off;`); | ||
await knex.transaction(async trx => { | ||
await trx.raw(`CREATE TABLE tbl_tmp (${columnsSql});`); | ||
await trx.raw(`INSERT INTO tbl_tmp SELECT * FROM \`${tableName}\`;`); | ||
await trx.raw(`DROP TABLE \`${tableName}\`;`); | ||
await trx.raw(`ALTER TABLE tbl_tmp RENAME TO \`${tableName}\`;`); | ||
}); | ||
} finally { | ||
await knex.schema.raw(`PRAGMA foreign_keys=on;`); | ||
} | ||
|
||
} | ||
|
||
function isMySQL(knex: Knex) { | ||
return ["mysql", "mariasql", "mariadb"].indexOf(knex.client.dialect) > -1; | ||
} |
16 changes: 16 additions & 0 deletions
16
registry/server/migrations/20210125185211_apps_wrappedWith.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,16 @@ | ||
import * as Knex from "knex"; | ||
|
||
|
||
export async function up(knex: Knex): Promise<any> { | ||
return knex.schema.table('apps', table => { | ||
table.string('wrappedWith', 50).nullable().references('apps.name'); | ||
}); | ||
} | ||
|
||
|
||
export async function down(knex: Knex): Promise<any> { | ||
return knex.schema.table('apps', table => { | ||
table.dropColumn('wrappedWith'); | ||
}); | ||
} | ||
|
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
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
Oops, something went wrong.