|
|
|
|
@@ -17,8 +17,8 @@ async function assertThatTimerHasStarted(page) {
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function assertNewTimeEntryResponse(page) {
|
|
|
|
|
await page.waitForResponse(async (response) => {
|
|
|
|
|
function newTimeEntryResponse(page) {
|
|
|
|
|
return page.waitForResponse(async (response) => {
|
|
|
|
|
return (
|
|
|
|
|
response.status() === 201 &&
|
|
|
|
|
(await response.headerValue('Content-Type')) ===
|
|
|
|
|
@@ -37,7 +37,7 @@ async function assertNewTimeEntryResponse(page) {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function assertThatTimerIsStoped(page) {
|
|
|
|
|
async function assertThatTimerIsStopped(page) {
|
|
|
|
|
await page.locator(
|
|
|
|
|
'[data-testid="dashboard_timer"] [data-testid="timer_button"].bg-accent-300/70'
|
|
|
|
|
);
|
|
|
|
|
@@ -47,12 +47,13 @@ test('test that starting and stopping a timer without description and project wo
|
|
|
|
|
page,
|
|
|
|
|
}) => {
|
|
|
|
|
await goToDashboard(page);
|
|
|
|
|
const newTimeEntryPromise = newTimeEntryResponse(page);
|
|
|
|
|
await startOrStopTimerWithButton(page);
|
|
|
|
|
await assertNewTimeEntryResponse(page);
|
|
|
|
|
await newTimeEntryPromise;
|
|
|
|
|
await assertThatTimerHasStarted(page);
|
|
|
|
|
await page.waitForTimeout(1500);
|
|
|
|
|
await startOrStopTimerWithButton(page);
|
|
|
|
|
await page.waitForResponse(async (response) => {
|
|
|
|
|
await Promise.all([
|
|
|
|
|
page.waitForResponse(async (response) => {
|
|
|
|
|
return (
|
|
|
|
|
response.status() === 200 &&
|
|
|
|
|
(await response.headerValue('Content-Type')) ===
|
|
|
|
|
@@ -68,8 +69,10 @@ test('test that starting and stopping a timer without description and project wo
|
|
|
|
|
JSON.stringify((await response.json()).data.tags) ===
|
|
|
|
|
JSON.stringify([])
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
await assertThatTimerIsStoped(page);
|
|
|
|
|
}),
|
|
|
|
|
startOrStopTimerWithButton(page),
|
|
|
|
|
]);
|
|
|
|
|
await assertThatTimerIsStopped(page);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('test that starting and stopping a timer with a description works', async ({
|
|
|
|
|
@@ -79,8 +82,8 @@ test('test that starting and stopping a timer with a description works', async (
|
|
|
|
|
await page
|
|
|
|
|
.getByTestId('time_entry_description')
|
|
|
|
|
.fill('New Time Entry Description');
|
|
|
|
|
await startOrStopTimerWithButton(page);
|
|
|
|
|
await page.waitForResponse(async (response) => {
|
|
|
|
|
await Promise.all([
|
|
|
|
|
page.waitForResponse(async (response) => {
|
|
|
|
|
return (
|
|
|
|
|
response.status() === 201 &&
|
|
|
|
|
(await response.headerValue('Content-Type')) ===
|
|
|
|
|
@@ -97,11 +100,13 @@ test('test that starting and stopping a timer with a description works', async (
|
|
|
|
|
JSON.stringify((await response.json()).data.tags) ===
|
|
|
|
|
JSON.stringify([])
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
}),
|
|
|
|
|
startOrStopTimerWithButton(page),
|
|
|
|
|
]);
|
|
|
|
|
await assertThatTimerHasStarted(page);
|
|
|
|
|
await page.waitForTimeout(500);
|
|
|
|
|
await startOrStopTimerWithButton(page);
|
|
|
|
|
await page.waitForResponse(async (response) => {
|
|
|
|
|
await page.waitForTimeout(1500);
|
|
|
|
|
await Promise.all([
|
|
|
|
|
page.waitForResponse(async (response) => {
|
|
|
|
|
return (
|
|
|
|
|
response.status() === 200 &&
|
|
|
|
|
(await response.headerValue('Content-Type')) ===
|
|
|
|
|
@@ -118,16 +123,19 @@ test('test that starting and stopping a timer with a description works', async (
|
|
|
|
|
JSON.stringify((await response.json()).data.tags) ===
|
|
|
|
|
JSON.stringify([])
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
await assertThatTimerIsStoped(page);
|
|
|
|
|
}),
|
|
|
|
|
await startOrStopTimerWithButton(page),
|
|
|
|
|
]);
|
|
|
|
|
await assertThatTimerIsStopped(page);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('test that starting and updating the description while running works', async ({
|
|
|
|
|
page,
|
|
|
|
|
}) => {
|
|
|
|
|
await goToDashboard(page);
|
|
|
|
|
await startOrStopTimerWithButton(page);
|
|
|
|
|
await page.waitForResponse(async (response) => {
|
|
|
|
|
|
|
|
|
|
await Promise.all([
|
|
|
|
|
page.waitForResponse(async (response) => {
|
|
|
|
|
return (
|
|
|
|
|
response.status() === 201 &&
|
|
|
|
|
(await response.headerValue('Content-Type')) ===
|
|
|
|
|
@@ -143,14 +151,17 @@ test('test that starting and updating the description while running works', asyn
|
|
|
|
|
JSON.stringify((await response.json()).data.tags) ===
|
|
|
|
|
JSON.stringify([])
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
}),
|
|
|
|
|
startOrStopTimerWithButton(page),
|
|
|
|
|
]);
|
|
|
|
|
await assertThatTimerHasStarted(page);
|
|
|
|
|
await page.waitForTimeout(500);
|
|
|
|
|
await page
|
|
|
|
|
.getByTestId('time_entry_description')
|
|
|
|
|
.fill('New Time Entry Description');
|
|
|
|
|
await page.getByTestId('time_entry_description').press('Tab');
|
|
|
|
|
await page.waitForResponse(async (response) => {
|
|
|
|
|
|
|
|
|
|
await Promise.all([
|
|
|
|
|
page.waitForResponse(async (response) => {
|
|
|
|
|
return (
|
|
|
|
|
response.status() === 200 &&
|
|
|
|
|
(await response.headerValue('Content-Type')) ===
|
|
|
|
|
@@ -167,10 +178,12 @@ test('test that starting and updating the description while running works', asyn
|
|
|
|
|
JSON.stringify((await response.json()).data.tags) ===
|
|
|
|
|
JSON.stringify([])
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
}),
|
|
|
|
|
page.getByTestId('time_entry_description').press('Tab'),
|
|
|
|
|
]);
|
|
|
|
|
await page.waitForTimeout(500);
|
|
|
|
|
await startOrStopTimerWithButton(page);
|
|
|
|
|
await page.waitForResponse(async (response) => {
|
|
|
|
|
await Promise.all([
|
|
|
|
|
page.waitForResponse(async (response) => {
|
|
|
|
|
return (
|
|
|
|
|
response.status() === 200 &&
|
|
|
|
|
(await response.headerValue('Content-Type')) ===
|
|
|
|
|
@@ -187,16 +200,18 @@ test('test that starting and updating the description while running works', asyn
|
|
|
|
|
JSON.stringify((await response.json()).data.tags) ===
|
|
|
|
|
JSON.stringify([])
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
await assertThatTimerIsStoped(page);
|
|
|
|
|
}),
|
|
|
|
|
await startOrStopTimerWithButton(page),
|
|
|
|
|
]);
|
|
|
|
|
await assertThatTimerIsStopped(page);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('test that starting and updating the time while running works', async ({
|
|
|
|
|
page,
|
|
|
|
|
}) => {
|
|
|
|
|
await goToDashboard(page);
|
|
|
|
|
await startOrStopTimerWithButton(page);
|
|
|
|
|
const createResponse = await page.waitForResponse(async (response) => {
|
|
|
|
|
const [createResponse] = await Promise.all([
|
|
|
|
|
page.waitForResponse(async (response) => {
|
|
|
|
|
return (
|
|
|
|
|
response.status() === 201 &&
|
|
|
|
|
(await response.headerValue('Content-Type')) ===
|
|
|
|
|
@@ -212,12 +227,15 @@ test('test that starting and updating the time while running works', async ({
|
|
|
|
|
JSON.stringify((await response.json()).data.tags) ===
|
|
|
|
|
JSON.stringify([])
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
}),
|
|
|
|
|
await startOrStopTimerWithButton(page),
|
|
|
|
|
]);
|
|
|
|
|
await assertThatTimerHasStarted(page);
|
|
|
|
|
await page.waitForTimeout(500);
|
|
|
|
|
await page.getByTestId('time_entry_time').fill('20min');
|
|
|
|
|
await page.getByTestId('time_entry_time').press('Tab');
|
|
|
|
|
await page.waitForResponse(async (response) => {
|
|
|
|
|
|
|
|
|
|
await Promise.all([
|
|
|
|
|
page.waitForResponse(async (response) => {
|
|
|
|
|
return (
|
|
|
|
|
response.status() === 200 &&
|
|
|
|
|
(await response.headerValue('Content-Type')) ===
|
|
|
|
|
@@ -235,11 +253,14 @@ test('test that starting and updating the time while running works', async ({
|
|
|
|
|
JSON.stringify((await response.json()).data.tags) ===
|
|
|
|
|
JSON.stringify([])
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
}),
|
|
|
|
|
page.getByTestId('time_entry_time').press('Tab'),
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
await expect(page.getByTestId('time_entry_time')).toHaveValue(/00:20/);
|
|
|
|
|
await page.waitForTimeout(500);
|
|
|
|
|
await startOrStopTimerWithButton(page);
|
|
|
|
|
await page.waitForResponse(async (response) => {
|
|
|
|
|
await Promise.all([
|
|
|
|
|
page.waitForResponse(async (response) => {
|
|
|
|
|
return (
|
|
|
|
|
response.status() === 200 &&
|
|
|
|
|
(await response.headerValue('Content-Type')) ===
|
|
|
|
|
@@ -255,15 +276,17 @@ test('test that starting and updating the time while running works', async ({
|
|
|
|
|
JSON.stringify((await response.json()).data.tags) ===
|
|
|
|
|
JSON.stringify([])
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
await assertThatTimerIsStoped(page);
|
|
|
|
|
}),
|
|
|
|
|
startOrStopTimerWithButton(page),
|
|
|
|
|
]);
|
|
|
|
|
await assertThatTimerIsStopped(page);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('test that entering a time starts the timer on blur', async ({ page }) => {
|
|
|
|
|
await goToDashboard(page);
|
|
|
|
|
await page.getByTestId('time_entry_time').fill('20min');
|
|
|
|
|
await page.getByTestId('time_entry_time').press('Tab');
|
|
|
|
|
await page.waitForResponse(async (response) => {
|
|
|
|
|
await Promise.all([
|
|
|
|
|
page.waitForResponse(async (response) => {
|
|
|
|
|
return (
|
|
|
|
|
response.status() === 201 &&
|
|
|
|
|
(await response.headerValue('Content-Type')) ===
|
|
|
|
|
@@ -279,10 +302,13 @@ test('test that entering a time starts the timer on blur', async ({ page }) => {
|
|
|
|
|
JSON.stringify((await response.json()).data.tags) ===
|
|
|
|
|
JSON.stringify([])
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
}),
|
|
|
|
|
page.getByTestId('time_entry_time').press('Tab'),
|
|
|
|
|
]);
|
|
|
|
|
await assertThatTimerHasStarted(page);
|
|
|
|
|
await startOrStopTimerWithButton(page);
|
|
|
|
|
await page.waitForResponse(async (response) => {
|
|
|
|
|
|
|
|
|
|
await Promise.all([
|
|
|
|
|
page.waitForResponse(async (response) => {
|
|
|
|
|
return (
|
|
|
|
|
response.status() === 200 &&
|
|
|
|
|
(await response.headerValue('Content-Type')) ===
|
|
|
|
|
@@ -298,7 +324,9 @@ test('test that entering a time starts the timer on blur', async ({ page }) => {
|
|
|
|
|
JSON.stringify((await response.json()).data.tags) ===
|
|
|
|
|
JSON.stringify([])
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
}),
|
|
|
|
|
startOrStopTimerWithButton(page),
|
|
|
|
|
]);
|
|
|
|
|
await page.locator(
|
|
|
|
|
'[data-testid="dashboard_timer"] [data-testid="timer_button"].bg-accent-300/70'
|
|
|
|
|
);
|
|
|
|
|
@@ -309,8 +337,8 @@ test('test that entering a time starts the timer on enter', async ({
|
|
|
|
|
}) => {
|
|
|
|
|
await goToDashboard(page);
|
|
|
|
|
await page.getByTestId('time_entry_time').fill('20min');
|
|
|
|
|
await page.getByTestId('time_entry_time').press('Enter');
|
|
|
|
|
await page.waitForResponse(async (response) => {
|
|
|
|
|
await Promise.all([
|
|
|
|
|
page.waitForResponse(async (response) => {
|
|
|
|
|
return (
|
|
|
|
|
response.status() === 201 &&
|
|
|
|
|
(await response.headerValue('Content-Type')) ===
|
|
|
|
|
@@ -326,10 +354,12 @@ test('test that entering a time starts the timer on enter', async ({
|
|
|
|
|
JSON.stringify((await response.json()).data.tags) ===
|
|
|
|
|
JSON.stringify([])
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
}),
|
|
|
|
|
page.getByTestId('time_entry_time').press('Enter'),
|
|
|
|
|
]);
|
|
|
|
|
await assertThatTimerHasStarted(page);
|
|
|
|
|
await startOrStopTimerWithButton(page);
|
|
|
|
|
await page.waitForResponse(async (response) => {
|
|
|
|
|
await Promise.all([
|
|
|
|
|
page.waitForResponse(async (response) => {
|
|
|
|
|
return (
|
|
|
|
|
response.status() === 200 &&
|
|
|
|
|
(await response.headerValue('Content-Type')) ===
|
|
|
|
|
@@ -345,8 +375,10 @@ test('test that entering a time starts the timer on enter', async ({
|
|
|
|
|
JSON.stringify((await response.json()).data.tags) ===
|
|
|
|
|
JSON.stringify([])
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
await assertThatTimerIsStoped(page);
|
|
|
|
|
}),
|
|
|
|
|
startOrStopTimerWithButton(page),
|
|
|
|
|
]);
|
|
|
|
|
await assertThatTimerIsStopped(page);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('test that adding a new tag works', async ({ page }) => {
|
|
|
|
|
@@ -354,15 +386,19 @@ test('test that adding a new tag works', async ({ page }) => {
|
|
|
|
|
await goToDashboard(page);
|
|
|
|
|
await page.getByTestId('tag_dropdown').click();
|
|
|
|
|
await page.getByTestId('tag_dropdown_search').fill(newTagName);
|
|
|
|
|
await page.getByTestId('tag_dropdown_search').press('Enter');
|
|
|
|
|
await page.waitForResponse(async (response) => {
|
|
|
|
|
|
|
|
|
|
await Promise.all([
|
|
|
|
|
page.waitForResponse(async (response) => {
|
|
|
|
|
return (
|
|
|
|
|
response.status() === 201 &&
|
|
|
|
|
(await response.headerValue('Content-Type')) ===
|
|
|
|
|
'application/json' &&
|
|
|
|
|
(await response.json()).data.name === newTagName
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
}),
|
|
|
|
|
page.getByTestId('tag_dropdown_search').press('Enter'),
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
await expect(page.getByTestId('tag_dropdown_search')).toHaveValue('');
|
|
|
|
|
await expect(page.getByRole('option', { name: newTagName })).toBeVisible();
|
|
|
|
|
});
|
|
|
|
|
@@ -372,24 +408,24 @@ test('test that adding a new tag when the timer is running', async ({
|
|
|
|
|
}) => {
|
|
|
|
|
const newTagName = 'New Tag' + Math.floor(Math.random() * 10000);
|
|
|
|
|
await goToDashboard(page);
|
|
|
|
|
await startOrStopTimerWithButton(page);
|
|
|
|
|
await assertNewTimeEntryResponse(page);
|
|
|
|
|
await Promise.all([
|
|
|
|
|
newTimeEntryResponse(page),
|
|
|
|
|
startOrStopTimerWithButton(page),
|
|
|
|
|
]);
|
|
|
|
|
await assertThatTimerHasStarted(page);
|
|
|
|
|
await page.getByTestId('tag_dropdown').click();
|
|
|
|
|
await page.getByTestId('tag_dropdown_search').fill(newTagName);
|
|
|
|
|
await page.getByTestId('tag_dropdown_search').press('Enter');
|
|
|
|
|
const tagCreateResponse = await page.waitForResponse(async (response) => {
|
|
|
|
|
const [tagCreateResponse] = await Promise.all([
|
|
|
|
|
page.waitForResponse(async (response) => {
|
|
|
|
|
return (
|
|
|
|
|
response.status() === 201 &&
|
|
|
|
|
(await response.headerValue('Content-Type')) ===
|
|
|
|
|
'application/json' &&
|
|
|
|
|
(await response.json()).data.name === newTagName
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
await expect(page.getByTestId('tag_dropdown_search')).toHaveValue('');
|
|
|
|
|
|
|
|
|
|
await expect(page.getByRole('option', { name: newTagName })).toBeVisible();
|
|
|
|
|
|
|
|
|
|
}),
|
|
|
|
|
page.getByTestId('tag_dropdown_search').press('Enter'),
|
|
|
|
|
]);
|
|
|
|
|
await page.waitForResponse(async (response) => {
|
|
|
|
|
return (
|
|
|
|
|
response.status() === 200 &&
|
|
|
|
|
@@ -407,10 +443,13 @@ test('test that adding a new tag when the timer is running', async ({
|
|
|
|
|
JSON.stringify([(await tagCreateResponse.json()).data.id])
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
await expect(page.getByTestId('tag_dropdown_search')).toHaveValue('');
|
|
|
|
|
await expect(page.getByRole('option', { name: newTagName })).toBeVisible();
|
|
|
|
|
await page.getByTestId('tag_dropdown_search').press('Escape');
|
|
|
|
|
await page.waitForTimeout(1000);
|
|
|
|
|
await startOrStopTimerWithButton(page);
|
|
|
|
|
await page.waitForResponse(async (response) => {
|
|
|
|
|
|
|
|
|
|
await Promise.all([
|
|
|
|
|
page.waitForResponse(async (response) => {
|
|
|
|
|
return (
|
|
|
|
|
response.status() === 200 &&
|
|
|
|
|
(await response.headerValue('Content-Type')) ===
|
|
|
|
|
@@ -426,8 +465,10 @@ test('test that adding a new tag when the timer is running', async ({
|
|
|
|
|
JSON.stringify((await response.json()).data.tags) ===
|
|
|
|
|
JSON.stringify([(await tagCreateResponse.json()).data.id])
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
await assertThatTimerIsStoped(page);
|
|
|
|
|
}),
|
|
|
|
|
startOrStopTimerWithButton(page),
|
|
|
|
|
]);
|
|
|
|
|
await assertThatTimerIsStopped(page);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// test that adding a new tag when the timer is running
|
|
|
|
|
|