mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-19 11:41:20 +08:00
merge release-6.2.4
Release 6.2.4
This commit is contained in:
@ -3,6 +3,17 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [6.2.4](https://github.com/ionic-team/ionic/compare/v6.2.3...v6.2.4) (2022-08-24)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **vue:** lifecycles now fire on tabs pages ([#25786](https://github.com/ionic-team/ionic/issues/25786)) ([3020005](https://github.com/ionic-team/ionic/commit/30200051bbab6ce57fd363668dafc49287c87c56)), closes [#25784](https://github.com/ionic-team/ionic/issues/25784)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [6.2.3](https://github.com/ionic-team/ionic/compare/v6.2.2...v6.2.3) (2022-08-17)
|
||||
|
||||
**Note:** Version bump only for package @ionic/vue
|
||||
|
34
packages/vue/package-lock.json
generated
34
packages/vue/package-lock.json
generated
@ -1,15 +1,15 @@
|
||||
{
|
||||
"name": "@ionic/vue",
|
||||
"version": "6.2.3",
|
||||
"version": "6.2.4",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@ionic/vue",
|
||||
"version": "6.2.3",
|
||||
"version": "6.2.4",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@ionic/core": "^6.2.3",
|
||||
"@ionic/core": "^6.2.4",
|
||||
"ionicons": "^6.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
@ -59,19 +59,19 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@ionic/core": {
|
||||
"version": "6.2.3",
|
||||
"resolved": "https://registry.npmjs.org/@ionic/core/-/core-6.2.3.tgz",
|
||||
"integrity": "sha512-TqSVN5nfDC8Ovcfgv6PH6FsNY8P9Awl2zSXVMBpgr5CSFNOb6xB4U8utdhMtJbuo/OYgqAbjSVq+pD4RiBt1rw==",
|
||||
"version": "6.2.4",
|
||||
"resolved": "https://registry.npmjs.org/@ionic/core/-/core-6.2.4.tgz",
|
||||
"integrity": "sha512-LDRIwG5plwTHELxQ/j3uEfLJ7YkzJzR1V4QGE+X59aE/l7XoXZyLb1NWFjY7glBbFHGQgSuPFWNhXFkyRBxRFQ==",
|
||||
"dependencies": {
|
||||
"@stencil/core": "^2.16.0",
|
||||
"@stencil/core": "^2.17.4",
|
||||
"ionicons": "^6.0.2",
|
||||
"tslib": "^2.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@ionic/core/node_modules/@stencil/core": {
|
||||
"version": "2.16.0",
|
||||
"resolved": "https://registry.npmjs.org/@stencil/core/-/core-2.16.0.tgz",
|
||||
"integrity": "sha512-oKxPYxpH1no0oMFSf8EesuFBcn9hVpoqrpiS2WH0H50RKKL8hhKoxDfn/cNeD12L0Aj7kf6nNtexIllmkYG6lw==",
|
||||
"version": "2.17.4",
|
||||
"resolved": "https://registry.npmjs.org/@stencil/core/-/core-2.17.4.tgz",
|
||||
"integrity": "sha512-SGRlHpjV1RyFvzw6jFMVKpLNox9Eds3VvpbpD2SW9CuxdLonHDSFtQks5zmT4zs1Rse9I6kFc2mFK/dHNTalkg==",
|
||||
"bin": {
|
||||
"stencil": "bin/stencil"
|
||||
},
|
||||
@ -768,19 +768,19 @@
|
||||
}
|
||||
},
|
||||
"@ionic/core": {
|
||||
"version": "6.2.3",
|
||||
"resolved": "https://registry.npmjs.org/@ionic/core/-/core-6.2.3.tgz",
|
||||
"integrity": "sha512-TqSVN5nfDC8Ovcfgv6PH6FsNY8P9Awl2zSXVMBpgr5CSFNOb6xB4U8utdhMtJbuo/OYgqAbjSVq+pD4RiBt1rw==",
|
||||
"version": "6.2.4",
|
||||
"resolved": "https://registry.npmjs.org/@ionic/core/-/core-6.2.4.tgz",
|
||||
"integrity": "sha512-LDRIwG5plwTHELxQ/j3uEfLJ7YkzJzR1V4QGE+X59aE/l7XoXZyLb1NWFjY7glBbFHGQgSuPFWNhXFkyRBxRFQ==",
|
||||
"requires": {
|
||||
"@stencil/core": "^2.16.0",
|
||||
"@stencil/core": "^2.17.4",
|
||||
"ionicons": "^6.0.2",
|
||||
"tslib": "^2.1.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@stencil/core": {
|
||||
"version": "2.16.0",
|
||||
"resolved": "https://registry.npmjs.org/@stencil/core/-/core-2.16.0.tgz",
|
||||
"integrity": "sha512-oKxPYxpH1no0oMFSf8EesuFBcn9hVpoqrpiS2WH0H50RKKL8hhKoxDfn/cNeD12L0Aj7kf6nNtexIllmkYG6lw=="
|
||||
"version": "2.17.4",
|
||||
"resolved": "https://registry.npmjs.org/@stencil/core/-/core-2.17.4.tgz",
|
||||
"integrity": "sha512-SGRlHpjV1RyFvzw6jFMVKpLNox9Eds3VvpbpD2SW9CuxdLonHDSFtQks5zmT4zs1Rse9I6kFc2mFK/dHNTalkg=="
|
||||
},
|
||||
"tslib": {
|
||||
"version": "2.2.0",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ionic/vue",
|
||||
"version": "6.2.3",
|
||||
"version": "6.2.4",
|
||||
"description": "Vue specific wrapper for @ionic/core",
|
||||
"scripts": {
|
||||
"prepublishOnly": "npm run build",
|
||||
@ -61,7 +61,7 @@
|
||||
"vue-router": "^4.0.16"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ionic/core": "^6.2.3",
|
||||
"@ionic/core": "^6.2.4",
|
||||
"ionicons": "^6.0.2"
|
||||
},
|
||||
"vetur": {
|
||||
|
@ -88,19 +88,20 @@ export const IonRouterOutlet = /*@__PURE__*/ defineComponent({
|
||||
* all of the keys in the params object, we check the url path to
|
||||
* see if they are different after ensuring we are in a parameterized route.
|
||||
*/
|
||||
if (currentMatchedRouteRef === undefined) { return; }
|
||||
if (currentMatchedRouteRef !== undefined) {
|
||||
const matchedDifferentRoutes = currentMatchedRouteRef !== previousMatchedRouteRef;
|
||||
const matchedDifferentParameterRoutes = (
|
||||
currentRoute.matched[currentRoute.matched.length - 1] === currentMatchedRouteRef &&
|
||||
currentRoute.path !== previousMatchedPath
|
||||
);
|
||||
|
||||
const matchedDifferentRoutes = currentMatchedRouteRef !== previousMatchedRouteRef;
|
||||
const matchedDifferentParameterRoutes = (
|
||||
currentRoute.matched[currentRoute.matched.length - 1] === currentMatchedRouteRef &&
|
||||
currentRoute.path !== previousMatchedPath
|
||||
);
|
||||
|
||||
if (matchedDifferentRoutes || matchedDifferentParameterRoutes) {
|
||||
setupViewItem(matchedRouteRef);
|
||||
previousMatchedRouteRef = currentMatchedRouteRef;
|
||||
previousMatchedPath = currentRoute.path;
|
||||
if (matchedDifferentRoutes || matchedDifferentParameterRoutes) {
|
||||
setupViewItem(matchedRouteRef);
|
||||
}
|
||||
}
|
||||
|
||||
previousMatchedRouteRef = currentMatchedRouteRef;
|
||||
previousMatchedPath = currentRoute.path;
|
||||
});
|
||||
|
||||
const canStart = () => {
|
||||
@ -274,13 +275,13 @@ See https://ionicframework.com/docs/vue/navigation#ionpage for more information.
|
||||
* return early for swipe to go back when
|
||||
* going from a non-tabs page to a tabs page.
|
||||
*/
|
||||
if (isViewVisible(enteringEl) && leavingViewItem !== undefined && !isViewVisible(leavingViewItem.ionPageElement)) {
|
||||
if (isViewVisible(enteringEl) && leavingViewItem?.ionPageElement !== undefined && !isViewVisible(leavingViewItem.ionPageElement)) {
|
||||
return;
|
||||
}
|
||||
|
||||
fireLifecycle(enteringViewItem.vueComponent, enteringViewItem.vueComponentRef, LIFECYCLE_WILL_ENTER);
|
||||
|
||||
if (leavingViewItem && enteringViewItem !== leavingViewItem) {
|
||||
if (leavingViewItem?.ionPageElement && enteringViewItem !== leavingViewItem) {
|
||||
let animationBuilder = routerAnimation;
|
||||
const leavingEl = leavingViewItem.ionPageElement;
|
||||
|
||||
|
@ -1,24 +0,0 @@
|
||||
# Copy ionic vue dist
|
||||
rm -rf node_modules/@ionic/vue/dist node_modules/@ionic/vue/css
|
||||
cp -a ../dist node_modules/@ionic/vue/dist
|
||||
cp -a ../css node_modules/@ionic/vue/css
|
||||
cp -a ../package.json node_modules/@ionic/vue/package.json
|
||||
|
||||
# Copy ionic vue router dist
|
||||
rm -rf node_modules/@ionic/vue-router/dist
|
||||
cp -a ../../vue-router/dist node_modules/@ionic/vue-router/dist
|
||||
cp -a ../../vue-router/package.json node_modules/@ionic/vue-router/package.json
|
||||
|
||||
# Copy core dist and components
|
||||
rm -rf node_modules/@ionic/core/dist node_modules/@ionic/core/components
|
||||
cp -a ../../../core/package.json node_modules/@ionic/core/package.json
|
||||
cp -a ../../../core/dist node_modules/@ionic/core/dist
|
||||
cp -a ../../../core/components node_modules/@ionic/core/components
|
||||
|
||||
# Copy stencil
|
||||
rm -rf node_modules/@stencil/core
|
||||
cp -a ../../../core/node_modules/@stencil/core node_modules/@stencil/core
|
||||
|
||||
# Copy ionicons
|
||||
rm -rf node_modules/ionicons
|
||||
cp -a ../../../core/node_modules/ionicons node_modules/ionicons
|
@ -1,108 +0,0 @@
|
||||
import { mount } from '@vue/test-utils';
|
||||
import { createRouter, createWebHistory } from '@ionic/vue-router';
|
||||
import { IonicVue, IonApp, IonRouterOutlet, IonPage } from '@ionic/vue';
|
||||
import { defineComponent } from 'vue';
|
||||
import { waitForRouter } from './utils';
|
||||
|
||||
const App = {
|
||||
components: { IonApp, IonRouterOutlet },
|
||||
template: '<ion-app><ion-router-outlet /></ion-app>',
|
||||
}
|
||||
|
||||
const BasePage = {
|
||||
template: '<ion-page :data-pageid="name"></ion-page>',
|
||||
components: { IonPage },
|
||||
}
|
||||
|
||||
const Page1 = {
|
||||
...BasePage,
|
||||
data() {
|
||||
return {
|
||||
name: 'page1'
|
||||
}
|
||||
},
|
||||
ionViewWillEnter: jest.fn(),
|
||||
ionViewDidEnter: jest.fn(),
|
||||
ionViewWillLeave: jest.fn(),
|
||||
ionViewDidLeave: jest.fn(),
|
||||
}
|
||||
|
||||
const Page2 = defineComponent({
|
||||
...BasePage,
|
||||
setup() {
|
||||
return {
|
||||
name: 'page2'
|
||||
}
|
||||
},
|
||||
ionViewWillEnter: jest.fn(),
|
||||
ionViewDidEnter: jest.fn(),
|
||||
ionViewWillLeave: jest.fn(),
|
||||
ionViewDidLeave: jest.fn(),
|
||||
});
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(process.env.BASE_URL),
|
||||
routes: [
|
||||
{ path: '/', component: Page1 },
|
||||
{ path: '/2', component: Page2 }
|
||||
]
|
||||
});
|
||||
|
||||
describe('Lifecycle Events', () => {
|
||||
beforeAll(() => {
|
||||
(HTMLElement.prototype as HTMLIonRouterOutletElement).commit = jest.fn();
|
||||
});
|
||||
it('Triggers lifecycle events', async () => {
|
||||
// Initial render
|
||||
router.push('/');
|
||||
await router.isReady();
|
||||
const wrapper = mount(App, {
|
||||
global: {
|
||||
plugins: [router, IonicVue]
|
||||
}
|
||||
});
|
||||
|
||||
// Page 1 lifecycle hooks
|
||||
expect(Page1.ionViewWillEnter).toHaveBeenCalledWith();
|
||||
expect(Page1.ionViewWillEnter.mock.instances[0]).toEqual(expect.objectContaining({ name: 'page1' }))
|
||||
|
||||
expect(Page1.ionViewDidEnter).toHaveBeenCalled();
|
||||
expect(Page1.ionViewDidEnter.mock.instances[0]).toEqual(expect.objectContaining({ name: 'page1' }))
|
||||
|
||||
expect(Page1.ionViewWillLeave).not.toHaveBeenCalled();
|
||||
expect(Page1.ionViewDidLeave).not.toHaveBeenCalled();
|
||||
expect(wrapper.html()).toContain('page1');
|
||||
|
||||
// Page 2 lifecycle hooks
|
||||
expect(Page2.ionViewWillEnter).not.toHaveBeenCalled();
|
||||
expect(Page2.ionViewDidEnter).not.toHaveBeenCalled();
|
||||
expect(Page2.ionViewWillLeave).not.toHaveBeenCalled();
|
||||
expect(Page2.ionViewDidLeave).not.toHaveBeenCalled();
|
||||
|
||||
// Navigate to 2nd page
|
||||
router.push('/2');
|
||||
jest.resetAllMocks();
|
||||
await waitForRouter();
|
||||
|
||||
// Page 1 lifecycle hooks
|
||||
expect(Page1.ionViewDidEnter).not.toHaveBeenCalled();
|
||||
expect(Page1.ionViewWillEnter).not.toHaveBeenCalled();
|
||||
|
||||
expect(Page1.ionViewWillLeave).toHaveBeenCalled();
|
||||
expect(Page1.ionViewWillLeave.mock.instances[0]).toEqual(expect.objectContaining({ name: 'page1' }))
|
||||
|
||||
expect(Page1.ionViewDidLeave).toHaveBeenCalled();
|
||||
expect(Page1.ionViewDidLeave.mock.instances[0]).toEqual(expect.objectContaining({ name: 'page1' }))
|
||||
|
||||
// Page 2 lifecycle hooks
|
||||
expect(Page2.ionViewWillEnter).toHaveBeenCalled();
|
||||
expect((Page2.ionViewWillEnter as jest.Mock).mock.instances[0]).toEqual(expect.objectContaining({ name: 'page2' }))
|
||||
|
||||
expect(Page2.ionViewDidEnter).toHaveBeenCalled();
|
||||
expect((Page2.ionViewDidEnter as jest.Mock).mock.instances[0]).toEqual(expect.objectContaining({ name: 'page2' }))
|
||||
|
||||
expect(Page2.ionViewWillLeave).not.toHaveBeenCalled();
|
||||
expect(Page2.ionViewDidLeave).not.toHaveBeenCalled();
|
||||
expect(wrapper.html()).toContain('page2');
|
||||
});
|
||||
});
|
43
packages/vue/test/README.md
Normal file
43
packages/vue/test/README.md
Normal file
@ -0,0 +1,43 @@
|
||||
# Vue E2E Test Apps
|
||||
|
||||
Ionic Framework supports multiple versions of Vue. As a result, we need to verify that Ionic works correctly with each of these Vue versions.
|
||||
|
||||
## Test App Build Structure
|
||||
|
||||
Unlike other test applications, these test apps are broken up into multiple directories. These directories are then combined to create a single application. This allows us to share common application code, tests, etc so that each app is being tested the same way. Below details the different pieces that help create a single test application.
|
||||
|
||||
**apps** - This directory contains partial applications for each version of Vue we want to test. Typically these directories contain new `package.json` files, `jest.config.js` files, and more. If you have code that is specific to a particular version of Vue, put it in this directory.
|
||||
|
||||
**base** - This directory contains the base application that each test app will use. This is where tests, application logic, and more live. If you have code that needs to be run on every test app, put it in this directory.
|
||||
|
||||
**build** - When the `apps` and `base` directories are merged, the final result is put in this directory. The `build` directory should never be committed to git.
|
||||
|
||||
**build.sh** - This is the script that merges the `apps` and `base` directories and places the built application in the `build` directory.
|
||||
|
||||
Usage:
|
||||
|
||||
```shell
|
||||
# Build a test app using apps/vue3 as a reference
|
||||
./build.sh vue3
|
||||
```
|
||||
|
||||
## How to modify test apps
|
||||
|
||||
To add new tests, components, or pages, modify the `base` project. This ensures that tests are run for every tested version.
|
||||
|
||||
If you want to add a version-specific change, add the change inside of the appropriate projects in `apps`. Be sure to replicate the directory structure. For example, if you are adding a new E2E test file called `test.e2e.ts` in `apps/vue3`, make sure you place the file in `apps/vue3/tests/e2e/test.e2e.ts`.
|
||||
|
||||
### Version-specific tests
|
||||
|
||||
If you need to add E2E tests that are only run on a specific version of the JS Framework, replicate the `VersionTest` component on each partial application. This ensures that tests for framework version X do not get run for framework version Y.
|
||||
|
||||
## Adding New Test Apps
|
||||
|
||||
As we add support for new versions of Vue, we will also need to update this directory to test against new applications. The following steps can serve as a guide for adding new apps:
|
||||
|
||||
1. Navigate to the built app for the most recent version of Vue that Ionic tests.
|
||||
2. Update the application to the latest version of Vue.
|
||||
3. Make note of any files that changed during the upgrade (`package.json`, `package-lock.json`, etc).
|
||||
4. Copy the changed files to a new directory in `apps`.
|
||||
5. Add a new entry to the matrix for `test-core-vue` in `./github/workflows/build.yml`. This will allow the new test app to run against all PRs.
|
||||
6. Commit these changes and push.
|
Before Width: | Height: | Size: 930 B After Width: | Height: | Size: 930 B |
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
24
packages/vue/test/base/scripts/sync.sh
Normal file
24
packages/vue/test/base/scripts/sync.sh
Normal file
@ -0,0 +1,24 @@
|
||||
# Copy ionic vue dist
|
||||
rm -rf node_modules/@ionic/vue/dist node_modules/@ionic/vue/css
|
||||
cp -a ../../../dist node_modules/@ionic/vue/dist
|
||||
cp -a ../../../css node_modules/@ionic/vue/css
|
||||
cp -a ../../../package.json node_modules/@ionic/vue/package.json
|
||||
|
||||
# Copy ionic vue router dist
|
||||
rm -rf node_modules/@ionic/vue-router/dist
|
||||
cp -a ../../../../vue-router/dist node_modules/@ionic/vue-router/dist
|
||||
cp -a ../../../../vue-router/package.json node_modules/@ionic/vue-router/package.json
|
||||
|
||||
# Copy core dist and components
|
||||
rm -rf node_modules/@ionic/core/dist node_modules/@ionic/core/components
|
||||
cp -a ../../../../../core/package.json node_modules/@ionic/core/package.json
|
||||
cp -a ../../../../../core/dist node_modules/@ionic/core/dist
|
||||
cp -a ../../../../../core/components node_modules/@ionic/core/components
|
||||
|
||||
# Copy stencil
|
||||
rm -rf node_modules/@stencil/core
|
||||
cp -a ../../../../../core/node_modules/@stencil/core node_modules/@stencil/core
|
||||
|
||||
# Copy ionicons
|
||||
rm -rf node_modules/ionicons
|
||||
cp -a ../../../../../core/node_modules/ionicons node_modules/ionicons
|
@ -8,6 +8,10 @@ const routes: Array<RouteRecordRaw> = [
|
||||
path: '/',
|
||||
component: Home
|
||||
},
|
||||
{
|
||||
path: '/version-test',
|
||||
component: () => import('@/views/VersionTest.vue')
|
||||
},
|
||||
{
|
||||
path: '/delayed-redirect',
|
||||
beforeEnter: DelayGuard,
|
41
packages/vue/test/base/src/views/VersionTest.vue
Normal file
41
packages/vue/test/base/src/views/VersionTest.vue
Normal file
@ -0,0 +1,41 @@
|
||||
<template>
|
||||
<ion-page data-pageid="version-test">
|
||||
<ion-header :translucent="true">
|
||||
<ion-toolbar>
|
||||
<ion-buttons>
|
||||
<ion-back-button></ion-back-button>
|
||||
</ion-buttons>
|
||||
<ion-title>VersionTest</ion-title>
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
|
||||
<ion-content :fullscreen="true" class="ion-padding">
|
||||
Version-specific tests
|
||||
</ion-content>
|
||||
</ion-page>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import {
|
||||
IonBackButton,
|
||||
IonButtons,
|
||||
IonContent,
|
||||
IonHeader,
|
||||
IonPage,
|
||||
IonTitle,
|
||||
IonToolbar
|
||||
} from '@ionic/vue';
|
||||
import { defineComponent } from 'vue';
|
||||
|
||||
export default defineComponent({
|
||||
components: {
|
||||
IonBackButton,
|
||||
IonButtons,
|
||||
IonContent,
|
||||
IonHeader,
|
||||
IonPage,
|
||||
IonTitle,
|
||||
IonToolbar
|
||||
}
|
||||
});
|
||||
</script>
|
221
packages/vue/test/base/tests/unit/lifecycle.spec.ts
Normal file
221
packages/vue/test/base/tests/unit/lifecycle.spec.ts
Normal file
@ -0,0 +1,221 @@
|
||||
import { mount } from '@vue/test-utils';
|
||||
import { createRouter, createWebHistory } from '@ionic/vue-router';
|
||||
import { IonicVue, IonApp, IonRouterOutlet, IonTabs, IonPage } from '@ionic/vue';
|
||||
import { defineComponent } from 'vue';
|
||||
import { waitForRouter } from './utils';
|
||||
|
||||
const App = {
|
||||
components: { IonApp, IonRouterOutlet },
|
||||
template: '<ion-app><ion-router-outlet /></ion-app>',
|
||||
}
|
||||
|
||||
const BasePage = {
|
||||
template: '<ion-page :data-pageid="name"></ion-page>',
|
||||
components: { IonPage },
|
||||
}
|
||||
|
||||
const Page1 = {
|
||||
...BasePage,
|
||||
data() {
|
||||
return {
|
||||
name: 'page1'
|
||||
}
|
||||
},
|
||||
ionViewWillEnter: jest.fn(),
|
||||
ionViewDidEnter: jest.fn(),
|
||||
ionViewWillLeave: jest.fn(),
|
||||
ionViewDidLeave: jest.fn(),
|
||||
}
|
||||
|
||||
const Page2 = defineComponent({
|
||||
...BasePage,
|
||||
setup() {
|
||||
return {
|
||||
name: 'page2'
|
||||
}
|
||||
},
|
||||
ionViewWillEnter: jest.fn(),
|
||||
ionViewDidEnter: jest.fn(),
|
||||
ionViewWillLeave: jest.fn(),
|
||||
ionViewDidLeave: jest.fn(),
|
||||
});
|
||||
|
||||
describe('Lifecycle Events', () => {
|
||||
beforeAll(() => {
|
||||
(HTMLElement.prototype as HTMLIonRouterOutletElement).commit = jest.fn();
|
||||
});
|
||||
it('Triggers lifecycle events', async () => {
|
||||
const router = createRouter({
|
||||
history: createWebHistory(process.env.BASE_URL),
|
||||
routes: [
|
||||
{ path: '/', component: Page1 },
|
||||
{ path: '/2', component: Page2 }
|
||||
]
|
||||
});
|
||||
|
||||
// Initial render
|
||||
router.push('/');
|
||||
await router.isReady();
|
||||
const wrapper = mount(App, {
|
||||
global: {
|
||||
plugins: [router, IonicVue]
|
||||
}
|
||||
});
|
||||
|
||||
// Page 1 lifecycle hooks
|
||||
expect(Page1.ionViewWillEnter).toHaveBeenCalledWith();
|
||||
expect(Page1.ionViewWillEnter.mock.instances[0]).toEqual(expect.objectContaining({ name: 'page1' }))
|
||||
|
||||
expect(Page1.ionViewDidEnter).toHaveBeenCalled();
|
||||
expect(Page1.ionViewDidEnter.mock.instances[0]).toEqual(expect.objectContaining({ name: 'page1' }))
|
||||
|
||||
expect(Page1.ionViewWillLeave).not.toHaveBeenCalled();
|
||||
expect(Page1.ionViewDidLeave).not.toHaveBeenCalled();
|
||||
expect(wrapper.html()).toContain('page1');
|
||||
|
||||
// Page 2 lifecycle hooks
|
||||
expect(Page2.ionViewWillEnter).not.toHaveBeenCalled();
|
||||
expect(Page2.ionViewDidEnter).not.toHaveBeenCalled();
|
||||
expect(Page2.ionViewWillLeave).not.toHaveBeenCalled();
|
||||
expect(Page2.ionViewDidLeave).not.toHaveBeenCalled();
|
||||
|
||||
// Navigate to 2nd page
|
||||
router.push('/2');
|
||||
jest.resetAllMocks();
|
||||
await waitForRouter();
|
||||
|
||||
// Page 1 lifecycle hooks
|
||||
expect(Page1.ionViewDidEnter).not.toHaveBeenCalled();
|
||||
expect(Page1.ionViewWillEnter).not.toHaveBeenCalled();
|
||||
|
||||
expect(Page1.ionViewWillLeave).toHaveBeenCalled();
|
||||
expect(Page1.ionViewWillLeave.mock.instances[0]).toEqual(expect.objectContaining({ name: 'page1' }))
|
||||
|
||||
expect(Page1.ionViewDidLeave).toHaveBeenCalled();
|
||||
expect(Page1.ionViewDidLeave.mock.instances[0]).toEqual(expect.objectContaining({ name: 'page1' }))
|
||||
|
||||
// Page 2 lifecycle hooks
|
||||
expect(Page2.ionViewWillEnter).toHaveBeenCalled();
|
||||
expect((Page2.ionViewWillEnter as jest.Mock).mock.instances[0]).toEqual(expect.objectContaining({ name: 'page2' }))
|
||||
|
||||
expect(Page2.ionViewDidEnter).toHaveBeenCalled();
|
||||
expect((Page2.ionViewDidEnter as jest.Mock).mock.instances[0]).toEqual(expect.objectContaining({ name: 'page2' }))
|
||||
|
||||
expect(Page2.ionViewWillLeave).not.toHaveBeenCalled();
|
||||
expect(Page2.ionViewDidLeave).not.toHaveBeenCalled();
|
||||
expect(wrapper.html()).toContain('page2');
|
||||
});
|
||||
it('should fire lifecycle events on inner tab page', async () => {
|
||||
const TabsPage = {
|
||||
template: `
|
||||
<ion-page>
|
||||
<ion-tabs>
|
||||
<ion-router-outlet></ion-router-outlet>
|
||||
</ion-tabs>
|
||||
</ion-page>
|
||||
`,
|
||||
components: { IonPage, IonTabs, IonRouterOutlet },
|
||||
ionViewWillEnter: jest.fn(),
|
||||
ionViewDidEnter: jest.fn(),
|
||||
ionViewWillLeave: jest.fn(),
|
||||
ionViewDidLeave: jest.fn(),
|
||||
}
|
||||
const Tab1Page = {
|
||||
...BasePage,
|
||||
ionViewWillEnter: jest.fn(),
|
||||
ionViewDidEnter: jest.fn(),
|
||||
ionViewWillLeave: jest.fn(),
|
||||
ionViewDidLeave: jest.fn(),
|
||||
}
|
||||
|
||||
const NonTabPage = {
|
||||
...BasePage,
|
||||
ionViewWillEnter: jest.fn(),
|
||||
ionViewDidEnter: jest.fn(),
|
||||
ionViewWillLeave: jest.fn(),
|
||||
ionViewDidLeave: jest.fn(),
|
||||
}
|
||||
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(process.env.BASE_URL),
|
||||
routes: [
|
||||
{ path: '/', component: TabsPage, children: [
|
||||
{ path: 'tab1', component: Tab1Page }
|
||||
]},
|
||||
{ path: '/non-tab', component: NonTabPage }
|
||||
]
|
||||
});
|
||||
|
||||
// Initial render
|
||||
router.push('/tab1');
|
||||
await router.isReady();
|
||||
const wrapper = mount(App, {
|
||||
global: {
|
||||
plugins: [router, IonicVue]
|
||||
}
|
||||
});
|
||||
|
||||
// Initial load
|
||||
expect(TabsPage.ionViewWillEnter).toHaveBeenCalled();
|
||||
expect(TabsPage.ionViewDidEnter).toHaveBeenCalled();
|
||||
|
||||
expect(Tab1Page.ionViewWillEnter).toHaveBeenCalled();
|
||||
expect(Tab1Page.ionViewDidEnter).toHaveBeenCalled();
|
||||
|
||||
expect(NonTabPage.ionViewWillEnter).not.toHaveBeenCalled();
|
||||
expect(NonTabPage.ionViewDidEnter).not.toHaveBeenCalled();
|
||||
|
||||
// Navigate out of tabs
|
||||
router.push('/non-tab');
|
||||
jest.resetAllMocks();
|
||||
await waitForRouter();
|
||||
|
||||
expect(TabsPage.ionViewWillLeave).toHaveBeenCalled();
|
||||
expect(TabsPage.ionViewDidLeave).toHaveBeenCalled();
|
||||
|
||||
// Tab1Page currently does not call leaving hooks
|
||||
// when navigating out of tabs
|
||||
//expect(Tab1Page.ionViewWillLeave).toHaveBeenCalled();
|
||||
//expect(Tab1Page.ionViewDidLeave).toHaveBeenCalled();
|
||||
|
||||
expect(NonTabPage.ionViewWillEnter).toHaveBeenCalled();
|
||||
expect(NonTabPage.ionViewDidEnter).toHaveBeenCalled();
|
||||
|
||||
// Go back
|
||||
router.back();
|
||||
jest.resetAllMocks();
|
||||
await waitForRouter();
|
||||
|
||||
expect(TabsPage.ionViewWillEnter).toHaveBeenCalled();
|
||||
expect(TabsPage.ionViewDidEnter).toHaveBeenCalled();
|
||||
|
||||
expect(Tab1Page.ionViewWillEnter).toHaveBeenCalled();
|
||||
expect(Tab1Page.ionViewDidEnter).toHaveBeenCalled();
|
||||
|
||||
expect(NonTabPage.ionViewWillLeave).toHaveBeenCalled();
|
||||
expect(NonTabPage.ionViewDidLeave).toHaveBeenCalled();
|
||||
|
||||
// Navigate out of tabs again
|
||||
router.push('/non-tab');
|
||||
jest.resetAllMocks();
|
||||
await waitForRouter();
|
||||
|
||||
expect(TabsPage.ionViewWillLeave).toHaveBeenCalled();
|
||||
expect(TabsPage.ionViewDidLeave).toHaveBeenCalled();
|
||||
|
||||
expect(NonTabPage.ionViewWillEnter).toHaveBeenCalled();
|
||||
expect(NonTabPage.ionViewDidEnter).toHaveBeenCalled();
|
||||
|
||||
// Go back again
|
||||
router.back();
|
||||
jest.resetAllMocks();
|
||||
await waitForRouter();
|
||||
|
||||
expect(TabsPage.ionViewWillEnter).toHaveBeenCalled();
|
||||
expect(TabsPage.ionViewDidEnter).toHaveBeenCalled();
|
||||
|
||||
expect(NonTabPage.ionViewWillLeave).toHaveBeenCalled();
|
||||
expect(NonTabPage.ionViewDidLeave).toHaveBeenCalled();
|
||||
})
|
||||
});
|
33
packages/vue/test/build.sh
Executable file
33
packages/vue/test/build.sh
Executable file
@ -0,0 +1,33 @@
|
||||
#!/bin/bash
|
||||
|
||||
# The directory where the source
|
||||
# for each specific application is.
|
||||
APPS_DIR="apps"
|
||||
|
||||
# The directory where the
|
||||
# base application logic is
|
||||
BASE_DIR="base"
|
||||
BUILD_DIR="build"
|
||||
|
||||
# The specific application
|
||||
# we are building
|
||||
APP_DIR="${1}"
|
||||
|
||||
# The full path to the specific application.
|
||||
FULL_APP_DIR="${APPS_DIR}/${APP_DIR}/."
|
||||
|
||||
# The full path to the base application.
|
||||
FULL_BASE_DIR="${BASE_DIR}/."
|
||||
|
||||
# The full path to the built application.
|
||||
BUILD_APP_DIR="${BUILD_DIR}/${APP_DIR}/"
|
||||
|
||||
# Make the build directory if it does not already exist.
|
||||
mkdir -p $BUILD_DIR
|
||||
|
||||
# First we need to copy the base application
|
||||
cp -R $FULL_BASE_DIR $BUILD_APP_DIR
|
||||
|
||||
# Then we can copy the specific app which
|
||||
# will override any files in the base application.
|
||||
cp -R $FULL_APP_DIR $BUILD_APP_DIR
|
Reference in New Issue
Block a user