Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/playwright-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Playwright tests

on:
push:
branches:
- '[0-9]+.[0-9]+'
pull_request: ~

jobs:
playwright-oss:
name: "Playwright/OSS"
uses: ibexa/gh-workflows/.github/workflows/playwright-browser-tests.yml@ibx-11740-playwright

Check failure on line 12 in .github/workflows/playwright-tests.yml

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use full commit SHA hash for this dependency.

See more on https://sonarcloud.io/project/issues?id=ibexa_admin-ui&issues=AZ701bIVbb0SHGvLlmsi&open=AZ701bIVbb0SHGvLlmsi&pullRequest=1947
with:
project-edition: 'oss'
test-package: 'admin-ui'
secrets: inherit

Check warning on line 16 in .github/workflows/playwright-tests.yml

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Only pass required secrets to this workflow.

See more on https://sonarcloud.io/project/issues?id=ibexa_admin-ui&issues=AZ701bIVbb0SHGvLlmse&open=AZ701bIVbb0SHGvLlmse&pullRequest=1947

playwright-headless:
name: "Playwright/Headless"
uses: ibexa/gh-workflows/.github/workflows/playwright-browser-tests.yml@ibx-11740-playwright

Check failure on line 20 in .github/workflows/playwright-tests.yml

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use full commit SHA hash for this dependency.

See more on https://sonarcloud.io/project/issues?id=ibexa_admin-ui&issues=AZ71BLJSjzY0enYhtimc&open=AZ71BLJSjzY0enYhtimc&pullRequest=1947
with:
project-edition: 'headless'
test-package: 'admin-ui'
secrets: inherit

Check warning on line 24 in .github/workflows/playwright-tests.yml

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Only pass required secrets to this workflow.

See more on https://sonarcloud.io/project/issues?id=ibexa_admin-ui&issues=AZ701bIVbb0SHGvLlmsf&open=AZ701bIVbb0SHGvLlmsf&pullRequest=1947

playwright-experience:
name: "Playwright/Experience"
uses: ibexa/gh-workflows/.github/workflows/playwright-browser-tests.yml@ibx-11740-playwright

Check failure on line 28 in .github/workflows/playwright-tests.yml

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use full commit SHA hash for this dependency.

See more on https://sonarcloud.io/project/issues?id=ibexa_admin-ui&issues=AZ71BLJSjzY0enYhtimd&open=AZ71BLJSjzY0enYhtimd&pullRequest=1947
with:
project-edition: 'experience'
test-package: 'admin-ui'
secrets: inherit

Check warning on line 32 in .github/workflows/playwright-tests.yml

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Only pass required secrets to this workflow.

See more on https://sonarcloud.io/project/issues?id=ibexa_admin-ui&issues=AZ701bIVbb0SHGvLlmsg&open=AZ701bIVbb0SHGvLlmsg&pullRequest=1947

playwright-commerce:
name: "Playwright/Commerce"
uses: ibexa/gh-workflows/.github/workflows/playwright-browser-tests.yml@ibx-11740-playwright

Check failure on line 36 in .github/workflows/playwright-tests.yml

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use full commit SHA hash for this dependency.

See more on https://sonarcloud.io/project/issues?id=ibexa_admin-ui&issues=AZ701bIVbb0SHGvLlmsl&open=AZ701bIVbb0SHGvLlmsl&pullRequest=1947
with:
project-edition: 'commerce'
test-package: 'admin-ui'
secrets: inherit

Check warning on line 40 in .github/workflows/playwright-tests.yml

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Only pass required secrets to this workflow.

See more on https://sonarcloud.io/project/issues?id=ibexa_admin-ui&issues=AZ701bIVbb0SHGvLlmsh&open=AZ701bIVbb0SHGvLlmsh&pullRequest=1947
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
"ts-test": "tsc --noEmit",
"eslint-test": "eslint \"./src/bundle/Resources/**/*.{js,ts}\" \"./src/bundle/ui-dev/**/*.{js,tsx}\"",
"prettier-test": "yarn prettier \"./src/bundle/Resources/**/*.{js,ts,scss}\" \"./src/bundle/ui-dev/**/*.{js,tsx}\" --check",
"postinstall": "yarn ibexa-generate-tsconfig --use-root-project-tsconfig"
"postinstall": "yarn ibexa-generate-tsconfig --use-root-project-tsconfig",
"pw:install": "npm --prefix tests/playwright-tests install",
"pw:test": "npm --prefix tests/playwright-tests test --",
"pw:test:headless": "npm --prefix tests/playwright-tests run test:headless --",
"pw:test:experience": "npm --prefix tests/playwright-tests run test:experience --",
"pw:test:commerce": "npm --prefix tests/playwright-tests run test:commerce --"
}
}
9 changes: 9 additions & 0 deletions tests/playwright-tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.env
.auth/
playwright-report/
test-results/
node_modules/
dist/
# un-ignore files excluded by root .gitignore
!tsconfig.json
!package-lock.json
135 changes: 135 additions & 0 deletions tests/playwright-tests/Tests/Trash.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
import { test, expect } from '@playwright/test';
import { TrashPage, ContentManagementPage, IbexaApiClient } from '@ibexa/cohesivo-playwright';


test.describe('Trash management', { tag: ['@IbexaOSS', '@IbexaHeadless', '@IbexaExperience', '@IbexaCommerce'] }, () => {
let api: IbexaApiClient;
let trashTestLocationId: number;
let trashTestContentId: number;
let runId: string;

test.beforeAll(async () => {
api = new IbexaApiClient();
await api.init();
runId = Date.now().toString().slice(-6);

trashTestContentId = await api.createFolder(`TrashTest${runId}`, 2);
trashTestLocationId = await api.getMainLocationId(trashTestContentId);
});

test.afterAll(async () => {
if (api && trashTestContentId) {
await api.deleteContent(trashTestContentId);
}
});

test('Trash can be emptied', async ({ page }) => {

Check failure on line 26 in tests/playwright-tests/Tests/Trash.spec.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add at least one assertion to this test case.

See more on https://sonarcloud.io/project/issues?id=ibexa_admin-ui&issues=AaBISByjjElgpndrCnbL&open=AaBISByjjElgpndrCnbL&pullRequest=1947
const childId = await api.createFolder(`FolderToTrash${runId}`, trashTestLocationId);
const childLocId = await api.getMainLocationId(childId);

const contentPage = new ContentManagementPage(page);
await contentPage.open(childId, childLocId);
await contentPage.sendToTrash();

const trash = new TrashPage(page);
await trash.open();
await trash.assertNotEmpty();
await trash.emptyTrash();
await trash.assertEmpty();
});

test('Content can be moved to trash', async ({ page }) => {

Check failure on line 41 in tests/playwright-tests/Tests/Trash.spec.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add at least one assertion to this test case.

See more on https://sonarcloud.io/project/issues?id=ibexa_admin-ui&issues=AaBISByjjElgpndrCnbM&open=AaBISByjjElgpndrCnbM&pullRequest=1947
const name = `FolderToTrashManually${runId}`;
const childId = await api.createFolder(name, trashTestLocationId);
const childLocId = await api.getMainLocationId(childId);

const contentPage = new ContentManagementPage(page);
await contentPage.open(childId, childLocId);
await contentPage.sendToTrash();

await contentPage.notifications.assertSuccess(`Location '${name}' moved to Trash`);

const trash = new TrashPage(page);
await trash.open();
await trash.assertItemInTrash(name);
});

test('Element in trash can be deleted', async ({ page }) => {

Check failure on line 57 in tests/playwright-tests/Tests/Trash.spec.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add at least one assertion to this test case.

See more on https://sonarcloud.io/project/issues?id=ibexa_admin-ui&issues=AaBISByjjElgpndrCnbN&open=AaBISByjjElgpndrCnbN&pullRequest=1947
const name = `DeleteFromTrash${runId}`;
const childId = await api.createFolder(name, trashTestLocationId);
const childLocId = await api.getMainLocationId(childId);

const contentPage = new ContentManagementPage(page);
await contentPage.open(childId, childLocId);
await contentPage.sendToTrash();

const trash = new TrashPage(page);
await trash.open();
await trash.assertItemInTrash(name);
await trash.deleteFromTrash([name]);
await trash.notifications.assertSuccess('Deleted selected item(s) from Trash');
await trash.assertItemNotInTrash(name);
});

test('Element in trash can be restored', async ({ page }) => {

Check failure on line 74 in tests/playwright-tests/Tests/Trash.spec.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add at least one assertion to this test case.

See more on https://sonarcloud.io/project/issues?id=ibexa_admin-ui&issues=AaBISByjjElgpndrCnbO&open=AaBISByjjElgpndrCnbO&pullRequest=1947
const name = `RestoreFromTrash${runId}`;
const childId = await api.createFolder(name, trashTestLocationId);
const childLocId = await api.getMainLocationId(childId);

const contentPage = new ContentManagementPage(page);
await contentPage.open(childId, childLocId);
await contentPage.sendToTrash();

const trash = new TrashPage(page);
await trash.open();
await trash.assertItemInTrash(name);
await trash.restoreFromTrash([name]);
await trash.notifications.assertSuccess('Restored content to its original Location');
await trash.assertItemNotInTrash(name);
});

test('Element in trash can be restored under new location', async ({ page }) => {
const name = `RestoreFromTrashNewLocation${runId}`;
const childId = await api.createFolder(name, trashTestLocationId);
const childLocId = await api.getMainLocationId(childId);

const contentPage = new ContentManagementPage(page);
await contentPage.open(childId, childLocId);
await contentPage.sendToTrash();

const trash = new TrashPage(page);
await trash.open();
await trash.assertItemInTrash(name);
await trash.restoreUnderNewLocation([name], 'Media/Files');

await trash.notifications.assertSuccess("Restored content under Location 'Files'");
await trash.assertItemNotInTrash(name);

// Verify the content actually landed under Media/Files (path resolution throws if absent)
const restoredContentId = await api.getContentIdByPath(`Media/Files/${name}`);
expect(restoredContentId).toBe(childId);

await api.deleteContent(childId);
});

test('Element in trash can be found by search', async ({ page }) => {

Check failure on line 115 in tests/playwright-tests/Tests/Trash.spec.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add at least one assertion to this test case.

See more on https://sonarcloud.io/project/issues?id=ibexa_admin-ui&issues=AaBISByjjElgpndrCnbP&open=AaBISByjjElgpndrCnbP&pullRequest=1947
const name1 = `TrashSearch1${runId}`;
const name2 = `TrashSearch2${runId}`;
const childId1 = await api.createFolder(name1, trashTestLocationId);
const childLocId1 = await api.getMainLocationId(childId1);
const childId2 = await api.createFolder(name2, trashTestLocationId);
const childLocId2 = await api.getMainLocationId(childId2);

const contentPage = new ContentManagementPage(page);
await contentPage.open(childId1, childLocId1);
await contentPage.sendToTrash();
await contentPage.open(childId2, childLocId2);
await contentPage.sendToTrash();

const trash = new TrashPage(page);
await trash.open();
await trash.searchInTrash(name1);
await trash.assertItemInTrash(name1);
await trash.assertItemNotInTrash(name2);
});
});
37 changes: 37 additions & 0 deletions tests/playwright-tests/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions tests/playwright-tests/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "@ibexa/admin-ui-playwright-tests",
"version": "1.0.0",
"private": true,
"scripts": {
"test": "NODE_PATH=./node_modules/@ibexa/cohesivo-playwright/node_modules ./node_modules/@ibexa/cohesivo-playwright/node_modules/.bin/playwright test",
"test:headless": "NODE_PATH=./node_modules/@ibexa/cohesivo-playwright/node_modules ./node_modules/@ibexa/cohesivo-playwright/node_modules/.bin/playwright test --project=headless",
"test:experience": "NODE_PATH=./node_modules/@ibexa/cohesivo-playwright/node_modules ./node_modules/@ibexa/cohesivo-playwright/node_modules/.bin/playwright test --project=experience",
"test:commerce": "NODE_PATH=./node_modules/@ibexa/cohesivo-playwright/node_modules ./node_modules/@ibexa/cohesivo-playwright/node_modules/.bin/playwright test --project=commerce",
"typecheck": "./node_modules/@ibexa/cohesivo-playwright/node_modules/.bin/tsc --noEmit"
},
"dependencies": {
"@ibexa/cohesivo-playwright": "file:../../../cohesivo-playwright"
}
}
3 changes: 3 additions & 0 deletions tests/playwright-tests/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { defineIbexaConfig } from '@ibexa/cohesivo-playwright';

export default defineIbexaConfig({ testDir: './Tests' });
13 changes: 13 additions & 0 deletions tests/playwright-tests/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": "./node_modules/@ibexa/cohesivo-playwright/tsconfig.playwright.json",
"compilerOptions": {
"outDir": "./dist",
"rootDir": "."
},
"include": [
"Tests/**/*.ts",
"Utils/**/*.ts",
"playwright.config.ts"
],
"exclude": ["node_modules", "dist"]
}
Loading