const { test, expect } = require('@playwright/test'); const SessionCreated = require('../src/models/SessionCreated'); const SessionRelatedToPublickey = require('../src/models/SessionRelatedToPublickey'); const NymSet = require('../src/models/NymSet'); const ContactDetailsSet = require('../src/models/ContactDetailsSet'); const hardcodedSessionUuid = '0195423c-33d7-75f8-921b-a06e6d3cb8c5'; const hardcodedPublicKey = 'd3d4c49e7bdbbbf3082151add080e92f9a458d5dec993b371fe6d02cd394d57a'; test.beforeEach(async () => { for (const someModel of [ SessionCreated, SessionRelatedToPublickey, NymSet, ContactDetailsSet, ]) { someModel.truncate(); } const currentTimestamp = new Date(); const expiryTimestamp = new Date(currentTimestamp.getTime()); expiryTimestamp.setSeconds(expiryTimestamp.getSeconds() + 60); await SessionCreated.create({ uuid: hardcodedSessionUuid, created_at: currentTimestamp.toISOString(), expires_at: expiryTimestamp.toISOString(), }); await SessionRelatedToPublickey.create({ uuid: '0195423b-f9ae-737e-98f3-880f6563ed8a', session_uuid: hardcodedSessionUuid, public_key: hardcodedPublicKey, created_at: new Date().toISOString(), }); await NymSet.create({ uuid: '01954240-ddbb-7d01-9017-efb3e500d333', public_key: hardcodedPublicKey, nym: 'test_nym', created_at: new Date().toISOString(), }); await ContactDetailsSet.create({ uuid: '01954240-ddbb-7d01-9017-efb3e500d333', public_key: hardcodedPublicKey, encrypted_contact_details: '+OD0/Y2IkJ99/E0KAJL/mp3kxQo4DFp1deSPnqiejlyGoeWzBiipemPVSTT/Jg/fCQbN9Pd/GJ6shxuwWECOVyB5PnMZOVJ1MPQ7I8A+63XZ0gKnSnJgry6F69f3MhEjH49JbeVJ37TbruFu/Woevo24VWz2gPXGBuyHLzeg1tyT9+7ZSygkcCrh+bchvymCoF1nNOm/UQKnwecH1wWzo8a+rNokazD1/3iey6iKmKewi+yGCgmljrB866akqBAl?iv=PAKhqTeBfYVX/muhM8xaEA==', created_at: new Date().toISOString(), }); }); test.beforeEach(async ({ context }) => { await context.addCookies([ { name: 'sessionUuid', value: hardcodedSessionUuid, domain: 'localhost', path: '/', expires: Math.floor( new Date(new Date().setMonth(new Date().getMonth() + 1)).getTime() / 1000 ), //This monster is this day next month, turned into epoch format httpOnly: true, secure: false, sameSite: 'Lax', }, ]); }); module.exports = { test, expect, hardcodedSessionUuid };