Skip to content

Commit bc38f3e

Browse files
Anton StandrikAnton Standrik
authored andcommitted
fix: tests
1 parent e5abc6a commit bc38f3e

File tree

2 files changed

+54
-26
lines changed

2 files changed

+54
-26
lines changed

.github/workflows/quality.yml

Lines changed: 53 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -220,36 +220,61 @@ jobs:
220220
- name: Analyze test changes
221221
id: analyze_tests
222222
run: |
223+
# Create temporary files for storing test lists
224+
current_tests_file=$(mktemp)
225+
base_tests_file=$(mktemp)
226+
227+
# Function to extract test names from a file
228+
extract_tests() {
229+
local file=$1
230+
if [ -f "$file" ]; then
231+
grep -E "test\(['\"]" "$file" | sed -E "s/.*test\(['\"]([^'\"]+)['\"].*/\1/"
232+
fi
233+
}
234+
235+
# Get list of test files
236+
test_files=$(find tests/suites -type f -name "*.test.ts")
237+
238+
# First pass: current branch tests
239+
for file in $test_files; do
240+
tests=$(extract_tests "$file")
241+
if [ ! -z "$tests" ]; then
242+
while IFS= read -r test_name; do
243+
echo "$test_name|$file" >> "$current_tests_file"
244+
done <<< "$tests"
245+
fi
246+
done
247+
248+
# Fetch and checkout main branch temporarily
223249
git fetch origin main:main
250+
current_branch=$(git rev-parse --abbrev-ref HEAD)
251+
git checkout main
252+
253+
# Second pass: main branch tests
254+
for file in $test_files; do
255+
if [ -f "$file" ]; then
256+
tests=$(extract_tests "$file")
257+
if [ ! -z "$tests" ]; then
258+
while IFS= read -r test_name; do
259+
echo "$test_name|$file" >> "$base_tests_file"
260+
done <<< "$tests"
261+
fi
262+
fi
263+
done
264+
265+
# Switch back to original branch
266+
git checkout "$current_branch"
267+
268+
# Compare and build test details
224269
new_tests=0
225270
test_details=""
226271
227-
# Get list of changed test files
228-
for file in $(git diff --name-only main...HEAD | grep -E '^tests/suites/.*\.(spec|test)\.(ts|tsx|js|jsx)$'); do
229-
echo "Analyzing file: $file"
230-
231-
# Get test names from current version
232-
if git show HEAD:"$file" > /dev/null 2>&1; then
233-
current_tests=$(git show HEAD:"$file" | grep -E "test\([\'\"]" | sed -E "s/.*test\(['\"]([^'\"]+)['\"].*/\1/")
234-
else
235-
current_tests=""
236-
fi
237-
238-
# Get test names from main version
239-
if git show main:"$file" > /dev/null 2>&1; then
240-
base_tests=$(git show main:"$file" | grep -E "test\([\'\"]" | sed -E "s/.*test\(['\"]([^'\"]+)['\"].*/\1/")
241-
else
242-
base_tests=""
243-
fi
244-
245-
# Compare and find new tests
246-
while IFS= read -r test_name; do
247-
if [ ! -z "$test_name" ] && ! echo "$base_tests" | grep -Fxq "$test_name"; then
248-
((new_tests++))
249-
test_details+="- ✨ Added test: \`$test_name\` in \`$file\`\\n"
272+
while IFS='|' read -r test_name file; do
273+
if ! grep -Fq "$test_name|" "$base_tests_file"; then
274+
((new_tests++))
275+
test_details+="- ✨ Added test: \`$test_name\` in \`$file\`\\n"
250276
fi
251-
done <<< "$current_tests"
252-
done
277+
done < "$current_tests_file"
253278
254279
# Escape the test details for GitHub Actions
255280
test_details="${test_details//'%'/'%25'}"
@@ -261,6 +286,9 @@ jobs:
261286
echo "$test_details" >> $GITHUB_OUTPUT
262287
echo "EOF" >> $GITHUB_OUTPUT
263288
289+
# Cleanup
290+
rm "$current_tests_file" "$base_tests_file"
291+
264292
- name: Update PR description
265293
uses: actions/github-script@v6
266294
with:

tests/suites/tenant/queryEditor/queryEditor.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ test.describe('Test Query Editor', async () => {
234234
await expect(queryEditor.resultTable.getResultHeadText()).resolves.toBe('Truncated(1)');
235235
});
236236

237-
test('Query execution status changes correctly', async ({page}) => {
237+
test.only('Query execution status changes correctly', async ({page}) => {
238238
const queryEditor = new QueryEditor(page);
239239
await queryEditor.setQuery(testQuery);
240240
await queryEditor.clickRunButton();

0 commit comments

Comments
 (0)