Skip to content

Commit

Permalink
Merge branch 'main' into FET-1640
Browse files Browse the repository at this point in the history
  • Loading branch information
sugh01 committed Sep 20, 2024
2 parents 2dbe5b0 + 1fa176e commit 4cafb7b
Show file tree
Hide file tree
Showing 40 changed files with 1,147 additions and 321 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
shard: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28]
shard: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]
steps:
- uses: actions/checkout@v3

Expand Down
File renamed without changes.
83 changes: 46 additions & 37 deletions e2e/specs/stateless/extendNames.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
/* eslint-disable no-await-in-loop */
import { expect } from '@playwright/test'

import { dateToDateInput, roundDurationWithDay, secondsToDateInput } from '@app/utils/date'
import {
dateToDateInput,
roundDurationWithDay,
secondsFromDateDiff,
secondsToDateInput,
} from '@app/utils/date'
import { daysToSeconds } from '@app/utils/time'

import { test } from '../../../playwright'
Expand Down Expand Up @@ -335,14 +340,14 @@ test('should be able to extend a name by a month', async ({
})

await test.step('should set and render a date properly', async () => {
const expiryTime = (await profilePage.getExpiryTimestamp()) / 1000
const expiryTimestamp = await profilePage.getExpiryTimestamp()
const expiryTime = expiryTimestamp / 1000
const calendar = page.getByTestId('calendar')
const monthLater = await page.evaluate(
(ts) => {
return new Date(ts)
},
(expiryTime + daysToSeconds(31)) * 1000,
)
const monthLater = await page.evaluate((ts) => {
const expiryDate = new Date(ts)
expiryDate.setMonth(expiryDate.getMonth() + 1)
return expiryDate
}, expiryTimestamp)

await calendar.fill(dateToDateInput(monthLater))
await expect(page.getByTestId('calendar-date')).toHaveValue(
Expand All @@ -354,7 +359,7 @@ test('should be able to extend a name by a month', async ({
await expect(extendNamesModal.getInvoiceExtensionFee).toContainText('0.0003')
await expect(extendNamesModal.getInvoiceTransactionFee).toContainText('0.0001')
await expect(extendNamesModal.getInvoiceTotal).toContainText('0.0004')
await expect(page.getByText('1 month extension', { exact: true })).toBeVisible()
await expect(page.getByText(/1 month .* extension/)).toBeVisible()
})

await test.step('should extend', async () => {
Expand All @@ -363,7 +368,9 @@ test('should be able to extend a name by a month', async ({
await transactionModal.autoComplete()

const newTimestamp = await profilePage.getExpiryTimestamp()
const comparativeTimestamp = timestamp + daysToSeconds(31) * 1000
const comparativeTimestamp =
timestamp +
secondsFromDateDiff({ startDate: new Date(timestamp), additionalMonths: 1 }) * 1000
await expect(comparativeTimestamp).toEqual(newTimestamp)
})
})
Expand Down Expand Up @@ -398,18 +405,18 @@ test('should be able to extend a name by a day', async ({
})

await test.step('should set and render a date properly', async () => {
const expiryTime = (await profilePage.getExpiryTimestamp()) / 1000
const expiryTimestamp = await profilePage.getExpiryTimestamp()
const expiryTime = expiryTimestamp / 1000
const calendar = page.getByTestId('calendar')
const monthLater = await page.evaluate(
(ts) => {
return new Date(ts)
},
(expiryTime + daysToSeconds(1)) * 1000,
)
const dayLater = await page.evaluate((ts) => {
const expiryDate = new Date(ts)
expiryDate.setDate(expiryDate.getDate() + 1)
return expiryDate
}, expiryTimestamp)

await calendar.fill(dateToDateInput(monthLater))
await calendar.fill(dateToDateInput(dayLater))
await expect(page.getByTestId('calendar-date')).toHaveValue(
secondsToDateInput(expiryTime + roundDurationWithDay(monthLater, expiryTime)),
secondsToDateInput(expiryTime + roundDurationWithDay(dayLater, expiryTime)),
)
})

Expand Down Expand Up @@ -473,14 +480,14 @@ test('should be able to extend a name in grace period by a month', async ({
})

await test.step('should set and render a date properly', async () => {
const expiryTime = (await profilePage.getExpiryTimestamp()) / 1000
const expiryTimestamp = await profilePage.getExpiryTimestamp()
const expiryTime = expiryTimestamp / 1000
const calendar = page.getByTestId('calendar')
const monthLater = await page.evaluate(
(ts) => {
return new Date(ts)
},
(expiryTime + daysToSeconds(31)) * 1000,
)
const monthLater = await page.evaluate((ts) => {
const expiryDate = new Date(ts)
expiryDate.setMonth(expiryDate.getMonth() + 1)
return expiryDate
}, expiryTimestamp)

await calendar.fill(dateToDateInput(monthLater))
await expect(page.getByTestId('calendar-date')).toHaveValue(
Expand All @@ -492,7 +499,7 @@ test('should be able to extend a name in grace period by a month', async ({
await expect(extendNamesModal.getInvoiceExtensionFee).toContainText('0.0003')
await expect(extendNamesModal.getInvoiceTransactionFee).toContainText('0.0001')
await expect(extendNamesModal.getInvoiceTotal).toContainText('0.0004')
await expect(page.getByText('1 month extension', { exact: true })).toBeVisible()
await expect(page.getByText(/1 month .* extension/)).toBeVisible()
})

await test.step('should extend', async () => {
Expand All @@ -501,7 +508,9 @@ test('should be able to extend a name in grace period by a month', async ({
await transactionModal.autoComplete()

const newTimestamp = await profilePage.getExpiryTimestamp()
const comparativeTimestamp = timestamp + daysToSeconds(31) * 1000
const comparativeTimestamp =
timestamp +
secondsFromDateDiff({ startDate: new Date(timestamp), additionalMonths: 1 }) * 1000
await expect(comparativeTimestamp).toEqual(newTimestamp)
})
})
Expand Down Expand Up @@ -548,18 +557,18 @@ test('should be able to extend a name in grace period by 1 day', async ({
})

await test.step('should set and render a date properly', async () => {
const expiryTime = (await profilePage.getExpiryTimestamp()) / 1000
const expiryTimestamp = await profilePage.getExpiryTimestamp()
const expiryTime = expiryTimestamp / 1000
const calendar = page.getByTestId('calendar')
const monthLater = await page.evaluate(
(ts) => {
return new Date(ts)
},
(expiryTime + daysToSeconds(1)) * 1000,
)
const dayLater = await page.evaluate((ts) => {
const expiryDate = new Date(ts)
expiryDate.setDate(expiryDate.getDate() + 1)
return expiryDate
}, expiryTimestamp)

await calendar.fill(dateToDateInput(monthLater))
await calendar.fill(dateToDateInput(dayLater))
await expect(page.getByTestId('calendar-date')).toHaveValue(
secondsToDateInput(expiryTime + roundDurationWithDay(monthLater, expiryTime)),
secondsToDateInput(expiryTime + roundDurationWithDay(dayLater, expiryTime)),
)
})

Expand Down
Loading

0 comments on commit 4cafb7b

Please sign in to comment.