Skip to content

Commit d76db16

Browse files
authoredJan 25, 2023
feat: api-migration-render (#25)
* feat: api-migration-render API Sample migrated from Heroku to Render Modify expectation to validate http status code * feat: api-migration-render API Sample migrated from Heroku to Render Modify expectation to validate http status code
1 parent afab255 commit d76db16

File tree

4 files changed

+13
-12
lines changed

4 files changed

+13
-12
lines changed
 

‎data/users.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[
22
{
3-
"username": "KKE42CYG8RV",
4-
"password": "nGJ77UNB7ZY12."
3+
"username": "Camryn26",
4+
"password": "YaYhuJ6kSt49BWs"
55
},
66
{
77
"username": "ZWX67FDB2LE",

‎tests/api.ui.spec.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ let apiContext: APIRequestContext;
1111
test.beforeEach(async ({ playwright }) => {
1212
apiContext = await playwright.request.newContext({
1313
// All requests we send go to this API endpoint.
14-
baseURL: 'https://task-mgmt-charlyautomatiza.herokuapp.com',
14+
baseURL: 'https://task-mgmt-charlyautomatiza.onrender.com',
1515
extraHTTPHeaders: {
1616
'Accept': 'application/json',
1717
},
@@ -37,7 +37,7 @@ test('API SignUp | Login UI', async ({ page }) => {
3737
password: password,
3838
}
3939
});
40-
expect(newUser.ok()).toBeTruthy();
40+
expect(newUser.status()).toEqual(201);
4141

4242
const login = new Login(page);
4343
await login.goto();
@@ -60,21 +60,21 @@ test('API: SignUp, Create Task | UI: Login, Find a task', async ({ page }) => {
6060
password: password,
6161
}
6262
});
63-
expect(newUser.ok()).toBeTruthy();
63+
expect(newUser.status()).toEqual(201);
6464
// Login
6565
const loginUser = await apiContext.post('/auth/signin', {
6666
data: {
6767
username: username,
6868
password: password,
6969
}
7070
});
71-
expect(loginUser.ok()).toBeTruthy();
71+
expect(newUser.status()).toEqual(201);
7272

7373
const userData: User = <User> await loginUser.json();
7474
// Create a new task
7575
const title = faker.lorem.sentence(2);
7676
const description = faker.lorem.sentence(5);
77-
const newTask = await apiContext.post('/tasks', {
77+
await apiContext.post('/tasks', {
7878
headers:{
7979
'Authorization': `Bearer ${userData.accessToken}`
8080
},
@@ -83,7 +83,7 @@ test('API: SignUp, Create Task | UI: Login, Find a task', async ({ page }) => {
8383
description: description,
8484
}
8585
});
86-
expect(newTask.ok()).toBeTruthy();
86+
expect(newUser.status()).toEqual(201);
8787

8888
// Get the list of tasks
8989
const getTasks = await apiContext.get('/tasks',{

‎tests/dataAPIExample.spec.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ let dataContext: APIRequestContext;
1010
test.beforeEach(async ({ playwright }) => {
1111
apiContext = await playwright.request.newContext({
1212
// All requests we send go to this API endpoint.
13-
baseURL: 'https://task-mgmt-charlyautomatiza.herokuapp.com',
13+
baseURL: 'https://task-mgmt-charlyautomatiza.onrender.com',
1414
extraHTTPHeaders: {
1515
Accept: 'application/json',
1616
},
@@ -36,6 +36,7 @@ test.afterEach(async () => {
3636
*/
3737
test('API SignUp | Login UI', async ({ page }) => {
3838
const newUserData = await dataContext.get('/users.json');
39+
expect(newUserData.status()).toEqual(200);
3940
const userAPIData: UserRequest[] = <UserRequest[]> await newUserData.json();
4041
// New User
4142
const { username } = userAPIData[0];
@@ -47,7 +48,7 @@ test('API SignUp | Login UI', async ({ page }) => {
4748
password,
4849
},
4950
});
50-
expect(newUser.ok()).toBeTruthy();
51+
expect(newUser.status()).toEqual(201);
5152

5253
const login = new Login(page);
5354
await login.goto();

‎tests/dataClassExample.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const userData = new UserData();
1010
test.beforeEach(async ({ playwright }) => {
1111
apiContext = await playwright.request.newContext({
1212
// All requests we send go to this API endpoint.
13-
baseURL: 'https://task-mgmt-charlyautomatiza.herokuapp.com',
13+
baseURL: 'https://task-mgmt-charlyautomatiza.onrender.com',
1414
extraHTTPHeaders: {
1515
Accept: 'application/json',
1616
},
@@ -35,7 +35,7 @@ test('API SignUp | Login UI', async ({ page }) => {
3535
password,
3636
},
3737
});
38-
expect(newUser.ok()).toBeTruthy();
38+
expect(newUser.status()).toEqual(201);
3939

4040
const login = new Login(page);
4141
await login.goto();

0 commit comments

Comments
 (0)
Please sign in to comment.