Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(test): change utils to .ts #20333

Merged
merged 3 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 9 additions & 11 deletions tests/e2e/constants.js → tests/e2e/constants.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
const { CUSTOM_TRANSFER_TOKEN_ACCESS_KEY } = require('./app-template/template/src/constants');
export const {
CUSTOM_TRANSFER_TOKEN_ACCESS_KEY,
} = require('./app-template/template/src/constants');

// NOTE: anything included here needs to be included in all test datasets exports
const ALLOWED_CONTENT_TYPES = [
export const ALLOWED_CONTENT_TYPES = [
'admin::user',
'admin::role',
'admin::permission',
Expand Down Expand Up @@ -35,15 +37,11 @@ const ALLOWED_CONTENT_TYPES = [
'plugin::upload.file',
];

export const TITLE_LOGIN = 'Strapi Admin';
export const TITLE_HOME = 'Homepage | Strapi';

// TODO: we should start using @strapi.io addresses to have the chance one day to
// actually receive and check the emails; also: it is not nice to spam other peoples
// websites
const ADMIN_EMAIL_ADDRESS = 'test@testing.com';
const ADMIN_PASSWORD = 'Testing123!';

module.exports = {
ADMIN_EMAIL_ADDRESS,
ADMIN_PASSWORD,
ALLOWED_CONTENT_TYPES,
CUSTOM_TRANSFER_TOKEN_ACCESS_KEY,
};
export const ADMIN_EMAIL_ADDRESS = 'test@testing.com';
export const ADMIN_PASSWORD = 'Testing123!';
10 changes: 5 additions & 5 deletions tests/e2e/tests/admin/login.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { test, expect } from '@playwright/test';
import { resetDatabaseAndImportDataFromPath } from '../../utils/dts-import';
import { toggleRateLimiting } from '../../utils/rate-limit';
import { ADMIN_EMAIL_ADDRESS, ADMIN_PASSWORD } from '../../constants';
import { ADMIN_EMAIL_ADDRESS, ADMIN_PASSWORD, TITLE_HOME, TITLE_LOGIN } from '../../constants';
import { login } from '../../utils/login';

test.describe('Login', () => {
Expand All @@ -17,23 +17,23 @@ test.describe('Login', () => {
}) => {
// Test without making user authentication persistent
await login({ page });
await expect(page).toHaveTitle('Homepage | Strapi');
await expect(page).toHaveTitle(TITLE_HOME);

await page.close();

page = await context.newPage();
await page.goto('/admin');
await expect(page).toHaveTitle('Strapi Admin');
await expect(page).toHaveTitle(TITLE_LOGIN);

// Test with making user authentication persistent
await login({ page, rememberMe: true });
await expect(page).toHaveTitle('Homepage | Strapi');
await expect(page).toHaveTitle(TITLE_HOME);

await page.close();

page = await context.newPage();
await page.goto('/admin');
await expect(page).toHaveTitle('Homepage | Strapi');
await expect(page).toHaveTitle(TITLE_HOME);
});
});

Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/tests/admin/signup.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { test, expect } from '@playwright/test';

import { resetDatabaseAndImportDataFromPath } from '../../utils/dts-import';
import { ADMIN_EMAIL_ADDRESS, ADMIN_PASSWORD } from '../../constants';
import { ADMIN_EMAIL_ADDRESS, ADMIN_PASSWORD, TITLE_HOME } from '../../constants';

/**
* Fill in the sign up form with valid values
Expand Down Expand Up @@ -98,6 +98,6 @@ test.describe('Sign Up', () => {
}) => {
await page.getByRole('button', { name: "Let's start" }).click();

await expect(page).toHaveTitle('Homepage | Strapi');
await expect(page).toHaveTitle(TITLE_HOME);
});
});
File renamed without changes.
File renamed without changes.
File renamed without changes.