Skip to content

feat(cts): add tests for analytics #69

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

Merged
merged 2 commits into from
Jan 7, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1619,8 +1619,12 @@ export type GetTopSearchesProps = {
clickAnalytics?: boolean;
startDate?: Date;
endDate?: Date;
orderBy?: Record<string, any>;
direction?: Record<string, any>;
orderBy?:
| 'averageClickPosition'
| 'clickThroughRate'
| 'conversionRate'
| 'searchCount';
direction?: 'asc' | 'desc';
limit?: number;
offset?: number;
tags?: string;
Expand Down
21 changes: 17 additions & 4 deletions doc/CTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ And that's it! If the name of the file matches a real `operationId` in the spec,
- Create a template in `test/CTS/templates/<your language>.mustache` that parse a array of test into your test framework of choice

When writing your template, here is a list of variables accessible from `mustache`:

```js
{
"import": "the name of the package or library to import",
Expand All @@ -60,14 +61,25 @@ When writing your template, here is a list of variables accessible from `mustach
"testName": "the descriptive name test (default to `method`)"
"method": "the method to call on the API Client",
"parameters": {
// Object of all parameters with their name, tobe used for languages that require the parameter name
// Object of all parameters with their name, to be used for languages that require the parameter name
"parameterName": "value",
...
},
"parametersArray": [
// The same paremeters but passed as an array for other languages
// It includes the `-last` properties used to join the parameters
"parametersWithDataType": [
{
"key": "key",
"value": "value",
// booleans indicating the data type
"isDate": "false",
"isArray": "false",
"isObject": "true",
"isString": "false",
// boolean indicating if it is the last parameter
"-last": "false",
}
],
// boolean indicating if the method has parameters, useful for `GET` requests
"hasParameters": "true",
"request": {
"path": "the expected path of the request",
"method": "the expected method: GET, POST, PUT, DELETE or PATCH",
Expand All @@ -83,6 +95,7 @@ When writing your template, here is a list of variables accessible from `mustach
## Get the list of remaining CTS to implement

To get the list of `operationId` not yet in the CTS but in the spec, run this command:

```bash
rm -rf ./specs/dist
comm -3 <(grep -r operationId ./specs | awk -F: '{gsub(/ /,""); print $NF}' | sort) <(find ./tests/CTS/clients -type f -name '*.json' | awk -F/ '{gsub(/.json/,"");print $NF}' | sort)
Expand Down
2 changes: 2 additions & 0 deletions specs/analytics/paths/common/parameters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ OrderBy:
name: orderBy
description: Reorder the results.
schema:
type: string
enum: [searchCount, clickThroughRate, conversionRate, averageClickPosition]
default: searchCount

Expand All @@ -21,6 +22,7 @@ Direction:
name: direction
description: The sorting of the result.
schema:
type: string
enum: [asc, desc]
default: asc

Expand Down
27 changes: 27 additions & 0 deletions tests/CTS/clients/analytics/getAverageClickPosition.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[
{
"method": "getAverageClickPosition",
"testName": "get getAverageClickPosition with minimal parameters",
"parameters": {
"index": "index"
},
"request": {
"path": "/2/clicks/averageClickPosition",
"method": "GET"
}
},
{
"method": "getAverageClickPosition",
"testName": "get getAverageClickPosition with all parameters",
"parameters": {
"index": "index",
"startDate": "1999-19-09",
"endDate": "2001-01-01",
"tags": "tag"
},
"request": {
"path": "/2/clicks/averageClickPosition",
"method": "GET"
}
}
]
27 changes: 27 additions & 0 deletions tests/CTS/clients/analytics/getClickPositions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[
{
"method": "getClickPositions",
"testName": "get getClickPositions with minimal parameters",
"parameters": {
"index": "index"
},
"request": {
"path": "/2/clicks/positions",
"method": "GET"
}
},
{
"method": "getClickPositions",
"testName": "get getClickPositions with all parameters",
"parameters": {
"index": "index",
"startDate": "1999-19-09",
"endDate": "2001-01-01",
"tags": "tag"
},
"request": {
"path": "/2/clicks/positions",
"method": "GET"
}
}
]
27 changes: 27 additions & 0 deletions tests/CTS/clients/analytics/getClickThroughRate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[
{
"method": "getClickThroughRate",
"testName": "get getClickThroughRate with minimal parameters",
"parameters": {
"index": "index"
},
"request": {
"path": "/2/clicks/clickThroughRate",
"method": "GET"
}
},
{
"method": "getClickThroughRate",
"testName": "get getClickThroughRate with all parameters",
"parameters": {
"index": "index",
"startDate": "1999-19-09",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should also check the query params to see if this is passed correctly

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, that's what I was checking

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR is here #70

"endDate": "2001-01-01",
"tags": "tag"
},
"request": {
"path": "/2/clicks/clickThroughRate",
"method": "GET"
}
}
]
27 changes: 27 additions & 0 deletions tests/CTS/clients/analytics/getConversationRate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[
{
"method": "getConversationRate",
"testName": "get getConversationRate with minimal parameters",
"parameters": {
"index": "index"
},
"request": {
"path": "/2/conversions/conversionRate",
"method": "GET"
}
},
{
"method": "getConversationRate",
"testName": "get getConversationRate with all parameters",
"parameters": {
"index": "index",
"startDate": "1999-19-09",
"endDate": "2001-01-01",
"tags": "tag"
},
"request": {
"path": "/2/conversions/conversionRate",
"method": "GET"
}
}
]
27 changes: 27 additions & 0 deletions tests/CTS/clients/analytics/getNoClickRate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[
{
"method": "getNoClickRate",
"testName": "get getNoClickRate with minimal parameters",
"parameters": {
"index": "index"
},
"request": {
"path": "/2/searches/noClickRate",
"method": "GET"
}
},
{
"method": "getNoClickRate",
"testName": "get getNoClickRate with all parameters",
"parameters": {
"index": "index",
"startDate": "1999-19-09",
"endDate": "2001-01-01",
"tags": "tag"
},
"request": {
"path": "/2/searches/noClickRate",
"method": "GET"
}
}
]
27 changes: 27 additions & 0 deletions tests/CTS/clients/analytics/getNoResultsRate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[
{
"method": "getNoResultsRate",
"testName": "get getNoResultsRate with minimal parameters",
"parameters": {
"index": "index"
},
"request": {
"path": "/2/searches/noResultRate",
"method": "GET"
}
},
{
"method": "getNoResultsRate",
"testName": "get getNoResultsRate with all parameters",
"parameters": {
"index": "index",
"startDate": "1999-19-09",
"endDate": "2001-01-01",
"tags": "tag"
},
"request": {
"path": "/2/searches/noResultRate",
"method": "GET"
}
}
]
27 changes: 27 additions & 0 deletions tests/CTS/clients/analytics/getSearchesCount.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[
{
"method": "getSearchesCount",
"testName": "get getSearchesCount with minimal parameters",
"parameters": {
"index": "index"
},
"request": {
"path": "/2/searches/count",
"method": "GET"
}
},
{
"method": "getSearchesCount",
"testName": "get getSearchesCount with all parameters",
"parameters": {
"index": "index",
"startDate": "1999-19-09",
"endDate": "2001-01-01",
"tags": "tag"
},
"request": {
"path": "/2/searches/count",
"method": "GET"
}
}
]
29 changes: 29 additions & 0 deletions tests/CTS/clients/analytics/getSearchesNoClicks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[
{
"method": "getSearchesNoClicks",
"testName": "get getSearchesNoClicks with minimal parameters",
"parameters": {
"index": "index"
},
"request": {
"path": "/2/searches/noClicks",
"method": "GET"
}
},
{
"method": "getSearchesNoClicks",
"testName": "get getSearchesNoClicks with all parameters",
"parameters": {
"index": "index",
"startDate": "1999-19-09",
"endDate": "2001-01-01",
"limit": 21,
"offset": 42,
"tags": "tag"
},
"request": {
"path": "/2/searches/noClicks",
"method": "GET"
}
}
]
29 changes: 29 additions & 0 deletions tests/CTS/clients/analytics/getSearchesNoResults.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[
{
"method": "getSearchesNoResults",
"testName": "get getSearchesNoResults with minimal parameters",
"parameters": {
"index": "index"
},
"request": {
"path": "/2/searches/noResults",
"method": "GET"
}
},
{
"method": "getSearchesNoResults",
"testName": "get getSearchesNoResults with all parameters",
"parameters": {
"index": "index",
"startDate": "1999-19-09",
"endDate": "2001-01-01",
"limit": 21,
"offset": 42,
"tags": "tag"
},
"request": {
"path": "/2/searches/noResults",
"method": "GET"
}
}
]
13 changes: 13 additions & 0 deletions tests/CTS/clients/analytics/getStatus.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[
{
"method": "getStatus",
"testName": "get getStatus with minimal parameters",
"parameters": {
"index": "index"
},
"request": {
"path": "/2/status",
"method": "GET"
}
}
]
29 changes: 29 additions & 0 deletions tests/CTS/clients/analytics/getTopCountries.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[
{
"method": "getTopCountries",
"testName": "get getTopCountries with minimal parameters",
"parameters": {
"index": "index"
},
"request": {
"path": "/2/countries",
"method": "GET"
}
},
{
"method": "getTopCountries",
"testName": "get getTopCountries with all parameters",
"parameters": {
"index": "index",
"startDate": "1999-19-09",
"endDate": "2001-01-01",
"limit": 21,
"offset": 42,
"tags": "tag"
},
"request": {
"path": "/2/countries",
"method": "GET"
}
}
]
Loading