@mirai/core 0.1.12 → 0.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env +1 -0
- package/__tests__/bookingQuery/bookingQuey.spec.js +52 -0
- package/build/Core.js +1 -0
- package/build/Core.js.map +1 -1
- package/package.json +6 -2
- package/playwright.config.js +110 -0
- package/public/e2e.html +29 -0
package/.env
CHANGED
|
@@ -3,6 +3,7 @@ BUNDLE_LOCALHOST=http://local.mirai.com:9090/dist/index.js?version=localhost
|
|
|
3
3
|
|
|
4
4
|
METRICS=8499ad730df132d03f1d532e287a9920
|
|
5
5
|
|
|
6
|
+
SERVICE_BOOKING=https://reservation-pre.mirai.com/XMAS/reservation
|
|
6
7
|
SERVICE_CLUB=https://api.mirai.com
|
|
7
8
|
SERVICE_ENGINE=https://engine.mirai.com
|
|
8
9
|
SERVICE_STATIC=https://static.mirai.com
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
const { test, expect } = require('@playwright/test');
|
|
3
|
+
|
|
4
|
+
const BOOKING_QUERY = 'bookingQuery';
|
|
5
|
+
const CORRECT_ID = '23011372299';
|
|
6
|
+
const CORRECT_PIN_CODE = '7950376';
|
|
7
|
+
const INCORRECT_ID = '123456789';
|
|
8
|
+
const INCORRECT_PIN_CODE = '123456';
|
|
9
|
+
|
|
10
|
+
//TODO: The tests execute in NODE_ENV=production but we don't have a booking in production yet. In preproduction we have a booking
|
|
11
|
+
process.env.SERVICE_USER = 'https://api-pre.mirai.com';
|
|
12
|
+
|
|
13
|
+
const executeTest = async (id, page, pinCode) => {
|
|
14
|
+
await page.goto('http://localhost:8080/e2e');
|
|
15
|
+
|
|
16
|
+
await expect(page.locator('form')).not.toBeVisible();
|
|
17
|
+
await page.getByTestId(`${BOOKING_QUERY}-button-open-modal`).click();
|
|
18
|
+
await expect(page.locator('form')).toBeVisible();
|
|
19
|
+
await expect(page.getByTestId(`${BOOKING_QUERY}-button-cta`)).toBeDisabled();
|
|
20
|
+
|
|
21
|
+
await page.getByTestId(`${BOOKING_QUERY}-input-id`).click();
|
|
22
|
+
await page.getByTestId(`${BOOKING_QUERY}-input-id`).fill(id);
|
|
23
|
+
await expect(page.getByTestId(`${BOOKING_QUERY}-button-cta`)).toBeDisabled();
|
|
24
|
+
|
|
25
|
+
await page.getByTestId(`${BOOKING_QUERY}-input-pinCode`).click();
|
|
26
|
+
await page.getByTestId(`${BOOKING_QUERY}-input-pinCode`).fill(pinCode);
|
|
27
|
+
await expect(page.getByTestId(`${BOOKING_QUERY}-button-cta`)).toBeEnabled();
|
|
28
|
+
|
|
29
|
+
await expect(page.getByTestId(`${BOOKING_QUERY}-notification-error`)).not.toBeVisible();
|
|
30
|
+
await page.getByTestId(`${BOOKING_QUERY}-button-cta`).click();
|
|
31
|
+
await page.waitForResponse((response) => response.url().includes('login_reservation') && response.status() === 200);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
test('incorrect id and pinCode booking', async ({ page }) => {
|
|
35
|
+
await executeTest(INCORRECT_ID, page, INCORRECT_PIN_CODE);
|
|
36
|
+
await expect(page.getByTestId(`${BOOKING_QUERY}-notification-error`)).toBeVisible();
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test('incorrect id and correct pinCode booking', async ({ page }) => {
|
|
40
|
+
await executeTest(INCORRECT_ID, page, CORRECT_PIN_CODE);
|
|
41
|
+
await expect(page.getByTestId(`${BOOKING_QUERY}-notification-error`)).toBeVisible();
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
test('correct id and incorrect pinCode booking', async ({ page }) => {
|
|
45
|
+
await executeTest(CORRECT_ID, page, INCORRECT_PIN_CODE);
|
|
46
|
+
await expect(page.getByTestId(`${BOOKING_QUERY}-notification-error`)).toBeVisible();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test('correct id and correct pinCode booking', async ({ page }) => {
|
|
50
|
+
await executeTest(CORRECT_ID, page, CORRECT_PIN_CODE);
|
|
51
|
+
await expect(page).toHaveURL(/.*forwarder_manage_reservation*/);
|
|
52
|
+
});
|
package/build/Core.js
CHANGED
|
@@ -60,6 +60,7 @@ const Core = _ref => {
|
|
|
60
60
|
fallback: /*#__PURE__*/_react.default.createElement("small", null, "Loading...")
|
|
61
61
|
}, /*#__PURE__*/_react.default.createElement(_components.default[component], {
|
|
62
62
|
...props,
|
|
63
|
+
['data-testid']: (process && process.env && process.env.NODE_ENV || "production") === 'production' ? component : undefined,
|
|
63
64
|
ghost: ghosts[index],
|
|
64
65
|
el
|
|
65
66
|
})), el);
|
package/build/Core.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Core.js","names":["ghosts","Core","children","components","value","currency","locale","DEFAULT_LOCALE","useStore","isMobile","isDesktop","useDevice","dictionary","setDictionary","useState","useEffect","next","ServiceDictionary","get","filter","desktop","mobile","map","index","el","component","props","getGhost","ReactDOM","createPortal","React","createElement","COMPONENTS","ghost","propTypes","PropTypes","node","arrayOf","shape","oneOf","Object","keys","any"],"sources":["../src/Core.jsx"],"sourcesContent":["import { useStore } from '@mirai/data-sources';\nimport { DEFAULT_LOCALE, LocaleProvider } from '@mirai/locale';\nimport { ServiceDictionary } from '@mirai/services';\nimport { useDevice } from '@mirai/ui';\nimport PropTypes from 'prop-types';\nimport React, { useEffect, useState, Suspense } from 'react';\nimport ReactDOM from 'react-dom';\n\nimport COMPONENTS from './components';\nimport { getGhost } from './helpers';\n\nconst ghosts = {};\n\nconst Core = ({ children, components = [] }) => {\n const {\n value: { currency, locale = DEFAULT_LOCALE },\n } = useStore();\n\n const { isMobile, isDesktop } = useDevice();\n const [dictionary, setDictionary] = useState();\n\n useEffect(() => {\n (async () => {\n const next = await ServiceDictionary.get(locale);\n if (next) setDictionary(next);\n })();\n }, [locale]);\n\n return (\n <LocaleProvider {...{ currency, dictionary, locale }}>\n <>\n {components\n .filter(({ desktop, mobile }) => !(isMobile && mobile === 'false') && !(isDesktop && desktop === 'false'))\n .map(({ el, component, ...props }, index) => {\n if (!ghosts[index]) ghosts[index] = getGhost(el);\n\n return ReactDOM.createPortal(\n <Suspense fallback={<small>Loading...</small>}>\n {React.createElement(COMPONENTS[component], {
|
|
1
|
+
{"version":3,"file":"Core.js","names":["ghosts","Core","children","components","value","currency","locale","DEFAULT_LOCALE","useStore","isMobile","isDesktop","useDevice","dictionary","setDictionary","useState","useEffect","next","ServiceDictionary","get","filter","desktop","mobile","map","index","el","component","props","getGhost","ReactDOM","createPortal","React","createElement","COMPONENTS","undefined","ghost","propTypes","PropTypes","node","arrayOf","shape","oneOf","Object","keys","any"],"sources":["../src/Core.jsx"],"sourcesContent":["import { useStore } from '@mirai/data-sources';\nimport { DEFAULT_LOCALE, LocaleProvider } from '@mirai/locale';\nimport { ServiceDictionary } from '@mirai/services';\nimport { useDevice } from '@mirai/ui';\nimport PropTypes from 'prop-types';\nimport React, { useEffect, useState, Suspense } from 'react';\nimport ReactDOM from 'react-dom';\n\nimport COMPONENTS from './components';\nimport { getGhost } from './helpers';\n\nconst ghosts = {};\n\nconst Core = ({ children, components = [] }) => {\n const {\n value: { currency, locale = DEFAULT_LOCALE },\n } = useStore();\n\n const { isMobile, isDesktop } = useDevice();\n const [dictionary, setDictionary] = useState();\n\n useEffect(() => {\n (async () => {\n const next = await ServiceDictionary.get(locale);\n if (next) setDictionary(next);\n })();\n }, [locale]);\n\n return (\n <LocaleProvider {...{ currency, dictionary, locale }}>\n <>\n {components\n .filter(({ desktop, mobile }) => !(isMobile && mobile === 'false') && !(isDesktop && desktop === 'false'))\n .map(({ el, component, ...props }, index) => {\n if (!ghosts[index]) ghosts[index] = getGhost(el);\n\n return ReactDOM.createPortal(\n <Suspense fallback={<small>Loading...</small>}>\n {React.createElement(COMPONENTS[component], {\n ...props,\n ['data-testid']: process.env.NODE_ENV === 'production' ? component : undefined,\n ghost: ghosts[index],\n el,\n })}\n </Suspense>,\n el,\n );\n })}\n </>\n {children}\n </LocaleProvider>\n );\n};\n\nCore.propTypes = {\n children: PropTypes.node,\n components: PropTypes.arrayOf(\n PropTypes.shape({\n component: PropTypes.oneOf(Object.keys(COMPONENTS)),\n el: PropTypes.any,\n }),\n ),\n};\n\nexport { Core };\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAAqC;AAAA;AAAA;AAErC,MAAMA,MAAM,GAAG,CAAC,CAAC;AAEjB,MAAMC,IAAI,GAAG,QAAmC;EAAA,IAAlC;IAAEC,QAAQ;IAAEC,UAAU,GAAG;EAAG,CAAC;EACzC,MAAM;IACJC,KAAK,EAAE;MAAEC,QAAQ;MAAEC,MAAM,GAAGC;IAAe;EAC7C,CAAC,GAAG,IAAAC,qBAAQ,GAAE;EAEd,MAAM;IAAEC,QAAQ;IAAEC;EAAU,CAAC,GAAG,IAAAC,aAAS,GAAE;EAC3C,MAAM,CAACC,UAAU,EAAEC,aAAa,CAAC,GAAG,IAAAC,eAAQ,GAAE;EAE9C,IAAAC,gBAAS,EAAC,MAAM;IACd,CAAC,YAAY;MACX,MAAMC,IAAI,GAAG,MAAMC,2BAAiB,CAACC,GAAG,CAACZ,MAAM,CAAC;MAChD,IAAIU,IAAI,EAAEH,aAAa,CAACG,IAAI,CAAC;IAC/B,CAAC,GAAG;EACN,CAAC,EAAE,CAACV,MAAM,CAAC,CAAC;EAEZ,oBACE,6BAAC,sBAAc;IAAOD,QAAQ;IAAEO,UAAU;IAAEN;EAAM,gBAChD,4DACGH,UAAU,CACRgB,MAAM,CAAC;IAAA,IAAC;MAAEC,OAAO;MAAEC;IAAO,CAAC;IAAA,OAAK,EAAEZ,QAAQ,IAAIY,MAAM,KAAK,OAAO,CAAC,IAAI,EAAEX,SAAS,IAAIU,OAAO,KAAK,OAAO,CAAC;EAAA,EAAC,CACzGE,GAAG,CAAC,QAA8BC,KAAK,KAAK;IAAA,IAAvC;MAAEC,EAAE;MAAEC,SAAS;MAAE,GAAGC;IAAM,CAAC;IAC/B,IAAI,CAAC1B,MAAM,CAACuB,KAAK,CAAC,EAAEvB,MAAM,CAACuB,KAAK,CAAC,GAAG,IAAAI,iBAAQ,EAACH,EAAE,CAAC;IAEhD,oBAAOI,iBAAQ,CAACC,YAAY,eAC1B,6BAAC,eAAQ;MAAC,QAAQ,eAAE;IAA0B,gBAC3CC,cAAK,CAACC,aAAa,CAACC,mBAAU,CAACP,SAAS,CAAC,EAAE;MAC1C,GAAGC,KAAK;MACR,CAAC,aAAa,GAAG,qEAAyB,YAAY,GAAGD,SAAS,GAAGQ,SAAS;MAC9EC,KAAK,EAAElC,MAAM,CAACuB,KAAK,CAAC;MACpBC;IACF,CAAC,CAAC,CACO,EACXA,EAAE,CACH;EACH,CAAC,CAAC,CACH,EACFtB,QAAQ,CACM;AAErB,CAAC;AAAC;AAEFD,IAAI,CAACkC,SAAS,GAAG;EACfjC,QAAQ,EAAEkC,kBAAS,CAACC,IAAI;EACxBlC,UAAU,EAAEiC,kBAAS,CAACE,OAAO,CAC3BF,kBAAS,CAACG,KAAK,CAAC;IACdd,SAAS,EAAEW,kBAAS,CAACI,KAAK,CAACC,MAAM,CAACC,IAAI,CAACV,mBAAU,CAAC,CAAC;IACnDR,EAAE,EAAEY,kBAAS,CAACO;EAChB,CAAC,CAAC;AAEN,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mirai/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.14",
|
|
4
4
|
"source": "src/index.js",
|
|
5
5
|
"repository": "https://gitlab.com/miraicorp/dev/frontend/core",
|
|
6
6
|
"author": "JΛVI <hello@soyjavi.com>",
|
|
@@ -16,6 +16,9 @@
|
|
|
16
16
|
"test": "node scripts/test.js --watchAll=false --silent",
|
|
17
17
|
"test:coverage": "node scripts/test.js --coverage --coverageReporters=text --detectOpenHandles --forceExit --silent",
|
|
18
18
|
"test:watch": "node scripts/test.js",
|
|
19
|
+
"test:e2e": "yarn playwright test",
|
|
20
|
+
"test:e2e:recorder": "yarn playwright codegen",
|
|
21
|
+
"test:e2e:report": "yarn playwright show-report",
|
|
19
22
|
"pipeline": "yarn lint && yarn test && yarn build",
|
|
20
23
|
"release": "yarn version --patch && yarn publish --access public"
|
|
21
24
|
},
|
|
@@ -37,11 +40,12 @@
|
|
|
37
40
|
"@babel/preset-env": "7.20.2",
|
|
38
41
|
"@babel/preset-react": "7.18.6",
|
|
39
42
|
"@mirai/eslint": "^0.1",
|
|
43
|
+
"@playwright/test": "^1.29.2",
|
|
40
44
|
"@testing-library/react": "12.1.5",
|
|
41
45
|
"@testing-library/react-hooks": "7.0.2",
|
|
42
46
|
"babel-plugin-inline-dotenv": "1.7.0",
|
|
43
47
|
"jest-fetch-mock": "^3.0.3",
|
|
44
|
-
"parcel": "2.
|
|
48
|
+
"parcel": "2.8.3",
|
|
45
49
|
"process": "0.11.10",
|
|
46
50
|
"react-scripts": "5.0.1",
|
|
47
51
|
"serve": "14.1.2"
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
const { devices } = require('@playwright/test');
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Read environment variables from file.
|
|
6
|
+
* https://github.com/motdotla/dotenv
|
|
7
|
+
*/
|
|
8
|
+
// require('dotenv').config();
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @see https://playwright.dev/docs/test-configuration
|
|
12
|
+
* @type {import('@playwright/test').PlaywrightTestConfig}
|
|
13
|
+
*/
|
|
14
|
+
const config = {
|
|
15
|
+
testDir: './__tests__',
|
|
16
|
+
/* Maximum time one test can run for. */
|
|
17
|
+
timeout: 30 * 1000,
|
|
18
|
+
expect: {
|
|
19
|
+
/**
|
|
20
|
+
* Maximum time expect() should wait for the condition to be met.
|
|
21
|
+
* For example in `await expect(locator).toHaveText();`
|
|
22
|
+
*/
|
|
23
|
+
timeout: 5000,
|
|
24
|
+
},
|
|
25
|
+
/* Run tests in files in parallel */
|
|
26
|
+
fullyParallel: true,
|
|
27
|
+
/* Fail the build on CI if you accidentally left test.only in the source code. */
|
|
28
|
+
forbidOnly: !!process.env.CI,
|
|
29
|
+
/* Retry on CI only */
|
|
30
|
+
retries: process.env.CI ? 2 : 0,
|
|
31
|
+
/* Opt out of parallel tests on CI. */
|
|
32
|
+
workers: process.env.CI ? 1 : undefined,
|
|
33
|
+
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
|
|
34
|
+
reporter: 'html',
|
|
35
|
+
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
|
|
36
|
+
use: {
|
|
37
|
+
/* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
|
|
38
|
+
actionTimeout: 0,
|
|
39
|
+
/* Base URL to use in actions like `await page.goto('/')`. */
|
|
40
|
+
// baseURL: 'http://localhost:3000',
|
|
41
|
+
|
|
42
|
+
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
|
43
|
+
trace: 'on-first-retry',
|
|
44
|
+
video: 'on',
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
/* Configure projects for major browsers */
|
|
48
|
+
projects: [
|
|
49
|
+
{
|
|
50
|
+
name: 'chromium',
|
|
51
|
+
use: {
|
|
52
|
+
...devices['Desktop Chrome'],
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
// {
|
|
57
|
+
// name: 'firefox',
|
|
58
|
+
// use: {
|
|
59
|
+
// ...devices['Desktop Firefox'],
|
|
60
|
+
// },
|
|
61
|
+
// },
|
|
62
|
+
|
|
63
|
+
// {
|
|
64
|
+
// name: 'webkit',
|
|
65
|
+
// use: {
|
|
66
|
+
// ...devices['Desktop Safari'],
|
|
67
|
+
// },
|
|
68
|
+
// },
|
|
69
|
+
|
|
70
|
+
/* Test against mobile viewports. */
|
|
71
|
+
// {
|
|
72
|
+
// name: 'Mobile Chrome',
|
|
73
|
+
// use: {
|
|
74
|
+
// ...devices['Pixel 5'],
|
|
75
|
+
// },
|
|
76
|
+
// },
|
|
77
|
+
// {
|
|
78
|
+
// name: 'Mobile Safari',
|
|
79
|
+
// use: {
|
|
80
|
+
// ...devices['iPhone 12'],
|
|
81
|
+
// },
|
|
82
|
+
// },
|
|
83
|
+
|
|
84
|
+
/* Test against branded browsers. */
|
|
85
|
+
// {
|
|
86
|
+
// name: 'Microsoft Edge',
|
|
87
|
+
// use: {
|
|
88
|
+
// channel: 'msedge',
|
|
89
|
+
// },
|
|
90
|
+
// },
|
|
91
|
+
// {
|
|
92
|
+
// name: 'Google Chrome',
|
|
93
|
+
// use: {
|
|
94
|
+
// channel: 'chrome',
|
|
95
|
+
// },
|
|
96
|
+
// },
|
|
97
|
+
],
|
|
98
|
+
|
|
99
|
+
/* Folder for test artifacts such as screenshots, videos, traces, etc. */
|
|
100
|
+
// outputDir: 'test-results/',
|
|
101
|
+
|
|
102
|
+
/* Run your local dev server before starting the tests */
|
|
103
|
+
webServer: {
|
|
104
|
+
command:
|
|
105
|
+
'rm -rf dist && NODE_ENV=production parcel build public/e2e.html --no-cache --no-source-maps --no-autoinstall --detailed-report && serve dist -p 8080 -u -n',
|
|
106
|
+
port: 8080,
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
module.exports = config;
|
package/public/e2e.html
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="utf-8" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
7
|
+
<title>@mirai/core - e2e</title>
|
|
8
|
+
<link rel="stylesheet" href="../src/theme.css" rel="preload" defer />
|
|
9
|
+
<link rel="stylesheet" href="index.css" />
|
|
10
|
+
</head>
|
|
11
|
+
|
|
12
|
+
<body>
|
|
13
|
+
<noscript>You need to enable JavaScript to run this app.</noscript>
|
|
14
|
+
<!-- Hotel Moderno -->
|
|
15
|
+
<div data-mirai-id="10030559" data-type="hotel" data-locale="en-GB" hidden></div>
|
|
16
|
+
|
|
17
|
+
<header>
|
|
18
|
+
<h1>@mirai/core</h1>
|
|
19
|
+
<nav>
|
|
20
|
+
<div data-mirai-component="bookingQuery"></div>
|
|
21
|
+
</nav>
|
|
22
|
+
</header>
|
|
23
|
+
<footer>
|
|
24
|
+
<small>Copyright, 2023</small>
|
|
25
|
+
</footer>
|
|
26
|
+
<script type="module" defer src="../src/index.js"></script>
|
|
27
|
+
</body>
|
|
28
|
+
|
|
29
|
+
</html>
|