Skip to content

Commit

Permalink
test: added migration script
Browse files Browse the repository at this point in the history
  • Loading branch information
pcheremu committed May 2, 2024
1 parent f8f1908 commit 27accd4
Show file tree
Hide file tree
Showing 2 changed files with 143 additions and 0 deletions.
47 changes: 47 additions & 0 deletions packages/testing-docs/migration-script/report.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
allure_id;name;description;precondition;status;scenario;tag
568;Block page - Pages - Verify informational tooltips on hover (Left table);/block/63781;;Active;"Informational tooltip of icon reveal the next content on hover (left block table):
Block Number
Block height, indicates the length of the blockchain, increases after the addition of the new block.
Block Size
Numer of transactions inside the block
Status
The finality status of the block.
Batch
The batch index where the block transactions are submitted to L1
Root Hash
State root hash obtained after this block execution.
Timestamp
The date and time at which a block is mined.
Tooltips displayed correctly in mobile view";Artifacts,Block,Full test,manual,Pages,Smoke test,Tooltip,ZKF-2463
575;Contract page - Pages - Artifacts (Empty state of Events tab);Open any contract with no events;;Active;"Events tab of Contract page in empty state (no events) contains:
Text
Smart Contract doesn't have any events at this moment
Search icon";Artifacts,Contract,Empty state,Events,Full test,manual,Pages,regression,ZKF-2363
673;Contract page - Pages - Connect MetaMask with incorrect network;"https://staging-scan-v2.zksync.dev/address/contract_address

* Prerequisites: (you can use https://github.com/JackHamer09/zkSync-2.0-Hardhat-example guide) or search for 0x772ab24587013a106e08f3868ef18361c8f3a4da contract

* upload your own contract for token with methods
verify this contract
* you need to have MetaMask with Mainnet network only";;Active;"Open Contract's page
Click on the ""Contract"" tab
Click ""Connect MetaMask"" button
MetaMask message for adding a network shown
MetaMask message for switching a network shown
Verify MetaMask wallet switched to correct testnet network from Mainnet
Verify appropriate testnet network added in MetaMask (open MetaMask network list to check)
Verify wallet is connected
""Connect Metamask"" label changed to the wallet address";ABI,Contract,Full test,MetaMask,Pages,regression,ZKF-2661
772;Common - Check social image for BE;"Environment: https://explorer.zksync.io/
https://socialsharepreview.com/";;Active;"Open environment page from the description
Check social image
Logo: ""Era Block Explorer""
Description: ""Deep dive into zkSync Era and explore the network.
The zkSync Era Block Explorer provides information on transactions, blocks, contracts, and much more.""";Artifacts,Common,Full test,Logs,Pages,regression,ZKF-3284
1865;Common - URL query support - Transaction Hash;"https://linear.app/matterlabs/issue/UEXP-4596/be-fe-search-query-url

https://explorer.zksync.io/search?q={txhash} - will open a transaction page for the specified tx hash.";;Active;"Open https://goerli.explorer.zksync.io/
:
add {Basic URL}/search?q=0xa125a1072d2e8f0a27e6ffa0d29973bb07ef166448fdcaa0aef5bde40ad707c7 to the Basic page URL (note this tx hash is for Mainnet Network)
URL is converted to ""{Basic URL}/tx/0xa125a1072d2e8f0a27e6ffa0d29973bb07ef166448fdcaa0aef5bde40ad707c7""
Transaction page is opened";Navigation,Pages,Positive,regression,Search,URL
96 changes: 96 additions & 0 deletions packages/testing-docs/migration-script/script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# put csv near this script and run
# csv should have this fields: allure_id;name;description;precondition;status;scenario;tag
# change output_folder() as you wish

import csv
import re
import os

def remove_extra_chars_from_filename(filename):
return re.sub(r'[^\w\s.-]', '', filename)

def output_folder():
return "BE Tests"

def escape_special_chars(text):
return re.sub(r'([{}<>])', r'\\\1', text)

def format_tags(tags):
return [tag.strip() for tag in tags.split(',')]

def format_as_list(text):
if not text:
return ''
lines = [line.strip() for line in text.split('\n') if line.strip()]
return escape_special_chars('\n'.join(f' - {line}' for line in lines))

def format_scenario(scenario):
if not scenario:
return ''
lines = [line.rstrip() for line in scenario.split('\n') if line.strip()]
formatted_scenario = ''
current_indent = 0
for line in lines:
indent = 0
for char in line:
if char == '\t':
indent += 1
elif char == ' ':
indent += 4
else:
break
if indent > current_indent:
formatted_scenario += ' ' * (indent - current_indent) + '- ' + line.lstrip('\t ') + '\n'
elif indent < current_indent:
formatted_scenario += ' ' * ((current_indent - indent) // 4) + '- ' + line.lstrip('\t ') + '\n'
else:
formatted_scenario += '- ' + line.lstrip('\t ') + '\n'
current_indent = indent
return escape_special_chars(formatted_scenario)

if not os.path.exists(output_folder()):
os.makedirs(output_folder())


with open('report.csv', newline='', encoding='utf-8') as csvfile:
reader = csv.DictReader(csvfile, delimiter=';')

for row in reader:
allure_id = row['allure_id']
name = row['name']
name_parts = name.split('-', 2) if '-' in name else ('Others', 'Others', name)
subfolder = name_parts[0]
root_folder = name_parts[1] if len(name_parts) > 2 else subfolder
test_name = '-'.join(name_parts[2:]) if len(name_parts) > 3 else name
filename = f'id{allure_id} - {remove_extra_chars_from_filename(name)}.md'
if root_folder == '':
root_folder = subfolder

root_folder_path = os.path.join(output_folder(), root_folder)
if not os.path.exists(root_folder_path):
os.makedirs(root_folder_path)

subfolder_path = os.path.join(root_folder_path, subfolder)
if not os.path.exists(subfolder_path):
os.makedirs(subfolder_path)

with open(os.path.join(subfolder_path, filename), 'w', encoding='utf-8') as mdfile:
# tags
tags = format_tags(row['tag'] + ', ' + row['status'])
mdfile.write('---\n')
mdfile.write(f'tags: {tags}\n')
mdfile.write('---\n\n')
# name
mdfile.write(f'# id{allure_id} {name}\n\n')
# description
description = row['description']
mdfile.write('## Description\n')
mdfile.write(format_as_list(description) + '\n\n')
# precondition
precondition = row['precondition']
mdfile.write('## Precondition\n')
mdfile.write(format_as_list(precondition) + '\n\n')
# scenario
scenario = row['scenario']
mdfile.write('## Scenario\n')
mdfile.write(format_scenario(scenario))

0 comments on commit 27accd4

Please sign in to comment.