Compare commits

...

3 Commits

Author SHA1 Message Date
Swayam Rana
d8fc0fb2e0 fix: contract matching and response 2023-08-09 17:39:51 +00:00
Swayam Rana
05c916171a Merge branch 'master' of github.com:openedx/frontend-app-profile into swayamrana-pact 2023-08-03 15:56:06 +00:00
Swayam Rana
5b676408e4 test: edit contract with different expected response and use cases 2023-08-03 14:30:41 +00:00
2 changed files with 41 additions and 54 deletions

View File

@@ -3,21 +3,6 @@
"name": "frontend-app-profile"
},
"interactions": [
{
"description": "A request for user's basic information",
"providerStates": [
{
"name": "Account and user's information does not exist"
}
],
"request": {
"method": "GET",
"path": "/api/user/v1/accounts/staff_not_found"
},
"response": {
"status": 404
}
},
{
"description": "A request for user's basic information",
"providerStates": [
@@ -30,13 +15,16 @@
"path": "/api/user/v1/accounts/staff"
},
"response": {
"status": 200,
"body": {
"bio": "This is my bio",
"country": "ME",
"dateJoined": "2017-06-07T00:44:23Z",
"email": "staff@example.com",
"gender": "m",
"goals": "Learn and Grow!",
"isActive": true,
"mailingAddress": "Park Ave",
"name": "Lemon Seltzer",
"phoneNumber": "+11234567890",
"username": "staff",
"yearOfBirth": 1901
},
@@ -44,18 +32,37 @@
"Content-Type": "application/json"
},
"matchingRules": {
"body": {
"$": {
"combine": "AND",
"matchers": [
{
"match": "type"
}
]
}
"$.body.bio": {
"match": "type"
},
"$.body.country": {
"match": "type"
},
"$.body.gender": {
"match": "type"
},
"$.body.goals": {
"match": "type"
},
"$.body.isActive": {
"match": "type"
},
"$.body.mailingAddress": {
"match": "type"
},
"$.body.name": {
"match": "type"
},
"$.body.phoneNumber": {
"match": "type"
},
"$.body.username": {
"match": "type"
},
"$.body.yearOfBirth": {
"match": "type"
}
},
"status": 200
}
}
}
],

View File

@@ -9,13 +9,15 @@ import { initializeMockApp, getConfig, setConfig } from '@edx/frontend-platform'
import { getAccount } from './services';
const expectedUserInfo200 = {
username: 'staff',
email: 'staff@example.com',
bio: 'This is my bio',
name: 'Lemon Seltzer',
country: 'ME',
dateJoined: '2017-06-07T00:44:23Z',
gender: 'm',
goals: 'Learn and Grow!',
isActive: true,
mailingAddress: 'Park Ave',
name: 'Lemon Seltzer',
phoneNumber: '+11234567890',
username: 'staff',
yearOfBirth: 1901,
};
@@ -55,26 +57,4 @@ describe('getAccount for one username', () => {
expect(response).toEqual(expectedUserInfo200);
});
});
it('Account does not exist', async () => {
const username404 = 'staff_not_found';
await provider.addInteraction({
states: [{ description: "Account and user's information does not exist" }],
uponReceiving: "A request for user's basic information",
withRequest: {
method: 'GET',
path: `/api/user/v1/accounts/${username404}`,
},
willRespondWith: {
status: 404,
},
});
await provider.executeTest(async (mockserver) => {
setConfig({
...getConfig(),
LMS_BASE_URL: mockserver.url,
});
await expect(getAccount(username404).then((response) => response.data)).rejects.toThrow('Request failed with status code 404');
});
});
});