cool tests!!!
This commit is contained in:
parent
3ac7425824
commit
c1161e3a66
3 changed files with 82 additions and 10 deletions
|
|
@ -5,9 +5,7 @@ const SessionRelatedToPublickey = require('../src/models/SessionRelatedToPublick
|
||||||
const NymSet = require('../src/models/NymSet');
|
const NymSet = require('../src/models/NymSet');
|
||||||
const ContactDetailsSet = require('../src/models/ContactDetailsSet');
|
const ContactDetailsSet = require('../src/models/ContactDetailsSet');
|
||||||
|
|
||||||
const sessionService = require('../src/services/sessionService');
|
test('Mock records are present', async () => {
|
||||||
|
|
||||||
test('Mock records are present', async ({ page }) => {
|
|
||||||
for (const someModel of [
|
for (const someModel of [
|
||||||
SessionCreated,
|
SessionCreated,
|
||||||
SessionRelatedToPublickey,
|
SessionRelatedToPublickey,
|
||||||
|
|
@ -28,12 +26,60 @@ test('Hardcoded session cookie is there', async ({ context }) => {
|
||||||
|
|
||||||
test('Offers is reachable', async ({ context }) => {
|
test('Offers is reachable', async ({ context }) => {
|
||||||
const page = await context.newPage();
|
const page = await context.newPage();
|
||||||
const cookiez = await page.context().cookies();
|
|
||||||
|
|
||||||
await page.pause();
|
|
||||||
await page.goto('http://localhost/offers');
|
await page.goto('http://localhost/offers');
|
||||||
|
|
||||||
const createOfferButton = page.locator('#button-start-create-offer');
|
const createOfferButton = page.locator('#button-start-create-offer');
|
||||||
await expect(createOfferButton).toBeVisible();
|
await expect(createOfferButton).toBeVisible();
|
||||||
await expect(createOfferButton).toContainText('Crear nueva oferta');
|
await expect(createOfferButton).toContainText('Crear nueva oferta');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Create an offer with a few options creates in DB', async ({
|
||||||
|
context,
|
||||||
|
}) => {
|
||||||
|
const page = await context.newPage();
|
||||||
|
await page.goto('http://localhost/offers');
|
||||||
|
|
||||||
|
await page.getByRole('button', { name: 'Crear nueva oferta' }).click();
|
||||||
|
await page.getByRole('button', { name: 'Quiero vender Bitcoin' }).click();
|
||||||
|
await page.getByRole('button', { name: 'Quiero comprar Bitcoin' }).click();
|
||||||
|
await page.getByRole('button', { name: '+' }).click();
|
||||||
|
await page.getByRole('button', { name: '+' }).click();
|
||||||
|
await page.getByRole('button', { name: '+' }).click();
|
||||||
|
await page.getByRole('button', { name: '-' }).click();
|
||||||
|
await expect(page.locator('#premium-value')).toContainText('2%');
|
||||||
|
await page.locator('#input-eur-amount').click();
|
||||||
|
await page.locator('#input-eur-amount').press('ControlOrMeta+a');
|
||||||
|
await page.locator('#input-eur-amount').fill('50');
|
||||||
|
await expect(page.locator('#input-eur-amount')).toHaveValue('50');
|
||||||
|
await page
|
||||||
|
.getByText(
|
||||||
|
'Añade los detalles de tu oferta Quiero comprar Bitcoin Quiero vender Bitcoin'
|
||||||
|
)
|
||||||
|
.click();
|
||||||
|
await page
|
||||||
|
.getByRole('textbox', { name: '¿Dónde? Ej."Eixample", "La' })
|
||||||
|
.click();
|
||||||
|
await page
|
||||||
|
.getByRole('textbox', { name: '¿Dónde? Ej."Eixample", "La' })
|
||||||
|
.fill('En algún lugar');
|
||||||
|
await page
|
||||||
|
.getByRole('textbox', { name: '¿Cuándo? Ej."Cualquier hora' })
|
||||||
|
.click();
|
||||||
|
await page
|
||||||
|
.getByRole('textbox', { name: '¿Cuándo? Ej."Cualquier hora' })
|
||||||
|
.fill('En algún momento');
|
||||||
|
await page.locator('#onchain-checkbox').uncheck();
|
||||||
|
await expect(page.locator('#onchain-checkbox')).not.toBeChecked();
|
||||||
|
await expect(page.locator('#lightning-checkbox')).toBeChecked();
|
||||||
|
await page.locator('#input-eur-amount').click();
|
||||||
|
await page.locator('#my-trusted-trusted-checkbox').uncheck();
|
||||||
|
await page.locator('#all-members-checkbox').check();
|
||||||
|
await page.locator('#my-trusted-trusted-checkbox').check();
|
||||||
|
await page.locator('#all-members-checkbox').uncheck();
|
||||||
|
await page.locator('#large-bills-checkbox').check();
|
||||||
|
await page.getByRole('button', { name: 'Publicar oferta' }).click();
|
||||||
|
await page.locator('#close-offer-controls-x').click();
|
||||||
|
await expect(page.locator('#offers-root')).toMatchAriaSnapshot(
|
||||||
|
`- button "Crear nueva oferta"`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
|
||||||
27
tests/recorderHelper.spec.js
Normal file
27
tests/recorderHelper.spec.js
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
// You can uncomment this below to open a recorder page
|
||||||
|
|
||||||
|
/*
|
||||||
|
const { chromium } = require('playwright');
|
||||||
|
test('Mock records are present', async () => {
|
||||||
|
const browser = await chromium.launch({ headless: false });
|
||||||
|
const context = await browser.newContext();
|
||||||
|
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',
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
const page = await context.newPage();
|
||||||
|
await page.goto('http://localhost');
|
||||||
|
});
|
||||||
|
*/
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { test } from '@playwright/test';
|
const { test, expect } = require('@playwright/test');
|
||||||
|
|
||||||
const SessionCreated = require('../src/models/SessionCreated');
|
const SessionCreated = require('../src/models/SessionCreated');
|
||||||
const SessionRelatedToPublickey = require('../src/models/SessionRelatedToPublickey');
|
const SessionRelatedToPublickey = require('../src/models/SessionRelatedToPublickey');
|
||||||
|
|
@ -9,7 +9,7 @@ const hardcodedSessionUuid = '0195423c-33d7-75f8-921b-a06e6d3cb8c5';
|
||||||
const hardcodedPublicKey =
|
const hardcodedPublicKey =
|
||||||
'd3d4c49e7bdbbbf3082151add080e92f9a458d5dec993b371fe6d02cd394d57a';
|
'd3d4c49e7bdbbbf3082151add080e92f9a458d5dec993b371fe6d02cd394d57a';
|
||||||
|
|
||||||
test.beforeEach(async ({ context }) => {
|
test.beforeEach(async () => {
|
||||||
for (const someModel of [
|
for (const someModel of [
|
||||||
SessionCreated,
|
SessionCreated,
|
||||||
SessionRelatedToPublickey,
|
SessionRelatedToPublickey,
|
||||||
|
|
@ -69,5 +69,4 @@ test.beforeEach(async ({ context }) => {
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
export { test, expect } from '@playwright/test';
|
module.exports = { test, expect, hardcodedSessionUuid };
|
||||||
export { hardcodedSessionUuid };
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue