Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
automated_testing_kit
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
automated_testing_kit
Commits
05b3e41b
Commit
05b3e41b
authored
4 months ago
by
ilyaukin
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3389608
: Add a test for advanced search
parent
8c8e11b9
Branches
1.0.x
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!12
Resolve #3389608 "Search"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
data/search.json
+24
-8
24 additions, 8 deletions
data/search.json
playwright/e2e/atk_search/atk_search.spec.js
+58
-4
58 additions, 4 deletions
playwright/e2e/atk_search/atk_search.spec.js
with
82 additions
and
12 deletions
data/search.json
+
24
−
8
View file @
05b3e41b
[
{
"keyword"
:
"dammit"
,
"results"
:
[
"Futurama"
]
}
]
\ No newline at end of file
{
"simple"
:
[
{
"keyword"
:
"dammit"
,
"results"
:
[
"Futurama"
]
}
],
"advanced"
:
[
{
"any"
:
"cicero ceaser"
,
"phrase"
:
""
,
"none"
:
"futurama"
,
"types"
:
[
"article"
],
"languages"
:
[],
"results"
:
[
"Cicero"
]
}
]
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
playwright/e2e/atk_search/atk_search.spec.js
+
58
−
4
View file @
05b3e41b
...
...
@@ -21,6 +21,11 @@ const baseUrl = playwrightConfig.use.baseURL;
// Import ATK Configuration.
import
atkConfig
from
'
../../playwright.atk.config
'
;
// Standard accounts that use user accounts created
// by QA Accounts. QA Accounts are created when the QA
// Accounts module is enabled.
import
qaUserAccounts
from
'
../data/qaUsers.json
'
;
// Search keywords and expected results.
// Adjust for your site.
import
searchData
from
'
../data/search.json
'
;
...
...
@@ -29,7 +34,7 @@ test.describe('Search tests.', () => {
test
(
'
(ATK-PW-1160) Search content by a keyword. @ATK-PW-1160 @search @content
'
,
async
({
page
})
=>
{
await
page
.
goto
(
baseUrl
);
for
(
let
item
of
searchData
)
{
for
(
let
item
of
searchData
.
simple
)
{
await
page
.
getByRole
(
"
button
"
,
{
name
:
"
Search Form
"
}).
click
();
const
keyInput
=
page
.
locator
(
'
input:focus
'
);
...
...
@@ -40,12 +45,61 @@ test.describe('Search tests.', () => {
await
expect
(
page
.
getByText
(
'
Search results
'
)).
toBeVisible
();
// Check that expected items are shown.
for
(
let
result
of
item
.
results
)
{
await
expect
(
page
.
getByText
(
result
)).
toBeVisible
();
}
await
checkResult
(
page
,
item
);
// Check that the search keyword is highlighted in the text.
await
expect
(
page
.
locator
(
`xpath=//strong[.="
${
item
.
keyword
}
"]`
).
first
()).
toBeVisible
();
}
});
test
(
'
(ATK-PW-1161) Advanced search. @ATK-PW-1161 @search @content
'
,
async
({
page
,
context
})
=>
{
for
(
let
item
of
searchData
.
advanced
)
{
// In the default installation, only admin can do advanced search.
// Change if it's configured different way on your site.
await
atkCommands
.
logInViaForm
(
page
,
context
,
qaUserAccounts
.
admin
);
await
page
.
goto
(
baseUrl
+
'
search/node
'
);
// Expand "Advanced search".
await
page
.
getByRole
(
"
button
"
,
{
name
:
"
Advanced search
"
}).
click
();
// Fill all the configured data.
if
(
item
.
any
)
{
await
page
.
getByLabel
(
"
Containing any of the words
"
).
fill
(
item
.
any
);
}
if
(
item
.
phrase
)
{
await
page
.
getByLabel
(
"
Containing the phrase
"
).
fill
(
item
.
phrase
);
}
if
(
item
.
none
)
{
await
page
.
getByLabel
(
"
Containing none of the words
"
).
fill
(
item
.
none
);
}
// Select node type if specified.
for
(
let
type
of
item
.
types
)
{
await
page
.
getByRole
(
"
group
"
,
{
name
:
"
Types
"
})
.
getByLabel
(
type
).
check
();
}
// Select languages if specified.
for
(
let
language
of
item
.
languages
)
{
await
page
.
getByRole
(
"
group
"
,
{
name
:
"
Languages
"
})
.
getByLabel
(
language
).
check
();
}
await
page
.
locator
(
'
input[value="Advanced search"]
'
).
click
();
// Wait for search result to be shown.
await
checkResult
(
page
,
item
);
}
});
async
function
checkResult
(
page
,
item
)
{
const
resultLocatorList
=
await
page
.
locator
(
'
.search-result__title
'
).
all
();
const
resultList
=
[];
for
(
let
resultLocator
of
resultLocatorList
)
{
resultList
.
push
((
await
resultLocator
.
textContent
()).
trim
());
}
for
(
let
result
of
item
.
results
)
{
expect
(
resultList
).
toContain
(
result
);
}
}
});
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment