finally some bloody test works
This commit is contained in:
parent
a1e07724ce
commit
1b5f227318
2 changed files with 47 additions and 20 deletions
|
|
@ -1,11 +1,15 @@
|
|||
const { test, expect } = require('./test-setup');
|
||||
const { test, expect, hardcodedSessionUuid } = require('./test-setup');
|
||||
|
||||
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 sessionService = require('../src/services/sessionService');
|
||||
|
||||
test('Mock records are present', async ({ page }) => {
|
||||
for (const someModel of [
|
||||
SessionCreated,
|
||||
SessionRelatedToPublickey,
|
||||
NymSet,
|
||||
ContactDetailsSet,
|
||||
|
|
@ -14,19 +18,22 @@ test('Mock records are present', async ({ page }) => {
|
|||
}
|
||||
});
|
||||
|
||||
test('Session cookie is there', async ({ page }) => {
|
||||
await page.goto('http://localhost');
|
||||
|
||||
test('Hardcoded session cookie is there', async ({ context }) => {
|
||||
const page = await context.newPage();
|
||||
const cookiesInPage = await page.context().cookies();
|
||||
expect(cookiesInPage).toHaveLength(1);
|
||||
expect(cookiesInPage[0].name).toBe('sessionUuid');
|
||||
expect(cookiesInPage[0].value).toBe(hardcodedSessionUuid);
|
||||
});
|
||||
|
||||
test('Offers is reachable', async ({ page }) => {
|
||||
test('Offers is reachable', async ({ context }) => {
|
||||
const page = await context.newPage();
|
||||
const cookiez = await page.context().cookies();
|
||||
|
||||
await page.pause();
|
||||
await page.goto('http://localhost/offers');
|
||||
console.log(await page.innerHTML('html'));
|
||||
|
||||
const createOfferButton = page.locator('#button-start-create-offer');
|
||||
await expect(createOfferButton).toBeVisible();
|
||||
await expect(createOfferButton).toContainText('Crear nueva oferta');
|
||||
});
|
||||
|
||||
// Check that UI controls are manageable with a few test cases.
|
||||
|
||||
// Check that the offer is created after submitting
|
||||
|
|
|
|||
|
|
@ -1,10 +1,17 @@
|
|||
import { test } from '@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 ({ context }) => {
|
||||
for (const someModel of [
|
||||
SessionCreated,
|
||||
SessionRelatedToPublickey,
|
||||
NymSet,
|
||||
ContactDetailsSet,
|
||||
|
|
@ -12,42 +19,55 @@ test.beforeEach(async ({ context }) => {
|
|||
someModel.truncate();
|
||||
}
|
||||
|
||||
const session = await SessionRelatedToPublickey.create({
|
||||
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: '0195423c-33d7-75f8-921b-a06e6d3cb8c5',
|
||||
public_key:
|
||||
'd3d4c49e7bdbbbf3082151add080e92f9a458d5dec993b371fe6d02cd394d57a',
|
||||
session_uuid: hardcodedSessionUuid,
|
||||
public_key: hardcodedPublicKey,
|
||||
created_at: new Date().toISOString(),
|
||||
});
|
||||
|
||||
await NymSet.create({
|
||||
uuid: '01954240-ddbb-7d01-9017-efb3e500d333',
|
||||
public_key:
|
||||
'd3d4c49e7bdbbbf3082151add080e92f9a458d5dec993b371fe6d02cd394d57a',
|
||||
public_key: hardcodedPublicKey,
|
||||
nym: 'test_nym',
|
||||
created_at: new Date().toISOString(),
|
||||
});
|
||||
|
||||
await ContactDetailsSet.create({
|
||||
uuid: '01954240-ddbb-7d01-9017-efb3e500d333',
|
||||
public_key:
|
||||
'd3d4c49e7bdbbbf3082151add080e92f9a458d5dec993b371fe6d02cd394d57a',
|
||||
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: session.uuid,
|
||||
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: 'None',
|
||||
sameSite: 'Lax',
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
export { test, expect } from '@playwright/test';
|
||||
export { hardcodedSessionUuid };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue