"Fossies" - the Fresh Open Source Software Archive

Member "selenium-selenium-4.8.1/javascript/grid-ui/src/tests/components/Node.test.tsx" (17 Feb 2023, 2557 Bytes) of package /linux/www/selenium-selenium-4.8.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) TSX (TypeScript with React) source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 // Licensed to the Software Freedom Conservancy (SFC) under one
    2 // or more contributor license agreements.  See the NOTICE file
    3 // distributed with this work for additional information
    4 // regarding copyright ownership.  The SFC licenses this file
    5 // to you under the Apache License, Version 2.0 (the
    6 // "License"); you may not use this file except in compliance
    7 // with the License.  You may obtain a copy of the License at
    8 //
    9 //   http://www.apache.org/licenses/LICENSE-2.0
   10 //
   11 // Unless required by applicable law or agreed to in writing,
   12 // software distributed under the License is distributed on an
   13 // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   14 // KIND, either express or implied.  See the License for the
   15 // specific language governing permissions and limitations
   16 // under the License.
   17 
   18 import * as React from 'react'
   19 import Node from '../../components/Node/Node'
   20 import NodeInfo from '../../models/node-info'
   21 import OsInfo from '../../models/os-info'
   22 import StereotypeInfo from '../../models/stereotype-info'
   23 import { render, screen } from '@testing-library/react'
   24 import userEvent from '@testing-library/user-event'
   25 
   26 const osInfo: OsInfo = {
   27   name: 'Mac OS X',
   28   version: '10.16',
   29   arch: 'x86_64'
   30 }
   31 
   32 const slotStereotype: StereotypeInfo = {
   33   browserName: 'chrome',
   34   browserVersion: 'v. 88',
   35   slotCount: 12,
   36   rawData: ['stereotype: {"browserName": "chrome"}'],
   37   platformName: 'macos'
   38 }
   39 
   40 const node: NodeInfo = {
   41   uri: 'http://192.168.1.7:4444',
   42   id: '9e92a45a-0de3-4424-824a-ff7b6aa57b16',
   43   status: 'UP',
   44   maxSession: 12,
   45   slotCount: 50,
   46   version: '4.0.0-beta-1',
   47   osInfo: osInfo,
   48   sessionCount: 2,
   49   slotStereotypes: [slotStereotype]
   50 }
   51 
   52 it('renders basic node information', () => {
   53   render(<Node node={node} />)
   54   expect(screen.getByText(node.uri)).toBeInTheDocument()
   55   expect(
   56     screen.getByText(`Sessions: ${node.sessionCount}`)).toBeInTheDocument()
   57   expect(screen.getByText(
   58     `Max. Concurrency: ${node.maxSession}`)).toBeInTheDocument()
   59 })
   60 
   61 it('renders detailed node information', async () => {
   62   render(<Node node={node}/>)
   63   const user = userEvent.setup()
   64   await user.click(screen.getByRole('button'))
   65   expect(screen.getByText(`Node Id: ${node.id}`)).toBeInTheDocument()
   66   expect(
   67     screen.getByText(`Total slots: ${node.slotCount}`)).toBeInTheDocument()
   68   expect(screen.getByText(`OS Arch: ${node.osInfo.arch}`)).toBeInTheDocument()
   69   expect(screen.getByText(`OS Name: ${node.osInfo.name}`)).toBeInTheDocument()
   70   expect(
   71     screen.getByText(`OS Version: ${node.osInfo.version}`)).toBeInTheDocument()
   72 })