Skip to content

Commit

Permalink
chore: move cli-tests to tests/cli
Browse files Browse the repository at this point in the history
  • Loading branch information
innerdvations authored Apr 3, 2024
1 parent 791bc2c commit 7b66962
Show file tree
Hide file tree
Showing 53 changed files with 16 additions and 24 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ playwright-report
test-results
!tests/e2e/data/*.tar
tests/e2e/.env
!tests/cli/data/*.tar.gz
tests/cli/.env

############################
# Strapi
Expand Down
10 changes: 1 addition & 9 deletions docs/docs/guides/e2e/00-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ The test-app you create uses a [template](https://docs.strapi.io/developer-docs/

If you add anything to the template, be sure to add this information to [the docs](/testing/e2e/app-template).

## Running tests with environment variables
## Running tests with environment variables (needed to run EE tests)

To set specific environment variables for your tests, a `.env` file can be created in the root of the e2e folder. This is useful if you need to run tests with a Strapi license or set future flags.

Expand All @@ -89,14 +89,6 @@ Playwright enables reliable end-to-end testing for modern web apps. It's cross b

For more information check out their [docs](https://playwright.dev/docs/intro). If you're struggling with their APIs, then check out their specific [API documentation](https://playwright.dev/docs/api/class-playwright).

## Running tests with environment variables

To set specific environment variables for your tests, a `.env` file can be created in the root of the e2e folder. This is useful if you need to run tests with a Strapi license or set future flags.

## Running tests with future flags

If you are writing tests for an unstable future feature you will need to add `app-template/config/features.js`. Currently the app template generation does not take the config folder into consideration. However, the run-e2e-tests script will apply the features config to the generated app. See the documentation for [features.js](https://docs.strapi.io/dev-docs/configurations/features#enabling-a-future-flag)

## What makes a good end to end test?

This is the million dollar question. E2E tests typically test complete user flows that touch numerous points of the application it's testing, we're not interested in what happens during a process, only the user perspective and end results. Consider writing them with your story hat on. E.g. "As a user I want to create a new entity, publish that entity, and then be able to retrieve its data from the content API".
Expand Down
2 changes: 1 addition & 1 deletion jest.config.cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = {
displayName: 'CLI tests',
testMatch: ['**/?(*.)+(spec|test).cli.(js|ts)'],
testEnvironment: 'node',
setupFilesAfterEnv: ['<rootDir>/../../../test/setup/jest-cli.setup.js'],
setupFilesAfterEnv: ['<rootDir>/../../../../tests/setup/jest-cli.setup.js'],
coveragePathIgnorePatterns: [
'<rootDir>/dist/',
'<rootDir>/node_modules/',
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@
"setup": "yarn && yarn clean && yarn build --skip-nx-cache",
"test:api": "node tests/scripts/run-api-tests.js",
"test:clean": "rimraf ./coverage",
"test:cli": "node test/scripts/run-cli-tests.js",
"test:cli:clean": "node test/scripts/run-cli-tests.js clean",
"test:cli:debug": "node test/scripts/run-cli-tests.js --debug",
"test:cli": "node tests/scripts/run-cli-tests.js",
"test:cli:clean": "node tests/scripts/run-cli-tests.js clean",
"test:cli:debug": "node tests/scripts/run-cli-tests.js --debug",
"test:e2e": "node tests/scripts/run-e2e-tests.js",
"test:e2e:clean": "node tests/scripts/run-e2e-tests.js clean",
"test:e2e:debug": "node tests/scripts/run-e2e-tests.js --debug",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 3 additions & 5 deletions tests/e2e/tests/content-releases/releases-page.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { test, expect } from '@playwright/test';
import { describeOnCondition } from '../../utils/shared';
import { describeOnCondition, navToHeader } from '../../utils/shared';
import { resetDatabaseAndImportDataFromPath } from '../../scripts/dts-import';
import { login } from '../../utils/login';

Expand Down Expand Up @@ -92,11 +92,9 @@ describeOnCondition(edition === 'EE')('Releases page', () => {
await expect(page.getByRole('link', { name: `${newReleaseName}` })).toBeVisible();
});

test('A user should be able to perform bulk release on entries', async ({ page }) => {
await page.getByRole('link', { name: 'Content Manager' }).click();
test.skip('A user should be able to perform bulk release on entries', async ({ page }) => {
await navToHeader(page, ['Content Manager', 'Article'], 'Article');

await expect(page).toHaveTitle('Content Manager');
await expect(page.getByRole('heading', { name: 'Article' })).toBeVisible();
const publishedItems = page.getByRole('gridcell', { name: 'published' });
expect(publishedItems).toHaveCount(2);
const checkbox = page.getByRole('checkbox', { name: 'Select all entries' });
Expand Down
6 changes: 3 additions & 3 deletions tests/e2e/tests/transfer/tokens.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { test, expect } from '@playwright/test';
import { login } from '../../../utils/login';
import { resetDatabaseAndImportDataFromPath } from '../../../scripts/dts-import';
import { navToHeader } from '../../../utils/shared';
import { login } from '../../utils/login';
import { resetDatabaseAndImportDataFromPath } from '../../scripts/dts-import';
import { navToHeader } from '../../utils/shared';

const createTransferToken = async (page, tokenName, duration, type) => {
await navToHeader(
Expand Down
4 changes: 2 additions & 2 deletions tests/scripts/run-cli-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const { cleanTestApp, generateTestApp } = require('../helpers/test-app');

const cwd = path.resolve(__dirname, '../..');
const testAppDirectory = path.join(cwd, 'test-apps', 'cli');
const testRoot = path.join(cwd, 'cli-tests');
const testRoot = path.join(cwd, 'tests', 'cli');
const testsDir = path.join(testRoot, 'tests');
const templateDir = path.join(testRoot, 'app-template');

Expand Down Expand Up @@ -222,7 +222,7 @@ yargs
'jest',
[
'--config',
'../../../jest.config.cli.js',
'../../../../jest.config.cli.js',
'--rootDir',
domainDir,
'--color',
Expand Down
2 changes: 1 addition & 1 deletion tests/scripts/run-e2e-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ yargs
* This lets us pass any other arguments to playwright
* e.g. the name of a specific test or the project we want to run
*/
'unknown-options-as-args': true,
'unknown-options-as-args': false,
})
.command({
command: '*',
Expand Down

0 comments on commit 7b66962

Please sign in to comment.