@appsemble/e2e 0.35.20 → 0.36.1

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/README.md CHANGED
@@ -1,8 +1,8 @@
1
- # ![](https://gitlab.com/appsemble/appsemble/-/raw/0.35.20/config/assets/logo.svg) Appsemble End 2 End Tests
1
+ # ![](https://gitlab.com/appsemble/appsemble/-/raw/0.36.1/config/assets/logo.svg) Appsemble End 2 End Tests
2
2
 
3
3
  > Run end 2 end tests on an Appsemble environment and provide Appsemble fixtures
4
4
 
5
- [![GitLab CI](https://gitlab.com/appsemble/appsemble/badges/0.35.20/pipeline.svg)](https://gitlab.com/appsemble/appsemble/-/releases/0.35.20)
5
+ [![GitLab CI](https://gitlab.com/appsemble/appsemble/badges/0.36.1/pipeline.svg)](https://gitlab.com/appsemble/appsemble/-/releases/0.36.1)
6
6
  [![Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://prettier.io)
7
7
 
8
8
  ## Table of Contents
@@ -82,7 +82,7 @@ to have logged in and set the access token in the `request` fixture beforehand.
82
82
  so:
83
83
 
84
84
  ```ts
85
- export const test = base.extend<{}>({
85
+ export const test = base.extend<object>({
86
86
  async request({}, use) {
87
87
  const newRequest = await request.newContext({
88
88
  extraHTTPHeaders: {
@@ -102,5 +102,5 @@ When writing end-to-end tests, have a look at the
102
102
 
103
103
  ## License
104
104
 
105
- [LGPL-3.0-only](https://gitlab.com/appsemble/appsemble/-/blob/0.35.20/LICENSE.md) ©
105
+ [LGPL-3.0-only](https://gitlab.com/appsemble/appsemble/-/blob/0.36.1/LICENSE.md) ©
106
106
  [Appsemble](https://appsemble.com)
@@ -7,6 +7,6 @@ export declare const baseTest: import("@playwright/test").TestType<import("@play
7
7
  *
8
8
  * Used for tests that require a logged in user
9
9
  */
10
- export declare const authenticatedTest: 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("./organization/index.js").OrganizationFixtures & import("./resource/index.js").ResourceFixtures & import("./studio/index.js").StudioFixtures & import("./test-utils/index.js").TestUtilsFixtures & import("./training/index.js").TrainingFixtures, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions & {
10
+ export declare const authenticatedTest: 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("./organization/index.js").OrganizationFixtures & import("./resource/index.js").ResourceFixtures & import("./studio/index.js").StudioFixtures & import("./test-utils/index.js").TestUtilsFixtures & import("./training/index.js").TrainingFixtures & object, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions & {
11
11
  workerStorageState: string;
12
12
  }>;
@@ -11,10 +11,21 @@ export interface ResourceFixtures {
11
11
  */
12
12
  createResource: (appId: number, type: string, input: unknown, assets?: Blob[]) => Promise<Resource>;
13
13
  /**
14
- * Delete all resources from an app.
14
+ * Delete all seed resources from an app,
15
+ * To delete all the resources of a specific type,
16
+ * use `resourceType` optional argument.
15
17
  *
16
18
  * @param appId Id of the app to delete the resources of.
19
+ * @param resourceType Type of the resource to delete.
17
20
  */
18
- deleteAllResources: (appId: number) => Promise<void>;
21
+ deleteAllResources: (appId: number, resourceType?: string) => Promise<void>;
22
+ /**
23
+ * Delete a resource from an app.
24
+ *
25
+ * @param appId Id of the app to delete the resource of.
26
+ * @param resourceType Type of the resource to delete.
27
+ * @param id Id of the resource to delete.
28
+ */
29
+ deleteResource: (appId: number, resourceType: string, id: number) => Promise<void>;
19
30
  }
20
31
  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>;
@@ -20,8 +20,26 @@ export const test = base.extend({
20
20
  });
21
21
  },
22
22
  async deleteAllResources({ request }, use) {
23
- await use(async (appId) => {
24
- const response = await request.delete(`/api/apps/${appId}/resources`);
23
+ await use(async (appId, resourceType) => {
24
+ if (resourceType) {
25
+ const queryResponse = await request.get(`/api/apps/${appId}/resources/${resourceType}`, {
26
+ params: { $select: 'id' },
27
+ });
28
+ const resources = (await queryResponse.json());
29
+ const response = await request.delete(`/api/apps/${appId}/resources/${resourceType}`, {
30
+ data: resources.map(({ id }) => id),
31
+ });
32
+ expect(response.status()).toBe(204);
33
+ }
34
+ else {
35
+ const response = await request.delete(`/api/apps/${appId}/resources`);
36
+ expect(response.status()).toBe(204);
37
+ }
38
+ });
39
+ },
40
+ async deleteResource({ request }, use) {
41
+ await use(async (appId, resourceType, id) => {
42
+ const response = await request.delete(`/api/apps/${appId}/resources/${resourceType}/${id}`);
25
43
  expect(response.status()).toBe(204);
26
44
  });
27
45
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appsemble/e2e",
3
- "version": "0.35.20",
3
+ "version": "0.36.1",
4
4
  "description": "End-to-end tests used for testing Appsemble apps in an existing environment.",
5
5
  "keywords": [
6
6
  "app",
@@ -38,9 +38,9 @@
38
38
  "test": "vitest"
39
39
  },
40
40
  "dependencies": {
41
- "@appsemble/lang-sdk": "0.35.20",
42
- "@appsemble/node-utils": "0.35.20",
43
- "@appsemble/types": "0.35.20",
41
+ "@appsemble/lang-sdk": "0.36.1",
42
+ "@appsemble/node-utils": "0.36.1",
43
+ "@appsemble/types": "0.36.1",
44
44
  "@playwright/test": "1.51.1",
45
45
  "strip-indent": "^4.0.0"
46
46
  },
@@ -27,7 +27,6 @@ test.describe('Payments', () => {
27
27
  .click();
28
28
  await page.getByLabel('Cancellation reason(Optional)').fill('Not happy.');
29
29
  await expect(page.getByRole('button', { name: 'Cancel subscription' })).toBeVisible();
30
- // eslint-disable-next-line playwright/no-conditional-in-test
31
30
  if (!CI) {
32
31
  await page.getByRole('button', { name: 'Cancel subscription' }).click();
33
32
  await expect(page.getByText('Extend')).toBeVisible();
@@ -54,7 +53,6 @@ test.describe('Payments', () => {
54
53
  await page.getByLabel('Name', { exact: true }).fill(organizationId);
55
54
  await page.getByRole('button').getByText('Continue').click();
56
55
  await expect(page.getByText('Total subscription price')).toBeVisible();
57
- // eslint-disable-next-line playwright/no-conditional-in-test
58
56
  if (!CI) {
59
57
  await page.getByRole('button', { name: 'Summary ' }).click();
60
58
  await expect(page).toHaveTitle('Appsemble b.v.');
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,26 @@
1
+ import { expect, authenticatedTest as test } from '../../index.js';
2
+ test.describe('Reseed', () => {
3
+ test.beforeEach(async ({ page }) => {
4
+ await page.route('**/api/apps/0?language=en', async (route) => {
5
+ await route.fulfill({ path: 'mock-data/demo-test-app-details.json' });
6
+ });
7
+ });
8
+ test('should not show the reseed button if user is not logged in', async ({ browser }) => {
9
+ const page = await browser.newPage({ storageState: undefined });
10
+ await page.route('**/api/apps/0?language=en', async (route) => {
11
+ await route.fulfill({ path: 'mock-data/demo-test-app-details.json' });
12
+ });
13
+ await page.goto('/apps/0/demo-test-app');
14
+ await expect(page.getByRole('button', { name: 'Reseed App' })).toBeHidden();
15
+ });
16
+ test('should show the reseed button if user is logged in', async ({ page }) => {
17
+ await page.goto('/apps/0/demo-test-app');
18
+ await expect(page.getByRole('button', { name: 'Reseed App' })).toBeVisible();
19
+ });
20
+ test('should show user they do not have permission when trying to reseed without permission', async ({ page, }) => {
21
+ await page.goto('/apps/0/demo-test-app');
22
+ await page.getByRole('button', { name: 'Reseed App' }).click();
23
+ await expect(page.getByText('You do not have permission to reseed this app.')).toBeVisible();
24
+ });
25
+ });
26
+ //# sourceMappingURL=reseed.spec.js.map