Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(pw): failed tests #3709

Merged
merged 12 commits into from
Jun 27, 2023
2 changes: 1 addition & 1 deletion test/acceptance/config_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Scenario('change config 5 @WebDriverIO @Puppeteer @Playwright @Protractor @Night

Scenario('make API call and check response @Playwright', ({ I }) => {
I.amOnPage('/');
I.makeApiRequest('get', 'https://jsonplaceholder.typicode.com/comments/1');
I.makeApiRequest('get', 'https://reqres.in/api/users?page=2');
I.seeResponseCodeIsSuccessful();
});

Expand Down
4 changes: 2 additions & 2 deletions test/data/app/view/form/fetch_call.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<script type="text/javascript">
const tableData = data =>
Object.entries(data).reduce(
(html, [key, value]) => `${html}
(html, [key, value]) => `${html}
<tr>
<td>${key}</td>
<td>${value}</td>
Expand Down Expand Up @@ -53,7 +53,7 @@
const getPostData = () =>
getData("https://jsonplaceholder.typicode.com/posts/1");
const getCommentsData = () =>
getData("https://jsonplaceholder.typicode.com/comments/1");
getData("https://reqres.in/api/comments/1");
const getUsersData = () =>
getData("https://jsonplaceholder.typicode.com/users/1");
</script>
Expand Down
14 changes: 7 additions & 7 deletions test/helper/Playwright_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ describe('Playwright', function () {
describe('#mockRoute, #stopMockingRoute', () => {
it('should mock a route', async () => {
await I.amOnPage('/form/fetch_call');
await I.mockRoute('https://jsonplaceholder.typicode.com/comments/1', route => {
await I.mockRoute('https://reqres.in/api/comments/1', route => {
route.fulfill({
status: 200,
headers: { 'Access-Control-Allow-Origin': '*' },
Expand All @@ -804,18 +804,18 @@ describe('Playwright', function () {
});
await I.click('GET COMMENTS');
await I.see('this was mocked');
await I.stopMockingRoute('https://jsonplaceholder.typicode.com/comments/1');
await I.stopMockingRoute('https://reqres.in/api/comments/1');
await I.click('GET COMMENTS');
await I.see('postId');
await I.see('data');
await I.dontSee('this was mocked');
});
});

describe('#makeApiRequest', () => {
it('should make 3rd party API request', async () => {
const response = await I.makeApiRequest('get', 'https://jsonplaceholder.typicode.com/comments/1');
const response = await I.makeApiRequest('get', 'https://reqres.in/api/users?page=2');
expect(response.status()).to.equal(200);
expect(await response.json()).to.include.keys(['id', 'name']);
expect(await response.json()).to.include.keys(['page']);
});

it('should make local API request', async () => {
Expand All @@ -826,10 +826,10 @@ describe('Playwright', function () {
it('should convert to axios response with onResponse hook', async () => {
let response;
I.config.onResponse = (resp) => response = resp;
await I.makeApiRequest('get', 'https://jsonplaceholder.typicode.com/comments/1');
await I.makeApiRequest('get', 'https://reqres.in/api/users?page=2');
expect(response).to.be.ok;
expect(response.status).to.equal(200);
expect(response.data).to.include.keys(['id', 'name']);
expect(response.data).to.include.keys(['page', 'total']);
});
});

Expand Down
4 changes: 2 additions & 2 deletions test/rest/REST_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ describe('REST', () => {
});

it('should be able to parse JSON responses', async () => {
await I.sendGetRequest('https://jsonplaceholder.typicode.com/comments/1');
await I.sendGetRequest('https://reqres.in/api/comments/1');
await jsonResponse.seeResponseCodeIsSuccessful();
await jsonResponse.seeResponseContainsKeys(['id', 'name', 'email']);
await jsonResponse.seeResponseContainsKeys(['data', 'support']);
});
});

Expand Down