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

This commit is contained in:
Ben Irvin 2024-05-20 11:15:33 +02:00 committed by GitHub
parent a3960e1ee5
commit 7d9787cb7c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 16 additions and 18 deletions

View File

@ -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',
@ -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!';

View File

@ -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', () => {
@ -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);
});
});

View File

@ -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
@ -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);
});
});