Skip to content

Commit b1e6b74

Browse files
Merge branch 'main' of https://github.com/appwrite/console into 1.6.x
2 parents 38cbb68 + 1bf64db commit b1e6b74

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

src/lib/helpers/sizeConvertion.ts

+6-7
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,24 @@ import prettyBytes from 'pretty-bytes';
33
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'] as const;
44
export type Size = (typeof sizes)[number];
55

6-
export function calculateSize(bytes: number, decimals = 1) {
6+
export function calculateSize(bytes: number, decimals = 1, base: 1000 | 1024 = 1000) {
77
if (bytes === 0) return '0 Bytes';
88

9-
const k = 1024;
109
const dm = decimals < 0 ? 0 : decimals;
1110

12-
const i = Math.floor(Math.log(bytes) / Math.log(k));
11+
const i = Math.floor(Math.log(bytes) / Math.log(base));
1312

14-
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
13+
return parseFloat((bytes / Math.pow(base, i)).toFixed(dm)) + ' ' + sizes[i];
1514
}
1615

17-
export function sizeToBytes(value: number, unit: Size, base = 1024) {
16+
export function sizeToBytes(value: number, unit: Size, base = 1000) {
1817
const index = sizes.indexOf(unit);
1918
return value * Math.pow(base, index);
2019
}
2120

22-
export function bytesToSize(value: number, unit: Size) {
21+
export function bytesToSize(value: number, unit: Size, base = 1000) {
2322
const index = sizes.indexOf(unit);
24-
return value / Math.pow(1024, index);
23+
return value / Math.pow(base, index);
2524
}
2625

2726
export function humanFileSize(

src/lib/helpers/unit.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export function createTimeUnitPair(initialValue = 0) {
7373
return { ...createValueUnitPair(initialValue, units), units };
7474
}
7575

76-
export function createByteUnitPair(initialValue = 0, base = 1024) {
76+
export function createByteUnitPair(initialValue = 0, base: 1000 | 1024 = 1000) {
7777
const units: Unit[] = [
7878
{ name: 'Bytes', value: 1 },
7979
{ name: 'Kilobytes', value: base },

tests/e2e/steps/pro-project.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,22 @@ type Metadata = {
77
};
88

99
export async function enterCreditCard(page: Page) {
10+
const dialog = page.locator('.modal').filter({
11+
hasText: 'add payment method'
12+
});
13+
await dialog.waitFor({
14+
state: 'visible'
15+
});
1016
await page.getByPlaceholder('cardholder').fill('Test User');
1117
const stripe = page.frameLocator('[title="Secure payment input frame"]');
1218
await stripe.locator('id=Field-numberInput').fill('4242424242424242');
1319
await stripe.locator('id=Field-expiryInput').fill('1250');
1420
await stripe.locator('id=Field-cvcInput').fill('123');
1521
await stripe.locator('id=Field-countryInput').selectOption('DE');
1622
await page.getByRole('button', { name: 'Add', exact: true }).click();
23+
await dialog.waitFor({
24+
state: 'hidden'
25+
});
1726
}
1827

1928
export async function createProProject(page: Page): Promise<Metadata> {
@@ -24,7 +33,6 @@ export async function createProProject(page: Page): Promise<Metadata> {
2433
await page.locator('id=plan').selectOption('tier-1');
2534
await page.getByRole('button', { name: 'get started' }).click();
2635
await page.waitForURL('./create-organization**');
27-
await new Promise((r) => setTimeout(r, 1000));
2836
await page.getByRole('button', { name: 'add' }).first().click();
2937
await enterCreditCard(page);
3038
// skip members

0 commit comments

Comments
 (0)