Browse Source

Fix Functional Javascript CI tests (#1004)

* Fixup js tests
* Move MINK env var into phpunit for easier local testing
* Fix xpath for 10.3

---------

Co-authored-by: Joe Corall <jjc223@lehigh.edu>
pull/1016/head
Adam 8 months ago committed by GitHub
parent
commit
54206de712
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 42
      .github/workflows/build-2.x.yml
  2. 2
      phpunit.xml
  3. 221
      tests/modules/integer_weight_test_views/test_views/views.view.test_integer_weight.yml
  4. 35
      tests/src/FunctionalJavascript/IntegerWeightTest.php

42
.github/workflows/build-2.x.yml

@ -1,30 +1,26 @@
# This is a basic workflow to help you get started with Actions
name: CI
# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the 2.x branch
push:
branches: [ 2.x ]
pull_request:
branches: [ 2.x ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
env:
DRUPAL_VERSION: ${{ matrix.drupal-version }}
SCRIPT_DIR: ${{ github.workspace }}/islandora_ci
DRUPAL_DIR: /opt/drupal
PHPUNIT_FILE: ${{ github.workspace }}/build_dir/phpunit.xml
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.allowed_failure }}
strategy:
fail-fast: false
matrix:
php-versions: ["8.1", "8.2", "8.3"]
# test-suite functional-javascript will appear to pass but will skip tests; missing chromedriver.
test-suite: ["kernel", "functional", "functional-javascript"]
drupal-version: ["10.1.x", "10.2.x", "10.3.x-dev"]
mysql: ["8.0"]
@ -51,17 +47,15 @@ jobs:
- 61616:61616
- 61613:61613
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: build_dir
- name: Checkout islandora_ci
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: islandora/islandora_ci
ref: github-actions
@ -79,13 +73,6 @@ jobs:
sudo apt-get remove -y mysql-client mysql-common
sudo apt-get install -y mysql-client
- name: Set environment variables
run: |
echo "DRUPAL_VERSION=${{ matrix.drupal-version }}" >> $GITHUB_ENV
echo "SCRIPT_DIR=$GITHUB_WORKSPACE/islandora_ci" >> $GITHUB_ENV
echo "DRUPAL_DIR=/opt/drupal" >> $GITHUB_ENV
echo "PHPUNIT_FILE=$GITHUB_WORKSPACE/build_dir/phpunit.xml" >> $GITHUB_ENV
- name: Cache Composer dependencies
uses: actions/cache@v3
with:
@ -119,7 +106,20 @@ jobs:
- name: Test scripts
run: $SCRIPT_DIR/travis_scripts.sh
- name: Start chromedriver
if: matrix.test-suite == 'functional-javascript'
run: |-
/usr/local/share/chromedriver-linux64/chromedriver \
--log-path=/tmp/chromedriver.log \
--verbose \
--allowed-ips= \
--allowed-origins=* &
- name: PHPUNIT tests
run: |
cd $DRUPAL_DIR/web/core
$DRUPAL_DIR/vendor/bin/phpunit --verbose --testsuite "${{ matrix.test-suite }}"
- name: Print chromedriver logs
if: matrix.test-suite == 'functional-javascript'
run: cat /tmp/chromedriver.log

2
phpunit.xml

@ -47,7 +47,7 @@
<!-- Example for changing the driver args to phantomjs tests MINK_DRIVER_ARGS_PHANTOMJS value: '["http://127.0.0.1:8510"]' -->
<env name="MINK_DRIVER_ARGS_PHANTOMJS" value=""/>
<!-- Example for changing the driver args to webdriver tests MINK_DRIVER_ARGS_WEBDRIVER value: '["chrome", { "chromeOptions": { "w3c": false } }, "http://localhost:4444/wd/hub"]' For using the Firefox browser, replace "chrome" with "firefox" -->
<env name="MINK_DRIVER_ARGS_WEBDRIVER" value=""/>
<env name="MINK_DRIVER_ARGS_WEBDRIVER" value='["chrome", {"browserName":"chrome","chromeOptions":{"args":["--disable-gpu","--headless", "--no-sandbox", "--disable-dev-shm-usage"]}}, "http://localhost:9515"]'/>
</php>
<testsuites>
<testsuite name="unit">

221
tests/modules/integer_weight_test_views/test_views/views.view.test_integer_weight.yml

@ -4,6 +4,7 @@ dependencies:
config:
- node.type.repo_item
module:
- islandora
- node
- user
id: test_integer_weight
@ -13,87 +14,36 @@ description: ''
tag: ''
base_table: node_field_data
base_field: nid
core: 8.x
display:
default:
display_plugin: default
id: default
display_title: Master
display_plugin: default
position: 0
display_options:
access:
type: perm
options:
perm: 'access content'
cache:
type: tag
options: { }
query:
type: views_query
options:
disable_sql_rewrite: false
distinct: false
replica: false
query_comment: ''
query_tags: { }
exposed_form:
type: basic
options:
submit_button: Apply
reset_button: false
reset_button_label: Reset
exposed_sorts_label: 'Sort by'
expose_sort_order: true
sort_asc_label: Asc
sort_desc_label: Desc
pager:
type: mini
options:
items_per_page: 10
offset: 0
id: 0
total_pages: null
expose:
items_per_page: false
items_per_page_label: 'Items per page'
items_per_page_options: '5, 10, 25, 50'
items_per_page_options_all: false
items_per_page_options_all_label: '- All -'
offset: false
offset_label: Offset
tags:
previous: ‹‹
next: ››
style:
type: table
row:
type: fields
title: 'test weight'
fields:
title:
id: title
table: node_field_data
field: title
relationship: none
group_type: group
admin_label: ''
entity_type: node
entity_field: title
plugin_id: field
label: Title
exclude: false
alter:
alter_text: false
make_link: false
absolute: false
trim: false
word_boundary: false
ellipsis: false
strip_tags: false
trim: false
html: false
hide_empty: false
empty_zero: false
settings:
link_to_entity: true
plugin_id: field
relationship: none
group_type: group
admin_label: ''
label: Title
exclude: false
element_type: ''
element_class: ''
element_label_type: ''
@ -103,9 +53,13 @@ display:
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
click_sort_column: value
type: string
settings:
link_to_entity: true
group_column: value
group_columns: { }
group_rows: true
@ -123,7 +77,8 @@ display:
relationship: none
group_type: group
admin_label: ''
label: 'Integer weight selector (field_integer_weight)'
plugin_id: integer_weight_selector
label: 'Integer Weight Selector (field_integer_weight)'
exclude: false
alter:
alter_text: false
@ -164,44 +119,57 @@ display:
hide_empty: false
empty_zero: false
hide_alter_empty: true
range: '20'
plugin_id: integer_weight_selector
filters:
status:
value: '1'
table: node_field_data
field: status
plugin_id: boolean
entity_type: node
entity_field: status
id: status
pager:
type: mini
options:
offset: 0
items_per_page: 10
total_pages: null
id: 0
tags:
next: ››
previous: ‹‹
expose:
operator: ''
group: 1
type:
id: type
table: node_field_data
field: type
value:
repo_item:repo_item
entity_type: node
entity_field: type
plugin_id: bundle
items_per_page: false
items_per_page_label: 'Items per page'
items_per_page_options: '5, 10, 25, 50'
items_per_page_options_all: false
items_per_page_options_all_label: '- All -'
offset: false
offset_label: Offset
exposed_form:
type: basic
options:
submit_button: Apply
reset_button: false
reset_button_label: Reset
exposed_sorts_label: 'Sort by'
expose_sort_order: true
sort_asc_label: Asc
sort_desc_label: Desc
access:
type: perm
options:
perm: 'access content'
cache:
type: tag
options: { }
empty: { }
sorts:
created:
id: created
table: node_field_data
field: created
order: DESC
entity_type: node
entity_field: created
plugin_id: date
relationship: none
group_type: group
admin_label: ''
exposed: false
entity_type: node
entity_field: created
plugin_id: date
order: DESC
expose:
label: ''
exposed: false
granularity: second
field_integer_weight_value:
id: field_integer_weight_value
@ -210,17 +178,82 @@ display:
relationship: none
group_type: group
admin_label: ''
plugin_id: standard
order: ASC
expose:
label: ''
field_identifier: ''
exposed: false
arguments: { }
filters:
status:
id: status
table: node_field_data
field: status
entity_type: node
entity_field: status
plugin_id: boolean
value: '1'
group: 1
expose:
operator: ''
type:
id: type
table: node_field_data
field: type
relationship: none
group_type: group
admin_label: ''
entity_type: node
entity_field: type
plugin_id: bundle
operator: in
value:
repo_item: repo_item
group: 1
exposed: false
expose:
operator_id: ''
label: ''
plugin_id: standard
title: 'test weight'
description: ''
use_operator: false
operator: ''
operator_limit_selection: false
operator_list: { }
identifier: ''
required: false
remember: false
multiple: false
remember_roles:
authenticated: authenticated
reduce: false
is_grouped: false
group_info:
label: ''
description: ''
identifier: ''
optional: true
widget: select
multiple: false
remember: false
default_group: All
default_group_multiple: { }
group_items: { }
style:
type: table
row:
type: fields
query:
type: views_query
options:
query_comment: ''
disable_sql_rewrite: false
distinct: false
replica: false
query_tags: { }
relationships: { }
header: { }
footer: { }
empty: { }
relationships: { }
arguments: { }
display_extenders: { }
cache_metadata:
max-age: -1
@ -232,9 +265,9 @@ display:
- user.permissions
tags: { }
page_1:
display_plugin: page
id: page_1
display_title: Page
display_plugin: page
position: 1
display_options:
display_extenders: { }

35
tests/src/FunctionalJavascript/IntegerWeightTest.php

@ -8,6 +8,7 @@ use Drupal\Tests\field_ui\Traits\FieldUiTestTrait;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\field\Entity\FieldConfig;
use Drupal\node\Entity\Node;
use Drupal\views\Tests\ViewTestData;
/**
* Test integer weight selector.
@ -30,6 +31,7 @@ class IntegerWeightTest extends WebDriverTestBase {
'views',
'field_ui',
'integer_weight_test_views',
'islandora',
];
/**
@ -82,27 +84,16 @@ class IntegerWeightTest extends WebDriverTestBase {
*/
public function setUp(): void {
parent::setUp();
$this->adminUser = $this->drupalCreateUser(
[
'administer content types',
'administer node fields',
'administer node display',
]
);
// Create dummy repo_item type to sort (since we don't have
// repository_object without islandora_defaults).
$type = $this->container->get('entity_type.manager')->getStorage('node_type')
->create([
$this->drupalCreateContentType([
'type' => 'repo_item',
'name' => 'Repository Item',
]);
$type->save();
$this->container->get('router.builder')->rebuild();
$account = $this->createUser(['edit any repo_item content'], 'test', TRUE);
$this->drupalLogin($account);
$fieldStorage = FieldStorageConfig::create([
'fieldName' => static::$fieldName,
'field_name' => static::$fieldName,
'entity_type' => 'node',
'type' => static::$fieldType,
]);
@ -124,16 +115,18 @@ class IntegerWeightTest extends WebDriverTestBase {
$this->nodes[] = $node;
}
ViewsTestData::createTestViews(get_class($this), ['integer_weight_test_views']);
ViewTestData::createTestViews(get_class($this), ['integer_weight_test_views']);
}
/**
* Test integer weight selector.
*/
public function testIntegerWeightSelector() {
$this->drupalGet('test-integer-weight');
$page = $this->getSession()->getPage();
$web_assert = $this->assertSession();
$this->drupalGet('/test-integer-weight');
$web_assert->pageTextContains('Item 1');
$page = $this->getSession()->getPage();
$weight_select1 = $page->findField("field_integer_weight[0][weight]");
$weight_select2 = $page->findField("field_integer_weight[1][weight]");
$weight_select3 = $page->findField("field_integer_weight[2][weight]");
@ -153,8 +146,8 @@ class IntegerWeightTest extends WebDriverTestBase {
$this->assertSession()->pageTextNotContains('You have unsaved changes.');
// Drag and drop 'Item 1' over 'Item 2'.
$dragged = $this->xpath("//tr[@class='draggable'][1]//a[@class='tabledrag-handle']")[0];
$target = $this->xpath("//tr[@class='draggable'][2]//a[@class='tabledrag-handle']")[0];
$dragged = $this->xpath("//tr[contains(@class, 'draggable')][1]//a[contains(@class, 'tabledrag-handle')]")[0];
$target = $this->xpath("//tr[contains(@class, 'draggable')][2]//a[contains(@class, 'tabledrag-handle')]")[0];
$dragged->dragTo($target);
// Pause for javascript to do it's thing.

Loading…
Cancel
Save