feat: add a demo feature

This commit is contained in:
gauthier-th
2026-06-16 15:11:06 +02:00
parent 6c8527fea3
commit d2da49c721
6 changed files with 21 additions and 21 deletions

View File

@@ -9,7 +9,7 @@ export default defineConfig({
env: {
ADMIN_EMAIL: 'admin@seerr.dev',
ADMIN_PASSWORD: 'test1234',
USER_EMAIL: 'friend@seerr.dev',
USER_EMAIL: 'demo@seerr.dev',
USER_PASSWORD: 'test1234',
},
retries: {

View File

@@ -145,7 +145,7 @@ describe('Discover', () => {
requestedBy: {
permissions: 4194336,
id: 18,
email: 'friend@seerr.dev',
email: 'demo@seerr.dev',
plexUsername: null,
username: '',
recoveryLinkExpirationDate: null,
@@ -159,7 +159,7 @@ describe('Discover', () => {
createdAt: '2022-08-17T04:55:28.000Z',
updatedAt: '2022-08-17T04:55:28.000Z',
requestCount: 1,
displayName: 'friend@seerr.dev',
displayName: 'demo@seerr.dev',
},
seasonCount: 0,
},

View File

@@ -189,7 +189,7 @@ describe('POST /auth/local', () => {
it('allows the non-admin user to log in', async () => {
const res = await request(app)
.post('/auth/local')
.send({ email: 'friend@seerr.dev', password: 'test1234' });
.send({ email: 'demo@seerr.dev', password: 'test1234' });
assert.strictEqual(res.status, 200);
assert.ok('id' in res.body);

View File

@@ -100,7 +100,7 @@ describe('POST /issue', () => {
const userRepo = getRepository(User);
const media = await seedMedia();
const friend = await userRepo.findOneOrFail({
where: { email: 'friend@seerr.dev' },
where: { email: 'demo@seerr.dev' },
});
const agent = await loginAs('admin@seerr.dev', 'test1234');
@@ -114,8 +114,8 @@ describe('POST /issue', () => {
});
assert.strictEqual(res.status, 201);
assert.strictEqual(res.body.createdBy.email, 'friend@seerr.dev');
assert.strictEqual(res.body.comments[0].user.email, 'friend@seerr.dev');
assert.strictEqual(res.body.createdBy.email, 'demo@seerr.dev');
assert.strictEqual(res.body.comments[0].user.email, 'demo@seerr.dev');
const persisted = await issueRepo.findOneOrFail({
where: { id: res.body.id },
@@ -144,13 +144,13 @@ describe('POST /issue', () => {
const userRepo = getRepository(User);
const media = await seedMedia();
const friend = await userRepo.findOneOrFail({
where: { email: 'friend@seerr.dev' },
where: { email: 'demo@seerr.dev' },
});
friend.permissions = Permission.CREATE_ISSUES;
await userRepo.save(friend);
const agent = await loginAs('friend@seerr.dev', 'test1234');
const agent = await loginAs('demo@seerr.dev', 'test1234');
const res = await agent.post('/issue').send({
issueType: IssueType.SUBTITLES,
message: 'Subtitles are missing.',
@@ -159,15 +159,15 @@ describe('POST /issue', () => {
});
assert.strictEqual(res.status, 201);
assert.strictEqual(res.body.createdBy.email, 'friend@seerr.dev');
assert.strictEqual(res.body.comments[0].user.email, 'friend@seerr.dev');
assert.strictEqual(res.body.createdBy.email, 'demo@seerr.dev');
assert.strictEqual(res.body.comments[0].user.email, 'demo@seerr.dev');
});
it('prevents non-managers from supplying another userId', async () => {
const userRepo = getRepository(User);
const media = await seedMedia();
const friend = await userRepo.findOneOrFail({
where: { email: 'friend@seerr.dev' },
where: { email: 'demo@seerr.dev' },
});
const admin = await userRepo.findOneOrFail({
where: { email: 'admin@seerr.dev' },
@@ -176,7 +176,7 @@ describe('POST /issue', () => {
friend.permissions = Permission.CREATE_ISSUES;
await userRepo.save(friend);
const agent = await loginAs('friend@seerr.dev', 'test1234');
const agent = await loginAs('demo@seerr.dev', 'test1234');
const res = await agent.post('/issue').send({
issueType: IssueType.OTHER,
message: 'Something else is wrong.',

View File

@@ -88,7 +88,7 @@ async function seedRequest(status = MediaRequestStatus.PENDING) {
const requestRepo = getRepository(MediaRequest);
const requestedBy = await userRepo.findOneOrFail({
where: { email: 'friend@seerr.dev' },
where: { email: 'demo@seerr.dev' },
});
const media = await mediaRepo.save(
@@ -121,7 +121,7 @@ describe('DELETE /request/:requestId', () => {
it('allows the owner to delete their own pending request', async () => {
const mediaRequest = await seedRequest();
const agent = await loginAs('friend@seerr.dev', 'test1234');
const agent = await loginAs('demo@seerr.dev', 'test1234');
const res = await agent.delete(`/request/${mediaRequest.id}`);
assert.strictEqual(res.status, 204);
@@ -165,7 +165,7 @@ describe('DELETE /request/:requestId', () => {
})
);
const agent = await loginAs('friend@seerr.dev', 'test1234');
const agent = await loginAs('demo@seerr.dev', 'test1234');
const res = await agent.delete(`/request/${mediaRequest.id}`);
assert.strictEqual(res.status, 401);
@@ -174,7 +174,7 @@ describe('DELETE /request/:requestId', () => {
it('prevents the owner from deleting an approved request', async () => {
const mediaRequest = await seedRequest(MediaRequestStatus.APPROVED);
const agent = await loginAs('friend@seerr.dev', 'test1234');
const agent = await loginAs('demo@seerr.dev', 'test1234');
const res = await agent.delete(`/request/${mediaRequest.id}`);
assert.strictEqual(res.status, 401);

View File

@@ -19,7 +19,7 @@ const TEST_USER_PASSWORD_HASH =
* Seeds test users into the database.
* Assumes the database schema is already set up.
*/
async function seedTestUsers(): Promise<void> {
export async function seedTestUsers(): Promise<void> {
const userRepository = getRepository(User);
const admin = await userRepository.findOne({
@@ -46,17 +46,17 @@ async function seedTestUsers(): Promise<void> {
// Create the other user
const otherUser =
(await userRepository.findOne({
where: { email: 'friend@seerr.dev' },
where: { email: 'demo@seerr.dev' },
})) ?? new User();
otherUser.plexId = admin?.plexId ?? 1;
otherUser.plexToken = '1234';
otherUser.plexUsername = 'friend';
otherUser.username = 'friend';
otherUser.email = 'friend@seerr.dev';
otherUser.email = 'demo@seerr.dev';
otherUser.userType = UserType.PLEX;
otherUser.password = TEST_USER_PASSWORD_HASH;
otherUser.permissions = 32;
otherUser.avatar = gravatarUrl('friend@seerr.dev', {
otherUser.avatar = gravatarUrl('demo@seerr.dev', {
default: 'mm',
size: 200,
});