diff --git a/jsonReports/jsonReport.json b/jsonReports/jsonReport.json index 4b72199..dfec5e6 100644 --- a/jsonReports/jsonReport.json +++ b/jsonReports/jsonReport.json @@ -93,12 +93,12 @@ { "workerIndex": 0, "status": "passed", - "duration": 439, + "duration": 267, "errors": [], "stdout": [], "stderr": [], "retry": 0, - "startTime": "2024-04-03T08:54:54.372Z", + "startTime": "2024-04-03T11:16:54.089Z", "attachments": [] } ], @@ -114,12 +114,12 @@ { "workerIndex": 4, "status": "passed", - "duration": 463, + "duration": 279, "errors": [], "stdout": [], "stderr": [], "retry": 0, - "startTime": "2024-04-03T08:54:54.372Z", + "startTime": "2024-04-03T11:16:54.093Z", "attachments": [] } ], @@ -146,12 +146,12 @@ { "workerIndex": 0, "status": "passed", - "duration": 205, + "duration": 202, "errors": [], "stdout": [], "stderr": [], "retry": 0, - "startTime": "2024-04-03T08:54:54.812Z", + "startTime": "2024-04-03T11:16:54.357Z", "attachments": [] } ], @@ -167,12 +167,12 @@ { "workerIndex": 4, "status": "passed", - "duration": 201, + "duration": 211, "errors": [], "stdout": [], "stderr": [], "retry": 0, - "startTime": "2024-04-03T08:54:54.836Z", + "startTime": "2024-04-03T11:16:54.374Z", "attachments": [] } ], @@ -199,12 +199,12 @@ { "workerIndex": 0, "status": "passed", - "duration": 168, + "duration": 181, "errors": [], "stdout": [], "stderr": [], "retry": 0, - "startTime": "2024-04-03T08:54:55.018Z", + "startTime": "2024-04-03T11:16:54.561Z", "attachments": [] } ], @@ -220,12 +220,12 @@ { "workerIndex": 4, "status": "passed", - "duration": 172, + "duration": 410, "errors": [], "stdout": [], "stderr": [], "retry": 0, - "startTime": "2024-04-03T08:54:55.038Z", + "startTime": "2024-04-03T11:16:54.586Z", "attachments": [] } ], @@ -252,12 +252,12 @@ { "workerIndex": 0, "status": "passed", - "duration": 166, + "duration": 193, "errors": [], "stdout": [], "stderr": [], "retry": 0, - "startTime": "2024-04-03T08:54:55.187Z", + "startTime": "2024-04-03T11:16:54.743Z", "attachments": [] } ], @@ -273,12 +273,12 @@ { "workerIndex": 4, "status": "passed", - "duration": 163, + "duration": 243, "errors": [], "stdout": [], "stderr": [], "retry": 0, - "startTime": "2024-04-03T08:54:55.210Z", + "startTime": "2024-04-03T11:16:54.997Z", "attachments": [] } ], @@ -305,12 +305,12 @@ { "workerIndex": 0, "status": "passed", - "duration": 223, + "duration": 200, "errors": [], "stdout": [], "stderr": [], "retry": 0, - "startTime": "2024-04-03T08:54:55.354Z", + "startTime": "2024-04-03T11:16:54.937Z", "attachments": [] } ], @@ -326,12 +326,12 @@ { "workerIndex": 4, "status": "passed", - "duration": 195, + "duration": 196, "errors": [], "stdout": [], "stderr": [], "retry": 0, - "startTime": "2024-04-03T08:54:55.374Z", + "startTime": "2024-04-03T11:16:55.241Z", "attachments": [] } ], @@ -358,12 +358,12 @@ { "workerIndex": 0, "status": "passed", - "duration": 189, + "duration": 184, "errors": [], "stdout": [], "stderr": [], "retry": 0, - "startTime": "2024-04-03T08:54:55.577Z", + "startTime": "2024-04-03T11:16:55.139Z", "attachments": [] } ], @@ -379,12 +379,12 @@ { "workerIndex": 4, "status": "passed", - "duration": 197, + "duration": 243, "errors": [], "stdout": [], "stderr": [], "retry": 0, - "startTime": "2024-04-03T08:54:55.571Z", + "startTime": "2024-04-03T11:16:55.437Z", "attachments": [] } ], @@ -395,6 +395,59 @@ "file": "playwright/tests/api-builds.test.ts", "line": 154, "column": 5 + }, + { + "title": "POST /api/builds use existing name", + "ok": true, + "tags": [], + "tests": [ + { + "timeout": 30000, + "annotations": [], + "expectedStatus": "passed", + "projectId": "chrome", + "projectName": "chrome", + "results": [ + { + "workerIndex": 0, + "status": "passed", + "duration": 168, + "errors": [], + "stdout": [], + "stderr": [], + "retry": 0, + "startTime": "2024-04-03T11:16:55.324Z", + "attachments": [] + } + ], + "status": "expected" + }, + { + "timeout": 30000, + "annotations": [], + "expectedStatus": "passed", + "projectId": "firefox", + "projectName": "firefox", + "results": [ + { + "workerIndex": 4, + "status": "passed", + "duration": 164, + "errors": [], + "stdout": [], + "stderr": [], + "retry": 0, + "startTime": "2024-04-03T11:16:55.682Z", + "attachments": [] + } + ], + "status": "expected" + } + ], + "id": "428847cbfb989d16a29c-77e586a4b9a28817e34b", + "file": "playwright/tests/api-builds.test.ts", + "line": 174, + "column": 5 } ] }, @@ -405,7 +458,7 @@ "line": 0, "specs": [ { - "title": "clickToLevelUp", + "title": "Click 5 times to level up", "ok": true, "tags": [], "tests": [ @@ -419,12 +472,12 @@ { "workerIndex": 1, "status": "passed", - "duration": 1603, + "duration": 1454, "errors": [], "stdout": [], "stderr": [], "retry": 0, - "startTime": "2024-04-03T08:54:54.358Z", + "startTime": "2024-04-03T11:16:54.077Z", "attachments": [] } ], @@ -440,21 +493,127 @@ { "workerIndex": 5, "status": "passed", - "duration": 1570, + "duration": 1394, "errors": [], "stdout": [], "stderr": [], "retry": 0, - "startTime": "2024-04-03T08:54:54.361Z", + "startTime": "2024-04-03T11:16:54.085Z", "attachments": [] } ], "status": "expected" } ], - "id": "ae863fb240454409d07e-33a8295487a1f74892d2", + "id": "ae863fb240454409d07e-20918e394174c65d4184", "file": "playwright/tests/levelUp.test.ts", - "line": 3, + "line": 4, + "column": 5 + }, + { + "title": "Click 4 times and no level up", + "ok": true, + "tags": [], + "tests": [ + { + "timeout": 30000, + "annotations": [], + "expectedStatus": "passed", + "projectId": "chrome", + "projectName": "chrome", + "results": [ + { + "workerIndex": 1, + "status": "passed", + "duration": 1089, + "errors": [], + "stdout": [], + "stderr": [], + "retry": 0, + "startTime": "2024-04-03T11:16:55.898Z", + "attachments": [] + } + ], + "status": "expected" + }, + { + "timeout": 30000, + "annotations": [], + "expectedStatus": "passed", + "projectId": "firefox", + "projectName": "firefox", + "results": [ + { + "workerIndex": 5, + "status": "passed", + "duration": 1180, + "errors": [], + "stdout": [], + "stderr": [], + "retry": 0, + "startTime": "2024-04-03T11:16:56.140Z", + "attachments": [] + } + ], + "status": "expected" + } + ], + "id": "ae863fb240454409d07e-979ad5bb011d61400a6c", + "file": "playwright/tests/levelUp.test.ts", + "line": 20, + "column": 5 + }, + { + "title": "Click 6 times, out of bound", + "ok": true, + "tags": [], + "tests": [ + { + "timeout": 30000, + "annotations": [], + "expectedStatus": "passed", + "projectId": "chrome", + "projectName": "chrome", + "results": [ + { + "workerIndex": 1, + "status": "passed", + "duration": 849, + "errors": [], + "stdout": [], + "stderr": [], + "retry": 0, + "startTime": "2024-04-03T11:16:56.989Z", + "attachments": [] + } + ], + "status": "expected" + }, + { + "timeout": 30000, + "annotations": [], + "expectedStatus": "passed", + "projectId": "firefox", + "projectName": "firefox", + "results": [ + { + "workerIndex": 5, + "status": "passed", + "duration": 689, + "errors": [], + "stdout": [], + "stderr": [], + "retry": 0, + "startTime": "2024-04-03T11:16:57.321Z", + "attachments": [] + } + ], + "status": "expected" + } + ], + "id": "ae863fb240454409d07e-8a829558acea44416b4f", + "file": "playwright/tests/levelUp.test.ts", + "line": 34, "column": 5 } ] @@ -480,12 +639,12 @@ { "workerIndex": 2, "status": "passed", - "duration": 1284, + "duration": 1171, "errors": [], "stdout": [], "stderr": [], "retry": 0, - "startTime": "2024-04-03T08:54:54.358Z", + "startTime": "2024-04-03T11:16:54.077Z", "attachments": [] } ], @@ -501,12 +660,12 @@ { "workerIndex": 6, "status": "passed", - "duration": 1407, + "duration": 1330, "errors": [], "stdout": [], "stderr": [], "retry": 0, - "startTime": "2024-04-03T08:54:56.151Z", + "startTime": "2024-04-03T11:16:55.698Z", "attachments": [] } ], @@ -541,12 +700,12 @@ { "workerIndex": 3, "status": "passed", - "duration": 2357, + "duration": 2022, "errors": [], "stdout": [], "stderr": [], "retry": 0, - "startTime": "2024-04-03T08:54:54.360Z", + "startTime": "2024-04-03T11:16:54.076Z", "attachments": [] } ], @@ -560,14 +719,14 @@ "projectName": "firefox", "results": [ { - "workerIndex": 4, + "workerIndex": 7, "status": "passed", - "duration": 1841, + "duration": 2070, "errors": [], "stdout": [], "stderr": [], "retry": 0, - "startTime": "2024-04-03T08:54:55.773Z", + "startTime": "2024-04-03T11:16:55.858Z", "attachments": [] } ], @@ -594,12 +753,12 @@ { "workerIndex": 3, "status": "passed", - "duration": 639, + "duration": 860, "errors": [], "stdout": [], "stderr": [], "retry": 0, - "startTime": "2024-04-03T08:54:57.076Z", + "startTime": "2024-04-03T11:16:56.464Z", "attachments": [] } ], @@ -613,14 +772,14 @@ "projectName": "firefox", "results": [ { - "workerIndex": 4, + "workerIndex": 7, "status": "passed", - "duration": 570, + "duration": 614, "errors": [], "stdout": [], "stderr": [], "retry": 0, - "startTime": "2024-04-03T08:54:58.062Z", + "startTime": "2024-04-03T11:16:58.338Z", "attachments": [] } ], @@ -647,12 +806,12 @@ { "workerIndex": 3, "status": "passed", - "duration": 660, + "duration": 753, "errors": [], "stdout": [], "stderr": [], "retry": 0, - "startTime": "2024-04-03T08:54:57.716Z", + "startTime": "2024-04-03T11:16:57.325Z", "attachments": [] } ], @@ -666,14 +825,14 @@ "projectName": "firefox", "results": [ { - "workerIndex": 4, + "workerIndex": 7, "status": "passed", - "duration": 1219, + "duration": 582, "errors": [], "stdout": [], "stderr": [], "retry": 0, - "startTime": "2024-04-03T08:54:58.633Z", + "startTime": "2024-04-03T11:16:58.953Z", "attachments": [] } ], @@ -700,12 +859,12 @@ { "workerIndex": 3, "status": "passed", - "duration": 633, + "duration": 711, "errors": [], "stdout": [], "stderr": [], "retry": 0, - "startTime": "2024-04-03T08:54:58.377Z", + "startTime": "2024-04-03T11:16:58.079Z", "attachments": [] } ], @@ -719,14 +878,14 @@ "projectName": "firefox", "results": [ { - "workerIndex": 4, + "workerIndex": 7, "status": "passed", - "duration": 609, + "duration": 570, "errors": [], "stdout": [], "stderr": [], "retry": 0, - "startTime": "2024-04-03T08:54:59.853Z", + "startTime": "2024-04-03T11:16:59.536Z", "attachments": [] } ], @@ -743,9 +902,9 @@ ], "errors": [], "stats": { - "startTime": "2024-04-03T08:54:54.164Z", - "duration": 6543.803000000001, - "expected": 24, + "startTime": "2024-04-03T11:16:53.883Z", + "duration": 6466.64, + "expected": 30, "skipped": 0, "unexpected": 0, "flaky": 0 diff --git a/playwright/resources/enums/errorMessages.ts b/playwright/resources/enums/errorMessages.ts index e760505..be7fc2e 100644 --- a/playwright/resources/enums/errorMessages.ts +++ b/playwright/resources/enums/errorMessages.ts @@ -2,4 +2,5 @@ export enum errorMessages{ expectedNumber = "Expected number, received string", expectedString = "Expected string, received number", exceedMaxValueStats = "Total value of stats cannot be more than 10", + nameExists = "a build with this name already exists", } \ No newline at end of file diff --git a/playwright/resources/enums/levelUpMessages.ts b/playwright/resources/enums/levelUpMessages.ts new file mode 100644 index 0000000..847fbdb --- /dev/null +++ b/playwright/resources/enums/levelUpMessages.ts @@ -0,0 +1,4 @@ +export enum levelUpMessage{ + clickButton = 'Great job! You levelled up', + +} \ No newline at end of file diff --git a/playwright/resources/pageobjects/LevelUpPage.ts b/playwright/resources/pageobjects/LevelUpPage.ts index 1944853..985448a 100644 --- a/playwright/resources/pageobjects/LevelUpPage.ts +++ b/playwright/resources/pageobjects/LevelUpPage.ts @@ -13,17 +13,14 @@ export class LevelUpPage{ this.clickLevelUpMessage = page.locator('//span[@data-task="clicker"]'); } - async clickButtonToLevelUp(){ + async clickButtonToLevelUp(j: number){ if (await this.clickLevelUpButton.isVisible()){ - let i; - for(i=5; i>0; i--){ - await expect(this.clickLevelUpButton).toBeEnabled() - await this.clickLevelUpButton.click(); + if( j > 5){ + throw new Error('ERROR: Click button input is greater than 5'); } - await expect(this.clickLevelUpButton).toBeDisabled(); - await expect(this.clickLevelUpMessage.textContent()).resolves.toBe('Great job! You levelled up'); - } - } - - -} \ No newline at end of file + else{ + for(let i=j; i>0; i--){ + await expect(this.clickLevelUpButton).toBeEnabled() + await this.clickLevelUpButton.click(); + }} + }}} diff --git a/playwright/tests/api-builds.test.ts b/playwright/tests/api-builds.test.ts index 407fd4f..c9ca039 100644 --- a/playwright/tests/api-builds.test.ts +++ b/playwright/tests/api-builds.test.ts @@ -168,4 +168,24 @@ test("POST /api/builds exceeds max stats value", async({ request }) =>{ expect(postResponse.status()).toBe(400); expect(postResponseBody.error[0].message).toEqual(errorMessages.exceedMaxValueStats); +}) + + +test("POST /api/builds use existing name", async({ request }) =>{ + const newCharacter = { + "build": { + "name": "mage", + "strength": 5, + "agility": 3.5, + "wisdom": 2.5, + "magic": 1 + } + } + const postResponse = await request.post(buildURL, { + data: newCharacter + }) + const postResponseBody = await postResponse.json() + + expect(postResponse.status()).toBe(400); + expect(postResponseBody.error[0].message).toEqual(errorMessages.nameExists); }) \ No newline at end of file diff --git a/playwright/tests/levelUp.test.ts b/playwright/tests/levelUp.test.ts index 74d37bb..68f4e3b 100644 --- a/playwright/tests/levelUp.test.ts +++ b/playwright/tests/levelUp.test.ts @@ -1,6 +1,8 @@ -import { test } from '../resources/config/fixtures'; +import { test , expect} from '../resources/config/fixtures'; +import { levelUpMessage } from '../resources/enums/levelUpMessages'; + +test("Click 5 times to level up", async ({ page, homepage, playpage, levelup}) =>{ -test("clickToLevelUp", async ({ page, homepage, playpage, levelup}) =>{ await page.goto("/"); await homepage.clickOnPlayButton(); @@ -8,6 +10,36 @@ test("clickToLevelUp", async ({ page, homepage, playpage, levelup}) =>{ await playpage.fillInCharacterName(' 123 Test '); await playpage.clickStartButton(); - await levelup.clickButtonToLevelUp(); + await levelup.clickButtonToLevelUp(5); + await expect(levelup.clickLevelUpButton).toBeDisabled(); + await expect(levelup.clickLevelUpMessage.textContent()).resolves.toBe(levelUpMessage.clickButton); }) + + +test("Click 4 times and no level up", async ({ page, homepage, playpage, levelup}) =>{ + await page.goto("/"); + await homepage.clickOnPlayButton(); + + await playpage.selectBuild('Mage'); + await playpage.fillInCharacterName(' 123 Test '); + await playpage.clickStartButton(); + + await levelup.clickButtonToLevelUp(4); + await expect(levelup.clickLevelUpButton).toBeEnabled(); + await expect(levelup.clickLevelUpMessage).not.toBeVisible(); + +}) + +test("Click 6 times, out of bound", async ({ page, homepage, playpage, levelup}) =>{ + await page.goto("/"); + await homepage.clickOnPlayButton(); + await playpage.selectBuild('Mage'); + await playpage.fillInCharacterName(' 123 Test '); + await playpage.clickStartButton(); + + const clickFunction = async () => { + await levelup.clickButtonToLevelUp(6); + }; + await expect(clickFunction).rejects.toThrow('ERROR: Click button input is greater than 5'); +}) \ No newline at end of file