@appsemble/e2e 0.32.2
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/LICENSE.md +126 -0
- package/README.md +64 -0
- package/fixtures/expect/index.d.ts +5 -0
- package/fixtures/expect/index.js +4 -0
- package/fixtures/expect/training/index.d.ts +17 -0
- package/fixtures/expect/training/index.js +30 -0
- package/fixtures/index.d.ts +2 -0
- package/fixtures/index.js +3 -0
- package/fixtures/test/app/index.d.ts +24 -0
- package/fixtures/test/app/index.js +40 -0
- package/fixtures/test/app-collection/index.d.ts +22 -0
- package/fixtures/test/app-collection/index.js +42 -0
- package/fixtures/test/demo-app/index.d.ts +15 -0
- package/fixtures/test/demo-app/index.js +22 -0
- package/fixtures/test/group/index.d.ts +11 -0
- package/fixtures/test/group/index.js +13 -0
- package/fixtures/test/index.d.ts +1 -0
- package/fixtures/test/index.js +11 -0
- package/fixtures/test/live-app/index.d.ts +27 -0
- package/fixtures/test/live-app/index.js +50 -0
- package/fixtures/test/resource/index.d.ts +18 -0
- package/fixtures/test/resource/index.js +29 -0
- package/fixtures/test/studio/index.d.ts +17 -0
- package/fixtures/test/studio/index.js +33 -0
- package/fixtures/test/training/index.d.ts +7 -0
- package/fixtures/test/training/index.js +18 -0
- package/index.d.ts +2 -0
- package/index.js +3 -0
- package/package.json +52 -0
- package/playwright.config.d.ts +5 -0
- package/playwright.config.js +48 -0
- package/setup/auth.setup.d.ts +1 -0
- package/setup/auth.setup.js +10 -0
- package/tests/studio/app-collections/app-collections.spec.d.ts +1 -0
- package/tests/studio/app-collections/app-collections.spec.js +158 -0
- package/tests/studio/apps/app.spec.d.ts +1 -0
- package/tests/studio/apps/app.spec.js +79 -0
- package/tests/studio/apps.spec.d.ts +1 -0
- package/tests/studio/apps.spec.js +30 -0
- package/tests/studio/blocks.spec.d.ts +1 -0
- package/tests/studio/blocks.spec.js +20 -0
- package/tests/studio/docs.spec.d.ts +1 -0
- package/tests/studio/docs.spec.js +28 -0
- package/tests/studio/logins/appsemble.spec.d.ts +1 -0
- package/tests/studio/logins/appsemble.spec.js +14 -0
- package/tests/studio/logins/demo.spec.d.ts +1 -0
- package/tests/studio/logins/demo.spec.js +9 -0
- package/tests/studio/logins/invite.spec.d.ts +1 -0
- package/tests/studio/logins/invite.spec.js +12 -0
- package/tests/studio/logins/oauth2.spec.d.ts +1 -0
- package/tests/studio/logins/oauth2.spec.js +56 -0
- package/tests/studio/logins/password.spec.d.ts +1 -0
- package/tests/studio/logins/password.spec.js +14 -0
- package/tests/studio/logins/register.spec.d.ts +1 -0
- package/tests/studio/logins/register.spec.js +14 -0
- package/tests/studio/logins/saml.spec.d.ts +1 -0
- package/tests/studio/logins/saml.spec.js +14 -0
- package/tests/studio/organizations.spec.d.ts +1 -0
- package/tests/studio/organizations.spec.js +33 -0
- package/tests/studio/root.spec.d.ts +1 -0
- package/tests/studio/root.spec.js +8 -0
- package/tests/studio/trainings/constants.d.ts +4 -0
- package/tests/studio/trainings/constants.js +5 -0
- package/tests/studio/trainings/logged-in.spec.d.ts +1 -0
- package/tests/studio/trainings/logged-in.spec.js +43 -0
- package/tests/studio/trainings/logged-out.spec.d.ts +1 -0
- package/tests/studio/trainings/logged-out.spec.js +42 -0
- package/tests/template-apps/empty.spec.d.ts +1 -0
- package/tests/template-apps/empty.spec.js +14 -0
- package/tests/template-apps/holidays.spec.d.ts +1 -0
- package/tests/template-apps/holidays.spec.js +25 -0
- package/tests/template-apps/notes.spec.d.ts +1 -0
- package/tests/template-apps/notes.spec.js +25 -0
- package/tests/template-apps/person.spec.d.ts +1 -0
- package/tests/template-apps/person.spec.js +25 -0
- package/vitest.config.js +3 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# GNU LESSER GENERAL PUBLIC LICENSE
|
|
2
|
+
|
|
3
|
+
Version 3, 29 June 2007
|
|
4
|
+
|
|
5
|
+
Copyright © 2018 Appsemble B.V. <https://appsemble.com>
|
|
6
|
+
|
|
7
|
+
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing
|
|
8
|
+
it is not allowed.
|
|
9
|
+
|
|
10
|
+
This version of the GNU Lesser General Public License incorporates the terms and conditions of
|
|
11
|
+
version 3 of the GNU General Public License, supplemented by the additional permissions listed
|
|
12
|
+
below.
|
|
13
|
+
|
|
14
|
+
## 0. Additional Definitions.
|
|
15
|
+
|
|
16
|
+
As used herein, _“this License”_ refers to version 3 of the GNU Lesser General Public License, and
|
|
17
|
+
the _“GNU GPL”_ refers to version 3 of the GNU General Public License.
|
|
18
|
+
|
|
19
|
+
_“The Library”_ refers to a covered work governed by this License, other than an Application or a
|
|
20
|
+
Combined Work as defined below.
|
|
21
|
+
|
|
22
|
+
An _“Application”_ is any work that makes use of an interface provided by the Library, but which is
|
|
23
|
+
not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed
|
|
24
|
+
a mode of using an interface provided by the Library.
|
|
25
|
+
|
|
26
|
+
A _“Combined Work”_ is a work produced by combining or linking an Application with the Library. The
|
|
27
|
+
particular version of the Library with which the Combined Work was made is also called the _“Linked
|
|
28
|
+
Version”_.
|
|
29
|
+
|
|
30
|
+
The _“Minimal Corresponding Source”_ for a Combined Work means the Corresponding Source for the
|
|
31
|
+
Combined Work, excluding any source code for portions of the Combined Work that, considered in
|
|
32
|
+
isolation, are based on the Application, and not on the Linked Version.
|
|
33
|
+
|
|
34
|
+
The _“Corresponding Application Code”_ for a Combined Work means the object code and/or source code
|
|
35
|
+
for the Application, including any data and utility programs needed for reproducing the Combined
|
|
36
|
+
Work from the Application, but excluding the System Libraries of the Combined Work.
|
|
37
|
+
|
|
38
|
+
## 1. Exception to Section 3 of the GNU GPL.
|
|
39
|
+
|
|
40
|
+
You may convey a covered work under sections 3 and 4 of this License without being bound by section
|
|
41
|
+
3 of the GNU GPL.
|
|
42
|
+
|
|
43
|
+
## 2. Conveying Modified Versions.
|
|
44
|
+
|
|
45
|
+
If you modify a copy of the Library, and, in your modifications, a facility refers to a function or
|
|
46
|
+
data to be supplied by an Application that uses the facility (other than as an argument passed when
|
|
47
|
+
the facility is invoked), then you may convey a copy of the modified version:
|
|
48
|
+
|
|
49
|
+
- a) under this License, provided that you make a good faith effort to ensure that, in the event an
|
|
50
|
+
Application does not supply the function or data, the facility still operates, and performs
|
|
51
|
+
whatever part of its purpose remains meaningful, or
|
|
52
|
+
- b) under the GNU GPL, with none of the additional permissions of this License applicable to that
|
|
53
|
+
copy.
|
|
54
|
+
|
|
55
|
+
## 3. Object Code Incorporating Material from Library Header Files.
|
|
56
|
+
|
|
57
|
+
The object code form of an Application may incorporate material from a header file that is part of
|
|
58
|
+
the Library. You may convey such object code under terms of your choice, provided that, if the
|
|
59
|
+
incorporated material is not limited to numerical parameters, data structure layouts and accessors,
|
|
60
|
+
or small macros, inline functions and templates (ten or fewer lines in length), you do both of the
|
|
61
|
+
following:
|
|
62
|
+
|
|
63
|
+
- a) Give prominent notice with each copy of the object code that the Library is used in it and that
|
|
64
|
+
the Library and its use are covered by this License.
|
|
65
|
+
- b) Accompany the object code with a copy of the GNU GPL and this license document.
|
|
66
|
+
|
|
67
|
+
## 4. Combined Works.
|
|
68
|
+
|
|
69
|
+
You may convey a Combined Work under terms of your choice that, taken together, effectively do not
|
|
70
|
+
restrict modification of the portions of the Library contained in the Combined Work and reverse
|
|
71
|
+
engineering for debugging such modifications, if you also do each of the following:
|
|
72
|
+
|
|
73
|
+
- a) Give prominent notice with each copy of the Combined Work that the Library is used in it and
|
|
74
|
+
that the Library and its use are covered by this License.
|
|
75
|
+
- b) Accompany the Combined Work with a copy of the GNU GPL and this license document.
|
|
76
|
+
- c) For a Combined Work that displays copyright notices during execution, include the copyright
|
|
77
|
+
notice for the Library among these notices, as well as a reference directing the user to the
|
|
78
|
+
copies of the GNU GPL and this license document.
|
|
79
|
+
- d) Do one of the following:
|
|
80
|
+
1. Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding
|
|
81
|
+
Application Code in a form suitable for, and under terms that permit, the user to recombine or
|
|
82
|
+
relink the Application with a modified version of the Linked Version to produce a modified
|
|
83
|
+
Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding
|
|
84
|
+
Source.
|
|
85
|
+
2. Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is
|
|
86
|
+
one that (a) uses at run time a copy of the Library already present on the user’s computer
|
|
87
|
+
system, and (b) will operate properly with a modified version of the Library that is
|
|
88
|
+
interface-compatible with the Linked Version.
|
|
89
|
+
- e) Provide Installation Information, but only if you would otherwise be required to provide such
|
|
90
|
+
information under section 6 of the GNU GPL, and only to the extent that such information is
|
|
91
|
+
necessary to install and execute a modified version of the Combined Work produced by recombining
|
|
92
|
+
or relinking the Application with a modified version of the Linked Version. (If you use option
|
|
93
|
+
4d0, the Installation Information must accompany the Minimal Corresponding Source and
|
|
94
|
+
Corresponding Application Code. If you use option 4d1, you must provide the Installation
|
|
95
|
+
Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding
|
|
96
|
+
Source.)
|
|
97
|
+
|
|
98
|
+
## 5. Combined Libraries.
|
|
99
|
+
|
|
100
|
+
You may place library facilities that are a work based on the Library side by side in a single
|
|
101
|
+
library together with other library facilities that are not Applications and are not covered by this
|
|
102
|
+
License, and convey such a combined library under terms of your choice, if you do both of the
|
|
103
|
+
following:
|
|
104
|
+
|
|
105
|
+
- a) Accompany the combined library with a copy of the same work based on the Library, uncombined
|
|
106
|
+
with any other library facilities, conveyed under the terms of this License.
|
|
107
|
+
- b) Give prominent notice with the combined library that part of it is a work based on the Library,
|
|
108
|
+
and explaining where to find the accompanying uncombined form of the same work.
|
|
109
|
+
|
|
110
|
+
## 6. Revised Versions of the GNU Lesser General Public License.
|
|
111
|
+
|
|
112
|
+
The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General
|
|
113
|
+
Public License from time to time. Such new versions will be similar in spirit to the present
|
|
114
|
+
version, but may differ in detail to address new problems or concerns.
|
|
115
|
+
|
|
116
|
+
Each version is given a distinguishing version number. If the Library as you received it specifies
|
|
117
|
+
that a certain numbered version of the GNU Lesser General Public License _“or any later version”_
|
|
118
|
+
applies to it, you have the option of following the terms and conditions either of that published
|
|
119
|
+
version or of any later version published by the Free Software Foundation. If the Library as you
|
|
120
|
+
received it does not specify a version number of the GNU Lesser General Public License, you may
|
|
121
|
+
choose any version of the GNU Lesser General Public License ever published by the Free Software
|
|
122
|
+
Foundation.
|
|
123
|
+
|
|
124
|
+
If the Library as you received it specifies that a proxy can decide whether future versions of the
|
|
125
|
+
GNU Lesser General Public License shall apply, that proxy’s public statement of acceptance of any
|
|
126
|
+
version is permanent authorization for you to choose that version for the Library.
|
package/README.md
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
#  Appsemble End 2 End Tests
|
|
2
|
+
|
|
3
|
+
> Run end 2 end tests on an Appsemble environment
|
|
4
|
+
|
|
5
|
+
[](https://gitlab.com/appsemble/appsemble/-/releases/0.32.2)
|
|
6
|
+
[](https://prettier.io)
|
|
7
|
+
|
|
8
|
+
## Table of Contents
|
|
9
|
+
|
|
10
|
+
- [Usage](#usage)
|
|
11
|
+
- [License](#license)
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
To run end to end tests, run:
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
npm run e2e
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
The tests use [Playwright](https://playwright.dev/).
|
|
22
|
+
|
|
23
|
+
After each test a video will be saved in the `packages/e2e/test-results/{name-test}` directory for
|
|
24
|
+
further inspection.
|
|
25
|
+
|
|
26
|
+
The end to end tests use the following environment variables:
|
|
27
|
+
|
|
28
|
+
- `BOT_ACCOUNT_EMAIL` — The email address used to login.
|
|
29
|
+
- `BOT_ACCOUNT_PASSWORD` — The password used to login.
|
|
30
|
+
- `CI_MERGE_REQUEST_IID` — By default tests are run against the staging environment on
|
|
31
|
+
<https://staging.appsemble.review>. If this variable is specified, tests are run against the merge
|
|
32
|
+
request review environment instead.
|
|
33
|
+
- `ACCESS_TOKEN` — The access token of the account that's logged in.
|
|
34
|
+
|
|
35
|
+
### Fixtures
|
|
36
|
+
|
|
37
|
+
Common end-to-end fixtures are defined under the `fixtures` directory. These are exported for other
|
|
38
|
+
packages to use, like client apps. This can be done by installing this package and importing `test`
|
|
39
|
+
or `expect`.
|
|
40
|
+
|
|
41
|
+
### Authentication
|
|
42
|
+
|
|
43
|
+
Some fixtures call the Appsemble API using the Playwright `request` object. This expects you to have
|
|
44
|
+
set an access token as environment variable with the name **ACCESS_TOKEN** beforehand. The easiest
|
|
45
|
+
way to do this is by setting it in a setup step using the `loginUser` fixture.
|
|
46
|
+
|
|
47
|
+
`auth.setup.ts`
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
setup('authenticate', async ({ loginUser }) => {
|
|
51
|
+
const accessToken = await loginUser('bot', '12345');
|
|
52
|
+
process.env.ACCESS_TOKEN = accessToken;
|
|
53
|
+
});
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Contributing
|
|
57
|
+
|
|
58
|
+
When writing end-to-end tests, have a look at the
|
|
59
|
+
[best practices](../../CONTRIBUTING.md#best-practices) to help you write solid tests.
|
|
60
|
+
|
|
61
|
+
## License
|
|
62
|
+
|
|
63
|
+
[LGPL-3.0-only](https://gitlab.com/appsemble/appsemble/-/blob/0.32.2/LICENSE.md) ©
|
|
64
|
+
[Appsemble](https://appsemble.com)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type TrainingStatus } from '@appsemble/types';
|
|
2
|
+
import { type Locator } from '@playwright/test';
|
|
3
|
+
export interface TrainingMatchers {
|
|
4
|
+
/**
|
|
5
|
+
* Asserts whether all child elements of this training node are correct for the given state
|
|
6
|
+
*
|
|
7
|
+
* @param status Status of the training
|
|
8
|
+
*/
|
|
9
|
+
toHaveChapterStatus: (trainingNode: Locator, status: TrainingStatus) => Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
export declare const expect: import("@playwright/test").Expect<{
|
|
12
|
+
toHaveChapterStatus(this: import("@playwright/test").ExpectMatcherState, trainingNode: Locator, status: TrainingStatus): Promise<{
|
|
13
|
+
message: () => string;
|
|
14
|
+
pass: true;
|
|
15
|
+
name: string;
|
|
16
|
+
}>;
|
|
17
|
+
}>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { expect as base } from '@playwright/test';
|
|
2
|
+
import { availableColor, blockedColor, completedColor, inProgressColor, } from '../../../tests/studio/trainings/constants.js';
|
|
3
|
+
export const expect = base.extend({
|
|
4
|
+
async toHaveChapterStatus(trainingNode, status) {
|
|
5
|
+
let backgroundColor = availableColor;
|
|
6
|
+
let title = 'node-title-available';
|
|
7
|
+
switch (status) {
|
|
8
|
+
case 'blocked':
|
|
9
|
+
backgroundColor = blockedColor;
|
|
10
|
+
title = 'node-title-blocked';
|
|
11
|
+
break;
|
|
12
|
+
case 'completed':
|
|
13
|
+
backgroundColor = completedColor;
|
|
14
|
+
break;
|
|
15
|
+
case 'in progress':
|
|
16
|
+
backgroundColor = inProgressColor;
|
|
17
|
+
break;
|
|
18
|
+
default:
|
|
19
|
+
backgroundColor = availableColor;
|
|
20
|
+
}
|
|
21
|
+
await expect(trainingNode.getByTestId('status-circle')).toHaveCSS('background-color', backgroundColor);
|
|
22
|
+
await expect(trainingNode.getByTestId(title)).toBeVisible();
|
|
23
|
+
return {
|
|
24
|
+
message: () => 'All elements are valid',
|
|
25
|
+
pass: true,
|
|
26
|
+
name: 'toHaveChapterStatus',
|
|
27
|
+
};
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type App } from '@appsemble/types';
|
|
2
|
+
export interface AppFixtures {
|
|
3
|
+
/**
|
|
4
|
+
* Create an app.
|
|
5
|
+
*/
|
|
6
|
+
createApp: (organization: string, yaml: string) => Promise<App>;
|
|
7
|
+
/**
|
|
8
|
+
* Set the role of the user.
|
|
9
|
+
*
|
|
10
|
+
* Note that this requires the user to be logged in to the studio.
|
|
11
|
+
*
|
|
12
|
+
* @param appId The ID of the app to set the role for.
|
|
13
|
+
* @param role The role to set.
|
|
14
|
+
*/
|
|
15
|
+
changeAppMemberRole: (appId: number, role: string) => Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Gets the ID of an app
|
|
18
|
+
*
|
|
19
|
+
* @param appPath Path of the app
|
|
20
|
+
* @returns ID of the app
|
|
21
|
+
*/
|
|
22
|
+
getAppId: (appPath: string) => Promise<number>;
|
|
23
|
+
}
|
|
24
|
+
export declare const test: import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions & AppFixtures, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { test as base } from '@playwright/test';
|
|
2
|
+
import stripIndent from 'strip-indent';
|
|
3
|
+
import { expect } from '../../expect/index.js';
|
|
4
|
+
export const test = base.extend({
|
|
5
|
+
async createApp({ request }, use) {
|
|
6
|
+
await use(async (organization, yaml) => {
|
|
7
|
+
const formData = new FormData();
|
|
8
|
+
formData.append('OrganizationId', organization.toLowerCase());
|
|
9
|
+
formData.append('yaml', stripIndent(yaml));
|
|
10
|
+
const response = await request.post('/api/apps', {
|
|
11
|
+
data: formData,
|
|
12
|
+
headers: {
|
|
13
|
+
Authorization: `Bearer ${process.env.ACCESS_TOKEN}`,
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
expect(response.status()).toBe(201);
|
|
17
|
+
const app = (await response.json());
|
|
18
|
+
expect(app).not.toBeNull();
|
|
19
|
+
return app;
|
|
20
|
+
});
|
|
21
|
+
},
|
|
22
|
+
async changeAppMemberRole({ browser }, use) {
|
|
23
|
+
await use(async (appId, role) => {
|
|
24
|
+
const page = await browser.newPage();
|
|
25
|
+
await page.goto(`/en/apps/${appId}/-/users`);
|
|
26
|
+
const select = page.locator('tr', { hasText: 'It’s you!' }).locator('select[class=""]');
|
|
27
|
+
await select.selectOption(role);
|
|
28
|
+
await page.close();
|
|
29
|
+
});
|
|
30
|
+
},
|
|
31
|
+
async getAppId({ request }, use) {
|
|
32
|
+
await use(async (appPath) => {
|
|
33
|
+
const apps = await (await request.get('/api/apps')).json();
|
|
34
|
+
const appId = apps.find(({ path }) => path === appPath)?.id;
|
|
35
|
+
expect(appId).not.toBeUndefined();
|
|
36
|
+
return appId;
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface AppCollectionFixtures {
|
|
2
|
+
/**
|
|
3
|
+
* Creates an app collection for the given organization
|
|
4
|
+
*
|
|
5
|
+
* @param organizationId ID of the organization to create the collection for
|
|
6
|
+
* @param collectionName Name of the collection
|
|
7
|
+
* @param expertName Name of the expert
|
|
8
|
+
* @param expertDescription Description of the expert
|
|
9
|
+
* @param headerImage Image that will be placed as the header of the collection
|
|
10
|
+
* @param expertPhoto Photo that represents the expert
|
|
11
|
+
* @param isPrivate Whether the collection should be private or not
|
|
12
|
+
*/
|
|
13
|
+
createAppCollection: (organizationId: string, collectionName: string, expertName: string, expertDescription: string, headerImage: string, expertPhoto: string, isPrivate: boolean) => Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Delete an existing app collection
|
|
16
|
+
*
|
|
17
|
+
* @param organizationId ID of the organization which the collection belongs to
|
|
18
|
+
* @param collectionName Name of the collection
|
|
19
|
+
*/
|
|
20
|
+
deleteAppCollection: (organizationId: string, collectionName: string) => Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
export declare const test: import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions & AppCollectionFixtures, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { test as base } from '@playwright/test';
|
|
2
|
+
import { expect } from '../../../index.js';
|
|
3
|
+
export const test = base.extend({
|
|
4
|
+
async createAppCollection({ page }, use) {
|
|
5
|
+
await use(async (organizationId, collectionName, expertName, expertDescription, headerImage, expertPhoto, isPrivate) => {
|
|
6
|
+
await page.goto(`/en/organizations/${organizationId}/collections`);
|
|
7
|
+
await page.getByRole('link', { name: 'App collections' }).first().click();
|
|
8
|
+
await page.getByRole('button', { name: 'Create new app collection' }).click();
|
|
9
|
+
await page.getByLabel('Name', { exact: true }).fill(collectionName);
|
|
10
|
+
await page
|
|
11
|
+
.locator('span')
|
|
12
|
+
.filter({ hasText: 'Header image' })
|
|
13
|
+
.first()
|
|
14
|
+
.setInputFiles(headerImage);
|
|
15
|
+
if (isPrivate) {
|
|
16
|
+
await page.getByText('Hide this app collection from the public list').click();
|
|
17
|
+
}
|
|
18
|
+
await page.getByLabel('Expert name').fill(expertName);
|
|
19
|
+
await page.getByLabel('Expert description').fill(expertDescription);
|
|
20
|
+
await page
|
|
21
|
+
.locator('span')
|
|
22
|
+
.filter({ hasText: 'Expert photo' })
|
|
23
|
+
.first()
|
|
24
|
+
.setInputFiles(expertPhoto);
|
|
25
|
+
// Avatar editor
|
|
26
|
+
await page.getByRole('button', { name: 'Save' }).click();
|
|
27
|
+
await page.getByRole('button', { name: 'Create app collection' }).click();
|
|
28
|
+
await expect(page.getByRole('heading', { name: collectionName })).toBeVisible();
|
|
29
|
+
});
|
|
30
|
+
},
|
|
31
|
+
async deleteAppCollection({ page }, use) {
|
|
32
|
+
await use(async (organizationId, collectionName) => {
|
|
33
|
+
await page.goto(`/en/organizations/${organizationId}/collections`);
|
|
34
|
+
await page.getByRole('link', { name: collectionName }).click();
|
|
35
|
+
await page.getByRole('link', { name: 'Settings' }).click();
|
|
36
|
+
await page.getByRole('button', { name: 'Delete app collection' }).click();
|
|
37
|
+
await page.getByRole('button', { name: 'Delete app collection', exact: true }).click();
|
|
38
|
+
await expect(page.getByRole('heading', { name: collectionName })).toBeHidden();
|
|
39
|
+
});
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface DemoAppFixtures {
|
|
2
|
+
/**
|
|
3
|
+
* Reseed the given app
|
|
4
|
+
*
|
|
5
|
+
* @param appId The ID of the app to reseed
|
|
6
|
+
*/
|
|
7
|
+
reseedDemoApp: (appId: number) => Promise<void>;
|
|
8
|
+
/**
|
|
9
|
+
* Login to an Appsemble demo app.
|
|
10
|
+
*
|
|
11
|
+
* @param role The role to login in as.
|
|
12
|
+
*/
|
|
13
|
+
loginDemoApp: (role: string) => Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
export declare const test: import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions & DemoAppFixtures, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { test as base } from '@playwright/test';
|
|
2
|
+
export const test = base.extend({
|
|
3
|
+
async reseedDemoApp({ browser }, use) {
|
|
4
|
+
await use(async (appId) => {
|
|
5
|
+
const page = await browser.newPage();
|
|
6
|
+
await page.goto(`/en/apps/${appId}/-/`);
|
|
7
|
+
await page.getByRole('button', { name: 'Reseed App' }).click();
|
|
8
|
+
await page.getByRole('button', { name: 'Reseed', exact: true }).click();
|
|
9
|
+
await page.close();
|
|
10
|
+
});
|
|
11
|
+
},
|
|
12
|
+
async loginDemoApp({ page }, use) {
|
|
13
|
+
await use(async (role) => {
|
|
14
|
+
const btn = page.getByTestId('create-account');
|
|
15
|
+
if (await btn.isVisible()) {
|
|
16
|
+
await page.getByTestId('app-role').selectOption(role);
|
|
17
|
+
await btn.click();
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface GroupFixtures {
|
|
2
|
+
/**
|
|
3
|
+
* Set the role of the member in a group.
|
|
4
|
+
*
|
|
5
|
+
* @param appId The app to set the role for.
|
|
6
|
+
* @param group The group to set the role for.
|
|
7
|
+
* @param role The role to set.
|
|
8
|
+
*/
|
|
9
|
+
changeGroupRole: (appId: number, group: string, role: string) => Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
export declare const test: import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions & GroupFixtures, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { test as base } from '@playwright/test';
|
|
2
|
+
export const test = base.extend({
|
|
3
|
+
async changeGroupRole({ browser }, use) {
|
|
4
|
+
await use(async (appId, group, role) => {
|
|
5
|
+
const page = await browser.newPage();
|
|
6
|
+
await page.goto(`/en/apps/${appId}/-/groups`);
|
|
7
|
+
await page.click(`text=${group}`);
|
|
8
|
+
await page.getByRole('row', { name: 'Bot' }).locator('#role').selectOption(role);
|
|
9
|
+
await page.close();
|
|
10
|
+
});
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const test: import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions & import("./app/index.js").AppFixtures & import("./app-collection/index.js").AppCollectionFixtures & import("./demo-app/index.js").DemoAppFixtures & import("./group/index.js").GroupFixtures & import("./live-app/index.js").LiveAppFixtures & import("./resource/index.js").ResourceFixtures & import("./studio/index.js").StudioFixtures & import("./training/index.js").TrainingFixtures, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { mergeTests } from '@playwright/test';
|
|
2
|
+
import { test as appFixtures } from './app/index.js';
|
|
3
|
+
import { test as appCollectionFixtures } from './app-collection/index.js';
|
|
4
|
+
import { test as demoAppFixtures } from './demo-app/index.js';
|
|
5
|
+
import { test as groupFixtures } from './group/index.js';
|
|
6
|
+
import { test as liveAppFixtures } from './live-app/index.js';
|
|
7
|
+
import { test as resourceFixtures } from './resource/index.js';
|
|
8
|
+
import { test as studioFixtures } from './studio/index.js';
|
|
9
|
+
import { test as trainingFixtures } from './training/index.js';
|
|
10
|
+
export const test = mergeTests(appFixtures, appCollectionFixtures, demoAppFixtures, groupFixtures, liveAppFixtures, resourceFixtures, studioFixtures, trainingFixtures);
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface LiveAppFixtures {
|
|
2
|
+
/**
|
|
3
|
+
* Visit an app.
|
|
4
|
+
*
|
|
5
|
+
* @param appId The app id.
|
|
6
|
+
*/
|
|
7
|
+
visitApp: (appPath: string) => Promise<void>;
|
|
8
|
+
/**
|
|
9
|
+
* Login to an app with the Appsemble OAuth2 flow.
|
|
10
|
+
*/
|
|
11
|
+
loginAppAppsembleOAuth: () => Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* Gives the app consent to perform actions on the app member's behalf
|
|
14
|
+
*
|
|
15
|
+
* This makes it so the consent screen doesn't pop up when trying to log in
|
|
16
|
+
*
|
|
17
|
+
* @param appId ID of the app to give consent to
|
|
18
|
+
*/
|
|
19
|
+
giveAppConsent: (appId: number) => Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* Gets the URL to visit the live app
|
|
22
|
+
*
|
|
23
|
+
* @param appId ID of the app
|
|
24
|
+
*/
|
|
25
|
+
getLiveAppURL: (appId: number) => Promise<string>;
|
|
26
|
+
}
|
|
27
|
+
export declare const test: import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions & LiveAppFixtures, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { test as base } from '@playwright/test';
|
|
2
|
+
import { expect } from '../../expect/index.js';
|
|
3
|
+
export const test = base.extend({
|
|
4
|
+
async visitApp({ getLiveAppURL, page, request }, use) {
|
|
5
|
+
await use(async (appPath) => {
|
|
6
|
+
const apps = await (await request.get('/api/apps')).json();
|
|
7
|
+
const appId = apps.find(({ path }) => path === appPath)?.id;
|
|
8
|
+
expect(appId).not.toBeUndefined();
|
|
9
|
+
const url = await getLiveAppURL(appId);
|
|
10
|
+
await page.goto(url);
|
|
11
|
+
});
|
|
12
|
+
},
|
|
13
|
+
async loginAppAppsembleOAuth({ page }, use) {
|
|
14
|
+
await use(async () => {
|
|
15
|
+
await page.waitForURL('**/Login**');
|
|
16
|
+
const params = new URLSearchParams(page.url().split('Login?')[1]);
|
|
17
|
+
const redirect = params.get('redirect');
|
|
18
|
+
await page.getByTestId('login-with-appsemble').click();
|
|
19
|
+
await page.waitForURL(`**${redirect}`);
|
|
20
|
+
});
|
|
21
|
+
},
|
|
22
|
+
async giveAppConsent({ getLiveAppURL, request }, use) {
|
|
23
|
+
await use(async (appId) => {
|
|
24
|
+
const url = await getLiveAppURL(appId);
|
|
25
|
+
const response = await request.post(`/api/users/current/auth/oauth2/apps/${appId}/consent/agree`, {
|
|
26
|
+
data: {
|
|
27
|
+
redirectUri: url,
|
|
28
|
+
scope: 'openid',
|
|
29
|
+
},
|
|
30
|
+
headers: {
|
|
31
|
+
Authorization: `Bearer ${process.env.ACCESS_TOKEN}`,
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
expect(response.status()).toBe(201);
|
|
35
|
+
});
|
|
36
|
+
},
|
|
37
|
+
async getLiveAppURL({ baseURL, request }, use) {
|
|
38
|
+
await use(async (appId) => {
|
|
39
|
+
expect(baseURL).not.toBeUndefined();
|
|
40
|
+
const response = await request.get(`/api/apps/${appId}`);
|
|
41
|
+
expect(response.status()).toBe(200);
|
|
42
|
+
const { OrganizationId, domain, path } = (await response.json());
|
|
43
|
+
expect(path).not.toBeNull();
|
|
44
|
+
const baseUrl = new URL(baseURL);
|
|
45
|
+
const origin = domain || `${path}.${OrganizationId}.${baseUrl.host}`;
|
|
46
|
+
return `${baseUrl.protocol}//${origin}`;
|
|
47
|
+
});
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type Resource } from '@appsemble/types';
|
|
2
|
+
export interface ResourceFixtures {
|
|
3
|
+
/**
|
|
4
|
+
* Create resource(s) from JSON input.
|
|
5
|
+
*
|
|
6
|
+
* @param appId The ID of the app.
|
|
7
|
+
* @param type The resource type.
|
|
8
|
+
* @param input The resource JSON input.
|
|
9
|
+
*/
|
|
10
|
+
createResource: (appId: number, type: string, input: unknown) => Promise<Resource>;
|
|
11
|
+
/**
|
|
12
|
+
* Delete all resources from an app.
|
|
13
|
+
*
|
|
14
|
+
* @param appId Id of the app to delete the resources of.
|
|
15
|
+
*/
|
|
16
|
+
deleteAllResources: (appId: number) => Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
export declare const test: import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions & ResourceFixtures, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { test as base } from '@playwright/test';
|
|
2
|
+
import { expect } from '../../expect/index.js';
|
|
3
|
+
export const test = base.extend({
|
|
4
|
+
async createResource({ request }, use) {
|
|
5
|
+
await use(async (appId, type, input) => {
|
|
6
|
+
const response = await request.post(`/api/apps/${appId}/resources/${type}`, {
|
|
7
|
+
data: JSON.stringify(input),
|
|
8
|
+
headers: {
|
|
9
|
+
Authorization: `Bearer ${process.env.ACCESS_TOKEN}`,
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
expect(response.status()).toBe(201);
|
|
13
|
+
const resource = (await response.json());
|
|
14
|
+
expect(resource).not.toBeNull();
|
|
15
|
+
return resource;
|
|
16
|
+
});
|
|
17
|
+
},
|
|
18
|
+
async deleteAllResources({ request }, use) {
|
|
19
|
+
await use(async (appId) => {
|
|
20
|
+
const response = await request.delete(`/api/apps/${appId}/resources`, {
|
|
21
|
+
headers: {
|
|
22
|
+
Authorization: `Bearer ${process.env.ACCESS_TOKEN}`,
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
expect(response.status()).toBe(204);
|
|
26
|
+
});
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface StudioFixtures {
|
|
2
|
+
/**
|
|
3
|
+
* Log into Appsemble studio as a user
|
|
4
|
+
*
|
|
5
|
+
* @param email Email address of the account to log in with
|
|
6
|
+
* @param password Password of the account
|
|
7
|
+
* @param saveInStorageState Whether or not to save the authenticated state as reusable storage
|
|
8
|
+
* state (see: https://playwright.dev/docs/auth#basic-shared-account-in-all-tests)
|
|
9
|
+
* @returns The user's access token
|
|
10
|
+
*/
|
|
11
|
+
loginUser: (email: string, password: string, saveInStorageState?: boolean) => Promise<string>;
|
|
12
|
+
/**
|
|
13
|
+
* Log the worker out of their current user account
|
|
14
|
+
*/
|
|
15
|
+
logoutUser: () => Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
export declare const test: import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions & StudioFixtures, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions>;
|