@mirai/core 0.3.390 → 0.3.391
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/__tests__/BookingQuery/__mocks__/user-booking-get.json +9 -0
- package/__tests__/BookingQuery/workflows/index.js +1 -0
- package/__tests__/BookingQuery/workflows/login.workflow.js +22 -0
- package/__tests__/bookingQuey.spec.js +43 -0
- package/package.json +1 -1
- package/public/App.Container.jsx +14 -1
- package/__tests__/bookingQuey._spec.js +0 -51
- package/public/e2e.html +0 -27
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './login.workflow';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { expect } from '@playwright/test';
|
|
2
|
+
|
|
3
|
+
export const login = async ({ id, page, pinCode, testId, wait = true } = {}) => {
|
|
4
|
+
await expect(page.locator('form')).not.toBeVisible();
|
|
5
|
+
await page.getByTestId(`${testId}-button-open-modal`).click();
|
|
6
|
+
await expect(page.locator('form')).toBeVisible();
|
|
7
|
+
await expect(page.getByTestId(`${testId}-button-cta`)).toHaveAttribute('disabled');
|
|
8
|
+
|
|
9
|
+
await page.getByTestId(`${testId}-input-id`).click();
|
|
10
|
+
await page.getByTestId(`${testId}-input-id`).fill(id);
|
|
11
|
+
await expect(page.getByTestId(`${testId}-button-cta`)).toHaveAttribute('disabled');
|
|
12
|
+
|
|
13
|
+
await page.getByTestId(`${testId}-input-pinCode`).click();
|
|
14
|
+
await page.getByTestId(`${testId}-input-pinCode`).fill(pinCode);
|
|
15
|
+
await expect(page.getByTestId(`${testId}-button-cta`)).toHaveAttribute('disabled');
|
|
16
|
+
|
|
17
|
+
await expect(page.getByTestId(`${testId}-notification-error`)).not.toBeVisible();
|
|
18
|
+
await page.getByTestId(`${testId}-button-cta`).click();
|
|
19
|
+
if (wait) {
|
|
20
|
+
await page.waitForResponse((response) => response.url().includes('login_reservation') && response.status() === 200);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { test, expect } from '@playwright/test';
|
|
2
|
+
|
|
3
|
+
import { login } from './BookingQuery/workflows';
|
|
4
|
+
|
|
5
|
+
const CORRECT_ID = '23011372299';
|
|
6
|
+
const CORRECT_PIN_CODE = '7950376';
|
|
7
|
+
const INCORRECT_ID = '123456789';
|
|
8
|
+
const INCORRECT_PIN_CODE = '123456';
|
|
9
|
+
|
|
10
|
+
const testId = 'bookingQuery';
|
|
11
|
+
|
|
12
|
+
test.beforeEach(async ({ context, page }) => {
|
|
13
|
+
await context.addInitScript(() => (window.IS_PLAYWRIGHT = true));
|
|
14
|
+
|
|
15
|
+
await page.goto('http://local.mirai.com:8080', { waitUntil: 'networkidle', timeout: 10000 });
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test('incorrect id and pinCode booking', async ({ page }) => {
|
|
19
|
+
await login({ id: INCORRECT_ID, page, pinCode: INCORRECT_PIN_CODE, testId });
|
|
20
|
+
await expect(page.getByTestId(`${testId}-notification-error`)).toBeVisible();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test('incorrect id and correct pinCode booking', async ({ page }) => {
|
|
24
|
+
await login({ id: INCORRECT_ID, page, pinCode: CORRECT_PIN_CODE, testId });
|
|
25
|
+
await expect(page.getByTestId(`${testId}-notification-error`)).toBeVisible();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
test('correct id and incorrect pinCode booking', async ({ page }) => {
|
|
29
|
+
await login({ id: CORRECT_ID, page, pinCode: INCORRECT_PIN_CODE, testId });
|
|
30
|
+
await expect(page.getByTestId(`${testId}-notification-error`)).toBeVisible();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test('correct id and correct pinCode booking', async ({ page }) => {
|
|
34
|
+
await page.route(/.*login_reservation.json*/, (route) => {
|
|
35
|
+
route.fulfill({
|
|
36
|
+
status: 200,
|
|
37
|
+
contentType: 'application/json',
|
|
38
|
+
body: JSON.stringify(require(`./BookingQuery/__mocks__/user-booking-get.json`)),
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
await login({ id: CORRECT_ID, page, pinCode: CORRECT_PIN_CODE, testId, wait: false });
|
|
42
|
+
await expect(page).toHaveURL(/.*step3-booking*/);
|
|
43
|
+
});
|
package/package.json
CHANGED
package/public/App.Container.jsx
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/* eslint-disable react/prop-types */
|
|
2
2
|
import { useStore } from '@mirai/data-sources';
|
|
3
|
-
import { Action, Input, Text, View } from '@mirai/ui';
|
|
3
|
+
import { Action, Input, Text, useDevice, View } from '@mirai/ui';
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { useLocation } from 'wouter';
|
|
6
6
|
|
|
7
7
|
import * as style from './App.module.css';
|
|
8
8
|
|
|
9
9
|
export const Container = ({ children }) => {
|
|
10
|
+
const { isMobile } = useDevice();
|
|
10
11
|
const [location, setLocation] = useLocation();
|
|
11
12
|
|
|
12
13
|
const {
|
|
@@ -23,6 +24,12 @@ export const Container = ({ children }) => {
|
|
|
23
24
|
<Text small className={[style.contact, style.hideMobile]}>
|
|
24
25
|
Contact us directly at +34 (0) 129 039 193
|
|
25
26
|
</Text>
|
|
27
|
+
{isMobile && (
|
|
28
|
+
<View
|
|
29
|
+
data-mirai-component="bookingQuery"
|
|
30
|
+
data-test-id={window.IS_PLAYWRIGHT ? 'bookingQuery' : undefined}
|
|
31
|
+
/>
|
|
32
|
+
)}
|
|
26
33
|
<View data-mirai-component="environment" data-locale="true" data-currencies="true" data-state="true" />
|
|
27
34
|
</View>
|
|
28
35
|
|
|
@@ -51,6 +58,12 @@ export const Container = ({ children }) => {
|
|
|
51
58
|
</View>
|
|
52
59
|
|
|
53
60
|
<View row>
|
|
61
|
+
{!isMobile && (
|
|
62
|
+
<View
|
|
63
|
+
data-mirai-component="bookingQuery"
|
|
64
|
+
data-test-id={window.IS_PLAYWRIGHT ? 'bookingQuery' : undefined}
|
|
65
|
+
/>
|
|
66
|
+
)}
|
|
54
67
|
<View data-mirai-component="session" />
|
|
55
68
|
|
|
56
69
|
{!session && (
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { test, expect } from '@playwright/test';
|
|
2
|
-
|
|
3
|
-
const BOOKING_QUERY = 'bookingQuery';
|
|
4
|
-
const CORRECT_ID = '23011372299';
|
|
5
|
-
const CORRECT_PIN_CODE = '7950376';
|
|
6
|
-
const INCORRECT_ID = '123456789';
|
|
7
|
-
const INCORRECT_PIN_CODE = '123456';
|
|
8
|
-
|
|
9
|
-
//TODO: The tests execute in NODE_ENV=production but we don't have a booking in production yet. In preproduction we have a booking
|
|
10
|
-
process.env.SERVICE_USER = 'https://api-pre.mirai.com';
|
|
11
|
-
|
|
12
|
-
const executeTest = async (id, page, pinCode) => {
|
|
13
|
-
await page.goto('http://localhost:8080/e2e');
|
|
14
|
-
|
|
15
|
-
await expect(page.locator('form')).not.toBeVisible();
|
|
16
|
-
await page.getByTestId(`${BOOKING_QUERY}-button-open-modal`).click();
|
|
17
|
-
await expect(page.locator('form')).toBeVisible();
|
|
18
|
-
await expect(page.getByTestId(`${BOOKING_QUERY}-button-cta`)).toBeDisabled();
|
|
19
|
-
|
|
20
|
-
await page.getByTestId(`${BOOKING_QUERY}-input-id`).click();
|
|
21
|
-
await page.getByTestId(`${BOOKING_QUERY}-input-id`).fill(id);
|
|
22
|
-
await expect(page.getByTestId(`${BOOKING_QUERY}-button-cta`)).toBeDisabled();
|
|
23
|
-
|
|
24
|
-
await page.getByTestId(`${BOOKING_QUERY}-input-pinCode`).click();
|
|
25
|
-
await page.getByTestId(`${BOOKING_QUERY}-input-pinCode`).fill(pinCode);
|
|
26
|
-
await expect(page.getByTestId(`${BOOKING_QUERY}-button-cta`)).toBeEnabled();
|
|
27
|
-
|
|
28
|
-
await expect(page.getByTestId(`${BOOKING_QUERY}-notification-error`)).not.toBeVisible();
|
|
29
|
-
await page.getByTestId(`${BOOKING_QUERY}-button-cta`).click();
|
|
30
|
-
await page.waitForResponse((response) => response.url().includes('login_reservation') && response.status() === 200);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
test('incorrect id and pinCode booking', async ({ page }) => {
|
|
34
|
-
await executeTest(INCORRECT_ID, page, INCORRECT_PIN_CODE);
|
|
35
|
-
await expect(page.getByTestId(`${BOOKING_QUERY}-notification-error`)).toBeVisible();
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
test('incorrect id and correct pinCode booking', async ({ page }) => {
|
|
39
|
-
await executeTest(INCORRECT_ID, page, CORRECT_PIN_CODE);
|
|
40
|
-
await expect(page.getByTestId(`${BOOKING_QUERY}-notification-error`)).toBeVisible();
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
test('correct id and incorrect pinCode booking', async ({ page }) => {
|
|
44
|
-
await executeTest(CORRECT_ID, page, INCORRECT_PIN_CODE);
|
|
45
|
-
await expect(page.getByTestId(`${BOOKING_QUERY}-notification-error`)).toBeVisible();
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
test('correct id and correct pinCode booking', async ({ page }) => {
|
|
49
|
-
await executeTest(CORRECT_ID, page, CORRECT_PIN_CODE);
|
|
50
|
-
await expect(page).toHaveURL(/.*forwarder_manage_reservation*/);
|
|
51
|
-
});
|
package/public/e2e.html
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8" />
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
-
<title>@mirai/core - e2e</title>
|
|
7
|
-
<link rel="stylesheet" href="../src/theme.css" rel="preload" defer />
|
|
8
|
-
<link rel="stylesheet" href="index.css" />
|
|
9
|
-
</head>
|
|
10
|
-
|
|
11
|
-
<body>
|
|
12
|
-
<noscript>You need to enable JavaScript to run this app.</noscript>
|
|
13
|
-
<!-- Hotel Moderno -->
|
|
14
|
-
<div data-mirai-id="10030559" data-type="hotel" data-locale="en-GB"></div>
|
|
15
|
-
|
|
16
|
-
<header>
|
|
17
|
-
<h1>@mirai/core</h1>
|
|
18
|
-
<nav>
|
|
19
|
-
<div data-mirai-component="bookingQuery"></div>
|
|
20
|
-
</nav>
|
|
21
|
-
</header>
|
|
22
|
-
<footer>
|
|
23
|
-
<small>Copyright, 2023</small>
|
|
24
|
-
</footer>
|
|
25
|
-
<script type="module" defer src="../src/index.js"></script>
|
|
26
|
-
</body>
|
|
27
|
-
</html>
|