Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions react-checkout/e2e/checkout.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ async function expectNoSidewaysScroll(page: Page) {
expect(overflow).toBeLessThanOrEqual(0)
}

/** Fills in an order that is valid: two mugs, shipped to Zagreb, paid by card. */
/** Fills in an order that is valid: two mugs, shipped to Belgrade, paid by card. */
async function fillValidOrder(page: Page) {
await page.getByRole('textbox', { name: 'Email' }).fill('jana@example.com')
await page.getByRole('textbox', { name: 'Email' }).fill('jelena@example.com')
await page.getByRole('button', { name: 'Add an item' }).click()
const item = page.getByRole('region', { name: 'Item 1' })
await item.getByLabel('Product').selectOption('Ceramic mug')
await item.getByLabel('Quantity').fill('2')
await page.getByRole('radio', { name: /^Standard/ }).check()
await page.getByLabel('Full name').fill('Jana Kovač')
await page.getByLabel('Street and number').fill('Ilica 1')
await page.getByLabel('Postal code').fill('10000')
await page.getByLabel('City').fill('Zagreb')
await page.getByLabel('Country').selectOption('Croatia')
await page.getByLabel('Full name').fill('Jelena Jovanović')
await page.getByLabel('Street and number').fill('Knez Mihailova 1')
await page.getByLabel('Postal code').fill('11000')
await page.getByLabel('City').fill('Belgrade')
await page.getByLabel('Country').selectOption('Serbia')
await page.getByRole('checkbox', { name: /terms of sale/ }).check()
}

Expand Down Expand Up @@ -67,18 +67,18 @@ test('places an order that the server validates and prices again', async ({
// The total comes from the server, which worked it out from the validated order.
await expect(page.getByText('Total paid: €42.40')).toBeVisible()
expect(await confirmedOrder(page)).toEqual({
email: 'jana@example.com',
email: 'jelena@example.com',
lines: [
{ product: 'mug', quantity: 2 },
{ product: 'notebook', quantity: 1 },
],
delivery: 'standard',
shipping: {
fullName: 'Jana Kovač',
street: 'Ilica 1',
zip: '10000',
city: 'Zagreb',
country: 'HR',
fullName: 'Jelena Jovanović',
street: 'Knez Mihailova 1',
zip: '11000',
city: 'Belgrade',
country: 'RS',
},
paymentMethod: 'card',
coupon: 'SPRING',
Expand All @@ -104,7 +104,7 @@ test('stops an invalid order in the browser, before it reaches the server', asyn
await expectNoSidewaysScroll(page)

// The messages of rules: a format, a whole number in a range, a pattern.
await page.getByRole('textbox', { name: 'Email' }).fill('jana@example')
await page.getByRole('textbox', { name: 'Email' }).fill('jelena@example')
await page.getByRole('button', { name: 'Add an item' }).click()
await page.getByLabel('Quantity').fill('11')
await page.getByLabel('Postal code').fill('ABC')
Expand Down Expand Up @@ -141,15 +141,15 @@ test('shows the fields a condition asks for, and drops what it hides', async ({
await page.getByRole('radio', { name: /^Invoice/ }).check()
await page.getByRole('button', { name: 'Place order' }).click()
await expect(page.getByText('Enter the company name')).toBeVisible()
await page.getByLabel('Company name').fill('Kovač d.o.o.')
await page.getByLabel('Company name').fill('Jovanović d.o.o.')
await page.getByRole('button', { name: 'Place order' }).click()

await expect(page.getByText('Total paid: €28.00')).toBeVisible()
expect(await confirmedOrder(page)).toMatchObject({
delivery: 'pickup',
shipping: {},
paymentMethod: 'invoice',
company: 'Kovač d.o.o.',
company: 'Jovanović d.o.o.',
})
})

Expand Down Expand Up @@ -202,7 +202,7 @@ test('shows the server rejecting an order that got past the browser', async ({
test('speaks German in the browser and on the server, and keeps the input', async ({
page,
}) => {
await page.getByRole('textbox', { name: 'Email' }).fill('jana@example')
await page.getByRole('textbox', { name: 'Email' }).fill('jelena@example')
await page.getByRole('button', { name: 'Add an item' }).click()
await page.getByLabel('Product').selectOption('Canvas tote bag')
await page.getByLabel('Quantity').fill('3')
Expand All @@ -211,7 +211,7 @@ test('speaks German in the browser and on the server, and keeps the input', asyn
await page.getByRole('button', { name: 'Deutsch' }).click()
await expect(page.getByRole('heading', { name: 'Kasse' })).toBeVisible()
await expect(page.getByRole('textbox', { name: 'E-Mail' })).toHaveValue(
'jana@example',
'jelena@example',
)
await expect(page.getByTestId('summary')).toContainText('3 x Stofftasche')
await expect(page.getByTestId('summary')).toContainText('54,00 €')
Expand All @@ -225,7 +225,7 @@ test('speaks German in the browser and on the server, and keeps the input', asyn
await expect(page.getByText('Wählen Sie eine Lieferart')).toBeVisible()
await expectNoSidewaysScroll(page)

await page.getByRole('textbox', { name: 'E-Mail' }).fill('jana@example.com')
await page.getByRole('textbox', { name: 'E-Mail' }).fill('jelena@example.com')
await page.getByRole('radio', { name: /^Abholung/ }).check()
await page.getByRole('checkbox', { name: /Verkaufsbedingungen/ }).check()

Expand Down
14 changes: 7 additions & 7 deletions react-checkout/server/app.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ const app = createApp()

/** An order that passes: one item, shipped, paid by card. */
const valid = {
email: 'jana@example.com',
email: 'jelena@example.com',
lines: [{ product: 'mug', quantity: 2 }],
delivery: 'standard',
shipping: {
fullName: 'Jana Kovač',
street: 'Ilica 1',
zip: '10000',
city: 'Zagreb',
country: 'HR',
fullName: 'Jelena Jovanović',
street: 'Knez Mihailova 1',
zip: '11000',
city: 'Belgrade',
country: 'RS',
},
paymentMethod: 'card',
acceptTerms: true,
Expand Down Expand Up @@ -79,7 +79,7 @@ describe('POST /api/orders', () => {
it('rejects an order the browser would never send, in the language asked for', async () => {
const tampered = {
...valid,
email: 'jana',
email: 'jelena',
lines: [{ product: 'mug', quantity: 'many' }, { quantity: 11 }],
shipping: { ...valid.shipping, zip: 'ABC' },
acceptTerms: false,
Expand Down
2 changes: 1 addition & 1 deletion react-checkout/shared/definition.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('the languages', () => {

it('give the same schema its messages, each in its own words', () => {
const input = {
email: 'jana',
email: 'jelena',
lines: [],
delivery: 'pickup',
paymentMethod: 'card',
Expand Down
2 changes: 1 addition & 1 deletion react-checkout/shared/definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export const checkoutDefinition = builders.en.defineForm({
required: { message: 'checkout.country.required' },
options: [
{ value: 'AT', label: 'checkout.country.AT' },
{ value: 'HR', label: 'checkout.country.HR' },
{ value: 'RS', label: 'checkout.country.RS' },
{ value: 'DE', label: 'checkout.country.DE' },
],
ui: { autocomplete: 'country' },
Expand Down
8 changes: 4 additions & 4 deletions react-checkout/shared/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function isLocale(value: unknown): value is Locale {
const messages = {
en: {
'app.title': 'Checkout',
'app.lead': 'Paper goods, shipped from Zagreb.',
'app.lead': 'Paper goods, shipped from Belgrade.',
'app.language': 'Language',
'app.loading': 'Loading the checkout...',
'app.loadFailed': "The checkout can't be loaded",
Expand Down Expand Up @@ -73,7 +73,7 @@ const messages = {
'checkout.country.label': 'Country',
'checkout.country.required': 'Choose a country',
'checkout.country.AT': 'Austria',
'checkout.country.HR': 'Croatia',
'checkout.country.RS': 'Serbia',
'checkout.country.DE': 'Germany',
'checkout.payment.label': 'Payment method',
'checkout.payment.required': 'Choose how to pay',
Expand Down Expand Up @@ -109,7 +109,7 @@ const messages = {
},
de: {
'app.title': 'Kasse',
'app.lead': 'Papierwaren, verschickt aus Zagreb.',
'app.lead': 'Papierwaren, verschickt aus Belgrad.',
'app.language': 'Sprache',
'app.loading': 'Die Kasse wird geladen...',
'app.loadFailed': 'Die Kasse kann nicht geladen werden',
Expand Down Expand Up @@ -164,7 +164,7 @@ const messages = {
'checkout.country.label': 'Land',
'checkout.country.required': 'Wählen Sie ein Land',
'checkout.country.AT': 'Österreich',
'checkout.country.HR': 'Kroatien',
'checkout.country.RS': 'Serbien',
'checkout.country.DE': 'Deutschland',
'checkout.payment.label': 'Zahlungsart',
'checkout.payment.required': 'Wählen Sie eine Zahlungsart',
Expand Down
2 changes: 1 addition & 1 deletion react-checkout/shared/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface Checkout {
street?: string
zip?: string
city?: string
country?: 'AT' | 'HR' | 'DE'
country?: 'AT' | 'RS' | 'DE'
}
paymentMethod: 'card' | 'invoice'
company?: string
Expand Down
72 changes: 40 additions & 32 deletions vue-event-registration/e2e/registration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ async function fillAboutYou(
page: Page,
ticket: 'Standard' | 'Student' | 'Business',
) {
await page.getByRole('textbox', { name: 'First name' }).fill(' Ana ')
await page.getByRole('textbox', { name: 'Last name' }).fill('Horvat')
await page.getByRole('textbox', { name: 'Email' }).fill('ana@example.com')
await page.getByRole('textbox', { name: 'First name' }).fill(' Marko ')
await page.getByRole('textbox', { name: 'Last name' }).fill('Petrović')
await page.getByRole('textbox', { name: 'Email' }).fill('marko@example.com')
await page.getByRole('radio', { name: new RegExp(`^${ticket}`) }).check()
}

Expand All @@ -50,7 +50,7 @@ test('registers a business attendee with guests, step by step', async ({
/Confirm/,
])
await fillAboutYou(page, 'Business')
await page.getByRole('textbox', { name: 'Phone' }).fill('+385 91 234 5678')
await page.getByRole('textbox', { name: 'Phone' }).fill('+381 61 234 5678')
await expect(stepLabels(page)).toHaveText([
/About you/,
/Your visit/,
Expand Down Expand Up @@ -80,26 +80,30 @@ test('registers a business attendee with guests, step by step', async ({
await expect(page.getByText('Nothing added yet.')).toBeVisible()
await page.getByRole('button', { name: 'Add guest' }).click()
const firstGuest = page.getByRole('region', { name: 'Guest 1' })
await firstGuest.getByRole('textbox', { name: 'Name' }).fill('Ivo Horvat')
await firstGuest
.getByRole('textbox', { name: 'Name' })
.fill('Nikola Petrović')
await firstGuest
.getByRole('textbox', { name: 'Email' })
.fill('ivo@example.com')
.fill('nikola@example.com')
// A new item starts with the defaults of its fields.
await expect(firstGuest.getByLabel('Meal')).toHaveValue('0')
await page.getByRole('button', { name: 'Add guest' }).click()
const secondGuest = page.getByRole('region', { name: 'Guest 2' })
await secondGuest.getByRole('textbox', { name: 'Name' }).fill('Mia Novak')
await secondGuest
.getByRole('textbox', { name: 'Name' })
.fill('Milica Nikolić')
await secondGuest.getByLabel('Meal').selectOption('Vegan')
await expectNoSidewaysScroll(page)
await next(page)

await expect(currentStep(page)).toHaveText(/Invoice/)
await page.getByLabel('Company name').fill('Horvat d.o.o.')
await page.getByLabel('VAT ID').fill('HR12345678901')
await page.getByLabel('Street and number').fill('Ilica 1')
await page.getByLabel('City').fill('Zagreb')
await page.getByLabel('ZIP code').fill('10000')
await page.getByLabel('Country').selectOption('Croatia')
await page.getByLabel('Company name').fill('Petrović d.o.o.')
await page.getByLabel('VAT ID').fill('RS123456789')
await page.getByLabel('Street and number').fill('Knez Mihailova 1')
await page.getByLabel('City').fill('Belgrade')
await page.getByLabel('ZIP code').fill('11000')
await page.getByLabel('Country').selectOption('Serbia')
await expectNoSidewaysScroll(page)
await next(page)

Expand All @@ -111,8 +115,8 @@ test('registers a business attendee with guests, step by step', async ({
await expect(summary).toContainText(
'Opening keynote, Hands-on forms workshop',
)
await expect(summary).toContainText('Mia Novak, Vegan')
await expect(summary).toContainText('Croatia')
await expect(summary).toContainText('Milica Nikolić, Vegan')
await expect(summary).toContainText('Serbia')
await expectNoSidewaysScroll(page)

await page
Expand All @@ -127,10 +131,10 @@ test('registers a business attendee with guests, step by step', async ({
(await page.getByTestId('output').textContent()) ?? '',
) as unknown
expect(output).toEqual({
firstName: 'Ana',
lastName: 'Horvat',
email: 'ana@example.com',
phone: '+385 91 234 5678',
firstName: 'Marko',
lastName: 'Petrović',
email: 'marko@example.com',
phone: '+381 61 234 5678',
ticketType: 'business',
arrival: '2027-05-10',
departure: '2027-05-11',
Expand All @@ -139,15 +143,19 @@ test('registers a business attendee with guests, step by step', async ({
needsAssistance: true,
assistanceDetails: 'Step-free access',
guests: [
{ name: 'Ivo Horvat', email: 'ivo@example.com', meal: 'standard' },
{ name: 'Mia Novak', meal: 'vegan' },
{
name: 'Nikola Petrović',
email: 'nikola@example.com',
meal: 'standard',
},
{ name: 'Milica Nikolić', meal: 'vegan' },
],
company: { name: 'Horvat d.o.o.', vatId: 'HR12345678901' },
company: { name: 'Petrović d.o.o.', vatId: 'RS123456789' },
billingAddress: {
street: 'Ilica 1',
city: 'Zagreb',
zip: '10000',
country: 'HR',
street: 'Knez Mihailova 1',
city: 'Belgrade',
zip: '11000',
country: 'RS',
},
acceptTerms: true,
newsletter: false,
Expand All @@ -170,19 +178,19 @@ test('keeps the user on a step until its fields are valid', async ({

// The messages of rules, and of a field that only shows for a student ticket.
await fillAboutYou(page, 'Student')
await page.getByRole('textbox', { name: 'Email' }).fill('ana@example')
await page.getByRole('textbox', { name: 'Email' }).fill('marko@example')
await page.getByRole('textbox', { name: 'Phone' }).fill('call me')
await next(page)
await expect(currentStep(page)).toHaveText(/About you/)
await expect(page.getByText('Enter a valid email address')).toBeVisible()
await expect(
page.getByText('Use digits and spaces, like +385 91 234 5678'),
page.getByText('Use digits and spaces, like +381 61 234 5678'),
).toBeVisible()
await expect(page.getByText('Enter your student ID')).toBeVisible()
await expect(page.getByText('Enter your first name')).toHaveCount(0)

// A failed step checks itself again as it is fixed.
await page.getByRole('textbox', { name: 'Email' }).fill('ana@example.com')
await page.getByRole('textbox', { name: 'Email' }).fill('marko@example.com')
await expect(page.getByText('Enter a valid email address')).toHaveCount(0)
await page.getByRole('textbox', { name: 'Phone' }).fill('')
await page.getByLabel('Student ID').fill('ST-2027-01')
Expand Down Expand Up @@ -218,11 +226,11 @@ test('keeps the user on a step until its fields are valid', async ({
await expect(currentStep(page)).toHaveText(/Guests/)
await page.getByRole('button', { name: 'Add guest' }).click()
const guest = page.getByRole('region', { name: 'Guest 1' })
await guest.getByRole('textbox', { name: 'Email' }).fill('ana@example.com')
await guest.getByRole('textbox', { name: 'Email' }).fill('marko@example.com')
await next(page)
await expect(currentStep(page)).toHaveText(/Guests/)
await expect(page.getByText("Enter the guest's name")).toBeVisible()
await guest.getByRole('textbox', { name: 'Name' }).fill('Ivo Horvat')
await guest.getByRole('textbox', { name: 'Name' }).fill('Nikola Petrović')
await next(page)
await expect(currentStep(page)).toHaveText(/Guests/)
await expect(
Expand Down Expand Up @@ -286,7 +294,7 @@ test('moves with Enter and with the step indicator', async ({ page }) => {
await page.getByRole('button', { name: /About you/ }).click()
await expect(currentStep(page)).toHaveText(/About you/)
await expect(page.getByRole('textbox', { name: 'Last name' })).toHaveValue(
'Horvat',
'Petrović',
)

// Going forward validates each step on the way, and stops at the first with errors.
Expand Down
4 changes: 2 additions & 2 deletions vue-event-registration/src/registration/definition.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
{
"rule": "regex",
"pattern": "^\\+?[0-9 ]{6,20}$",
"message": "Use digits and spaces, like +385 91 234 5678"
"message": "Use digits and spaces, like +381 61 234 5678"
}
],
"ui": { "autocomplete": "tel" }
Expand Down Expand Up @@ -282,7 +282,7 @@
"required": { "message": "Choose a country" },
"options": [
{ "value": "AT", "label": "Austria" },
{ "value": "HR", "label": "Croatia" },
{ "value": "RS", "label": "Serbia" },
{ "value": "DE", "label": "Germany" },
{ "value": "SI", "label": "Slovenia" }
],
Expand Down
Loading
Loading