mirror of
https://github.com/strapi/strapi.git
synced 2025-09-15 19:39:06 +00:00

Remove old cypress related files Update config and reorg tests Run test app before running playwright tests feat: add beginning of authentication test feat: add app template with database dumping ability chore: pr amends Run test app before running playwright tests feat: add beginning of authentication test feat: add app template with database dumping ability chore: pr amends init deits fix: e2e test chore: rename to e2e chore: commit tar for data Init playwright Run test app before running playwright tests feat: add beginning of authentication test feat: add app template with database dumping ability chore: pr amends chore: remove unneeded workflow fix: add private: true to the template so `test-apps` aren't published docs: add docs chore: add warning about DTS caveats chore: tweak docs docs(e2e): add correct route to api example for template chore: fix package.json tests chore: update from feature/DEITS chore: updates from DTS chore: update data-transfer Update yarn.lock fix: remove duplicate type chore(e2e): set up folder structure fix(e2e): avoid clearing 'admin_' DB tables through DTS or DB Dump feat(e2e): DTS scripts and backup files add route to change rate limit fix wront appPath for API test in CI no template by default when creating a test app Fix typo double equal fix template path for e2e tests chore(e2e): fix broken signup spec feat(e2e): basic logout test spec Login e2e tests globalSetup attempt use withAdmin backup cleanup fix playwright config & rate limit test remove example.spec.js refactor and merge some login tests Chore: Cleanup login and signup specs feat(e2e): sign up password error cases feat(e2e): add homepage expectation to signup spec refactor(e2e) refactor(e2e): signUp refactor(e2e): use global login util for logout and logins specs Init playwright fix: remove duplicate type chore: uncomment transfer route registering Update yarn.lock chore: update data-transfer chore: updates from DTS chore: update from feature/DEITS chore: fix package.json tests docs(e2e): add correct route to api example for template chore: tweak docs chore: add warning about DTS caveats docs: add docs fix: add private: true to the template so `test-apps` aren't published chore: remove unneeded workflow chore: pr amends feat: add app template with database dumping ability feat: add beginning of authentication test Run test app before running playwright tests Init playwright chore: commit tar for data chore: rename to e2e fix: e2e test init deits chore: pr amends feat: add app template with database dumping ability feat: add beginning of authentication test Run test app before running playwright tests chore: pr amends feat: add app template with database dumping ability feat: add beginning of authentication test Run test app before running playwright tests Update config and reorg tests Remove old cypress related files chore(e2e): cleanup e2e dir chore(docs): improve e2e testing documentation chore(docs): PR feedback chore: tweak action to run browsers in matrix & build packages chore: fix tests based on merge chore: shuffle e2e tests and add first conent-type fix: tests Make use of yarn linking for api & e2e tests Chore: Fix running backend unit tests Chore: Bring opts.run back Chore: Update playwright Chore: Update Playwright setup fix: workflow chore: fix path to package.json chore: build ts projects before tests chore: update e2e workflow chore: add no-immutable Use simpler transfer token to avoid misinterpretation Remove console.log Ensure that the custom transfer token exists in the e2e test app's database upon startup Use the custom transfer token for transferring data to the e2e test app Fix code analysis warning Define and export a constant for the custom transfer token Allow passing a custom access key for the transfer token service chore: add test-apps to workspace chore: update lockfile Co-Authored-By: Josh <37798644+joshuaellis@users.noreply.github.com> Co-Authored-By: Gustav Hansen <gu@stav.dev> Co-Authored-By: Alexandre BODIN <alexandrebodin@users.noreply.github.com> Co-Authored-By: Jean-Sébastien Herbaux <25851739+Convly@users.noreply.github.com>
103 lines
3.6 KiB
JavaScript
103 lines
3.6 KiB
JavaScript
import { test, expect } from '@playwright/test';
|
|
|
|
import { resetDatabaseAndImportDataFromPath } from '../../scripts/dts-import';
|
|
import { ADMIN_EMAIL_ADDRESS, ADMIN_PASSWORD } from '../../constants';
|
|
|
|
/**
|
|
* Fill in the sign up form with valid values
|
|
* @param {EventEmitter} page - playwright page
|
|
*/
|
|
export const fillValidSignUpForm = async ({ page }) => {
|
|
await page.getByLabel('First name').fill('John');
|
|
await page.getByLabel('Last name').fill('Smith');
|
|
await page.getByLabel('Email').fill(ADMIN_EMAIL_ADDRESS);
|
|
await page
|
|
.getByLabel('Password*', {
|
|
exact: true,
|
|
})
|
|
.fill(ADMIN_PASSWORD);
|
|
await page
|
|
.getByLabel('Confirm Password*', {
|
|
exact: true,
|
|
})
|
|
.fill(ADMIN_PASSWORD);
|
|
};
|
|
|
|
test.describe('Sign Up', () => {
|
|
test.beforeEach(async ({ page }) => {
|
|
await resetDatabaseAndImportDataFromPath('./e2e/data/without-admin.tar');
|
|
await page.goto('/admin');
|
|
await fillValidSignUpForm({ page });
|
|
});
|
|
|
|
test('a user cannot submit the form if the first name field is not filled', async ({ page }) => {
|
|
const nameInput = page.getByRole('textbox', { name: 'First name *' });
|
|
|
|
await nameInput.fill('');
|
|
await page.getByRole('button', { name: "Let's start" }).click();
|
|
await expect(nameInput).toBeFocused();
|
|
await expect(page.getByText('Value is required')).toBeVisible();
|
|
});
|
|
|
|
test('a user cannot submit the form if the email is: not provided, not lowercase or not a valid email address', async ({
|
|
page,
|
|
}) => {
|
|
const emailInput = page.getByRole('textbox', { name: 'Email *' });
|
|
const letsStartButton = page.getByRole('button', { name: "Let's start" });
|
|
|
|
const fillEmailAndSubmit = async (emailValue) => {
|
|
await emailInput.fill(emailValue);
|
|
await letsStartButton.click();
|
|
await expect(emailInput).toBeFocused();
|
|
};
|
|
|
|
await fillEmailAndSubmit('');
|
|
await expect(page.getByText('Value is required')).toBeVisible();
|
|
|
|
await fillEmailAndSubmit(ADMIN_EMAIL_ADDRESS.toUpperCase());
|
|
await expect(page.getByText('The value must be a lowercase string')).toBeVisible();
|
|
|
|
await fillEmailAndSubmit('notanemail');
|
|
await expect(page.getByText('This is an invalid email')).toBeVisible();
|
|
});
|
|
|
|
test("a user cannot submit the form if a password isn't provided or doesn't meet the password validation requirements", async ({
|
|
page,
|
|
}) => {
|
|
const passwordInput = page.getByRole('textbox', { name: 'Password *', exact: true });
|
|
const letsStartButton = page.getByRole('button', { name: "Let's start" });
|
|
|
|
const fillPasswordAndSubmit = async (passwordValue) => {
|
|
await passwordInput.fill(passwordValue);
|
|
await letsStartButton.click();
|
|
await expect(passwordInput).toBeFocused();
|
|
};
|
|
|
|
await fillPasswordAndSubmit('');
|
|
await expect(page.getByText('Value is required')).toBeVisible();
|
|
|
|
await fillPasswordAndSubmit('noNumberInHere');
|
|
await expect(page.getByText('Password must contain at least one number')).toBeVisible();
|
|
|
|
await fillPasswordAndSubmit('lowerca5e');
|
|
await expect(
|
|
page.getByText('Password must contain at least one uppercase character')
|
|
).toBeVisible();
|
|
|
|
await fillPasswordAndSubmit('S4ort');
|
|
await expect(page.getByText('The value is too short')).toBeVisible();
|
|
|
|
await fillPasswordAndSubmit('doesNotMatch');
|
|
await expect(page.getByText('Passwords do not match')).toBeVisible();
|
|
});
|
|
|
|
test('a user should be able to signup when the strapi instance starts fresh', async ({
|
|
page,
|
|
}) => {
|
|
await page.getByRole('button', { name: "Let's start" }).click();
|
|
|
|
await page.waitForURL('**/admin/');
|
|
await expect(page).toHaveTitle('Homepage');
|
|
});
|
|
});
|