Skip to content

Commit

Permalink
Merge branch 'develop' into fix-e2e-tests-for-authoring-react
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaskikutis committed Dec 13, 2024
2 parents 3bf8c2a + 7d4f943 commit 7c06b28
Show file tree
Hide file tree
Showing 449 changed files with 89,474 additions and 35,865 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ module.exports = Object.assign({}, sharedConfigs, {
'@typescript-eslint/ban-types': 'off',
'@typescript-eslint/no-inferrable-types': 'off',
'@typescript-eslint/no-this-alias': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-vars': 'off',
}),
plugins: [...(sharedConfigs.plugins ?? []), '@typescript-eslint'],

Expand Down
48 changes: 19 additions & 29 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,80 +1,70 @@
name: "CI"

on:
[push, pull_request]

jobs:

test:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: '14.x'

cache: 'npm'
# avoid file watch limit error
- run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

- run: npm ci
- run: npm run test
- run: npm run test || npm run test || npm run test
env:
TZ: "Europe/Prague"

e2e:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
suite: [a, b]

steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: '14.x'


cache: 'npm'
- name: Start e2e server
run: |
docker compose pull
docker compose build
docker compose up -d
working-directory: e2e/server

- name: Build client
run: npm install && npm run build && npm run specs--compile && npm run start-client-server
working-directory: e2e/client

# playwright start

- name: Install Playwright Browsers
run: npx playwright install --with-deps
working-directory: e2e/client

- name: Run Playwright tests
run: npx playwright test
working-directory: e2e/client

- uses: actions/upload-artifact@v3
if: always()
- uses: actions/upload-artifact@v4
if: ${{ failure() }}
with:
name: playwright-report
path: e2e/client/playwright-report/
retention-days: 30

name: playwright-report-${{ matrix.suite }}
path: e2e/client/test-results
# playwright end

# protractor start
- name: Setup Chrome
uses: browser-actions/setup-chrome@v1
id: setup-chrome
with:
chrome-version: 127.0.6533.99
install-dependencies: true
install-chromedriver: true

- name: Protractor
run: npx protractor-flake --parser standard --max-attempts=3 -- protractor.conf.js --suite=${{ matrix.suite }}
- name: Run Protractor
run: npx protractor-flake --parser standard --max-attempts=3 -- protractor.conf.js --suite=${{ matrix.suite }}
env:
CHROME_BIN: ${{ steps.setup-chrome.outputs.chrome-path }}
CHROMEWEBDRIVER: ${{ steps.setup-chrome.outputs.chromedriver-path }}
TRAVIS: ci
SCREENSHOTS_DIR: /tmp
working-directory: e2e/client
Expand All @@ -90,5 +80,5 @@ jobs:

- name: Server Logs
if: ${{ failure() }}
run: docker compose logs superdesk
run: docker compose logs server
working-directory: e2e/server
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,4 @@ You can override default search repos (all set `true` by default).
- `validatorMediaMetadata`: `object` - describes a fields that are required for media items (images/video). If the field is present in the object then it is displayed.
- `infoRemovedFields`: `object` - contains fields that should be removed from metadata editing
- `profileLanguages` - list of languages available in user profile

3 changes: 3 additions & 0 deletions TAGS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# TAG: AUTHORING-ANGULAR

AUTHORING-ANGULAR tag is meant to mark code that has to be removed together with angular based authoring component when time comes.
14 changes: 12 additions & 2 deletions e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
### Starting server and client

* open a terminal in `./server`
* run `docker-compose up`
* run `docker compose up`
* open a terminal in `./client`
* run `npm install` if needed
* run `npx grunt server`
Expand Down Expand Up @@ -85,4 +85,14 @@ await page.locator(s('authoring', 'comments-widget', 'submit')).click();

### Known issues

* Playwright VSCode extension seems not to respect viewport size that is set in `e2e/client/playwright.config.ts`. An easy workaround is adjusting browser size manually in development. It will work in CI.
* Playwright VSCode extension seems not to respect viewport size that is set in `e2e/client/playwright.config.ts`. An easy workaround is adjusting browser size manually in development. It will work in CI.

### Utilities

#### Quickly replacing generated locators to use our `s` or `cs` helpers

Find regex: `locator\('\[data-test-id="(.+)?"\]'`
Replace regex: `locator(cs('$1')`

Will replace `locator('[data-test-id="abc"]')` with `locator(cs('abc'))`

13 changes: 6 additions & 7 deletions e2e/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
"superdesk-core": "file:../../"
},
"devDependencies": {
"@playwright/test": "^1.39.0",
"@playwright/test": "^1.47.0",
"@superdesk/build-tools": "file:../../build-tools",
"@superdesk/end-to-end-testing-helpers": "1.0.11",
"@types/node": "^20.8.9",
"btoa": "1.2.1",
"grunt": "1.3.0",
"http-server": "14.1.1",
Expand All @@ -20,14 +19,14 @@
"scripts": {
"build": "npx @superdesk/build-tools build-root-repo ./",
"server": "grunt server",
"start-client-server": "http-server dist -p 9000 -s &",
"stop-client-server": "fuser -k 9000/tcp",
"playwright": "playwright test --workers 1",
"playwright-interactive": "playwright test --ui",
"protractor": "protractor protractor.conf.js",
"specs--compile": "find ./specs/ -name '*.js' -type f -delete && tsc -p ./specs",
"specs--watch": "find ./specs/ -name '*.js' -type f -delete && tsc -p ./specs -w",
"start-client-server": "http-server dist -p 9000 -s &",
"stop-client-server": "fuser -k 9000/tcp",
"start-test-server": "cd ../server && docker-compose build && docker-compose up -d",
"stop-test-server": "cd ../server && docker-compose stop"
"stop-test-server": "cd ../server && docker-compose stop",
"specs--compile": "find ./specs/ -name '*.js' -type f -delete && tsc -p ./specs",
"specs--watch": "find ./specs/ -name '*.js' -type f -delete && tsc -p ./specs -w"
}
}
7 changes: 4 additions & 3 deletions e2e/client/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {defineConfig, devices} from '@playwright/test';
import path from 'path';

/**
* Read environment variables from file.
Expand All @@ -12,7 +13,7 @@ import {defineConfig, devices} from '@playwright/test';
export default defineConfig({
testDir: './playwright',
/* Run tests in files in parallel */
fullyParallel: true,
fullyParallel: false,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
Expand All @@ -29,7 +30,7 @@ export default defineConfig({
viewport: {width: 1280, height: 800},

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
trace: 'retain-on-failure',

screenshot: 'only-on-failure',
},
Expand All @@ -40,7 +41,7 @@ export default defineConfig({
name: 'chromium',
use: {
...devices['Desktop Chrome'],
storageState: 'playwright/.auth/user.json',
storageState: path.join(__dirname, './playwright/.auth/user.json'),
},
},

Expand Down
10 changes: 5 additions & 5 deletions e2e/client/playwright/.auth/user.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
{
"name": "session",
"value": "eyJzZXNzaW9uX3Rva2VuIjoiMDc5ZmI2M2MtZGM5OC00NTBmLWEzM2UtYzE5NzkzNzU2ZGYxIn0.Za43nw.4OjKgOWCcJ3oxa0kHscH-h47aLo",
"value": "eyJzZXNzaW9uX3Rva2VuIjoiN2VjM2UzYjUtOTc0NC00YjAyLWEzZjktNjdhMjY5NjYzNzMzIn0.Zqu1EQ.jLabsVCRMPN6BkZpxSQnDvNltcs",
"domain": "localhost",
"path": "/",
"expires": -1,
Expand All @@ -27,19 +27,19 @@
"localStorage": [
{
"name": "sess:id",
"value": "65ae379f77677941642bb478"
"value": "66abb510f2ff97e74a138403"
},
{
"name": "sess:href",
"value": "auth_db/65ae379f77677941642bb478"
"value": "auth_db/66abb510f2ff97e74a138403"
},
{
"name": "sess:user",
"value": "{\"_id\":\"655494d8dfb36babb9663383\",\"username\":\"admin\",\"email\":\"[email protected]\",\"user_type\":\"administrator\",\"is_active\":true,\"is_support\":false,\"needs_activation\":false,\"is_author\":true,\"private\":false,\"is_enabled\":true,\"password_changed_on\":\"2023-11-15T09:52:24+0000\",\"display_name\":\"admin\",\"sign_off\":\"ADM\",\"role\":null,\"_created\":\"2023-11-15T09:52:24+0000\",\"_updated\":\"2024-01-22T09:38:39+0000\",\"_etag\":\"d7adcb6bc3104208aacdfefeeefd7a01f8949663\",\"invisible_stages\":[],\"last_activity_at\":\"2024-01-22T09:38:39+0000\",\"_links\":{\"self\":{\"title\":\"User\",\"href\":\"users/655494d8dfb36babb9663383\"},\"parent\":{\"title\":\"home\",\"href\":\"/\"},\"collection\":{\"title\":\"users\",\"href\":\"users\"}},\"dateline_source\":\"Short name for your organisation\"}"
"value": "{\"_id\":\"655494d8dfb36babb9663383\",\"username\":\"admin\",\"email\":\"[email protected]\",\"user_type\":\"administrator\",\"is_active\":true,\"is_support\":false,\"needs_activation\":false,\"is_author\":true,\"private\":false,\"is_enabled\":true,\"password_changed_on\":\"2023-11-15T09:52:24+0000\",\"display_name\":\"John Doe\",\"sign_off\":\"ADM\",\"role\":null,\"_created\":\"2023-11-15T09:52:24+0000\",\"_updated\":\"2024-08-01T16:17:20+0000\",\"_etag\":\"618b115f9c52f9af13cd7ac4326665a5c42947b4\",\"invisible_stages\":[],\"last_activity_at\":\"2024-08-01T16:17:20+0000\",\"first_name\":\"John\",\"last_name\":\"Doe\",\"desk\":\"6554951a71839faddb615a2a\",\"_links\":{\"self\":{\"title\":\"User\",\"href\":\"users/655494d8dfb36babb9663383\"},\"related\":{\"desk\":{\"title\":\"Desk\",\"href\":\"desks/6554951a71839faddb615a2a\"}},\"parent\":{\"title\":\"home\",\"href\":\"/\"},\"collection\":{\"title\":\"users\",\"href\":\"users\"}},\"dateline_source\":\"Short name for your organisation\"}"
},
{
"name": "sess:token",
"value": "Basic MDc5ZmI2M2MtZGM5OC00NTBmLWEzM2UtYzE5NzkzNzU2ZGYxOg=="
"value": "Basic N2VjM2UzYjUtOTc0NC00YjAyLWEzZjktNjdhMjY5NjYzNzMzOg=="
}
]
}
Expand Down
71 changes: 71 additions & 0 deletions e2e/client/playwright/article-send-to.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import {test, expect} from '@playwright/test';
import {Monitoring} from './page-object-models/monitoring';
import {restoreDatabaseSnapshot, s} from './utils';
import {TreeSelectDriver} from './utils/tree-select-driver';

test.describe('sending an article', async () => {
test('sending an article to another desk', async ({page}) => {
const monitoring = new Monitoring(page);

await restoreDatabaseSnapshot();
await page.goto('/#/workspace/monitoring');
await monitoring.selectDeskOrWorkspace('Sports');

await monitoring.executeActionOnMonitoringItem(
page.locator(s('monitoring-group=Sports / Working Stage', 'article-item=story 2')),
'Edit',
);

await page.locator(s('authoring-topbar', 'open-send-publish-pane')).click();
await page.locator(s('interactive-actions-panel', 'tabs')).getByRole('tab', {name: 'Send to'}).click();

// selecting other desk
await new TreeSelectDriver(
page,
page.locator(s('destination-select')),
).setValue(['Education']);
await page
.locator(s('interactive-actions-panel', 'stage-select'))
.getByRole('radio', {name: 'Working Stage'})
.check();
await page.locator(s('interactive-actions-panel', 'send')).click();

await expect(
page.locator(s('monitoring-group=Sports / Working Stage', 'article-item=story 2')),
).not.toBeVisible();
await monitoring.selectDeskOrWorkspace('Education');
await expect(
page.locator(s('monitoring-group=Education / Working Stage', 'article-item=story 2')),
).toBeVisible();
});

test('sending an article to another stage', async ({page}) => {
const monitoring = new Monitoring(page);

await restoreDatabaseSnapshot();
await page.goto('/#/workspace/monitoring');
await monitoring.selectDeskOrWorkspace('Sports');

await monitoring.executeActionOnMonitoringItem(
page.locator(s('monitoring-group=Sports / Working Stage', 'article-item=story 2')),
'Edit',
);

await page.locator(s('authoring-topbar', 'open-send-publish-pane')).click();
await page.locator(s('interactive-actions-panel', 'tabs')).getByRole('tab', {name: 'Send to'}).click();

// selecting other stage
await page
.locator(s('interactive-actions-panel', 'stage-select'))
.getByRole('radio', {name: 'Incoming Stage'})
.check();
await page.locator(s('interactive-actions-panel', 'send')).click();

await expect(
page.locator(s('monitoring-group=Sports / Working Stage', 'article-item=story 2')),
).not.toBeVisible();
await expect(
page.locator(s('monitoring-group=Sports / Incoming Stage', 'article-item=story 2')),
).toBeVisible();
});
});
5 changes: 3 additions & 2 deletions e2e/client/playwright/authoring.correct.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {test, expect} from '@playwright/test';
import {Monitoring} from './page-object-models/monitoring';
import {restoreDatabaseSnapshot, s} from './utils';
import {clearInput} from './utils/inputs';

test.setTimeout(50000);

Expand Down Expand Up @@ -41,10 +42,10 @@ test('correcting with unsaved changes', async ({page}) => {

await page.locator(s('authoring', 'authoring-topbar')).getByLabel('Correct').click();

await (await getHeadlineField()).clear();
await clearInput(await getHeadlineField());
await (await getHeadlineField()).fill('test sports story [corrected]');

await (await getBodyField()).clear();
await clearInput(await getBodyField());
await (await getBodyField()).fill('test sport story body [corrected]');

await page.locator(s('authoring', 'authoring-topbar')).getByRole('button', {name: 'Send Correction'}).click();
Expand Down
Loading

0 comments on commit 7c06b28

Please sign in to comment.